private void OnMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (currentEntity != null && e.LeftButton == MouseButtonState.Pressed) { if (currentEntity is ConnectionLine && selected != null && selected is Port) { connect(); } else if (currentEntity is SubDiagram) { SubDiagram sd = currentEntity as SubDiagram; ScrollableCanvas sc = currentCanvas as ScrollableCanvas; if (sc.Equals(sc, sd.ProjectItem.Canvas as ScrollableCanvas)) { currentEntity = null; MessageBox.Show("Нельзя добавить процесс к самому себе"); } else { UndoRedoManager.putInUndoStack((ScrollableCanvas)currentCanvas); UndoRedoManager.clearRedoStack((ScrollableCanvas)currentCanvas); sd.canvas = currentCanvas; drawOnCanvas(e.GetPosition(this)); } } else if (!(currentEntity is ConnectionLine)) { UndoRedoManager.putInUndoStack((ScrollableCanvas)currentCanvas); UndoRedoManager.clearRedoStack((ScrollableCanvas)currentCanvas); drawOnCanvas(e.GetPosition(this)); } } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj.GetType() != typeof(ProjectItem)) { return(false); } ProjectItem another = obj as ProjectItem; // C#... ScrollableCanvas thisCanvas = canvas as ScrollableCanvas; ScrollableCanvas anotherCanvas = another.Canvas as ScrollableCanvas; return(thisCanvas.Equals(thisCanvas, anotherCanvas)); }
public ProjectItem byCanvas(ScrollableCanvas canvas) { return(items.Where(i => canvas.Equals(i.Canvas as ScrollableCanvas, canvas)).First()); }