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 ClearDrawingPanel() { DrawnShapes.Clear(); SelectedShapes.Clear(); CreateMemento(); _g.RefreshView(); }
private void SelectorCanvas_Draw(CanvasControl canvas, CanvasDrawEventArgs args) { var ds = args.DrawingSession; var W = (float)canvas.Width; var HW = W / 2; var n = SymbolShapes.Count; var m = SelectorCanvas.MinHeight; var v = (n + 1) * W; SelectorCanvas.Height = (v > m) ? v : m; var center_0 = new Vector2(HW, HW); for (int i = 0; i < n; i++) { var a = i * W; var b = (i + 1) * W; var center = new Vector2(HW, a + HW); var shape = SymbolShapes[i]; var strokeWidth = shape.StrokeWidth; if (SelectedShapes.Contains(shape)) { Shape.HighLight(ds, W, i); } shape.Draw(canvas, ds, HW, center, strokeWidth); ds.DrawLine(0, b, b, b, Colors.LightGray, 1); } }
private void ShapeSelectorMiss() { SelectedShapes.Clear(); SetSizeSliders(); SelectorCanvas.Invalidate(); SetIdleOnVoid(); }
public void Remove() { MarkedShapes.ForEach(e => Elements.Remove(e)); SelectedShapes.Clear(); UpdateInput(); RerenderAll(); }
public void DrawingPanelRightMouseButtonPressed(int mouseX, int mouseY) { RightClickPopUp = null; var clickedOnSelectedShape = SelectedShapes.Where(s => s.Contains(mouseX, mouseY)).ToList().Count > 0; if (SelectedShapes.Count > 1 && clickedOnSelectedShape) { var tmpSelectedShapes = new GroupShapes(); foreach (var shape in SelectedShapes) { tmpSelectedShapes.Add(shape); } RightClickPopUp = tmpSelectedShapes.CreateRightClickPopUp(); } else { var shape = DrawnShapes.LastOrDefault(s => s.Contains(mouseX, mouseY)); if (shape != null) { RightClickPopUp = shape.CreateRightClickPopUp(); } } if (RightClickPopUp != null) { _g.OpenRightClickPopUp(); } }
private void ConnectVisuals() { if (SelectedShapes == null || SelectedShapes.Count() != 2) { return; } AddConnection(SelectedShapes.First(), SelectedShapes.Last()); }
private void CompleteShape(ISVGElement sVGElement) { if (SelectedShapes.Count == 1) { EditMode = EditMode.None; sVGElement.Complete(); SelectedShapes.Clear(); } }
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(); }
public void DeleteSelectedShapes() { DrawnShapes.RemoveAll(s => SelectedShapes.Contains(s)); SelectedShapes.Clear(); _g.RefreshView(); ClickedOnSelectedShape = false; CreateMemento(); }
public void DrawingPanelLeftMouseButtonPressed(int mouseX, int mouseY) { var shape = SelectedShapes.FirstOrDefault(s => s.Contains(mouseX, mouseY)); if (shape != null) { ClickedOnSelectedShape = true; } }
private void ScaleShape(Shape shape) { SelectedShapes.Clear(); SelectedShapes.Add(shape); if (FocusedShapes != shape) { FocusedShapes = null; } EditMode = EditMode.Scale; }
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); }
public void CreateGroup(GroupShapes gr) { foreach (var shape in gr.Children) { DrawnShapes.Remove(shape); SelectedShapes.Remove(shape); } DrawnShapes.Add(gr); SelectedShapes.Add(gr); CreateMemento(); }
internal void ClickSelect(Shape clickedShape) { if ((Control.ModifierKeys & Keys.Control) == 0) { SelectedShapes.Clear(); } if ((_focusShape = clickedShape) != null) { SelectedShapes.Toggle(_focusShape); } RecreateSelectionAdorners(); }
private void SetIdleOnVoid() { if (SetEditorState(EditorState.IdleOnVoid)) { PickerShape = null; SelectedShapes.Clear(); SetSizeSliders(); PickerCanvas.Invalidate(); EditorCanvas.Invalidate(); } }
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(); }
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 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(); } }
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(); } }
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(); } }
private void HandleSelectionEnded(object sender, MouseButtonEventArgs e) { if (!CanvasSelectable) { return; //Canvas is marked as not selectable, abort } Point pos = e.GetPosition(c); var raycastResult = GetSelectedShapes(c, new RectangleGeometry(new Rect(Math.Min(pos.X, selectionStartPoint.X), Math.Min(pos.Y, selectionStartPoint.Y), selectionRectangle.Width, selectionRectangle.Height))); foreach (Shape s in raycastResult) { SelectedShapes.Add(s); } c.Children.Remove(selectionRectangle); selectionRectangle.Visibility = Visibility.Collapsed; }
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); }
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)); }
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(); }
private void EditorCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs args) { var ds = args.DrawingSession; var scale = EditSize / 2; DrawEditorBackgroundGrid(ds); if (EditContact == Edit_Contact.Contacts) { foreach (var shape in SymbolShapes) { var strokeWidth = shape.StrokeWidth * 5; shape.Draw(EditorCanvas, ds, scale, Center, strokeWidth, Shape.Coloring.Light); } DrawTargetContacts(ds); } else { if (SelectedShapes.Count > 0) { foreach (var shape in SymbolShapes) { var coloring = SelectedShapes.Contains(shape) ? Shape.Coloring.Light : Shape.Coloring.Gray; var strokeWidth = shape.StrokeWidth * 5; shape.Draw(EditorCanvas, ds, scale, Center, strokeWidth, coloring); } _polylineTarget = SelectedShapes.First() as Polyline; _targetPoints.Clear(); Shape.DrawTargets(SelectedShapes, _targetPoints, ds, scale, Center); } else { foreach (var shape in SymbolShapes) { var strokeWidth = shape.StrokeWidth * 5; shape.Draw(EditorCanvas, ds, scale, Center, strokeWidth, Shape.Coloring.Normal); } } SymbolCanvas.Invalidate(); SelectorCanvas.Invalidate(); } }
private void DuplicateSelected() { var newItems = new List <IShape>(); var selectedShapes = SelectedShapes.ToList(); for (int i = selectedShapes.Count - 1; i >= 0; i--) { var oldItem = selectedShapes[i]; var newItem = oldItem.Clone() as IShape; oldItem.IsSelected = false; newItem.Left += 10; newItem.Top += 10; newItems.Add(newItem); } foreach (var item in newItems) { Visuals.Add(item); } }
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(); }
private void MovableMoved(IShape sender, Point oldPos, Point newPos) { if (SelectedShapes == null) { return; } var deltaX = newPos.X - oldPos.X; var deltaY = newPos.Y - oldPos.Y; if (Math.Abs(deltaX) < 1e-6 && Math.Abs(deltaY) < 1e-6) { return; } foreach (var item in SelectedShapes?.Where(x => x != sender)) { item.Left = item.Left + deltaX; item.Top = item.Top + deltaY; } CheckBounds(sender); }