private void MouseLeftButtonDownSubCanvas(object sender, MouseButtonEventArgs e) { d = new Canvas(); trafo = new Substation(); drag = true; d = (Canvas)sender; foreach (Substation s in Singleton.Instance().Substations) { if (s.mRID.Equals(d.Name)) { trafo = s; x = s.x; y = s.y; break; } } DragDrop.DoDragDrop(mainWindow, d, DragDropEffects.All); drag = false; }
private void DropSubCanvas(object sender, DragEventArgs e) { DropSub ds = new DropSub(trafo, x, y); Singleton.Instance().inv.DodajIzvrsi(ds); if (d != null) { if (((Canvas)sender).Resources["taken"] == null) { ((Canvas)sender).Resources.Add("taken", true); drag = false; } } t = true; e.Handled = true; trafo = null; d = null; }
private void PrintLines() { foreach (ACLineSegment l in Singleton.Instance().AClines) { System.Windows.Shapes.Line line = new System.Windows.Shapes.Line(); SolidColorBrush brush = new SolidColorBrush(); brush.Color = Colors.Green; line.StrokeThickness = 1; line.Stroke = brush; ConnectivityNode od = null; //cvor pocetni ConnectivityNode na = null; //dest foreach (Terminal terminal in l.terminali) { if (od == null) { foreach (CIM.IEC61970.Base.Core.Substation s in Singleton.Instance().Substations) { foreach (ConnectivityNode cvor in s.connectivityNodes) { if (cvor.mRID.Equals(terminal.ConnectivityNode.mRID)) { od = cvor; od.X = cvor.x + s.x + (s.connectivityNodes.IndexOf(cvor) * 50) + 10; od.Y = cvor.y + s.y + (s.connectivityNodes.IndexOf(cvor) * 50) + 10; break; } } } } else { foreach (CIM.IEC61970.Base.Core.Substation s in Singleton.Instance().Substations) { foreach (ConnectivityNode cvor1 in s.connectivityNodes) { if (cvor1.mRID.Equals(terminal.ConnectivityNode.mRID)) { na = cvor1; na.X = cvor1.x + s.x + (s.connectivityNodes.IndexOf(cvor1) * 50) + 10; na.Y = cvor1.y + s.y + (s.connectivityNodes.IndexOf(cvor1) * 50) + 10; break; } } } } } BindingOperations.SetBinding(line, System.Windows.Shapes.Line.X1Property, new Binding { Source = od, Path = new PropertyPath("X") }); BindingOperations.SetBinding(line, System.Windows.Shapes.Line.Y1Property, new Binding { Source = od, Path = new PropertyPath("Y") }); BindingOperations.SetBinding(line, System.Windows.Shapes.Line.X2Property, new Binding { Source = na, Path = new PropertyPath("X") }); BindingOperations.SetBinding(line, System.Windows.Shapes.Line.Y2Property, new Binding { Source = na, Path = new PropertyPath("Y") }); viewCanvas.Children.Add(line); } }
public override void Izvrsi() { substation = (CIM.IEC61970.Base.Core.Substation)substation.Clone(); substation.mRID = ID; Singleton.Instance().Substations.Add(substation); }