Ejemplo n.º 1
0
        internal WpfPen RealizeWpfPen()
        {
#if !SILVERLIGHT
            if (_dirty || !_dirty) // TODOWPF: XPen is frozen by design, WPF Pen can change
            {
                //if (_wpfPen == null)
                _wpfPen = new WpfPen(new SolidColorBrush(_color.ToWpfColor()), _width);
                //else
                //{
                //  _wpfPen.Brush = new SolidColorBrush(_color.ToWpfColor());
                //  _wpfPen.Thickness = _width;
                //}
                PenLineCap lineCap = XConvert.ToPenLineCap(_lineCap);
                _wpfPen.StartLineCap = lineCap;
                _wpfPen.EndLineCap   = lineCap;
                _wpfPen.LineJoin     = XConvert.ToPenLineJoin(_lineJoin);
                if (_dashStyle == XDashStyle.Custom)
                {
                    // TODOWPF: does not work in all cases
                    _wpfPen.DashStyle = new System.Windows.Media.DashStyle(_dashPattern, _dashOffset);
                }
                else
                {
                    switch (_dashStyle)
                    {
                    case XDashStyle.Solid:
                        _wpfPen.DashStyle = DashStyles.Solid;
                        break;

                    case XDashStyle.Dash:
                        //_wpfPen.DashStyle = DashStyles.Dash;
                        _wpfPen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 2, 2 }, 0);
                        break;

                    case XDashStyle.Dot:
                        //_wpfPen.DashStyle = DashStyles.Dot;
                        _wpfPen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 0, 2 }, 1.5);
                        break;

                    case XDashStyle.DashDot:
                        //_wpfPen.DashStyle = DashStyles.DashDot;
                        _wpfPen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 2, 2, 0, 2 }, 0);
                        break;

                    case XDashStyle.DashDotDot:
                        //_wpfPen.DashStyle = DashStyles.DashDotDot;
                        _wpfPen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 2, 2, 0, 2, 0, 2 }, 0);
                        break;
                    }
                }
            }
#else
            _wpfPen           = new System.Windows.Media.Pen();
            _wpfPen.Brush     = new SolidColorBrush(_color.ToWpfColor());
            _wpfPen.Thickness = _width;
#endif
            return(_wpfPen);
        }
Ejemplo n.º 2
0
        internal override System.Windows.Media.Brush RealizeWpfBrush()
        {
            if (_wpfDirty)
            {
                if (_wpfBrush == null)
                {
                    _wpfBrush = new SolidColorBrush(_color.ToWpfColor());
                }
                else
                {
                    _wpfBrush.Color = _color.ToWpfColor();
                }
                _wpfDirty = false;
            }

#if DEBUG_
            System.Windows.Media.Color           clr    = _color.ToWpfColor();
            System.Windows.Media.SolidColorBrush brush1 = new System.Windows.Media.SolidColorBrush(clr); //System.Drawing.Color.FromArgb(128, 128, 0, 0));
            Debug.Assert(_wpfBrush.Color == brush1.Color);                                               // Crashes during unit testing
#endif
            return(_wpfBrush);
        }