Exemple #1
0
        protected void SelectSingleChildShape()
        {
            Controller.DeselectCurrentSelectedElements();
            GraphicElement el = Controller.GetChildShapeAt(CurrentMousePosition);

            Controller.SelectElement(el);
        }
Exemple #2
0
 protected void DetachFromAllShapes(GraphicElement el)
 {
     el.DisconnectShapeFromConnector(GripType.Start);
     el.DisconnectShapeFromConnector(GripType.End);
     el.RemoveConnection(GripType.Start);
     el.RemoveConnection(GripType.End);
 }
Exemple #3
0
        public void Redraw(GraphicElement el, int dx = 0, int dy = 0)
        {
            var els = EraseTopToBottom(el, dx, dy);

            DrawBottomToTop(els, dx, dy);
            UpdateScreen(els, dx, dy);
        }
Exemple #4
0
 public override void Update(GraphicElement el)
 {
     base.Update(el);
     el.Text      = Text;
     el.TextFont  = Font;
     el.TextColor = TextColor;
 }
        // Deselect all other elements.
        public override void SelectOnlyElement(GraphicElement el)
        {
            List <GraphicElement> intersections      = FindAllIntersections(el).ToList();
            List <GraphicElement> deselectedElements = new List <GraphicElement>();

            selectedElements.Where(e => e != el).ForEach(e =>
            {
                intersections.AddRange(FindAllIntersections(e));
                e.Deselect();
                deselectedElements.Add(e);
            });

            if (!selectedElements.Contains(el))
            {
                selectedElements.Add(el);
                el.Select();
            }

            deselectedElements.ForEach(e => selectedElements.Remove(e));

            EraseTopToBottom(intersections);
            DrawBottomToTop(intersections);
            UpdateScreen(intersections);
            ElementSelected.Fire(this, new ElementEventArgs()
            {
                Element = el
            });
        }
 public ShapeProperties(GraphicElement el) : base(el)
 {
     Text      = el.Text;
     Font      = el.TextFont;
     TextColor = el.TextColor;
     TextAlign = el.TextAlign;
 }
Exemple #7
0
 public void Remove(GraphicElement el)
 {
     if (cachedElements.Contains(el))
     {
         cachedElements.Remove(el);
     }
 }
Exemple #8
0
 public void MoveElement(GraphicElement el, Point delta)
 {
     if (el.OnScreen())
     {
         Trace.WriteLine("*** MoveElement " + el.GetType().Name);
         int dx  = delta.X.Abs();
         int dy  = delta.Y.Abs();
         var els = EraseIntersectionsTopToBottom(el, dx, dy);
         // X1
         //el.MoveUndoRedo(delta, false);
         el.Move(delta);
         el.UpdatePath();
         UpdateConnections(el);
         DrawBottomToTop(els, dx, dy);
         UpdateScreen(els, dx, dy);
     }
     else
     {
         el.CancelBackground();
         // X1
         //el.MoveUndoRedo(delta, false);
         el.Move(delta);
         // TODO: Display element if moved back on screen at this point?
     }
 }
 protected void Reorder(GraphicElement el, int n)
 {
     EraseTopToBottom(elements);
     elements.Swap(n, elements.IndexOf(el));
     DrawBottomToTop(elements);
     UpdateScreen(elements);
 }
Exemple #10
0
 public virtual void Update(GraphicElement el)
 {
     el.DisplayRectangle = Rectangle;
     el.BorderPen.Color  = BorderColor;
     el.BorderPen.Width  = BorderWidth;
     el.FillBrush.Color  = FillColor;
     el.PropertiesChanged.Fire(this, new PropertiesChangedEventArgs(el));
 }
