Exemplo n.º 1
0
 private void ShapeSelectorMiss()
 {
     SelectedShapes.Clear();
     SetSizeSliders();
     SelectorCanvas.Invalidate();
     SetIdleOnVoid();
 }
 public void Remove()
 {
     MarkedShapes.ForEach(e => Elements.Remove(e));
     SelectedShapes.Clear();
     UpdateInput();
     RerenderAll();
 }
Exemplo n.º 3
0
 public void ClearDrawingPanel()
 {
     DrawnShapes.Clear();
     SelectedShapes.Clear();
     CreateMemento();
     _g.RefreshView();
 }
Exemplo n.º 4
0
        private void SymbolCanvas_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            if (_symbolPointerPressed)
            {
                _symbolPointerPressed = false;

                if (SelectedShapes.Count > 0)
                {
                    SelectedShapes.Clear();
                    SetIdleOnVoid();
                }
                else
                {
                    foreach (var shape in SymbolShapes)
                    {
                        SelectedShapes.Add(shape);
                    }
                    SetShapesAreSelected();
                }


                PickerShape = null;
                PickerCanvas.Invalidate();
            }
        }
    public void Ungroup(G g)
    {
        List <string> elementsAsHtml = Elements.Select(e => e.StoredHtml).ToList();
        int           pos            = Elements.IndexOf(g);

        elementsAsHtml[pos] = string.Join("\n", g.ChildShapes.Select(e => e.StoredHtml));
        SelectedShapes.Clear();
        InputUpdated(string.Join("\n", elementsAsHtml));
    }
 private void MoveToFront(Shape shape)
 {
     SelectedShapes.Clear();
     Elements.Remove(shape);
     Elements.Insert(Elements.Count, shape);
     Elements.ForEach(e => e.UpdateHtml());
     UpdateInput();
     RerenderAll();
 }
Exemplo n.º 7
0
        public void DeleteSelectedShapes()
        {
            DrawnShapes.RemoveAll(s => SelectedShapes.Contains(s));

            SelectedShapes.Clear();
            _g.RefreshView();
            ClickedOnSelectedShape = false;
            CreateMemento();
        }
 private void CompleteShape(ISVGElement sVGElement)
 {
     if (SelectedShapes.Count == 1)
     {
         EditMode = EditMode.None;
         sVGElement.Complete();
         SelectedShapes.Clear();
     }
 }
 private void ScaleShape(Shape shape)
 {
     SelectedShapes.Clear();
     SelectedShapes.Add(shape);
     if (FocusedShapes != shape)
     {
         FocusedShapes = null;
     }
     EditMode = EditMode.Scale;
 }
Exemplo n.º 10
0
        private void HandleSelectionBegin(object sender, MouseButtonEventArgs e)
        {
            if (!CanvasSelectable)
            {
                return; //Canvas is marked as not selectable, abort
            }
            Point pos = e.GetPosition(c);

            selectionStartPoint = pos;
            SelectedShapes.Clear(ResetEffect);
        }
Exemplo n.º 11
0
        private void SetIdleOnVoid()
        {
            if (SetEditorState(EditorState.IdleOnVoid))
            {
                PickerShape = null;
                SelectedShapes.Clear();
                SetSizeSliders();

                PickerCanvas.Invalidate();
                EditorCanvas.Invalidate();
            }
        }
Exemplo n.º 12
0
 internal void ClickSelect(Shape clickedShape)
 {
     if ((Control.ModifierKeys & Keys.Control) == 0)
     {
         SelectedShapes.Clear();
     }
     if ((_focusShape = clickedShape) != null)
     {
         SelectedShapes.Toggle(_focusShape);
     }
     RecreateSelectionAdorners();
 }
Exemplo n.º 13
0
 public void RestoreState(Memento newState)
 {
     DrawnShapes.Clear();
     SelectedShapes.Clear();
     foreach (var shape in newState.DrawnShapes)
     {
         DrawnShapes.Add((IShape)shape.Clone());
     }
     ToolBar = (ToolBar)newState.ToolBar.Clone();
     _g.RefreshView();
     _g.RefreshToolBar();
 }
Exemplo n.º 14
0
        private void CopyButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (SelectedShapes.Count > 0)
            {
                CutCopyShapes.Clear();
                foreach (var shape in SelectedShapes)
                {
                    CutCopyShapes.Add(shape.Clone());
                }
                SelectedShapes.Clear();

                EditorCanvas.Invalidate();
            }
        }
