Ejemplo n.º 1
0
        private void DrawSpiroKnots(DrawingContext dc, SpiroShape shape, bool shapeIsSelected, int index)
        {
            var pointCache    = FromCache(_pointStyle);
            var hitPointCache = FromCache(_hitPointStyle);

            IList <SpiroKnot> knots;

            SpiroEditor.Knots.TryGetValue(shape, out knots);
            if (knots != null)
            {
                for (int i = 0; i < knots.Count; i++)
                {
                    var knot  = knots[i];
                    var brush = shapeIsSelected && i == index ? hitPointCache.FillBrush : pointCache.FillBrush;
                    var pen   = shapeIsSelected && i == index ? hitPointCache.StrokePen : pointCache.StrokePen;
                    DrawSpiroKnot(dc, brush, pen, knot);
                }
            }
            else
            {
                for (int i = 0; i < shape.Points.Count; i++)
                {
                    var point = shape.Points[i];
                    var brush = shapeIsSelected && i == index ? hitPointCache.FillBrush : pointCache.FillBrush;
                    var pen   = shapeIsSelected && i == index ? hitPointCache.StrokePen : pointCache.StrokePen;
                    DrawSpiroPoint(dc, brush, pen, point);
                }
            }
        }
Ejemplo n.º 2
0
        private void DrawSpiroShape(DrawingContext dc, SpiroShape shape, bool isSelected)
        {
            string data;
            var    result = SpiroEditor.Data.TryGetValue(shape, out data);

            if (result && !string.IsNullOrEmpty(data))
            {
                var geometry = Geometry.Parse(data);
                if (isSelected)
                {
                    var cache = FromCache(_hitGeometryStyle);
                    dc.DrawGeometry(
                        shape.IsFilled ? cache.FillBrush : null,
                        shape.IsStroked ? cache.StrokePen : null,
                        geometry);
                }
                else
                {
                    var cache = FromCache(_geometryStyle);
                    dc.DrawGeometry(
                        shape.IsFilled ? cache.FillBrush : null,
                        shape.IsStroked ? cache.StrokePen : null,
                        geometry);
                }
            }
        }
Ejemplo n.º 3
0
 private void DrawSpiroShape(DrawingContext dc, SpiroShape shape, bool isSelected)
 {
     string data;
     var result = SpiroEditor.Data.TryGetValue(shape, out data);
     if (result && !string.IsNullOrEmpty(data))
     {
         var geometry = StreamGeometry.Parse(data);
         if (isSelected)
         {
             var cache = FromCache(_hitGeometryStyle);
             dc.DrawGeometry(
                 shape.IsFilled ? cache.FillBrush : null,
                 shape.IsStroked ? cache.StrokePen : null,
                 geometry);
         }
         else
         {
             var cache = FromCache(_geometryStyle);
             dc.DrawGeometry(
                 shape.IsFilled ? cache.FillBrush : null,
                 shape.IsStroked ? cache.StrokePen : null,
                 geometry);
         }
     }
 }
Ejemplo n.º 4
0
        private void DrawSpiroKnots(DrawingContext dc, SpiroShape shape, bool shapeIsSelected, int index)
        {
            var pointCache = FromCache(_pointStyle);
            var hitPointCache = FromCache(_hitPointStyle);

            IList<SpiroKnot> knots;
            SpiroEditor.Knots.TryGetValue(shape, out knots);
            if (knots != null)
            {
                for (int i = 0; i < knots.Count; i++)
                {
                    var knot = knots[i];
                    var brush = shapeIsSelected && i == index ? hitPointCache.FillBrush : pointCache.FillBrush;
                    var pen = shapeIsSelected && i == index ? hitPointCache.StrokePen : pointCache.StrokePen;
                    DrawSpiroKnot(dc, brush, pen, knot);
                }
            }
            else
            {
                for (int i = 0; i < shape.Points.Count; i++)
                {
                    var point = shape.Points[i];
                    var brush = shapeIsSelected && i == index ? hitPointCache.FillBrush : pointCache.FillBrush;
                    var pen = shapeIsSelected && i == index ? hitPointCache.StrokePen : pointCache.StrokePen;
                    DrawSpiroPoint(dc, brush, pen, point);
                }
            }
        }