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? } }
/// <summary> /// Clone onto the specified canvas the default shape. /// </summary> public virtual GraphicElement CloneDefault(Canvas canvas, Point offset) { GraphicElement el = (GraphicElement)Activator.CreateInstance(GetType(), new object[] { canvas }); el.DisplayRectangle = el.DefaultRectangle(); el.Move(offset); el.UpdateProperties(); el.UpdatePath(); return el; }
// We're using reflect here so that the call: // ex: this.ChangePropertyWithUndoRedo<string>(el, "Text", "Text")); // can be as general purpose as possible, otherwise we have to write separate undo/redo handlers for each property, which is just gross. public static void ChangePropertyWithUndoRedo <T>(this ElementProperties props, GraphicElement el, string elementPropertyName, string propertyName) { T save = default(T); T redosave = default(T); PropertyInfo piElement = el.GetType().GetProperty(elementPropertyName); PropertyInfo piThis = props.GetType().GetProperty(propertyName); el.Canvas.Controller.UndoStack.Do((@do, redo) => { if (redo) { piElement.SetValue(el, redosave); piThis.SetValue(props, redosave); el.Canvas.Controller.ElementSelected.Fire(props, new ElementEventArgs() { Element = el }); el.UpdateProperties(); el.UpdatePath(); el.Canvas.Controller.Redraw(el); } else if (@do) { save = CastObject <T>(piElement.GetValue(el)); T newVal = CastObject <T>(piThis.GetValue(props)); piElement.SetValue(el, newVal); redosave = newVal; } else { piElement.SetValue(el, save); piThis.SetValue(props, save); el.Canvas.Controller.ElementSelected.Fire(props, new ElementEventArgs() { Element = el }); el.UpdateProperties(); el.UpdatePath(); el.Canvas.Controller.Redraw(el); } }); }
public void Redraw(GraphicElement el, Action <GraphicElement> afterErase) { Trace.WriteLine("*** Redraw2 " + el.GetType().Name); var els = EraseIntersectionsTopToBottom(el); UpdateScreen(els); afterErase(el); el.UpdatePath(); DrawBottomToTop(els); UpdateScreen(els); }
/// <summary> /// Direct update of display rectangle, used in DynamicConnector. /// </summary> public void UpdateDisplayRectangle(GraphicElement el, Rectangle newRect, Point delta) { int dx = delta.X.Abs(); int dy = delta.Y.Abs(); var els = EraseTopToBottom(el, dx, dy); el.DisplayRectangle = newRect; el.UpdatePath(); DrawBottomToTop(els, dx, dy); UpdateScreen(els, dx, dy); }
public void Redraw(GraphicElement el, Action <GraphicElement> afterErase) { // Trace.WriteLine("Shape:Redraw2"); var els = EraseIntersectionsTopToBottom(el); UpdateScreen(els); afterErase(el); el.UpdatePath(); DrawBottomToTop(els); UpdateScreen(els); }
/// <summary> /// Direct update of display rectangle, used in DynamicConnector. /// </summary> public void UpdateDisplayRectangle(GraphicElement el, Rectangle newRect, Point delta) { Trace.WriteLine("*** UpdateDisplayRectangle " + el.GetType().Name); int dx = delta.X.Abs(); int dy = delta.Y.Abs(); var els = EraseIntersectionsTopToBottom(el, dx, dy); el.DisplayRectangle = newRect; el.UpdatePath(); DrawBottomToTop(els, dx, dy); UpdateScreen(els, dx, dy); }
/// <summary> /// Direct update of display rectangle, used in DynamicConnector. /// </summary> public void UpdateDisplayRectangle(GraphicElement el, Rectangle newRect, Point delta) { int dx = delta.X.Abs(); int dy = delta.Y.Abs(); var els = EraseIntersectionsTopToBottom(el, dx, dy); // X1 // el.ChangePropertyWithUndoRedo(nameof(el.DisplayRectangle), newRect, false); el.DisplayRectangle = newRect; el.UpdatePath(); DrawBottomToTop(els, dx, dy); UpdateScreen(els, dx, dy); }
// Sort of kludgy workaround for Issue #40? // TODO: Vertical / Horizontal shapes represent a sort of special case, which we might want to deal with at some point // in the future. public void MoveElementNoEraseNorRedraw(GraphicElement el, Point delta) { if (el.OnScreen()) { int dx = delta.X.Abs(); int dy = delta.Y.Abs(); el.Move(delta); el.UpdatePath(); } else { el.Move(delta); } }
public void MoveElement(GraphicElement el, Point delta) { if (el.OnScreen()) { int dx = delta.X.Abs(); int dy = delta.Y.Abs(); var els = EraseTopToBottom(el, dx, dy); el.Move(delta); el.UpdatePath(); DrawBottomToTop(els, dx, dy); UpdateScreen(els, dx, dy); } else { el.CancelBackground(); el.Move(delta); // TODO: Display element if moved back on screen at this point? } }
public void MoveElementTo(GraphicElement el, Point location) { Point delta = new Point(location.X - el.DisplayRectangle.Left, location.Y - el.DisplayRectangle.Top); if (el.OnScreen()) { Trace.WriteLine("*** MoveElement " + el.GetType().Name); int dx = delta.X.Abs(); int dy = delta.Y.Abs(); var els = EraseOurselvesAndIntersectionsTopToBottom(el, dx, dy); el.Move(delta); el.UpdatePath(); UpdateConnections(el); DrawBottomToTop(els, dx, dy); UpdateScreen(els, dx, dy); } else { el.CancelBackground(); el.Move(delta); // TODO: Display element if moved back on screen at this point? } }