public override void NeIzvrsi() { Singleton.Instance().Nodes.Add(node); Singleton.Instance().Substations[index].connectivityNodes.Add(node); foreach (ACLineSegment line in lines) { Singleton.Instance().AClines.Add(line); } }
private void BrisiTrafostanicu(object sender, RoutedEventArgs e) { if (dataGrid.SelectedItem != null) { Substation s = dataGrid.SelectedItem as Substation; BrisiTrafo bt = new BrisiTrafo(s.mRID); Singleton.Instance().inv.DodajIzvrsi(bt); serializer.SerializeObject <BindingList <Substation> >(Singleton.Instance().Substations, "../../doc/trafostanice.xml"); Singleton.Instance().NotifyObservers(); } }
private void KlonirajTrafo(object sender, RoutedEventArgs e) { if (dataGrid.SelectedItem != null) { Substation s = dataGrid.SelectedItem as CIM.IEC61970.Base.Core.Substation; CloneTrafo ct = new CloneTrafo(s.mRID); Singleton.Instance().inv.DodajIzvrsi(ct); serializer.SerializeObject <BindingList <CIM.IEC61970.Base.Core.Substation> >(Singleton.Instance().Substations, "../../doc/trafostanice.xml"); Singleton.Instance().NotifyObservers(); } }
public override void NeIzvrsi() { for (int i = 0; i < Singleton.Instance().Substations.Count; i++) { if (Singleton.Instance().Substations[i].mRID.Equals(s.mRID)) { Singleton.Instance().Substations.Remove(Singleton.Instance().Substations[i]); break; } } }
private void KlonirajCvor(object sender, RoutedEventArgs e) { if (dataGrid_Copy.SelectedItem != null) { ConnectivityNode s = dataGrid_Copy.SelectedItem as ConnectivityNode; CloneCvor cc = new CloneCvor(s.mRID); Singleton.Instance().inv.DodajIzvrsi(cc); serializer.SerializeObject <BindingList <ConnectivityNode> >(Singleton.Instance().Nodes, "../../doc/cvorovi.xml"); Singleton.Instance().NotifyObservers(); } }
public override void NeIzvrsi() { foreach (ACLineSegment acl in Singleton.Instance().AClines) { if (acl.mRID.Equals(acl.mRID)) { Singleton.Instance().AClines.Remove(acl); break; } } }
public override void Izvrsi() { for (int i = 0; i < Singleton.Instance().AClines.Count; i++) { if (Singleton.Instance().AClines[i].mRID.Equals(line.mRID)) { Singleton.Instance().AClines.Remove(Singleton.Instance().AClines[i]); break; } } }
public override void NeIzvrsi() { for (int i = 0; i < Singleton.Instance().Nodes.Count; i++) { if (Singleton.Instance().Nodes[i].mRID.Equals(cvor.mRID)) { sub.connectivityNodes.Remove(Singleton.Instance().Nodes[i]); Singleton.Instance().Nodes.Remove(Singleton.Instance().Nodes[i]); break; } } }
public AddLine() { InitializeComponent(); if (File.Exists("../../doc/cvorovi.xml")) { foreach (ConnectivityNode cvor in Singleton.Instance().Nodes) { comboBox.Items.Add(cvor); comboBox_Copy.Items.Add(cvor); } } }
public AddCvor() { InitializeComponent(); if (File.Exists("../../doc/trafostanice.xml")) { foreach (Substation s in Singleton.Instance().Substations) { comboBox.Items.Add(s); } } }
public AddACLine() { InitializeComponent(); Singleton.Instance().AClines = serializer.DeSerializeObject <BindingList <ACLineSegment> >("../../doc/konekcije.xml"); if (Singleton.Instance().AClines == null) { Singleton.Instance().AClines = new BindingList <ACLineSegment>(); } dataGrid.ItemsSource = Singleton.Instance().AClines; }
public CloneTrafo(String id) { foreach (Substation subs in Singleton.Instance().Substations) { if (subs.mRID.Equals(id)) { substation = subs; break; } } ID = "a" + Guid.NewGuid().ToString().Substring(0, 8); }
public CloneCvor(String id) { foreach (ConnectivityNode conNode in Singleton.Instance().Nodes) { if (conNode.mRID.Equals(id)) { cnode = conNode; break; } } ID = "a" + Guid.NewGuid().ToString().Substring(0, 8); }
private void AddSubstations() { viewCanvas.Children.Clear(); viewCanvas.AddHandler(Canvas.DragOverEvent, new DragEventHandler(DragOverSubCanvas)); viewCanvas.AddHandler(Canvas.DropEvent, new DragEventHandler(DropSubCanvas)); foreach (Substation s in Singleton.Instance().Substations) { Canvas c = new Canvas(); c.Name = s.mRID; c.Width = 180; c.Height = 180; c.AllowDrop = true; c.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("White")); c.AddHandler(Canvas.MouseLeftButtonDownEvent, new MouseButtonEventHandler(MouseLeftButtonDownSubCanvas)); TextBox text = new TextBox(); text.Text = "Trafostanica ID: " + s.mRID; text.IsEnabled = false; text.Height = 20; text.Width = 180; text.Background = new SolidColorBrush(Colors.Black); text.Foreground = new SolidColorBrush(Colors.White); Canvas.SetLeft(text, 0); Canvas.SetBottom(text, 0); c.Children.Add(text); if (s.x != -1 && s.y != -1) { Canvas.SetLeft(c, s.x); Canvas.SetTop(c, s.y); DodajNode(s, c); viewCanvas.Children.Add(c); } else { Canvas.SetLeft(c, 5); Canvas.SetTop(c, 5); s.x = 5; s.y = 5; DodajNode(s, c); viewCanvas.Children.Add(c); } } }
public override void NeIzvrsi() { Singleton.Instance().Substations.Add(s); foreach (ACLineSegment line in lines) { Singleton.Instance().AClines.Add(line); } lines.Clear(); foreach (ConnectivityNode cn in s.connectivityNodes) { Singleton.Instance().Nodes.Add(cn); } }
public override void NeIzvrsi() { s.x = x; s.y = y; foreach (Substation sub in Singleton.Instance().Substations) { if (!s.mRID.Equals(sub.mRID)) { if (Kanvas.Check(s.x, s.y, sub.x, sub.y, 180)) { sub.x = -1; sub.y = -1; } } } }
public Tabele() { InitializeComponent(); DataContext = Singleton.Instance(); Singleton.Instance().Nodes = serializer.DeSerializeObject <BindingList <ConnectivityNode> >("../../doc/cvorovi.xml"); if (Singleton.Instance().Nodes == null) { Singleton.Instance().Nodes = new BindingList <ConnectivityNode>(); } dataGrid_Copy.ItemsSource = Singleton.Instance().Nodes; Singleton.Instance().Substations = serializer.DeSerializeObject <BindingList <Substation> >("../../doc/trafostanice.xml"); if (Singleton.Instance().Substations == null) { Singleton.Instance().Substations = new BindingList <Substation>(); } dataGrid.ItemsSource = Singleton.Instance().Substations; }
public MainWindow() { InitializeComponent(); Visibilityy(); Observer observer = new Observer(ViewCanvas, this); Singleton.Instance().Register(observer); DataContext = Singleton.Instance(); Singleton.Instance().Register(observer); Registracija reg = new Registracija(); this.Show(); reg.ShowDialog(); }
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 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; }
public override void Izvrsi() { for (int i = 0; i < Singleton.Instance().Nodes.Count; i++) { if (Singleton.Instance().Nodes[i].mRID.Equals(node.mRID)) { node = Singleton.Instance().Nodes[i]; for (int j = 0; j < Singleton.Instance().Substations.Count; j++) { for (int k = 0; k < Singleton.Instance().Substations[j].connectivityNodes.Count; k++) { if (Singleton.Instance().Substations[j].connectivityNodes[k].mRID.Equals(Singleton.Instance().Nodes[i].mRID)) { foreach (ACLineSegment line in Singleton.Instance().AClines) { foreach (Terminal t in line.terminali) { if (t.ConnectivityNode.mRID.Equals(node.mRID)) { lines.Add(line); Singleton.Instance().AClines.Remove(line); break; } } } Singleton.Instance().Substations[j].connectivityNodes.RemoveAt(k); index = j; break; } } } Singleton.Instance().Nodes.Remove(Singleton.Instance().Nodes[i]); break; } } }
public override void NeIzvrsi() { for (int i = 0; i < Singleton.Instance().Nodes.Count; i++) { if (Singleton.Instance().Nodes[i].mRID.Equals(cnode.mRID)) { for (int j = 0; j < Singleton.Instance().Substations.Count; j++) { for (int k = 0; k < Singleton.Instance().Substations[j].connectivityNodes.Count; k++) { if (Singleton.Instance().Substations[j].connectivityNodes[k].mRID.Equals(Singleton.Instance().Nodes[i].mRID)) { Singleton.Instance().Substations[j].connectivityNodes.Remove(cnode); break; } } } Singleton.Instance().Nodes.Remove(Singleton.Instance().Nodes[i]); break; } } }
public override void Izvrsi() { cnode = (ConnectivityNode)cnode.Clone(); cnode.mRID = ID; Singleton.Instance().Nodes.Add(cnode); }
private void Redo(object sender, RoutedEventArgs e) { Singleton.Instance().inv.Redo(); Singleton.Instance().NotifyObservers(); }
private void Ok(object sender, RoutedEventArgs e) { bool ok = true; if (textBox1.Text.Trim().Equals("")) { textBox1.BorderBrush = Brushes.Red; textBox1.BorderThickness = new Thickness(1); ok = false;//length } else { try { float.Parse(textBox1.Text.Trim()); if (float.Parse(textBox1.Text.Trim()) < 5) { textBox1.BorderBrush = Brushes.Red; textBox1.BorderThickness = new Thickness(1); ok = false; } } catch { textBox1.BorderBrush = Brushes.Red; textBox1.BorderThickness = new Thickness(1); ok = false; } } if (textBox_Copy.Text.Trim().Equals(""))//gch { textBox_Copy.BorderBrush = Brushes.Red; textBox_Copy.BorderThickness = new Thickness(1); ok = false;//length } else { try { float.Parse(textBox_Copy.Text.Trim()); if (float.Parse(textBox_Copy.Text.Trim()) < 1) { textBox_Copy.BorderBrush = Brushes.Red; textBox_Copy.BorderThickness = new Thickness(1); ok = false; } } catch { textBox_Copy.BorderBrush = Brushes.Red; textBox_Copy.BorderThickness = new Thickness(1); ok = false; } } if (textBox_Copy1.Text.Trim().Equals(""))//bch { textBox_Copy1.BorderBrush = Brushes.Red; textBox_Copy1.BorderThickness = new Thickness(1); ok = false;//length } else { try { float.Parse(textBox_Copy1.Text.Trim()); if (float.Parse(textBox_Copy1.Text.Trim()) < 1) { textBox_Copy1.BorderBrush = Brushes.Red; textBox_Copy1.BorderThickness = new Thickness(1); ok = false; } } catch { textBox_Copy1.BorderBrush = Brushes.Red; textBox_Copy1.BorderThickness = new Thickness(1); ok = false; } } if (textBox_Copy2.Text.Trim().Equals(""))//r { textBox_Copy2.BorderBrush = Brushes.Red; textBox_Copy2.BorderThickness = new Thickness(1); ok = false;//length } else { try { float.Parse(textBox_Copy2.Text.Trim()); if (float.Parse(textBox_Copy2.Text.Trim()) < 1) { textBox_Copy2.BorderBrush = Brushes.Red; textBox_Copy2.BorderThickness = new Thickness(1); ok = false; } } catch { textBox_Copy2.BorderBrush = Brushes.Red; textBox_Copy2.BorderThickness = new Thickness(1); ok = false; } } if (textBox_Copy3.Text.Trim().Equals(""))//x { textBox_Copy3.BorderBrush = Brushes.Red; textBox_Copy3.BorderThickness = new Thickness(1); ok = false;//length } else { try { float.Parse(textBox_Copy3.Text.Trim()); if (float.Parse(textBox_Copy3.Text.Trim()) < 1) { textBox_Copy3.BorderBrush = Brushes.Red; textBox_Copy3.BorderThickness = new Thickness(1); ok = false; } } catch { textBox_Copy3.BorderBrush = Brushes.Red; textBox_Copy3.BorderThickness = new Thickness(1); ok = false; } } if (textBox.Text.Trim().Equals("")) { textBox.BorderBrush = Brushes.Red; textBox.BorderThickness = new Thickness(1); ok = false;//name } if (comboBox.SelectedItem == null) { ok = false; //node1 } if (comboBox_Copy.SelectedItem == null) { ok = false; //node2 } ConnectivityNode n1 = comboBox.SelectedItem as ConnectivityNode; ConnectivityNode n2 = comboBox_Copy.SelectedItem as ConnectivityNode; bool sameSubstation = false; bool sameSubstation2 = false; foreach (Substation s in Singleton.Instance().Substations) { foreach (ConnectivityNode conNode in s.connectivityNodes) { if (conNode.mRID.Equals(n1.mRID)) { sameSubstation = true; } else if (conNode.mRID.Equals(n2.mRID)) { sameSubstation2 = true; } } if (sameSubstation && sameSubstation2) { break; } sameSubstation = false; sameSubstation2 = false; } if (n1.mRID.Equals(n2.mRID)) { MessageBox.Show("Cvorovi moraju biti razliciti."); ok = false; } else if (n1.m_BaseVoltage.nominalVoltage != n2.m_BaseVoltage.nominalVoltage) { MessageBox.Show("Cvorovi moraju imati isti nominaln napon."); ok = false; } else if (sameSubstation && sameSubstation2) { MessageBox.Show("Cvorovi ne smeju pripadati istoj trafostanici."); ok = false; } if (ok) { DodajACLine dl = new DodajACLine(n1, n2, textBox.Text.Trim(), float.Parse(textBox1.Text.Trim()), float.Parse(textBox_Copy.Text.Trim()), float.Parse(textBox_Copy1.Text.Trim()), float.Parse(textBox_Copy2.Text.Trim()), float.Parse(textBox_Copy3.Text.Trim())); Singleton.Instance().inv.DodajIzvrsi(dl); this.Close(); } }
private void Create(object sender, RoutedEventArgs e) { bool isOk = true; if (textBox.Text.Trim().Equals("")) { textBox.BorderBrush = Brushes.Red; textBox.BorderThickness = new Thickness(1); isOk = false;//name } if (textBox_Copy1.Text.Trim().Equals("")) { textBox_Copy1.BorderBrush = Brushes.Red; textBox_Copy1.BorderThickness = new Thickness(1); isOk = false;//alias } if (textBox_Copy2.Text.Trim().Equals("")) { textBox_Copy2.BorderBrush = Brushes.Red; textBox_Copy2.BorderThickness = new Thickness(1); isOk = false;//desc } if (comboBox.SelectedItem == null) { comboBox.BorderBrush = Brushes.Red; comboBox.BorderThickness = new Thickness(1); isOk = false; //substation } if (textBox1.Text.Trim().Equals("")) { textBox1.BorderBrush = Brushes.Red; textBox1.BorderThickness = new Thickness(1); isOk = false;//voltage } else { try { float.Parse(textBox1.Text.Trim()); if (float.Parse(textBox1.Text.Trim()) < 10) { textBox1.BorderBrush = Brushes.Red; textBox1.BorderThickness = new Thickness(1); isOk = false; } } catch { textBox1.BorderBrush = Brushes.Red; textBox1.BorderThickness = new Thickness(1); isOk = false; } } if (isOk) { Substation s = comboBox.SelectedItem as Substation; DodajCvor asc = new DodajCvor(textBox.Text.Trim(), textBox_Copy1.Text.Trim(), textBox_Copy2.Text.Trim(), s, float.Parse(textBox1.Text.Trim())); Singleton.Instance().inv.DodajIzvrsi(asc); this.Close(); } }
public override void Izvrsi() { Singleton.Instance().Substations.Add(s); }
public override void Izvrsi() { Singleton.Instance().Nodes.Add(cvor); sub.connectivityNodes.Add(cvor); }
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 CloneLine(string id) { foreach (ACLineSegment ac in Singleton.Instance().AClines) { if (ac.mRID.Equals(id)) { line = ac; break; } } ID = Guid.NewGuid().ToString().Substring(0, 8); foreach (ACLineSegment l in Singleton.Instance().AClines) { if (id.Equals(l.mRID)) { foreach (Terminal t in l.terminali) { foreach (CIM.IEC61970.Base.Core.Substation s in Singleton.Instance().Substations) { foreach (ConnectivityNode cn in s.connectivityNodes) { if (t.ConnectivityNode.mRID.Equals(cn.mRID)) { if (terminal1 == null) { terminal1 = new Terminal() { aliasName = "Terminal", ConductingEquipment = new ConductingEquipment(), connected = false, ConnectivityNode = cn, description = "something", mRID = Guid.NewGuid().ToString().Substring(0, 8), name = "Terminal", phases = PhaseCode.A, sequenceNumber = 1 }; } else { terminal2 = new Terminal() { aliasName = "Terminal", ConductingEquipment = new ConductingEquipment(), connected = false, ConnectivityNode = cn, description = "something", mRID = Guid.NewGuid().ToString().Substring(0, 8), name = "Terminal", phases = PhaseCode.A, sequenceNumber = 1 }; } } } } } } } }