Пример #1
0
        private void AddStrokes_Click(object sender, RoutedEventArgs e)
        {
            Stroke stroke = s.Clone();

            Stroke[] strokeArray = { s };
            AddStrokes();
        }
Пример #2
0
        protected void DrawLeapTouch(Leap.Frame frame)
        {
            InteractionBox interactionBox = frame.InteractionBox;

            if (frame.Pointables.Extended().Count != 1)
            {
                return;
            }

            Pointable pointable = frame.Pointables.Extended()[0];

            // InteractionBox を利用した座標変換
            Leap.Vector normalizedPosition = interactionBox.NormalizePoint(pointable.StabilizedTipPosition);

            double                tx         = normalizedPosition.x * windowWidth;
            double                ty         = windowHeight - normalizedPosition.y * windowHeight;
            StylusPoint           touchPoint = new StylusPoint(tx, ty);
            StylusPointCollection tips       = new StylusPointCollection(new StylusPoint[] { touchPoint });

            // タッチ状態
            if (normalizedPosition.z <= TouchBorder)
            {
                Stroke touchStroke = new Stroke(tips, touchIndicator);
                this.InkCanvas_LeapPaintLine.Strokes.Add(touchStroke.Clone());
            }
        }
        protected override void OnDraw(DrawingContext drawingContext,
                                       StylusPointCollection stylusPoints,
                                       Geometry geometry, Brush fillBrush)
        {
            var str = new Stroke(stylusPoints);

            var mat = new Matrix();

            int teiler = (int)Math.Pow(2, InkCanvas.Multiplier);

            str.Draw(drawingContext, this.DrawingAttributes);

            if (!InkCanvas.LiveRender)
            {
                return;
            }

            var cx = InkCanvas.cx;
            var cy = InkCanvas.cy;


            for (int i = 0; i < teiler; i++)
            {
                mat.RotateAt(360.0 / teiler, cx, cy);
                str = str.Clone();
                str.Transform(mat, false);
                str.Draw(drawingContext, this.DrawingAttributes);
            }


            str = str.Clone();
            mat.ScaleAt(-1, 1, cx, cy);
            str.Transform(mat, false);
            str.Draw(drawingContext, this.DrawingAttributes);

            mat = new Matrix();

            for (int i = 0; i < teiler; i++)
            {
                mat.RotateAt(360.0 / teiler, cx, cy);
                str = str.Clone();
                str.Transform(mat, false);

                str.Draw(drawingContext, this.DrawingAttributes);
            }
        }
Пример #4
0
 public void UpdateStrokeForFocused(Stroke stroke)
 {
     if (_selected.Count != 1)
     {
         return;
     }
     FileChanged         = true;
     _selected[0].Stroke = (Stroke)stroke.Clone();
     _container.Invalidate();
 }
Пример #5
0
        // 复制
        object ICloneable.Clone()
        {
            Segment seg = new Segment();

            seg.X1     = X1;
            seg.Y1     = Y1;
            seg.X2     = X2;
            seg.Y2     = Y2;
            seg.Stroke = Stroke.Clone();
            return(seg);
        }
Пример #6
0
 public override void MouseUp(Point point, CustomStrokeCollection strokes)
 {
     if (ActiveStroke != null)
     {
         strokes.Remove(ActiveStroke);
         var clone = ActiveStroke.Clone();
         strokes.Add(clone);
         ((CustomStroke)clone).Select();
         EditionSocket.AddStroke(((Savable)clone).toJson());
         Editeur.instance.Do(new NewStroke(((CustomStroke)clone).Id.ToString(), ((Savable)clone).toJson()));
     }
     IsDrawing = false;
     this.FirstAnchorPointId = null;
 }
Пример #7
0
 /// <summary>
 /// Clones shape style.
 /// </summary>
 /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns>
 public ShapeStyle Clone()
 {
     return(new ShapeStyle()
     {
         Name = Name,
         Stroke = Stroke.Clone(),
         Fill = Fill.Clone(),
         Thickness = Thickness,
         LineCap = LineCap,
         Dashes = Dashes,
         DashOffset = 0.0,
         LineStyle = _lineStyle.Clone(),
         TextStyle = _textStyle.Clone(),
         StartArrowStyle = _startArrowStyle.Clone(),
         EndArrowStyle = _endArrowStyle.Clone()
     });
 }
Пример #8
0
 protected virtual void CloneTo(DDObject target)
 {
     target.X      = X;
     target.Y      = Y;
     target.Width  = Width;
     target.Height = Height;
     if (Fill != null)
     {
         target.Fill = Fill.Clone();
     }
     if (Stroke != null)
     {
         target.Stroke = Stroke.Clone();
     }
     target.StrokeThickness = StrokeThickness;
     //TODO: Add more when needed!
 }
Пример #9
0
 protected virtual void CopyToCLR(Shape target)
 {
     Canvas.SetLeft(target, X);
     Canvas.SetTop(target, Y);
     target.Width  = Width;
     target.Height = Height;
     if (Fill != null)
     {
         target.Fill = Fill.Clone();
     }
     if (Stroke != null)
     {
         target.Stroke = Stroke.Clone();
     }
     target.StrokeThickness = StrokeThickness;
     //TODO: Add more when needed!
 }
