Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / ScrollBarRenderer.cs / 1 / ScrollBarRenderer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using System.Drawing; using System.Windows.Forms.VisualStyles; using System.Diagnostics.CodeAnalysis; using Microsoft.Win32; ////// /// public sealed class ScrollBarRenderer { //Make this per-thread, so that different threads can safely use these methods. [ThreadStatic] private static VisualStyleRenderer visualStyleRenderer = null; //cannot instantiate private ScrollBarRenderer() { } ////// This is a rendering class for the ScrollBar control. /// ////// /// public static bool IsSupported { get { return VisualStyleRenderer.IsSupported; // no downlevel support } } ////// Returns true if this class is supported for the current OS and user/application settings, /// otherwise returns false. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawArrowButton(Graphics g, Rectangle bounds, ScrollBarArrowButtonState state) { InitializeRenderer(VisualStyleElement.ScrollBar.ArrowButton.LeftNormal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a ScrollBar arrow button. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawHorizontalThumb(Graphics g, Rectangle bounds, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.ThumbButtonHorizontal.Normal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a horizontal ScrollBar thumb. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawVerticalThumb(Graphics g, Rectangle bounds, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.ThumbButtonVertical.Normal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a vertical ScrollBar thumb. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawHorizontalThumbGrip(Graphics g, Rectangle bounds, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.GripperHorizontal.Normal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a horizontal ScrollBar thumb grip. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawVerticalThumbGrip(Graphics g, Rectangle bounds, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.GripperVertical.Normal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a vertical ScrollBar thumb grip. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawRightHorizontalTrack(Graphics g, Rectangle bounds, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.RightTrackHorizontal.Normal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a horizontal ScrollBar thumb. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawLeftHorizontalTrack(Graphics g, Rectangle bounds, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.LeftTrackHorizontal.Normal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a horizontal ScrollBar thumb. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawUpperVerticalTrack(Graphics g, Rectangle bounds, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.UpperTrackVertical.Normal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a vertical ScrollBar thumb in the center of the given bounds. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawLowerVerticalTrack(Graphics g, Rectangle bounds, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.LowerTrackVertical.Normal, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a vertical ScrollBar thumb in the center of the given bounds. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static void DrawSizeBox(Graphics g, Rectangle bounds, ScrollBarSizeBoxState state) { InitializeRenderer(VisualStyleElement.ScrollBar.SizeBox.LeftAlign, (int)state); visualStyleRenderer.DrawBackground(g, bounds); } ////// Renders a ScrollBar size box in the center of the given bounds. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static Size GetThumbGripSize(Graphics g, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.GripperHorizontal.Normal, (int)state); return visualStyleRenderer.GetPartSize(g, ThemeSizeType.True); } ////// Returns the size of the ScrollBar thumb grip. /// ////// /// [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally public static Size GetSizeBoxSize(Graphics g, ScrollBarState state) { InitializeRenderer(VisualStyleElement.ScrollBar.SizeBox.LeftAlign, (int)state); return visualStyleRenderer.GetPartSize(g, ThemeSizeType.True); } private static void InitializeRenderer(VisualStyleElement element, int state) { if (visualStyleRenderer == null) { visualStyleRenderer = new VisualStyleRenderer(element.ClassName, element.Part, state); } else { visualStyleRenderer.SetParameters(element.ClassName, element.Part, state); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved./// Returns the size of the ScrollBar size box. /// ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IOException.cs
- OracleTransaction.cs
- AnnotationMap.cs
- UIAgentMonitor.cs
- SqlVersion.cs
- PackagingUtilities.cs
- SerializableAttribute.cs
- RadioButtonFlatAdapter.cs
- HyperLinkDesigner.cs
- InfoCardXmlSerializer.cs
- TextRange.cs
- OracleDataReader.cs
- WebPartConnectVerb.cs
- CompilationRelaxations.cs
- DependencySource.cs
- IteratorFilter.cs
- PropertyPathWorker.cs
- PageTheme.cs
- WsdlBuildProvider.cs
- Baml2006Reader.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- ConfigXmlSignificantWhitespace.cs
- OdbcConnectionHandle.cs
- ObjectDataSourceFilteringEventArgs.cs
- DataGridViewButtonCell.cs
- DetailsViewPageEventArgs.cs
- TableCellAutomationPeer.cs
- IsolatedStorageFileStream.cs
- ListDictionary.cs
- TargetException.cs
- InsufficientMemoryException.cs
- NameValueSectionHandler.cs
- SoapObjectWriter.cs
- CompareValidator.cs
- mactripleDES.cs
- Convert.cs
- XsdDataContractImporter.cs
- FormViewAutoFormat.cs
- Sql8ExpressionRewriter.cs
- DataListCommandEventArgs.cs
- RefType.cs
- SqlConnectionFactory.cs
- SafeHandle.cs
- FSWPathEditor.cs
- RawUIStateInputReport.cs
- TransformerInfo.cs
- GacUtil.cs
- FormsAuthenticationUserCollection.cs
- ExecutionContext.cs
- CachedCompositeFamily.cs
- IssuedTokenClientBehaviorsElement.cs
- ColumnClickEvent.cs
- DbConnectionPoolGroupProviderInfo.cs
- PathSegment.cs
- RestHandler.cs
- LocalFileSettingsProvider.cs
- MetaColumn.cs
- MachineSettingsSection.cs
- QueryConverter.cs
- ClientRolePrincipal.cs
- XPathParser.cs
- CFStream.cs
- EdmSchemaAttribute.cs
- SafeNativeMethods.cs
- CodeMemberProperty.cs
- AssertSection.cs
- ValidatingPropertiesEventArgs.cs
- DocComment.cs
- NumericUpDownAcceleration.cs
- BitmapEffectInput.cs
- AssociationSet.cs
- NameValueConfigurationElement.cs
- FormatterConverter.cs
- AdornerDecorator.cs
- BindingGraph.cs
- TransactionFlowProperty.cs
- TemplateManager.cs
- XmlNodeList.cs
- NameValueSectionHandler.cs
- SoapFault.cs
- OrCondition.cs
- IsolationInterop.cs
- StylusEventArgs.cs
- ImageMetadata.cs
- BinaryKeyIdentifierClause.cs
- PrimitiveXmlSerializers.cs
- ZipIOExtraFieldElement.cs
- FocusChangedEventArgs.cs
- MimeWriter.cs
- InputProcessorProfilesLoader.cs
- LassoSelectionBehavior.cs
- Visual3D.cs
- RotationValidation.cs
- DataListItemCollection.cs
- StreamGeometryContext.cs
- RefType.cs
- HtmlControl.cs
- InternalControlCollection.cs
- JavaScriptString.cs
- StringAttributeCollection.cs