//MouseDown EventHandler --------- private void DiagramElement_MouseDown(object sender, MouseButtonEventArgs e) { if (!(sender is StackPanel)) { return; } diagramPanel = (StackPanel)sender; if (!movingLine && e.RightButton == MouseButtonState.Pressed) { if (DiagramLines.Any(l => l.CheckConnected(diagramPanel) != 0)) { BusinessMessageBox.Show("이 객체에 연결된 다이어그램선이 있습니다.", "다이어그램 객체 삭제"); } else if (BusinessMessageBox.Show("정말 이 객체를 삭제하시겠습니까?", "다이어그램 객체 삭제", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { DiagramUIElements.Remove(diagramPanel); DiagramCanvas.Children.Remove(diagramPanel); } } else // If not trying to delete it { Func <List <DiagramLine>, UIElement, List <DiagramLine> > GetConnectedLines = (Lines, BaseElement) => { List <DiagramLine> lines = new List <DiagramLine>(); foreach (var line in Lines) { if (line.CheckConnected(BaseElement) != 0) { lines.Add(line); } } return(lines); }; connectedLines = GetConnectedLines(DiagramLines, diagramPanel); MPoint1 = e.GetPosition(DiagramCanvas); MPoint2 = e.GetPosition(diagramPanel); MPoint1.X -= diagramPanel.Margin.Left + MPoint2.X; MPoint1.Y -= diagramPanel.Margin.Top + MPoint2.Y; Mouse.Capture(diagramPanel); MMove = true; } }
public DiagramLine GetLineByName(string name) { return(DiagramLines.Find(x => string.Equals(name, x.Name))); }