⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dockingmanager.cs

📁 Magic Library 1.7,有说明文档
💻 CS
📖 第 1 页 / 共 5 页
字号:
// *****************************************************************************
// 
//  (c) Crownwood Consulting Limited 2002 
//  All rights reserved. The software and associated documentation 
//  supplied hereunder are the proprietary information of Crownwood Consulting 
//	Limited, Haxey, North Lincolnshire, England and are supplied subject to 
//	licence terms.
// 
//  Magic Version 1.7 	www.dotnetmagic.com
// *****************************************************************************

using System;
using System.IO;
using System.Xml;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Xml.Serialization;
using Microsoft.Win32;
using Crownwood.Magic.Menus;
using Crownwood.Magic.Common;
using Crownwood.Magic.Docking;
using Crownwood.Magic.Collections;

namespace Crownwood.Magic.Docking
{
    public enum PropogateName
    {
        BackColor,
        ActiveColor,
        ActiveTextColor,
        InactiveTextColor,
        ResizeBarColor,
        ResizeBarVector,
        CaptionFont,
		TabControlFont,
        ZoneMinMax,
        PlainTabBorder
    }

    public class DockingManager
    {
        // Instance fields
        protected bool _zoneMinMax;
        protected bool _insideFill;
        protected bool _autoResize;
        protected bool _firstHalfWidth;
        protected bool _firstHalfHeight;
        protected int _surpressVisibleEvents;
        protected int _resizeBarVector;
        protected Size _innerMinimum;
        protected Color _backColor;
        protected Color _activeColor;
        protected Color _activeTextColor;
        protected Color _inactiveTextColor;
        protected Color _resizeBarColor;
        protected Font _captionFont;
		protected Font _tabControlFont;
        protected bool _defaultBackColor;
        protected bool _defaultActiveColor;
        protected bool _defaultActiveTextColor;
        protected bool _defaultInactiveTextColor;
        protected bool _defaultResizeBarColor;
        protected bool _defaultCaptionFont;
		protected bool _defaultTabControlFont;
        protected bool _plainTabBorder;
        protected Control _innerControl;
        protected Control _outerControl;
        protected AutoHidePanel _ahpTop;
        protected AutoHidePanel _ahpLeft;
        protected AutoHidePanel _ahpBottom;
        protected AutoHidePanel _ahpRight;
        protected VisualStyle _visualStyle;
        protected ContainerControl _container;
        protected ManagerContentCollection _contents;

        public delegate void ContentHandler(Content c, EventArgs cea);
        public delegate void ContentHidingHandler(Content c, CancelEventArgs cea);
        public delegate void ContextMenuHandler(PopupMenu pm, CancelEventArgs cea);
		public delegate void TabControlCreatedHandler(Magic.Controls.TabControl tabControl);
		public delegate void SaveCustomConfigHandler(XmlTextWriter xmlOut);
        public delegate void LoadCustomConfigHandler(XmlTextReader xmlIn);

        // Exposed events
        public event ContentHandler ContentShown;
        public event ContentHandler ContentHidden;
        public event ContentHidingHandler ContentHiding;
        public event ContextMenuHandler ContextMenu;
		public event TabControlCreatedHandler TabControlCreated;
		public event SaveCustomConfigHandler SaveCustomConfig;
        public event LoadCustomConfigHandler LoadCustomConfig;

        public DockingManager(ContainerControl container, VisualStyle vs)
        {
            // Must provide a valid container instance
            if (container == null)
                throw new ArgumentNullException("Container");

            // Default state
            _container = container;
            _visualStyle = vs;
            _innerControl = null;
			_zoneMinMax = true;
			_insideFill = false;
			_autoResize = true;
			_firstHalfWidth = true;
			_firstHalfHeight = true;
			_plainTabBorder = false;
			_surpressVisibleEvents = 0;
			_innerMinimum = new Size(20, 20);
	
            // Default font/resize
			_resizeBarVector = -1;
			_captionFont = SystemInformation.MenuFont;
			_tabControlFont = SystemInformation.MenuFont;
			_defaultCaptionFont = true;
			_defaultTabControlFont = true;

			// Create and add hidden auto hide panels
			AddAutoHidePanels();

            // Define initial colors
            ResetColors();

            // Create an object to manage the collection of Content
            _contents = new ManagerContentCollection(this);

            // We want notification when contents are removed/cleared
            _contents.Clearing += new CollectionClear(OnContentsClearing);
            _contents.Removed += new CollectionChange(OnContentRemoved);

			// We want to perform special action when container is resized
			_container.Resize += new EventHandler(OnContainerResized);
			
			// A Form can cause the child controls to be reordered after the initialisation
			// but before the Form.Load event. To handle this we hook into the event and force
			// the auto hide panels to be ordered back into their proper place.
			if (_container is Form)
			{   
			    Form formContainer = _container as Form;			    
			    formContainer.Load += new EventHandler(OnFormLoaded);
			}

            // Need notification when colors change
            Microsoft.Win32.SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(OnPreferenceChanged);
        }

