Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Persistence Test/WinFormsUI/Docking/DockPanelSkin.cs @ 4593

Last change on this file since 4593 was 2134, checked in by gkronber, 15 years ago

Added up to date source of Weifen Luo dock panel suit in a separate project (and added strong name key). Removed binary versions of Weifen Luo dock panel suite and references to it. #687 (Update AdvancedOptimizationFrontend to use more recent version of Weifen Luo Docking library)

File size: 15.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Drawing;
5using System.Drawing.Drawing2D;
6using System.Drawing.Design;
7using System.Windows.Forms.Design;
8using System.ComponentModel;
9
10namespace WeifenLuo.WinFormsUI.Docking
11{
12    #region DockPanelSkin classes
13    /// <summary>
14    /// The skin to use when displaying the DockPanel.
15    /// The skin allows custom gradient color schemes to be used when drawing the
16    /// DockStrips and Tabs.
17    /// </summary>
18    [TypeConverter(typeof(DockPanelSkinConverter))]
19    public class DockPanelSkin
20    {
21        private AutoHideStripSkin m_autoHideStripSkin;
22        private DockPaneStripSkin m_dockPaneStripSkin;
23
24        public DockPanelSkin()
25        {
26            m_autoHideStripSkin = new AutoHideStripSkin();
27            m_dockPaneStripSkin = new DockPaneStripSkin();
28        }
29
30        /// <summary>
31        /// The skin used to display the auto hide strips and tabs.
32        /// </summary>
33        public AutoHideStripSkin AutoHideStripSkin
34        {
35            get { return m_autoHideStripSkin; }
36            set { m_autoHideStripSkin = value; }
37        }
38
39        /// <summary>
40        /// The skin used to display the Document and ToolWindow style DockStrips and Tabs.
41        /// </summary>
42        public DockPaneStripSkin DockPaneStripSkin
43        {
44            get { return m_dockPaneStripSkin; }
45            set { m_dockPaneStripSkin = value; }
46        }
47    }
48
49    /// <summary>
50    /// The skin used to display the auto hide strip and tabs.
51    /// </summary>
52    [TypeConverter(typeof(AutoHideStripConverter))]
53    public class AutoHideStripSkin
54    {
55        private DockPanelGradient m_dockStripGradient;
56        private TabGradient m_TabGradient;
57
58        public AutoHideStripSkin()
59        {
60            m_dockStripGradient = new DockPanelGradient();
61            m_dockStripGradient.StartColor = SystemColors.ControlLight;
62            m_dockStripGradient.EndColor = SystemColors.ControlLight;
63
64            m_TabGradient = new TabGradient();
65            m_TabGradient.TextColor = SystemColors.ControlDarkDark;
66        }
67
68        /// <summary>
69        /// The gradient color skin for the DockStrips.
70        /// </summary>
71        public DockPanelGradient DockStripGradient
72        {
73            get { return m_dockStripGradient; }
74            set { m_dockStripGradient = value; }
75        }
76
77        /// <summary>
78        /// The gradient color skin for the Tabs.
79        /// </summary>
80        public TabGradient TabGradient
81        {
82            get { return m_TabGradient; }
83            set { m_TabGradient = value; }
84        }
85    }
86
87    /// <summary>
88    /// The skin used to display the document and tool strips and tabs.
89    /// </summary>
90    [TypeConverter(typeof(DockPaneStripConverter))]
91    public class DockPaneStripSkin
92    {
93        private DockPaneStripGradient m_DocumentGradient;
94        private DockPaneStripToolWindowGradient m_ToolWindowGradient;
95
96        public DockPaneStripSkin()
97        {
98            m_DocumentGradient = new DockPaneStripGradient();
99            m_DocumentGradient.DockStripGradient.StartColor = SystemColors.Control;
100            m_DocumentGradient.DockStripGradient.EndColor = SystemColors.Control;
101            m_DocumentGradient.ActiveTabGradient.StartColor = SystemColors.ControlLightLight;
102            m_DocumentGradient.ActiveTabGradient.EndColor = SystemColors.ControlLightLight;
103            m_DocumentGradient.InactiveTabGradient.StartColor = SystemColors.ControlLight;
104            m_DocumentGradient.InactiveTabGradient.EndColor = SystemColors.ControlLight;
105
106            m_ToolWindowGradient = new DockPaneStripToolWindowGradient();
107            m_ToolWindowGradient.DockStripGradient.StartColor = SystemColors.ControlLight;
108            m_ToolWindowGradient.DockStripGradient.EndColor = SystemColors.ControlLight;
109           
110            m_ToolWindowGradient.ActiveTabGradient.StartColor = SystemColors.Control;
111            m_ToolWindowGradient.ActiveTabGradient.EndColor = SystemColors.Control;
112           
113            m_ToolWindowGradient.InactiveTabGradient.StartColor = Color.Transparent;
114            m_ToolWindowGradient.InactiveTabGradient.EndColor = Color.Transparent;
115            m_ToolWindowGradient.InactiveTabGradient.TextColor = SystemColors.ControlDarkDark;
116           
117            m_ToolWindowGradient.ActiveCaptionGradient.StartColor = SystemColors.GradientActiveCaption;
118            m_ToolWindowGradient.ActiveCaptionGradient.EndColor = SystemColors.ActiveCaption;
119            m_ToolWindowGradient.ActiveCaptionGradient.LinearGradientMode = LinearGradientMode.Vertical;
120            m_ToolWindowGradient.ActiveCaptionGradient.TextColor = SystemColors.ActiveCaptionText;
121
122            m_ToolWindowGradient.InactiveCaptionGradient.StartColor = SystemColors.GradientInactiveCaption;
123            m_ToolWindowGradient.InactiveCaptionGradient.EndColor = SystemColors.GradientInactiveCaption;
124            m_ToolWindowGradient.InactiveCaptionGradient.LinearGradientMode = LinearGradientMode.Vertical;
125            m_ToolWindowGradient.InactiveCaptionGradient.TextColor = SystemColors.ControlText;
126        }
127
128        /// <summary>
129        /// The skin used to display the Document style DockPane strip and tab.
130        /// </summary>
131        public DockPaneStripGradient DocumentGradient
132        {
133            get { return m_DocumentGradient; }
134            set { m_DocumentGradient = value; }
135        }
136
137        /// <summary>
138        /// The skin used to display the ToolWindow style DockPane strip and tab.
139        /// </summary>
140        public DockPaneStripToolWindowGradient ToolWindowGradient
141        {
142            get { return m_ToolWindowGradient; }
143            set { m_ToolWindowGradient = value; }
144        }
145    }
146
147    /// <summary>
148    /// The skin used to display the DockPane ToolWindow strip and tab.
149    /// </summary>
150    [TypeConverter(typeof(DockPaneStripGradientConverter))]
151    public class DockPaneStripToolWindowGradient : DockPaneStripGradient
152    {
153        private TabGradient m_activeCaptionGradient;
154        private TabGradient m_inactiveCaptionGradient;
155
156        public DockPaneStripToolWindowGradient()
157        {
158            m_activeCaptionGradient = new TabGradient();
159            m_inactiveCaptionGradient = new TabGradient();
160        }
161
162        /// <summary>
163        /// The skin used to display the active ToolWindow caption.
164        /// </summary>
165        public TabGradient ActiveCaptionGradient
166        {
167            get { return m_activeCaptionGradient; }
168            set { m_activeCaptionGradient = value; }
169        }
170
171        /// <summary>
172        /// The skin used to display the inactive ToolWindow caption.
173        /// </summary>
174        public TabGradient InactiveCaptionGradient
175        {
176            get { return m_inactiveCaptionGradient; }
177            set { m_inactiveCaptionGradient = value; }
178        }
179    }
180
181    /// <summary>
182    /// The skin used to display the DockPane strip and tab.
183    /// </summary>
184    [TypeConverter(typeof(DockPaneStripGradientConverter))]
185    public class DockPaneStripGradient
186    {
187        private DockPanelGradient m_dockStripGradient;
188        private TabGradient m_activeTabGradient;
189        private TabGradient m_inactiveTabGradient;
190
191        public DockPaneStripGradient()
192        {
193            m_dockStripGradient = new DockPanelGradient();
194            m_activeTabGradient = new TabGradient();
195            m_inactiveTabGradient = new TabGradient();
196        }
197
198        /// <summary>
199        /// The gradient color skin for the DockStrip.
200        /// </summary>
201        public DockPanelGradient DockStripGradient
202        {
203            get { return m_dockStripGradient; }
204            set { m_dockStripGradient = value; }
205        }
206
207        /// <summary>
208        /// The skin used to display the active DockPane tabs.
209        /// </summary>
210        public TabGradient ActiveTabGradient
211        {
212            get { return m_activeTabGradient; }
213            set { m_activeTabGradient = value; }
214        }
215
216        /// <summary>
217        /// The skin used to display the inactive DockPane tabs.
218        /// </summary>
219        public TabGradient InactiveTabGradient
220        {
221            get { return m_inactiveTabGradient; }
222            set { m_inactiveTabGradient = value; }
223        }
224    }
225
226    /// <summary>
227    /// The skin used to display the dock pane tab
228    /// </summary>
229    [TypeConverter(typeof(DockPaneTabGradientConverter))]
230    public class TabGradient : DockPanelGradient
231    {
232        private Color m_textColor;
233
234        public TabGradient()
235        {
236            m_textColor = SystemColors.ControlText;
237        }
238
239        /// <summary>
240        /// The text color.
241        /// </summary>
242        [DefaultValue(typeof(SystemColors), "ControlText")]
243        public Color TextColor
244        {
245            get { return m_textColor; }
246            set { m_textColor = value; }
247        }
248    }
249
250    /// <summary>
251    /// The gradient color skin.
252    /// </summary>
253    [TypeConverter(typeof(DockPanelGradientConverter))]
254    public class DockPanelGradient
255    {
256        private Color m_startColor;
257        private Color m_endColor;
258        private LinearGradientMode m_linearGradientMode;
259
260        public DockPanelGradient()
261        {
262            m_startColor = SystemColors.Control;
263            m_endColor = SystemColors.Control;
264            m_linearGradientMode = LinearGradientMode.Horizontal;
265        }
266
267        /// <summary>
268        /// The beginning gradient color.
269        /// </summary>
270        [DefaultValue(typeof(SystemColors), "Control")]
271        public Color StartColor
272        {
273            get { return m_startColor; }
274            set { m_startColor = value; }
275        }
276
277        /// <summary>
278        /// The ending gradient color.
279        /// </summary>
280        [DefaultValue(typeof(SystemColors), "Control")]
281        public Color EndColor
282        {
283            get { return m_endColor; }
284            set { m_endColor = value; }
285        }
286
287        /// <summary>
288        /// The gradient mode to display the colors.
289        /// </summary>
290        [DefaultValue(LinearGradientMode.Horizontal)]
291        public LinearGradientMode LinearGradientMode
292        {
293            get { return m_linearGradientMode; }
294            set { m_linearGradientMode = value; }
295        }
296    }
297
298    #endregion
299
300    #region Converters
301    public class DockPanelSkinConverter : ExpandableObjectConverter
302    {
303        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
304        {
305            if (destinationType == typeof(DockPanelSkin))
306                return true;
307
308            return base.CanConvertTo(context, destinationType);
309        }
310
311        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
312        {
313            if (destinationType == typeof(String) && value is DockPanelSkin)
314            {
315                return "DockPanelSkin";
316            }
317            return base.ConvertTo(context, culture, value, destinationType);
318        }
319    }
320
321    public class DockPanelGradientConverter : ExpandableObjectConverter
322    {
323        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
324        {
325            if (destinationType == typeof(DockPanelGradient))
326                return true;
327
328            return base.CanConvertTo(context, destinationType);
329        }
330
331        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
332        {
333            if (destinationType == typeof(String) && value is DockPanelGradient)
334            {
335                return "DockPanelGradient";
336            }
337            return base.ConvertTo(context, culture, value, destinationType);
338        }
339    }
340
341    public class AutoHideStripConverter : ExpandableObjectConverter
342    {
343        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
344        {
345            if (destinationType == typeof(AutoHideStripSkin))
346                return true;
347
348            return base.CanConvertTo(context, destinationType);
349        }
350
351        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
352        {
353            if (destinationType == typeof(String) && value is AutoHideStripSkin)
354            {
355                return "AutoHideStripSkin";
356            }
357            return base.ConvertTo(context, culture, value, destinationType);
358        }
359    }
360
361    public class DockPaneStripConverter : ExpandableObjectConverter
362    {
363        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
364        {
365            if (destinationType == typeof(DockPaneStripSkin))
366                return true;
367
368            return base.CanConvertTo(context, destinationType);
369        }
370
371        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
372        {
373            if (destinationType == typeof(String) && value is DockPaneStripSkin)
374            {
375                return "DockPaneStripSkin";
376            }
377            return base.ConvertTo(context, culture, value, destinationType);
378        }
379    }
380
381    public class DockPaneStripGradientConverter : ExpandableObjectConverter
382    {
383        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
384        {
385            if (destinationType == typeof(DockPaneStripGradient))
386                return true;
387
388            return base.CanConvertTo(context, destinationType);
389        }
390
391        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
392        {
393            if (destinationType == typeof(String) && value is DockPaneStripGradient)
394            {
395                return "DockPaneStripGradient";
396            }
397            return base.ConvertTo(context, culture, value, destinationType);
398        }
399    }
400
401    public class DockPaneTabGradientConverter : ExpandableObjectConverter
402    {
403        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
404        {
405            if (destinationType == typeof(TabGradient))
406                return true;
407
408            return base.CanConvertTo(context, destinationType);
409        }
410
411        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
412        {
413            if (destinationType == typeof(String) && value is TabGradient)
414            {
415                return "DockPaneTabGradient";
416            }
417            return base.ConvertTo(context, culture, value, destinationType);
418        }
419    }
420    #endregion
421}
Note: See TracBrowser for help on using the repository browser.