Exemple #11
0
 public ElementProperties(GraphicElement el)
 {
     this.element = el;
     Rectangle    = el.DisplayRectangle;
     BorderColor  = el.BorderPen.Color;
     BorderWidth  = (int)el.BorderPen.Width;
     FillColor    = el.FillBrush.Color;
 }
        public void Redraw(GraphicElement el, int dx = 0, int dy = 0)
        {
            // Trace.WriteLine("Shape:Redraw1");
            var els = EraseIntersectionsTopToBottom(el, dx, dy);

            DrawBottomToTop(els, dx, dy);
            UpdateScreen(els, dx, dy);
        }
 public override void Update(GraphicElement el, string label)
 {
     (label == "Text").If(() => this.ChangePropertyWithUndoRedo <string>(el, "Text", "Text"));
     (label == "Font").If(() => this.ChangePropertyWithUndoRedo <Font>(el, "TextFont", "Font"));
     (label == "TextColor").If(() => this.ChangePropertyWithUndoRedo <Color>(el, "TextColor", "TextColor"));
     (label == "TextAlign").If(() => this.ChangePropertyWithUndoRedo <Color>(el, "TextAlign", "TextAlign"));
     base.Update(el, label);
 }
Exemple #14
0
        protected void AddShape()
        {
            Controller.DeselectGroupedElements();
            GraphicElement el = Controller.GetRootShapeAt(CurrentMousePosition);

            Controller.SelectElement(el);
            justAddedShape.Add(el);
        }
 public void DeleteElement(GraphicElement el)
 {
     el.DetachAll();
     EraseTopToBottom(elements);
     elements.Remove(el);
     el.Dispose();
     DrawBottomToTop(elements);
 }
Exemple #16
0
        public void UpdateSize(GraphicElement el, ShapeAnchor anchor, Point delta)
        {
            Point     adjustedDelta = anchor.AdjustedDelta(delta);
            Rectangle newRect       = anchor.Resize(el.DisplayRectangle, adjustedDelta);

            UpdateDisplayRectangle(el, newRect, adjustedDelta);
            UpdateConnections(el);
        }
Exemple #17
0
        public IEnumerable <GraphicElement> FindAllIntersections(GraphicElement el, int dx = 0, int dy = 0)
        {
            List <GraphicElement> intersections = new List <GraphicElement>();

            RecursiveFindAllIntersections(intersections, el, dx, dy);

            return(intersections.OrderBy(e => elements.IndexOf(e)));
        }
Exemple #18
0
        public void Redraw(GraphicElement el, int dx = 0, int dy = 0)
        {
            Trace.WriteLine("*** Redraw1 " + el.GetType().Name);
            var els = EraseIntersectionsTopToBottom(el, dx, dy);

            DrawBottomToTop(els, dx, dy);
            UpdateScreen(els, dx, dy);
        }
Exemple #19
0
 public virtual void Update(GraphicElement el, string label)
 {
     (label == "DisplayRectangle").If(() => el.DisplayRectangle = Rectangle);
     (label == "BorderColor").If(() => el.BorderPen.Color       = BorderColor);
     (label == "BorderWidth").If(() => el.BorderPen.Width       = BorderWidth);
     (label == "FillColor").If(() => el.FillBrush.Color         = FillColor);
     // el.PropertiesChanged.Fire(this, new PropertiesChangedEventArgs(el));
 }
        protected IEnumerable <GraphicElement> EraseTopToBottom(GraphicElement el, int dx = 0, int dy = 0)
        {
            Trace.WriteLine("EraseTopToBottom");
            IEnumerable <GraphicElement> intersections = FindAllIntersections(el, dx, dy);

            intersections.Where(e => e.OnScreen(dx, dy)).ForEach(e => e.Erase());

            return(intersections);
        }
Exemple #21
0
 public void UpdateConnections(GraphicElement el)
 {
     el.Connections.ForEach(c =>
     {
         // Connection point on shape.
         var cps = el.GetConnectionPoints().Where(cp2 => cp2.Type == c.ElementConnectionPoint.Type);
         cps.ForEach(cp => c.ToElement.MoveAnchor(cp, c.ToConnectionPoint));
     });
 }
