Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / WPF

Sofa, AvalonDock and MEF

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
6 May 2011CPOL4 min read 54.7K   3K   36  
Sofa makes the link between AvalonDock and MEF, both using composable elements
using System;
using System.ComponentModel;
using System.Windows;
using Sofa.Commons;

namespace Sofa.WebBrowser.Controls
{

    public class BaseControlData : INotifyPropertyChanged
    {

        public BaseControlData(CmpLoaded thisCmpLoaded) { ThisCmpLoaded = thisCmpLoaded; }

        private CmpLoaded thisCmpLoaded;
        public CmpLoaded ThisCmpLoaded
        {
            get { return thisCmpLoaded; }
            set { thisCmpLoaded = value; }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private string _address;
        public string Address
        {
            get { return _address; }
            set { 
                _address = value;
                ThisPropertyChanged("Address");
            }
        }

        private string _title;
        public string Title
        {
            get { return _title; }
            set
            {
                _title = value;
                //Title is not shown in the BaseControl window but in the AvalonDock DockableContent title
                thisCmpLoaded.VisualControl.Title = _title;
            }
        }

        private string _statusBarContent;
        public string StatusBarContent
        {
            get { return _statusBarContent; }
            set
            {
                _statusBarContent = value;
                ThisPropertyChanged("StatusBarContent");
            }
        }

        private Visibility _loadingStatus;
        public Visibility LoadingStatus
        {
            get { return _loadingStatus; }
            set
            {
                _loadingStatus = value;
                ThisPropertyChanged("LoadingStatus");
            }
        }
        
        private Visibility _goButtonStatus;
        public Visibility GoButtonStatus
        {
            get { return _goButtonStatus; }
            set
            {
                _goButtonStatus = value;
                ThisPropertyChanged("GoButtonStatus");
            }
        }


        private bool _canGoBack;
        public bool CanGoBack
        {
            get { return _canGoBack; }
            set
            {
                _canGoBack = value;
                ThisPropertyChanged("CanGoBack");
            }
        }

        private bool _canGoForward;
        public bool CanGoForward
        {
            get { return _canGoForward; }
            set
            {
                _canGoForward = value;
                ThisPropertyChanged("CanGoForward");
            }
        }

        private bool _defaultButtonStatus;
        public bool DefaultButtonStatus
        {
            get { return _defaultButtonStatus; }
            set
            {
                _defaultButtonStatus = value;
                ThisPropertyChanged("DefaultButtonStatus");
            }
        }

        private bool _backToDefaultButtonStatus;
        public bool BackToDefaultButtonStatus
        {
            get { return _backToDefaultButtonStatus; }
            set
            {
                _backToDefaultButtonStatus = value;
                ThisPropertyChanged("BackToDefaultButtonStatus");
            }
        }

        protected void ThisPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }

        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions