コード例 #1
0
ファイル: XPen.cs プロジェクト: jmora000/Impresora-Braille
        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);
        }
コード例 #2
0
ファイル: XSolidBrush.cs プロジェクト: mapilab/PDFsharp
        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);
        }
コード例 #3
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
    //public void Flush();
    //public void Flush(FlushIntention intention);

    #region Drawing

    // ----- Clear --------------------------------------------------------------------------------

    /// <summary>
    /// Fills the entire drawing surface with the specified color. The functions works only if
    /// the current transformation is identity, i.e. the function should be called only immediately
    /// after the XGraphics object was created.
    /// </summary>
    public void Clear(XColor color)
    {
      if (this.drawGraphics)
      {
#if GDI
        if (this.targetContext == XGraphicTargetContext.GDI)
          this.gfx.Clear(color.ToGdiColor());
#endif
#if WPF
        if (this.targetContext == XGraphicTargetContext.WPF)
        {
          Rect rc = new Rect();
          rc.Width = rc.Height = 10000;
          this.dc.DrawRectangle(new SolidColorBrush(color.ToWpfColor()), null, rc);
        }
#endif
      }

      if (this.renderer != null)
        this.renderer.Clear(color);
    }