Пример #10
0
 /// <summary>
 /// Clones arrow style.
 /// </summary>
 /// <returns>The new instance of the <see cref="ArrowStyle"/> class.</returns>
 public ArrowStyle Clone()
 {
     return(new ArrowStyle()
     {
         Name = Name,
         Stroke = Stroke.Clone(),
         Fill = Fill.Clone(),
         Thickness = Thickness,
         LineCap = LineCap,
         Dashes = Dashes,
         DashOffset = DashOffset,
         ArrowType = _arrowType,
         IsStroked = _isStroked,
         IsFilled = _isFilled,
         RadiusX = _radiusX,
         RadiusY = _radiusY
     });
 }
Пример #11
0
        private void inkcanvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (drawCanvas.myCanvas.EditingMode == InkCanvasEditingMode.None)
            {
                if (st != null)
                {
                    drawCanvas.myCanvas.Strokes.Remove(st);
                    drawCanvas.myCanvas.Strokes.Add(st.Clone());
                }
                IsDrawing = false;
                StreamResourceInfo sri          = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/PointerImage/unselected_pointer.cur", UriKind.RelativeOrAbsolute));
                Cursor             customCursor = new Cursor(sri.Stream);
                drawCanvas.myCanvas.Cursor = customCursor;
            }
            //笔触记录

            drawCanvas.strokeList.Add(theNumberOfStrokIndex);
        }
Пример #12
0
        // <Snippet5>

        // <Snippet22>

        Stroke GetLittleRedStroke(Stroke theStroke)
        {
            // Copy the incoming stroke
            Stroke sCopy = theStroke.Clone();

            // Scale it by 50%
            Matrix xform = new Matrix();

            xform.Scale(0.5, 0.5);

            sCopy.Transform(xform, false);

            // Color it red
            sCopy.DrawingAttributes.Color = Colors.Red;

            // Return the new stroke
            return(sCopy);
        }
Пример #13
0
        public override void MouseUp(Point point, CustomStrokeCollection strokes)
        {
            if (ActiveStroke != null)
            {
                strokes.Remove(ActiveStroke);
                var clone = ActiveStroke.Clone();
                if (clone is TextStroke)
                {
                    ((TextStroke)clone).showBorder = false;
                }

                strokes.Add(clone);
                ((CustomStroke)clone).Select();
                EditionSocket.AddStroke(((Savable)clone).toJson());
                Editeur.instance.Do(new NewStroke(((CustomStroke)clone).Id.ToString(), ((Savable)clone).toJson()));
            }
            IsDrawing = false;
        }
Пример #14
0
        /// <summary>
        /// Clones the Stroq. This does as deep a clone as it can manage--properties are Cloned if they are ICloneable, but simply copied otherwise.
        /// Callbacks are *not* copied over. (For now. Is this the right decision?) However, if properties are IStroqCloneable, AfterClone will be
        /// called on the cloned property so it can fix callbacks, etc.
        /// </summary>
        /// <returns></returns>
        public Stroq Clone()
        {
            Dictionary <Guid, object> sprops = new Dictionary <Guid, object>(_strokeProperties.Count);

            foreach (var sp in _strokeProperties)
            {
                ICloneable pval = sp.Value as ICloneable;
                sprops[sp.Key] = pval == null ? sp.Value : (object)pval.Clone();
            }
            Dictionary <Guid, SortedDictionary <int, object> > ptprops = new Dictionary <Guid, SortedDictionary <int, object> >(_ptProperties.Count);

            foreach (var pp in _ptProperties)
            {
                ptprops[pp.Key] = new SortedDictionary <int, object>();
                foreach (var prop in pp.Value)
                {
                    ICloneable pval = prop.Value as ICloneable;
                    ptprops[pp.Key][prop.Key] = pval == null ? prop.Value : (object)pval.Clone();
                }
            }
            return(new Stroq(_backingStroke.Clone(), sprops, ptprops, this));
        }
Пример #15
0
        /// <summary>
        /// Analyze a new stroke.
        /// </summary>
        /// <param name="stroke"></param>
        /// <returns>true if the stroke was recognized as belonging to a graph (and so should be excluded from InkAnalyzer)</returns>
        public bool newStroke(Stroke stroke)
        {
            if (strokes.ContainsKey(stroke))
            {
                // already have it!
                return(true);
            }
            foreach (Graph g in graphs)
            {
                if (g.containsStroke(stroke) && g.takeStroke(stroke))
                {
                    strokes.Add(stroke, g);
                    return(true);
                }
            }
            Stroke copy = stroke.Clone();

            analyzer.AddStroke(copy);

            analyzer.Analyze();

            StrokeCollection      sc       = new StrokeCollection(new Stroke[] { copy });
            ContextNodeCollection ctxNodes = analyzer.FindInkLeafNodes(sc);

            foreach (ContextNode ctxNode in ctxNodes)
            {
                if (ctxNode is InkDrawingNode && (ctxNode as InkDrawingNode).GetShapeName() == "Rectangle")
                {
                    Graph g = new XYGraph(this, stroke);
                    graphs.Add(g);
                    strokes.Add(stroke, g);
                    analyzer.RemoveStroke(copy);
                    return(true);
                }
            }
            analyzer.RemoveStroke(copy);
            return(false);
        }
