-//\r
-// TrackBarRenderer.cs\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-// Copyright (c) 2006 Novell, Inc.\r
-//\r
-// Authors:\r
-// Jonathan Pobst (monkey@jpobst.com)\r
-//\r
-\r
-#if NET_2_0\r
-using System.Drawing;\r
-using System.Windows.Forms.VisualStyles;\r
-\r
-namespace System.Windows.Forms\r
-{\r
- public sealed class TrackBarRenderer\r
- {\r
- #region Private Constructor\r
- private TrackBarRenderer () { }\r
- #endregion\r
-\r
- #region Public Static Methods\r
- public static void DrawBottomPointingThumb(Graphics g, Rectangle bounds, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Pressed);\r
- break;\r
- }\r
-\r
- vsr.DrawBackground (g, bounds);\r
- }\r
-\r
- public static void DrawHorizontalThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Pressed);\r
- break;\r
- }\r
-\r
- vsr.DrawBackground (g, bounds);\r
- }\r
-\r
- public static void DrawHorizontalTicks(Graphics g, Rectangle bounds, int numTicks, EdgeStyle edgeStyle)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- if (bounds.Height <= 0 || bounds.Width <= 0 || numTicks <= 0)\r
- return;\r
- \r
- VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Ticks.Normal);\r
- \r
- double x = bounds.Left;\r
- double delta = (double)(bounds.Width - 2) / (double)(numTicks-1);\r
- \r
- for(int i = 0; i < numTicks; i++)\r
- {\r
- vsr.DrawEdge(g, new Rectangle((int)Math.Round(x), bounds.Top, 5, bounds.Height), Edges.Left, edgeStyle, EdgeEffects.None);\r
- x += delta;\r
- }\r
- }\r
- \r
- public static void DrawHorizontalTrack(Graphics g, Rectangle bounds)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
- \r
- VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Track.Normal);\r
- \r
- vsr.DrawBackground (g, bounds);\r
- }\r
-\r
- public static void DrawLeftPointingThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Pressed);\r
- break;\r
- }\r
-\r
- vsr.DrawBackground (g, bounds);\r
- }\r
-\r
- public static void DrawRightPointingThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Pressed);\r
- break;\r
- }\r
-\r
- vsr.DrawBackground (g, bounds);\r
- }\r
-\r
- public static void DrawTopPointingThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Pressed);\r
- break;\r
- }\r
-\r
- vsr.DrawBackground (g, bounds);\r
- }\r
-\r
- public static void DrawVerticalThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbVertical.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbVertical.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbVertical.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbVertical.Pressed);\r
- break;\r
- }\r
-\r
- vsr.DrawBackground (g, bounds);\r
- }\r
-\r
- public static void DrawVerticalTicks (Graphics g, Rectangle bounds, int numTicks, EdgeStyle edgeStyle)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- if (bounds.Height <= 0 || bounds.Width <= 0 || numTicks <= 0)\r
- return;\r
-\r
- VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.TicksVertical.Normal);\r
-\r
- double y = bounds.Top;\r
- double delta = (double)(bounds.Height - 2) / (double)(numTicks - 1);\r
-\r
- for (int i = 0; i < numTicks; i++) {\r
- vsr.DrawEdge (g, new Rectangle (bounds.Left, (int)Math.Round (y), bounds.Width, 5), Edges.Top, edgeStyle, EdgeEffects.None);\r
- y += delta;\r
- }\r
- }\r
-\r
- public static void DrawVerticalTrack (Graphics g, Rectangle bounds)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Track.Normal);\r
-\r
- vsr.DrawBackground (g, bounds);\r
- }\r
-\r
- public static Size GetBottomPointingThumbSize(Graphics g, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Pressed);\r
- break;\r
- }\r
-\r
- return vsr.GetPartSize (g, ThemeSizeType.Draw);\r
- }\r
-\r
- public static Size GetLeftPointingThumbSize (Graphics g, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Pressed);\r
- break;\r
- }\r
-\r
- return vsr.GetPartSize (g, ThemeSizeType.Draw);\r
- }\r
-\r
- public static Size GetRightPointingThumbSize (Graphics g, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Pressed);\r
- break;\r
- }\r
-\r
- return vsr.GetPartSize (g, ThemeSizeType.Draw);\r
- }\r
-\r
- public static Size GetTopPointingThumbSize (Graphics g, TrackBarThumbState state)\r
- {\r
- if (!IsSupported)\r
- throw new InvalidOperationException ();\r
-\r
- VisualStyleRenderer vsr;\r
-\r
- switch (state) {\r
- case TrackBarThumbState.Disabled:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Disabled);\r
- break;\r
- case TrackBarThumbState.Hot:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Hot);\r
- break;\r
- case TrackBarThumbState.Normal:\r
- default:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Normal);\r
- break;\r
- case TrackBarThumbState.Pressed:\r
- vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Pressed);\r
- break;\r
- }\r
-\r
- return vsr.GetPartSize (g, ThemeSizeType.Draw);\r
- }\r
- #endregion\r
-\r
- #region Public Static Properties\r
- public static bool IsSupported {\r
- get { return VisualStyleInformation.IsEnabledByUser && (Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled || Application.VisualStyleState == VisualStyleState.ClientAreaEnabled); }\r
- }\r
- #endregion\r
- }\r
-}\r
+//
+// TrackBarRenderer.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2006 Novell, Inc.
+//
+// Authors:
+// Jonathan Pobst (monkey@jpobst.com)
+//
+
+#if NET_2_0
+using System.Drawing;
+using System.Windows.Forms.VisualStyles;
+
+namespace System.Windows.Forms
+{
+ public sealed class TrackBarRenderer
+ {
+ #region Private Constructor
+ private TrackBarRenderer () { }
+ #endregion
+
+ #region Public Static Methods
+ public static void DrawBottomPointingThumb(Graphics g, Rectangle bounds, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Pressed);
+ break;
+ }
+
+ vsr.DrawBackground (g, bounds);
+ }
+
+ public static void DrawHorizontalThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Pressed);
+ break;
+ }
+
+ vsr.DrawBackground (g, bounds);
+ }
+
+ public static void DrawHorizontalTicks(Graphics g, Rectangle bounds, int numTicks, EdgeStyle edgeStyle)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ if (bounds.Height <= 0 || bounds.Width <= 0 || numTicks <= 0)
+ return;
+
+ VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Ticks.Normal);
+
+ double x = bounds.Left;
+ double delta = (double)(bounds.Width - 2) / (double)(numTicks-1);
+
+ for(int i = 0; i < numTicks; i++)
+ {
+ vsr.DrawEdge(g, new Rectangle((int)Math.Round(x), bounds.Top, 5, bounds.Height), Edges.Left, edgeStyle, EdgeEffects.None);
+ x += delta;
+ }
+ }
+
+ public static void DrawHorizontalTrack(Graphics g, Rectangle bounds)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Track.Normal);
+
+ vsr.DrawBackground (g, bounds);
+ }
+
+ public static void DrawLeftPointingThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Pressed);
+ break;
+ }
+
+ vsr.DrawBackground (g, bounds);
+ }
+
+ public static void DrawRightPointingThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Pressed);
+ break;
+ }
+
+ vsr.DrawBackground (g, bounds);
+ }
+
+ public static void DrawTopPointingThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Pressed);
+ break;
+ }
+
+ vsr.DrawBackground (g, bounds);
+ }
+
+ public static void DrawVerticalThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbVertical.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbVertical.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbVertical.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbVertical.Pressed);
+ break;
+ }
+
+ vsr.DrawBackground (g, bounds);
+ }
+
+ public static void DrawVerticalTicks (Graphics g, Rectangle bounds, int numTicks, EdgeStyle edgeStyle)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ if (bounds.Height <= 0 || bounds.Width <= 0 || numTicks <= 0)
+ return;
+
+ VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.TicksVertical.Normal);
+
+ double y = bounds.Top;
+ double delta = (double)(bounds.Height - 2) / (double)(numTicks - 1);
+
+ for (int i = 0; i < numTicks; i++) {
+ vsr.DrawEdge (g, new Rectangle (bounds.Left, (int)Math.Round (y), bounds.Width, 5), Edges.Top, edgeStyle, EdgeEffects.None);
+ y += delta;
+ }
+ }
+
+ public static void DrawVerticalTrack (Graphics g, Rectangle bounds)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Track.Normal);
+
+ vsr.DrawBackground (g, bounds);
+ }
+
+ public static Size GetBottomPointingThumbSize(Graphics g, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbBottom.Pressed);
+ break;
+ }
+
+ return vsr.GetPartSize (g, ThemeSizeType.Draw);
+ }
+
+ public static Size GetLeftPointingThumbSize (Graphics g, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbLeft.Pressed);
+ break;
+ }
+
+ return vsr.GetPartSize (g, ThemeSizeType.Draw);
+ }
+
+ public static Size GetRightPointingThumbSize (Graphics g, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbRight.Pressed);
+ break;
+ }
+
+ return vsr.GetPartSize (g, ThemeSizeType.Draw);
+ }
+
+ public static Size GetTopPointingThumbSize (Graphics g, TrackBarThumbState state)
+ {
+ if (!IsSupported)
+ throw new InvalidOperationException ();
+
+ VisualStyleRenderer vsr;
+
+ switch (state) {
+ case TrackBarThumbState.Disabled:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Disabled);
+ break;
+ case TrackBarThumbState.Hot:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Hot);
+ break;
+ case TrackBarThumbState.Normal:
+ default:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Normal);
+ break;
+ case TrackBarThumbState.Pressed:
+ vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Pressed);
+ break;
+ }
+
+ return vsr.GetPartSize (g, ThemeSizeType.Draw);
+ }
+ #endregion
+
+ #region Public Static Properties
+ public static bool IsSupported {
+ get { return VisualStyleInformation.IsEnabledByUser && (Application.VisualStyleState == VisualStyleState.ClientAndNonClientAreasEnabled || Application.VisualStyleState == VisualStyleState.ClientAreaEnabled); }
+ }
+ #endregion
+ }
+}
#endif
\ No newline at end of file