当前位置: 首页>>代码示例>>C#>>正文


C# IPalette.GetCheckBoxImage方法代码示例

本文整理汇总了C#中IPalette.GetCheckBoxImage方法的典型用法代码示例。如果您正苦于以下问题:C# IPalette.GetCheckBoxImage方法的具体用法?C# IPalette.GetCheckBoxImage怎么用?C# IPalette.GetCheckBoxImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPalette的用法示例。


在下文中一共展示了IPalette.GetCheckBoxImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawCheckBox

        /// <summary>
        /// Perform drawing of a check box.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="palette">Palette for sourcing display values.</param>
        /// <param name="enabled">Should check box be displayed as enabled.</param>
        /// <param name="checkState">The checked state of the check box.</param>
        /// <param name="tracking">Should check box be displayed as hot tracking.</param>
        /// <param name="pressed">Should check box be displayed as pressed.</param>
        public override void DrawCheckBox(RenderContext context,
                                          Rectangle displayRect,
                                          IPalette palette,
                                          bool enabled,
                                          CheckState checkState,
                                          bool tracking,
                                          bool pressed)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            // Grab an image appropriate to the state
            Image drawImage = palette.GetCheckBoxImage(enabled, checkState, tracking, pressed);

            // If no image from the palette then get a system check box
            if (drawImage == null)
            {
                // Convert incoming parameters to check box state
                CheckBoxState state = DiscoverCheckBoxState(enabled, checkState, tracking, pressed);

                // Request the glyph be drawn at the top left of the display rectangle
                CheckBoxRenderer.DrawCheckBox(context.Graphics, displayRect.Location, state);
            }
            else
            {
                // Find the offset to center the image
                int xOffset = (displayRect.Width - drawImage.Width) / 2;
                int yOffset = (displayRect.Height - drawImage.Height) / 2;

                // Draw the image centered
                context.Graphics.DrawImage(drawImage,
                                           displayRect.X + xOffset, displayRect.Y + yOffset,
                                           drawImage.Width, drawImage.Height);
            }
        }
开发者ID:Cocotteseb,项目名称:Krypton,代码行数:49,代码来源:RenderStandard.cs

示例2: GetCheckBoxPreferredSize

        /// <summary>
        /// Calculate the requested display size for the check box.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="palette">Palette for sourcing display values.</param>
        /// <param name="enabled">Should check box be displayed as enabled.</param>
        /// <param name="checkState">The checked state of the check box.</param>
        /// <param name="tracking">Should check box be displayed as hot tracking.</param>
        /// <param name="pressed">Should check box be displayed as pressed.</param>
        public override Size GetCheckBoxPreferredSize(ViewLayoutContext context,
                                                      IPalette palette,
                                                      bool enabled,
                                                      CheckState checkState,
                                                      bool tracking,
                                                      bool pressed)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            // Grab an image appropriate to the state
            Image drawImage = palette.GetCheckBoxImage(enabled, checkState, tracking, pressed);

            // If no image from the palette then get a system check box
            if (drawImage == null)
            {
                // Convert incoming parameters to check box state
                CheckBoxState state = DiscoverCheckBoxState(enabled, checkState, tracking, pressed);

                // Request the drawing size of the check box glyph
                return CheckBoxRenderer.GetGlyphSize(context.Graphics, state);
            }
            else
                return drawImage.Size;
        }
开发者ID:Cocotteseb,项目名称:Krypton,代码行数:38,代码来源:RenderStandard.cs


注:本文中的IPalette.GetCheckBoxImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。