Пример #16
0
 public ComplexStroke(Stroke stroke)
 {
     BaseStroke = stroke.Clone();
     UpdateComplexPoints();
 }
Пример #17
0
        /// <summary>
        /// Отпускание кнопки мышки
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContainerMouseUp(object sender, MouseEventArgs e)
        {
            // если мышь была захвачена
            if (!_container.Capture)
            {
                return;
            }
            // освобождаем захват мышки
            _container.Capture = false;
            // если нажата левая кнопка
            if (e.Button == MouseButtons.Left)
            {
                var    rect = _ribbonRect;
                Figure figure;
                switch (EditorMode)
                {
                case EditorMode.Selection:
                    // нормализация параметров для прямоугольника выбора
                    // добавляем все фигуры, которые оказались охваченными прямоугольником выбора
                    // в список выбранных фигур
                    foreach (var fig in _figures.Where(fig => rect.Contains(Rectangle.Ceiling(fig.Bounds))))
                    {
                        _selected.Add(fig);
                    }
                    if (_selected.Count > 0)
                    {
                        Focus(_selected[0]);
                    }
                    break;

                // перетаскивание выбранных фигур "мышкой"
                case EditorMode.Dragging:
                    if (CurrentMarker == null)
                    {
                        FileChanged = true;
                        // перебираем все выделенные фигуры и смещаем
                        foreach (var fig in _selected)
                        {
                            fig.UpdateLocation(_mouseOffset);
                        }
                        _container.Invalidate();
                        OnEditorFarConnerUpdated();
                    }
                    else if (CurrentMarker is ISizeMarker)     // тянут за размерный маркер
                    {
                        FileChanged = true;
                        // перебираем все выделенные фигуры и меняем размер
                        foreach (var fig in _selected)
                        {
                            fig.UpdateSize(_mouseOffset, CurrentMarker);
                        }
                        _container.Invalidate();
                        OnEditorFarConnerUpdated();
                    }
                    else if ((CurrentMarker is VertexLocationMarker) && _selected.Count == 1)     // тянут за маркер узла
                    {
                        FileChanged = true;
                        var fig = _selected[0];
                        fig.UpdateSize(_mouseOffset, CurrentMarker);
                        _container.Invalidate();
                        OnEditorFarConnerUpdated();
                    }
                    break;

                //TODO Сделать что-то с этой "лестницей"
                case EditorMode.AddLine:
                    figure = new Polyline(MouseDownLocation, _mouseOffset)
                    {
                        Stroke = (Stroke)DefaultStroke.Clone()
                    };
                    AddFigure(figure);
                    OnEditorFarConnerUpdated();
                    break;

                case EditorMode.AddPolygon:
                    figure = new Polygon(rect.Location, new Point(rect.Width, rect.Height))
                    {
                        Stroke = (Stroke)DefaultStroke.Clone(),
                        Fill   = (Fill)DefaultFill.Clone()
                    };
                    AddFigure(figure);
                    OnEditorFarConnerUpdated();
                    break;

                case EditorMode.AddRectangle:
                    figure = new Rect(rect.Location, new Point(rect.Width, rect.Height))
                    {
                        Stroke = (Stroke)DefaultStroke.Clone(),
                        Fill   = (Fill)DefaultFill.Clone()
                    };
                    AddFigure(figure);
                    OnEditorFarConnerUpdated();
                    break;

                case EditorMode.AddSquare:
                    figure = new Square(rect.Location,
                                        new Point(Math.Min(rect.Width, rect.Height), Math.Min(rect.Width, rect.Height)))
                    {
                        Stroke = (Stroke)DefaultStroke.Clone(),
                        Fill   = (Fill)DefaultFill.Clone()
                    };
                    AddFigure(figure);
                    OnEditorFarConnerUpdated();
                    break;

                case EditorMode.AddEllipse:
                    figure = new Oval(rect.Location, new Point(rect.Width, rect.Height))
                    {
                        Stroke = (Stroke)DefaultStroke.Clone(),
                        Fill   = (Fill)DefaultFill.Clone()
                    };
                    AddFigure(figure);
                    OnEditorFarConnerUpdated();
                    break;

                case EditorMode.AddCircle:
                    figure = new Circle(rect.Location,
                                        new Point(Math.Min(rect.Width, rect.Height), Math.Min(rect.Width, rect.Height)))
                    {
                        Stroke = (Stroke)DefaultStroke.Clone(),
                        Fill   = (Fill)DefaultFill.Clone()
                    };
                    AddFigure(figure);
                    OnEditorFarConnerUpdated();
                    break;
                }
            }
            // возвращаем режим
            EditorMode = EditorMode.Selection;
            // обнуление прямоугольника выбора
            _ribbonRect = Rectangle.Empty;
            _pt1        = _pt2 = Point.Empty;
            _container.Invalidate();
        }