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


C# Color.GetTextColor方法代码示例

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


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

示例1: DrawItem

        // For Ownder Drawn TreeViews
        public static void DrawItem(this DrawTreeNodeEventArgs e, Color channelColor, TreeView treeView, bool useCheckmark)
        {
            if (treeView == null) {
                e.DrawDefault = true;
                return;
            }

            if (e.Bounds.Left < 0 || e.Bounds.Top < 0) {
                return;
            }

            var fillRect = new Rectangle(e.Node.Bounds.X, e.Node.Bounds.Y, treeView.Width - e.Node.Bounds.Left, e.Node.Bounds.Height);
            GenericBrush.Color = channelColor;

            bool selected;
            var view = treeView as MultiSelectTreeview;
            if (view != null) {
                selected = view.SelectedNodes.Contains(e.Node);
            }
            else {
                selected = (e.State & TreeNodeStates.Selected) != 0;
            }

            var rectBrush = selected && !useCheckmark ? SystemBrushes.Highlight : GenericBrush;
            e.Graphics.FillRectangle(rectBrush, fillRect);
            var stringBrush = selected && !useCheckmark ? SystemBrushes.HighlightText : channelColor.GetTextColor();
            e.Graphics.DrawString(e.Node.Text, treeView.Font, stringBrush, e.Bounds.Left, e.Bounds.Top);

            if (selected && useCheckmark) {
                e.Graphics.DrawString(Checkmark, treeView.Font, channelColor.GetTextColor(), fillRect.Right - 40, e.Bounds.Top);
            }
        }
开发者ID:jmcadams,项目名称:vplus,代码行数:33,代码来源:OwnerDrawnUtils.cs

示例2: DrawItemWide

        public static void DrawItemWide(this DrawItemEventArgs e, string name, Color color, bool useCheckmark)
        {
            //TODO: Dupe from above
            e.DrawBackground();

            var selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected ||
                           (e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit;
            GenericBrush.Color = color;
            e.Graphics.FillRectangle(selected && !useCheckmark ? SystemBrushes.Highlight : GenericBrush, e.Bounds);
            var contrastingBrush = selected && !useCheckmark ? SystemBrushes.HighlightText : color.GetTextColor();
            // End Dupe

            var loc = e.Bounds.Location;
            if (useCheckmark) {
                loc.Offset((int)e.Graphics.MeasureString(Checkmark, e.Font).Width + 2, 0);
            }
            e.Graphics.DrawString(name, e.Font, contrastingBrush, new RectangleF(loc, e.Graphics.MeasureString(name, e.Font)));
            if (selected && useCheckmark) {
                e.Graphics.DrawString(Checkmark, e.Font, contrastingBrush, 2, e.Bounds.Y);
            }
            e.DrawFocusRectangle();
        }
开发者ID:jmcadams,项目名称:vplus,代码行数:22,代码来源:OwnerDrawnUtils.cs


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