예제 #1
0
 public void ApplyStyle(CanvasStyle style)
 {
     _path.Fill = style.Fill;
     _path.Stroke = style.Stroke;
     _path.StrokeThickness = style.StrokeWidth;
     _path.StrokeLineJoin = style.StrokeLineJoin;
     _path.StrokeEndLineCap = style.LineCap;
     _path.StrokeStartLineCap = style.LineCap;
     _path.StrokeMiterLimit = style.StrokeMiterLimit;
     _path.Opacity = style.GlobalAlpha;
     _latestStyle = style;
 }
예제 #2
0
 private bool AreStylesEquals(Path _path, CanvasStyle style)
 {
     return _path.Fill == style.Fill &&
            _path.Stroke == style.Stroke &&
            _path.StrokeThickness == style.StrokeWidth &&
            _path.StrokeLineJoin == style.StrokeLineJoin &&
            _path.StrokeEndLineCap == style.LineCap &&
            _path.StrokeStartLineCap == style.LineCap &&
            _path.StrokeMiterLimit == style.StrokeMiterLimit &&
            _path.Opacity == style.GlobalAlpha;
 }
예제 #3
0
 public CanvasStyle GetStyle()
 {
     //use super constructor in order to avoid triggers CommitAndApplyStyle after each property get-call
     var style = new CanvasStyle(this, _path.Fill.Clone(), _path.Stroke.Clone(), _path.StrokeThickness,
                                 _path.StrokeLineJoin, _path.StrokeEndLineCap,
                                 (float) _path.StrokeMiterLimit, _path.Opacity);
     return style;
 }
예제 #4
0
 public void CommitAndApplyStyle(CanvasStyle style)
 {
     bool isDifferentStyle = !AreStylesEquals(_path, style);
     if (!_isEmpty)
     {
         if (isDifferentStyle)
         {
     //style is changed, so we have to have new path
             Commit();
         }
         else
         {
     //style the same, so we can keep current path and continue draw in it
             CommitToGeometryAndInit();
         }
     }
     ApplyStyle(style);
 }
예제 #5
0
 public CanvasState(CanvasStyle style, MatrixTransform transformation)
 {
     Style = style;
     Transformation = transformation;
 }
 private void SetDefaultValues()
 {
     _fill = Brushes.Black;
     _stroke = Brushes.Black;
     //store current style
     _style = new CanvasStyle(_path);
     _style.Fill = _fill;
     _style.Stroke = _stroke;
     _textAlign = "start";
     _textBaseLine = "alphabetic";
     _globalAlpha = 1.0;
     _globalCompositeOperation = "source-over";
     _shadowColor = "rgba(0,0,0,0)";
     _shadowOffsetX = 0;
     _shadowOffsetY = 0;
     _shadowBlur = 0;
     lineWidth = 1.0;
     lineCap = "butt";
     lineJoin = "miter";
     miterLimit = 10.0;
     globalAlpha = 1;
     _compositier = new Compositer();
 }