        public ContainerControl Container
        {
            get { return _container; }
        }

        public Control InnerControl
        {
            get { return _innerControl; }
            set { _innerControl = value; }
        }

        public Control OuterControl
        {
            get { return _outerControl; }
            set 
			{
			    if (_outerControl != value)
			    {
				    _outerControl = value;
				    
				    // Use helper routine to ensure panels are in correct positions
                    ReorderAutoHidePanels();
		        }
			}
        }

        public ManagerContentCollection Contents
        {
            get { return _contents; }
			
            set 
            {
                _contents.Clear();
                _contents = value;	
            }
        }

		public bool ZoneMinMax
		{
			get { return _zoneMinMax; }

			set 
			{ 
			    if (value != _zoneMinMax)
			    {
			        _zoneMinMax = value;
                
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.ZoneMinMax, (object)_zoneMinMax);
                } 
			}
		}

		public bool InsideFill
		{
			get { return _insideFill; }

			set
			{
				if (_insideFill != value)
				{
					_insideFill = value;

					if (_insideFill)
					{
					    // Add Fill style to innermost docking window
						AddInnerFillStyle();
			        }
					else
					{
					    // Remove Fill style from innermost docking window
						RemoveAnyFillStyle();
						
						// Ensure that inner control can be seen
                        OnContainerResized(null, EventArgs.Empty);
					}
				}
			}
		}

		public bool AutoResize
		{
			get { return _autoResize; }
			set { _autoResize = value; }
		}

		public Size InnerMinimum
		{
			get { return _innerMinimum; }
			set { _innerMinimum = value; }
		}

        public VisualStyle Style
        {
            get { return _visualStyle; }
        }

        public int ResizeBarVector
        {
            get { return _resizeBarVector; }
            
            set 
            {
                if (value != _resizeBarVector)
                {
                    _resizeBarVector = value;
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.ResizeBarVector, (object)_resizeBarVector);
                }
            }
        }

        public Color BackColor
        {
            get { return _backColor; }
            
            set 
            {
                if (value != _backColor)
                {
                    _backColor = value;
                    _defaultBackColor = (_backColor == SystemColors.Control);
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.BackColor, (object)_backColor);
                }
            }
        }
    
        public Color ActiveColor
        {
            get { return _activeColor; }
            
            set 
            {
                if (value != _activeColor)
                {
                    _activeColor = value;
                    _defaultActiveColor = (_activeColor == SystemColors.ActiveCaption);
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.ActiveColor, (object)_activeColor);
                }
            }
        }
        
        public Color ActiveTextColor
        {
            get { return _activeTextColor; }
            
            set 
            {
                if (value != _activeTextColor)
                {
                    _activeTextColor = value;
                    _defaultActiveTextColor = (_activeTextColor == SystemColors.ActiveCaptionText);
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.ActiveTextColor, (object)_activeTextColor);
                }
            }
        }

        public Color InactiveTextColor
        {
            get { return _inactiveTextColor; }
            
            set 
            {
                if (value != _inactiveTextColor)
                {
                    _inactiveTextColor = value;
                    _defaultInactiveTextColor = (_inactiveTextColor == SystemColors.ControlText);
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.InactiveTextColor, (object)_inactiveTextColor);
                }
            }
        }

        public Color ResizeBarColor
        {
            get { return _resizeBarColor; }
            
            set 
            {
                if (value != _resizeBarColor)
                {
                    _resizeBarColor = value;
                    _defaultResizeBarColor = (_resizeBarColor == SystemColors.Control);
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.ResizeBarColor, (object)_resizeBarColor);
                }
            }
        }
        
        public Font CaptionFont
        {
            get { return _captionFont; }
            
            set 
            {
                if (value != _captionFont)
                {
                    _captionFont = value;
                    _defaultCaptionFont = (_captionFont == SystemInformation.MenuFont);
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.CaptionFont, (object)_captionFont);
                }
            }
        }

        public Font TabControlFont
        {
            get { return _tabControlFont; }
            
            set 
            {
                if (value != _tabControlFont)
                {
                    _tabControlFont = value;
                    _defaultTabControlFont = (_captionFont == SystemInformation.MenuFont);
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.TabControlFont, (object)_tabControlFont);
                }
            }
        }

        public bool PlainTabBorder
        {
            get { return _plainTabBorder; }
            
            set 
            {
                if (value != _plainTabBorder)
                {
                    _plainTabBorder = value;
                    
                    // Notify each object in docking hierarchy in case they need to know new value
                    PropogateNameValue(PropogateName.PlainTabBorder, (object)_plainTabBorder);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -