Пример #1
0
        /// <summary>
        /// Initializes a new instance of the Content class.
        /// </summary>
        /// <param name="xmlIn">Steam containing information to be loaded.</param>
        /// <param name="formatVersion">Version number.</param>
        public Content(XmlTextReader xmlIn, int formatVersion)
        {
            // Define the initial object state
            _control             = null;
            _title               = "";
            _fullTitle           = "";
            _uniqueName          = "";
            _imageList           = null;
            _icon                = null;
            _imageIndex          = -1;
            _manager             = null;
            _parentWindowContent = null;
            _displaySize         = new Size(_defaultDisplaySize, _defaultDisplaySize);
            _autoHideSize        = new Size(_defaultAutoHideSize, _defaultAutoHideSize);
            _floatingSize        = new Size(_defaultFloatingSize, _defaultFloatingSize);
            _displayLocation     = new Point(_defaultLocation, _defaultLocation);
            _order               = _counter++;
            _tag                 = null;
            _visible             = false;
            _defaultRestore      = null;
            _autoHideRestore     = null;
            _floatingRestore     = null;
            _dockingRestore      = null;
            _autoHidePanel       = null;
            _docked              = true;
            _captionBar          = true;
            _closeButton         = true;
            _hideButton          = true;
            _autoHidden          = false;
            _closeOnHide         = false;
            _office2003BackColor = Office2003Color.Disable;

            // Overwrite default with values read in
            LoadFromXml(xmlIn, formatVersion, true);
        }
Пример #2
0
        private void OnPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
        {
            // Need to get the latest theme
            _colorDetails.Reset();

            // Update each control with latest color
            foreach (Control c in _controls.Keys)
            {
                Office2003Color color = (Office2003Color)_controls[c];

                switch (color)
                {
                case Office2003Color.Base:
                    c.BackColor = _colorDetails.BaseColor;
                    break;

                case Office2003Color.Light:
                    c.BackColor = _colorDetails.BaseColor1;
                    break;

                case Office2003Color.Dark:
                    c.BackColor = _colorDetails.BaseColor2;
                    break;

                case Office2003Color.Enhanced:
                    c.BackColor = _colorDetails.TrackLightColor2;
                    break;
                }
            }
        }
 public Color this[Office2003Color color]
 {
     get
     {
         object val = Colors[color];
         if (val == null)
         {
             return(SystemColors.Control);
         }
         return((Color)val);
     }
 }
Пример #4
0
        private void InternalConstruct(DockingManager manager,
                                       Control control,
                                       string title,
                                       ImageList imageList,
                                       int imageIndex,
                                       Icon icon)
        {
            // Must provide a valid manager instance
            if (manager == null)
            {
                throw new ArgumentNullException("DockingManager");
            }

            // Define the initial object state
            _control             = control;
            _title               = title;
            _uniqueName          = "";
            _imageList           = imageList;
            _imageIndex          = imageIndex;
            _icon                = icon;
            _manager             = manager;
            _parentWindowContent = null;
            _order               = _counter++;
            _visible             = false;
            _displaySize         = new Size(_defaultDisplaySize, _defaultDisplaySize);
            _autoHideSize        = new Size(_defaultAutoHideSize, _defaultAutoHideSize);
            _floatingSize        = new Size(_defaultFloatingSize, _defaultFloatingSize);
            _displayLocation     = new Point(_defaultLocation, _defaultLocation);
            _defaultRestore      = new RestoreContentState(State.DockLeft, this);
            _floatingRestore     = new RestoreContentState(State.Floating, this);
            _autoHideRestore     = new RestoreAutoHideState(State.DockLeft, this);
            _dockingRestore      = _defaultRestore;
            _autoHidePanel       = null;
            _tag         = null;
            _docked      = true;
            _captionBar  = true;
            _closeButton = true;
            _hideButton  = true;
            _autoHidden  = false;
            _closeOnHide = false;
            _fullTitle   = title;

            // A control that is a Panel of Form should have its back color auto set
            if ((_control != null) && ((_control is Form) || (_control is Panel)))
            {
                _office2003BackColor = Office2003Color.Base;
            }
            else
            {
                _office2003BackColor = Office2003Color.Disable;
            }
        }
Пример #5
0
        /// <summary>
        /// Gets a value indicating if the given control is to automatically get the Office2003 back color.
        /// </summary>
        /// <param name="control">Target control.</param>
        /// <param name="color">How to color the background.</param>
        public void SetOffice2003BackColor(Control control, Office2003Color color)
        {
            bool wasFound = false;

            // Is the control already in the lookup?
            if (_controls.Contains(control))
            {
                wasFound = true;

                // Then remove it
                _controls.Remove(control);
            }

            // Add back again with the new value
            _controls.Add(control, color);

            switch (color)
            {
            case Office2003Color.Disable:
                if (wasFound)
                {
                    control.ResetBackColor();
                }
                break;

            case Office2003Color.Base:
                control.BackColor = _colorDetails.BaseColor;
                break;

            case Office2003Color.Light:
                control.BackColor = _colorDetails.BaseColor1;
                break;

            case Office2003Color.Dark:
                control.BackColor = _colorDetails.BaseColor2;
                break;

            case Office2003Color.Enhanced:
                control.BackColor = _colorDetails.TrackLightColor2;
                break;
            }
        }
Пример #6
0
 public Color this[Office2003Color color]
 {
     get
     {
         object val = Colors[color];
         if (val == null) return SystemColors.Control;
         return (Color)val;
     }
 }
Пример #7
0
        internal void LoadFromXml(XmlTextReader xmlIn, int formatVersion, bool fullConfig)
        {
            // Read in the attribute values
            string attrTitle           = xmlIn.GetAttribute(0);
            string attrVisible         = xmlIn.GetAttribute(1);
            string attrDocked          = xmlIn.GetAttribute(2);
            string attrAutoHide        = xmlIn.GetAttribute(3);
            string attrCaptionBar      = xmlIn.GetAttribute(4);
            string attrCloseButton     = xmlIn.GetAttribute(5);
            string attrDisplaySize     = xmlIn.GetAttribute(6);
            string attrDisplayLocation = xmlIn.GetAttribute(7);
            string attrAutoHideSize    = xmlIn.GetAttribute(8);
            string attrFloatingSize    = xmlIn.GetAttribute(9);
            string attrFullTitle       = attrTitle;
            string attrAutoOffice2003  = "Disable";
            string attrUniqueName      = "";

            // 'FullTitle' property added in version 5 format and above
            if (formatVersion >= 5)
            {
                attrFullTitle = xmlIn.GetAttribute(10);
            }

            // 'AutoOffice2003' property added in version 7 format and above
            if (formatVersion >= 7)
            {
                attrAutoOffice2003 = xmlIn.GetAttribute(11);
            }

            // 'UniqueName' property added in version 8 format and above
            if (formatVersion >= 8)
            {
                attrUniqueName = xmlIn.GetAttribute(12);
            }

            // Convert to correct types
            _title               = attrTitle;
            _captionBar          = Convert.ToBoolean(attrCaptionBar);
            _closeButton         = Convert.ToBoolean(attrCloseButton);
            _displaySize         = ConversionHelper.StringToSize(attrDisplaySize);
            _displayLocation     = ConversionHelper.StringToPoint(attrDisplayLocation);
            _autoHideSize        = ConversionHelper.StringToSize(attrAutoHideSize);
            _floatingSize        = ConversionHelper.StringToSize(attrFloatingSize);
            _fullTitle           = attrFullTitle;
            _office2003BackColor = (Office2003Color)Enum.Parse(typeof(Office2003Color), attrAutoOffice2003);
            _uniqueName          = attrUniqueName;

            // Only a full config should reinstate the visible value
            if (fullConfig)
            {
                _visible = Convert.ToBoolean(attrVisible);
            }

            // Can only override the current docking state if we are not visible
            // or doing a full configuration reload in which case it does not matter
            if (fullConfig || !_visible)
            {
                _docked     = Convert.ToBoolean(attrDocked);
                _autoHidden = Convert.ToBoolean(attrAutoHide);
            }

            // Load the Restore objects
            _defaultRestore  = Restore.CreateFromXml(xmlIn, true, formatVersion);
            _autoHideRestore = Restore.CreateFromXml(xmlIn, true, formatVersion);
            _dockingRestore  = Restore.CreateFromXml(xmlIn, true, formatVersion);
            _floatingRestore = Restore.CreateFromXml(xmlIn, true, formatVersion);

            // If not a full restore then just reloading content details, so reconnect now
            if (!fullConfig)
            {
                ReconnectRestore();
            }

            // Move past the end element
            if (!xmlIn.Read())
            {
                throw new ArgumentException("Could not read in next expected node");
            }

            // Check it has the expected name
            if (xmlIn.NodeType != XmlNodeType.EndElement)
            {
                throw new ArgumentException("EndElement expected but not found");
            }
        }