示例#1
0
 internal System.Drawing.Pen RealizeGdiPen()
 {
     if (_dirty)
     {
         if (_gdiPen == null)
         {
             _gdiPen = new System.Drawing.Pen(_color.ToGdiColor(), (float)_width);
         }
         else
         {
             _gdiPen.Color = _color.ToGdiColor();
             _gdiPen.Width = (float)_width;
         }
         LineCap lineCap = XConvert.ToLineCap(_lineCap);
         _gdiPen.StartCap   = lineCap;
         _gdiPen.EndCap     = lineCap;
         _gdiPen.LineJoin   = XConvert.ToLineJoin(_lineJoin);
         _gdiPen.DashOffset = (float)_dashOffset;
         if (_dashStyle == XDashStyle.Custom)
         {
             int     len     = _dashPattern == null ? 0 : _dashPattern.Length;
             float[] pattern = new float[len];
             for (int idx = 0; idx < len; idx++)
             {
                 pattern[idx] = (float)_dashPattern[idx];
             }
             _gdiPen.DashPattern = pattern;
         }
         else
         {
             _gdiPen.DashStyle = (System.Drawing.Drawing2D.DashStyle)_dashStyle;
         }
     }
     return(_gdiPen);
 }
示例#2
0
        internal override System.Drawing.Brush RealizeGdiBrush()
        {
            if (_gdiDirty)
            {
                if (_gdiBrush == null)
                {
                    _gdiBrush = new SolidBrush(_color.ToGdiColor());
                }
                else
                {
                    _gdiBrush.Color = _color.ToGdiColor();
                }
                _gdiDirty = false;
            }

#if DEBUG
            System.Drawing.Color clr    = _color.ToGdiColor();
            SolidBrush           brush1 = new SolidBrush(clr);
            Debug.Assert(_gdiBrush.Color == brush1.Color);
#endif
            return(_gdiBrush);
        }