Exemple #22
0
        /// <summary>
        /// Center the canvas on the selected element.
        /// This does not add the action to the undo stack.
        /// </summary>
        public void FocusOn(GraphicElement el)
        {
            int cx = (Canvas.Width - el.DisplayRectangle.Width) / 2;
            int cy = (Canvas.Height - el.DisplayRectangle.Height) / 2;
            int dx = -(el.DisplayRectangle.X - cx);
            int dy = -(el.DisplayRectangle.Y - cy);

            MoveAllElements(new Point(dx, dy));
        }
Exemple #23
0
 public void Add(GraphicElement el)
 {
     if (!cachedElements.Contains(el))
     {
         // Cache the element being deleted so we can do a proper dispose of deleted elements at some point.
         // TODO: When is that "point"?
         cachedElements.Add(el);
     }
 }
 public override void Update(GraphicElement el, string label)
 {
     // X1
     //(label == nameof(StartCap)).If(()=> this.ChangePropertyWithUndoRedo<AvailableLineCap>(el, nameof(StartCap), nameof(StartCap)));
     //(label == nameof(StartCap)).If(() => this.ChangePropertyWithUndoRedo<AvailableLineCap>(el, nameof(EndCap), nameof(EndCap)));
     (label == nameof(StartCap)).If(() => ((Connector)el).StartCap = StartCap);
     (label == nameof(EndCap)).If(() => ((Connector)el).EndCap     = EndCap);
     base.Update(el, label);
 }
Exemple #25
0
 /// <summary>
 /// Recursive loop to get all intersecting rectangles, including intersectors of the intersectees, so that all elements that
 /// are affected by an overlap redraw are erased and redrawn, otherwise we get artifacts of some intersecting elements when intersection count > 2.
 /// </summary>
 protected void FindAllIntersections(List <GraphicElement> intersections, GraphicElement el, int dx = 0, int dy = 0)
 {
     // Cool thing here is that if the element has no intersections, this list still returns that element because it intersects with itself!
     elements.Where(e => !intersections.Contains(e) && e.UpdateRectangle.IntersectsWith(el.UpdateRectangle.Grow(dx, dy))).ForEach((e) =>
     {
         intersections.Add(e);
         FindAllIntersections(intersections, e);
     });
 }
Exemple #26
0
 protected void UpdateConnections(GraphicElement el)
 {
     el.Connections.ForEach(c =>
     {
         // Connection point on shape.
         ConnectionPoint cp = el.GetConnectionPoints().Single(cp2 => cp2.Type == c.ElementConnectionPoint.Type);
         c.ToElement.MoveAnchor(cp, c.ToConnectionPoint);
     });
 }
Exemple #27
0
        public void Redraw(GraphicElement el, Action <GraphicElement> afterErase)
        {
            var els = EraseTopToBottom(el);

            UpdateScreen(els);
            afterErase(el);
            DrawBottomToTop(els);
            UpdateScreen(els);
        }
Exemple #28
0
 public void ShapeDeleted(GraphicElement el)
 {
     if (HoverShape == el)
     {
         DraggingSurface        = false;
         HoverShape.ShowAnchors = false;
         HoverShape             = null;
     }
 }
Exemple #29
0
        protected void ShowAnchors()
        {
            GraphicElement el = Controller.GetRootShapeAt(CurrentMousePosition);

            el.ShowAnchors = true;
            Controller.Redraw(el);
            HoverShape = el;
            Controller.SetAnchorCursor(el);
        }
Exemple #30
0
        public override void DeselectElement(GraphicElement el)
        {
            IEnumerable <GraphicElement> intersections = FindAllIntersections(el);

            EraseTopToBottom(intersections);
            el.Selected = false;
            selectedElements.Remove(el);
            DrawBottomToTop(intersections);
            UpdateScreen(intersections);
        }