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


C# SolidColorBrush.Freeze方法代码示例

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


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

示例1: SolidColorBrushFromUint

        public static SolidColorBrush SolidColorBrushFromUint(uint argb)
        {
            SolidColorBrush scp = null;

            lock(s_solidColorBrushCache)
            {
                // Attempt to retrieve the color.  If it fails create it.
                if (!s_solidColorBrushCache.TryGetValue(argb, out scp))
                {
                    scp = new SolidColorBrush(Color.FromUInt32(argb));
                    scp.Freeze();
                    s_solidColorBrushCache[argb] = scp;
                }
#if DEBUG
                else
                {
                    s_count++;
                }
#endif
            }

            return scp;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:23,代码来源:Knowncolors.cs

示例2: ApplyStyle

        private void ApplyStyle(Shape shape, bool fillShape)
        {
            if (_currentState.CurrentPen == null)
            {
                // Stock Pen
                var newBrush = new SolidColorBrush(Colors.Black);
            #if !NETFX_CORE
                newBrush.Freeze();
            #endif
                shape.Stroke = newBrush;
                shape.StrokeThickness = 1;
            }
            else
            {
                LogPen currentPen = _currentState.CurrentPen;

                if (currentPen.Width > 0)
                {
                    shape.StrokeThickness = ScaleWidth(currentPen.Width);
                }

                // Style
                if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_NULL)
                {
                    // Do nothing, null is the default
                    //shape.Stroke = null;
                }
                else
                {
                    var newBrush = new SolidColorBrush(currentPen.Colour);
            #if !NETFX_CORE
                    newBrush.Freeze();
            #endif
                    shape.Stroke = newBrush;

                    if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_DASH)
                    {
                        shape.StrokeDashArray.Add(30);
                        shape.StrokeDashArray.Add(10);
                    }
                    else if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_DASHDOT)
                    {
                        shape.StrokeDashArray.Add(30);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                    }
                    else if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_DASHDOTDOT)
                    {

                        shape.StrokeDashArray.Add(30);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                    }
                    else if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_DOT)
                    {
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashCap = PenLineCap.Round;
                    }
                }

                // Join
                if ((PenStyle)(currentPen.Style & 0xF000) == PenStyle.PS_JOIN_BEVEL)
                {
                    shape.StrokeLineJoin = PenLineJoin.Bevel;
                }
                else if ((PenStyle)(currentPen.Style & 0xF000) == PenStyle.PS_JOIN_MITER)
                {
                    // Do nothing, miter is the default
                    shape.StrokeLineJoin = PenLineJoin.Miter;

                    if (_miterLimit != 0)
                    {
                        shape.StrokeMiterLimit = _miterLimit;
                    }
                }
                else if ((PenStyle)(currentPen.Style & 0xF000) == PenStyle.PS_JOIN_ROUND)
                {
                    shape.StrokeLineJoin = PenLineJoin.Round;
                }

                // End cap
                if ((PenStyle)(currentPen.Style & 0x0F00) == PenStyle.PS_ENDCAP_FLAT)
                {
                    // Do nothing, flat is the default
                    // shape.StrokeEndLineCap = PenLineCap.Flat;
                    // shape.StrokeStartLineCap = PenLineCap.Flat;
                }
                else if ((PenStyle)(currentPen.Style & 0x0F00) == PenStyle.PS_ENDCAP_SQUARE)
                {
                    shape.StrokeEndLineCap = PenLineCap.Square;
                    shape.StrokeStartLineCap = PenLineCap.Square;
//.........这里部分代码省略.........
开发者ID:bbowyersmyth,项目名称:WMF2WPF,代码行数:101,代码来源:WpfGdi.cs


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