Exemplo n.º 15
0
 public void DeleteGroup(GroupShapes gr)
 {
     if (DrawnShapes.Contains(gr))
     {
         DrawnShapes.Remove(gr);
         foreach (var shape in gr.Children)
         {
             DrawnShapes.Add(shape);
         }
         SelectedShapes.Clear();
         _g.RefreshView();
     }
     CreateMemento();
 }
    private void MoveForward(Shape shape)
    {
        int index = Elements.IndexOf(shape);

        if (index != Elements.Count - 1)
        {
            SelectedShapes.Clear();
            Elements.Remove(shape);
            Elements.Insert(index + 1, shape);
            Elements.ForEach(e => e.UpdateHtml());
            UpdateInput();
            RerenderAll();
        }
    }
Exemplo n.º 17
0
 private void PasteButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     if (CutCopyShapes.Count > 0)
     {
         SelectedShapes.Clear();
         foreach (var template in CutCopyShapes)
         {
             var shape = template.Clone();
             SymbolShapes.Add(shape);
             SelectedShapes.Add(shape);
         }
         SetShapesAreSelected();
         EditorCanvas.Invalidate();
     }
 }
    public async Task PasteElementsAsync(ISVGElement SVGElement = null)
    {
        string clipboard = await JSRuntime.InvokeAsync <string>("navigator.clipboard.readText");

        List <string> elementsAsHtml = Elements.Select(e => e.StoredHtml).ToList();

        if (SVGElement != null)
        {
            int index = Elements.IndexOf(SVGElement);
            elementsAsHtml.Insert(index + 1, clipboard);
        }
        else
        {
            elementsAsHtml.Add(clipboard);
        }
        SelectedShapes.Clear();
        InputUpdated(string.Join("\n", elementsAsHtml));
    }
Exemplo n.º 19
0
        private void HandleSelectionBegin(object sender, MouseButtonEventArgs e)
        {
            if (!CanvasSelectable)
            {
                return; //Canvas is marked as not selectable, abort
            }
            if (selectionRectangle.Visibility == Visibility.Visible)
            {
                return;
            }

            Point pos = e.GetPosition(c);

            selectionStartPoint           = pos;
            selectionRectangle.Visibility = Visibility.Visible;
            c.Children.Add(selectionRectangle);
            SelectedShapes.Clear(ResetEffect);
        }
Exemplo n.º 20
0
 internal void Clear()
 {
     /* initialize local variables */
     ReferencePoint = new Point();
     /* reset object variables */
     selectedNodes.Clear();
     selectedArcs.Clear();
     foreach (var a in gd.arcIcons)
     {
         a.Selected = false;
     }
     foreach (var a in gd.hyperarcIcons)
     {
         a.Selected = false;
     }
     selectedHyperArcs.Clear();
     SelectedShapes.Clear();
 }
Exemplo n.º 21
0
        public void AddRemoveSelectedShape(int x, int y)
        {
            var shape = DrawnShapes.LastOrDefault(s => s.Contains(x, y));

            if (shape == null)
            {
                SelectedShapes.Clear();
            }
            else
            {
                if (!SelectedShapes.Contains(shape))
                {
                    SelectedShapes.Add(shape);
                }
                else
                {
                    SelectedShapes.Remove(shape);
                }
            }
            _g.RefreshView();
        }
Exemplo n.º 22
0
        private void ShapeSelectorHit(int index)
        {
            var shape = SymbolShapes[index];

            if (IsSelectOneOrMoreShapeMode)
            {
                if (SelectedShapes.Contains(shape))
                {
                    SelectedShapes.Remove(shape);
                }
                else
                {
                    SelectedShapes.Add(shape);
                }
            }
            else
            {
                SelectedShapes.Clear();
                SelectedShapes.Add(shape);
            }

            GrtProperty(shape);
            PickerShape = null;

            if (SelectedShapes.Count > 0)
            {
                SetShapesAreSelected();
            }
            else
            {
                SetIdleOnVoid();
            }

            PickerShape = null;
            SetSizeSliders();
            PickerCanvas.Invalidate();
            EditorCanvas.Invalidate();
        }
    public void Group(Shape shape)
    {
        List <string> elementsAsHtml = Elements.Select(e => e.StoredHtml).ToList();

        if (MarkedShapes.Count == 1)
        {
            int pos = Elements.IndexOf(shape);
            elementsAsHtml[pos] = "<g>" + shape.StoredHtml + "</g>";
        }
        else
        {
            ISVGElement frontElement = MarkedShapes.MaxBy(e => Elements.IndexOf(e));
            elementsAsHtml[Elements.IndexOf(frontElement)] = "<g>\n" + string.Join("\n", MarkedShapes.OrderBy(e => Elements.IndexOf(e)).Select(e => e.StoredHtml)) + "\n</g>";
            foreach (ISVGElement element in MarkedShapes.Where(e => e != frontElement))
            {
                int pos = Elements.IndexOf(element);
                Elements.RemoveAt(pos);
                elementsAsHtml.RemoveAt(pos);
            }
        }
        SelectedShapes.Clear();
        InputUpdated(string.Join("\n", elementsAsHtml));
    }