/// <summary> /// When our mouse is pressed, find and highlight our element /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pnlElements_MouseDown(object sender, MouseEventArgs e) { pnlElements.Focus(); //If we have a middle button down, start to display our cursor if (e.Button == System.Windows.Forms.MouseButtons.Middle) { pnlElements.Cursor = Cursors.SizeAll; pnlElements.Capture = true; pnlElements.Tag = e.Location; return; } //Find our element, and highlight it foreach (MM_OneLine_Element Elem in DisplayComponents) { if (Elem.BaseElement != null && Elem.Bounds.Contains((int)((e.X / ZoomLevel) - pnlElements.AutoScrollPosition.X), (int)((e.Y / ZoomLevel) - pnlElements.AutoScrollPosition.Y))) { MM_OneLine_Element SelectedElement; if (Elem.ElemType == MM_OneLine_Element.enumElemTypes.Descriptor || Elem.ElemType == MM_OneLine_Element.enumElemTypes.SecondaryDescriptor) { SelectedElement = HighlightedElement = Elem.ParentElement; } else { SelectedElement = HighlightedElement = Elem; } Refresh(); if (e.Button == System.Windows.Forms.MouseButtons.Right) { new User_Interfaces.Menuing.MM_Popup_Menu().Show(this, e.Location, SelectedElement.BaseElement, true); } else if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (OneLineElementClicked != null && (Control.ModifierKeys & Keys.Control) == Keys.Control) { OneLineElementClicked(SelectedElement, e); } if (btnFollowMap.Checked) { if (Elem.ElemType == MM_OneLine_Element.enumElemTypes.Line) { nMap.Coordinates.Center = ((Elem.BaseElement as MM_Line).Midpoint); nMap.Coordinates.UpdateZoom(19); } else if (Elem.BaseElement.Substation != null) { nMap.Coordinates.Center = (((Elem.BaseElement.Substation).LngLat)); nMap.Coordinates.UpdateZoom(19); } } } return; } } HighlightedElement = null; if (OneLineElementClicked != null) { OneLineElementClicked(null, e); } }
/// <summary> /// Handle the user's clicking on a one-line element /// </summary> /// <param name="ClickedElement"></param> /// <param name="e"></param> private void OneLine_OneLineElementClicked(MM_OneLine_Element ClickedElement, MouseEventArgs e) { if (e.Button == MouseButtons.Right) //viewPropertyPage.SetElement(ClickedElement.BaseElement); //else { MM_Popup_Menu c = new MM_Popup_Menu(); if (ClickedElement.ElemType == MM_OneLine_Element.enumElemTypes.Descriptor || ClickedElement.ElemType == MM_OneLine_Element.enumElemTypes.SecondaryDescriptor) { c.Show(ClickedElement, e.Location, ClickedElement.ParentElement.BaseElement, true, olView.DataSourceApplication); } else { c.Show(ClickedElement, e.Location, ClickedElement.BaseElement, true, olView.DataSourceApplication); } /* * //ClickedElement.BaseElement.BuildMenuItems(c, false, true); * if (ClickedElement.ConnectedElements != null) * { * c.Items.Add("-"); * foreach (Int32 Conn in ClickedElement.ConnectedElements) * c.Items.Add(" Connected to: " + viewOneLine.Elements[Conn].BaseElement.ElemType + " " + viewOneLine.Elements[Conn].BaseElement.Name); * } * c.Show(ClickedElement, e.Location);*/ } }
/// <summary> /// Initialize a new one-line node /// </summary> /// <param name="xElem"></param> /// <param name="DisplayElementsByTEID"></param> /// <param name="ParentElement"></param> public MM_OneLine_Node(XmlElement xElem, Dictionary <int, MM_OneLine_Element> DisplayElementsByTEID, MM_OneLine_Element ParentElement = null) : base(xElem, ParentElement) { MM_OneLine_Element TargetElem; NodeTargets = new Dictionary <MM_OneLine_Element, MM_OneLine_Node[]>(); NodePaths = new Dictionary <MM_OneLine_Element, GraphicsPath>(); //Pull in our node targets and paths foreach (XmlElement xChild in xElem.ChildNodes) { if (xChild.Name != "Descriptor" && xChild.Name != "SecondaryDescriptor" && xChild.HasAttribute("TEID")) { if (DisplayElementsByTEID.TryGetValue(XmlConvert.ToInt32(xChild.Attributes["TEID"].Value), out TargetElem)) { List <MM_OneLine_Node> SubElements = new List <MM_OneLine_Node>(); foreach (XmlElement xChild2 in xChild.ChildNodes) { SubElements.Add(new MM_OneLine_Node(xChild2, DisplayElementsByTEID, xChild2.Name == "PricingVector" ? null : this)); } NodeTargets.Add(TargetElem, SubElements.ToArray()); NodePaths.Add(TargetElem, MM_OneLine_Element.BuildNodePath(this, TargetElem, SubElements.ToArray())); } } } }
/// <summary> /// Handle our click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGridView_CellClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridView Sender = (DataGridView)sender; if (e.RowIndex == -1) { return; } MM_Element SelectedObject = (MM_Element)Sender.Rows[e.RowIndex].DataBoundItem.GetType().GetProperties()[0].GetValue(Sender.Rows[e.RowIndex].DataBoundItem); MM_Element HighlightElement = SelectedObject is MM_Substation ? null : SelectedObject; if (SelectedObject is MM_Line) { SelectedObject = SelectedObject.Contingencies[0]; } else if (SelectedObject.Substation != null) { SelectedObject = SelectedObject.Substation; } Sender.UseWaitCursor = true; if (SelectedObject == olView.BaseElement) { olView.HighlightElement(HighlightElement); } else if (olView.DataSource == null) { olView.SetControls(SelectedObject, nMap, BaseData, null, Data_Integration.NetworkSource); olView.HighlightElement(HighlightElement); } else { olView.LoadOneLine(SelectedObject, HighlightElement); olView.HighlightElement(HighlightElement); } if (HighlightElement is MM_Unit) { if (HighlightElement != null && HighlightElement.ElemType.Configuration != null && HighlightElement.ElemType.Configuration["ControlPanel"] != null) { if (MM_Server_Interface.ClientAreas.ContainsKey("ERCOT") || MM_Server_Interface.ClientAreas.ContainsKey(HighlightElement.Operator.Alias)) { MM_OneLine_Element Unit = olView.ElementsByTEID[HighlightElement.TEID]; new OneLines.MM_ControlPanel(Unit, HighlightElement.ElemType.Configuration["ControlPanel"], olView) { StartPosition = FormStartPosition.Manual, Location = Cursor.Position }.Show(this); } else { MessageBox.Show("Control of " + (olView.BaseElement.Substation == null ? "" : olView.BaseElement.Substation.LongName) + " " + olView.BaseElement.ElemType.Name + " " + olView.BaseElement.Name + " is not permitted.\n(operated by " + olView.BaseElement.Operator.Name + " - " + olView.BaseElement.Operator.Alias + ").", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } Sender.UseWaitCursor = false; Sender.Invalidate(); }
/// <summary> /// Report all the node targets for an element /// </summary> /// <param name="Elem"></param> public MM_Element[] ElementNodes(MM_OneLine_Element Elem) { List <MM_Element> FoundElems = new List <MM_Element>(); foreach (KeyValuePair <MM_Element, MM_OneLine_Node> Node in DisplayNodes) { if (Node.Value.NodeTargets.ContainsKey(Elem)) { FoundElems.Add(Node.Key); } } return(FoundElems.ToArray()); }
/// <summary> /// Initialize a new transformer winding /// </summary> /// <param name="xElem"></param> /// <param name="ParentElement"></param> public MM_OneLine_TransformerWinding(XmlElement xElem, MM_OneLine_Element ParentElement = null) : base(xElem, ParentElement) { if (xElem.HasAttribute("BaseElement.IsPrimary")) { IsPrimary = XmlConvert.ToBoolean(xElem.Attributes["BaseElement.IsPrimary"].Value); } if (xElem.ParentNode.Attributes["BaseElement.PhaseShifter"] != null && XmlConvert.ToBoolean(xElem.ParentNode.Attributes["BaseElement.PhaseShifter"].Value)) { IsPhaseShifter = true; } }
/// <summary> /// Handle a mouse double-click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pnlElements_MouseDoubleClick(object sender, MouseEventArgs e) { //Find our element foreach (MM_OneLine_Element Elem in DisplayComponents) { if (Elem.BaseElement != null && Elem.Bounds.Contains((int)((e.X / ZoomLevel) - pnlElements.AutoScrollPosition.X), (int)((e.Y / ZoomLevel) - pnlElements.AutoScrollPosition.Y))) { MM_OneLine_Element SelectedElement = null; if (Elem.ElemType == MM_OneLine_Element.enumElemTypes.Descriptor || Elem.ElemType == MM_OneLine_Element.enumElemTypes.SecondaryDescriptor) { SelectedElement = Elem.ParentElement; } else { SelectedElement = Elem; } if (SelectedElement.ElemType == MM_OneLine_Element.enumElemTypes.Line && BaseElement is MM_Substation) { MM_Line Line = (MM_Line)SelectedElement.BaseElement; if (Line.Substation1 == BaseElement) { LoadOneLine(Line.Substation2, Line); } else { LoadOneLine(Line.Substation1, Line); } } else if (SelectedElement.ElemType == MM_OneLine_Element.enumElemTypes.Node) { if (BaseElement is MM_Substation) { LoadOneLine(SelectedElement.Contingencies[0], SelectedElement.BaseElement); } else { LoadOneLine(SelectedElement.BaseElement.Substation, SelectedElement.BaseElement); } } else if (SelectedElement.BaseElement != null && SelectedElement.BaseElement.ElemType.Configuration != null && SelectedElement.BaseElement.ElemType.Configuration["ControlPanel"] != null) { if (MM_Server_Interface.ClientAreas.ContainsKey("ERCOT") || MM_Server_Interface.ClientAreas.ContainsKey(SelectedElement.BaseElement.Operator.Alias)) { new MM_ControlPanel(Elem, SelectedElement.BaseElement.ElemType.Configuration["ControlPanel"], this) { StartPosition = FormStartPosition.Manual, Location = Cursor.Position } }
/// <summary> /// Handle our click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGridView_CellClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridView Sender = (DataGridView)sender; if (e.RowIndex == -1) { return; } MM_Element HighlightElement = (MM_Element)Sender.Rows[e.RowIndex].DataBoundItem.GetType().GetProperties()[0].GetValue(Sender.Rows[e.RowIndex].DataBoundItem); Sender.UseWaitCursor = true; if (HighlightElement != null && HighlightElement.ElemType.Configuration != null && HighlightElement.ElemType.Configuration["ControlPanel"] != null) { olView.LoadOneLine(HighlightElement.Substation, HighlightElement); //olView.BaseElement = HighlightElement; //olView.HighlightElement(HighlightElement); if (MM_Server_Interface.ClientAreas.ContainsKey("ERCOT") || MM_Server_Interface.ClientAreas.ContainsKey(HighlightElement.Operator.Alias)) { if (olView.ElementsByTEID.Count > 0) { MM_OneLine_Element Unit = olView.ElementsByTEID[HighlightElement.TEID]; new OneLines.MM_ControlPanel(Unit, HighlightElement.ElemType.Configuration["ControlPanel"], olView) { StartPosition = FormStartPosition.Manual, Location = Cursor.Position }.Show(this); } else { MessageBox.Show("unable to open Control Panel for " + (olView.BaseElement.Substation == null ? "" : olView.BaseElement.Substation.LongName) + " " + olView.BaseElement.ElemType.Name + " " + olView.BaseElement.Name + ".", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop); } } else { MessageBox.Show("Control of " + (olView.BaseElement.Substation == null ? "" : olView.BaseElement.Substation.LongName) + " " + olView.BaseElement.ElemType.Name + " " + olView.BaseElement.Name + " is not permitted.\n(operated by " + olView.BaseElement.Operator.Name + " - " + olView.BaseElement.Operator.Alias + ").", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop); } } Sender.UseWaitCursor = false; Sender.Invalidate(); }
/// <summary> /// Highlight a one-line element /// </summary> /// <param name="HighlightElem"></param> public void HighlightElement(MM_Element HighlightElem) { if (HighlightElem == null) { HighlightedElement = null; } else if (!ElementsByTEID.TryGetValue(HighlightElem.TEID, out HighlightedElement)) { HighlightedElement = null; } else if (!Rectangle.FromLTRB(-pnlElements.AutoScrollPosition.X, -pnlElements.AutoScrollPosition.Y, pnlElements.DisplayRectangle.Width, pnlElements.DisplayRectangle.Height).IntersectsWith(HighlightedElement.Bounds)) { Control ctl = new Control() { Bounds = HighlightedElement.Bounds }; pnlElements.Controls.Add(ctl); pnlElements.ScrollControlIntoView(ctl); pnlElements.Controls.Remove(ctl); } }
/// <summary> /// Initialize a new control panel /// </summary> /// <param name="SourceElement">Our source element</param> /// <param name="xConfiguration">The configuration for the control panel</param> /// <param name="OneLineViewer">The one-line viewer</param> public MM_ControlPanel(MM_OneLine_Element SourceElement, XmlElement xConfiguration, MM_OneLine_Viewer OneLineViewer) { //xConfiguration.InnerXml = Clipboard.GetText(); this.OneLineViewer = OneLineViewer; InitializeComponent(); this.xConfiguration = xConfiguration; this.SourceElement = SourceElement; Keys CurKeys = Control.ModifierKeys; if (CurKeys == (Keys.Control | Keys.Shift | Keys.Alt)) { Editable = true; this.FormBorderStyle = FormBorderStyle.SizableToolWindow; } else { Editable = false; } //Create our Communications view btnComm = new Button(); btnComm.Text = "Comm"; btnComm.Size = new System.Drawing.Size(78, 17); btnComm.Font = new System.Drawing.Font("Arial", 10); btnComm.Click += btnComm_Click; btnComm.Paint += btnComm_Paint; Controls.Add(btnComm); SizePanel = new Panel(); SizePanel.Location = new Point(4, 4); SizePanel.AutoScroll = true; SizePanel.AutoSize = false; SizePanel.HorizontalScroll.Enabled = true; SizePanel.VerticalScroll.Enabled = true; SizePanel.HorizontalScroll.Visible = true; SizePanel.VerticalScroll.Visible = true; Controls.Add(SizePanel); //Now, initialize the window, and sublements MM_Serializable.ReadXml(xConfiguration, this, false); this.Text = xConfiguration.Attributes["Title"].Value + " - " + SourceElement.BaseElement.SubLongName + " " + SourceElement.BaseElement.ElemType.Name + " " + SourceElement.BaseElement.Name; foreach (XmlElement xElem in xConfiguration.ChildNodes.OfType <XmlElement>()) { if (xElem.Name != "DataSource") { AddElement(SizePanel, xElem); } } btnComm.Location = new Point(DisplayRectangle.Width - btnComm.Width + 4, 2);//DisplayRectangle.Height - btnComm.Height); //If we are in editable mode, add in our propery page if (Editable) { PropertyGrid pG = new PropertyGrid(); pG.Name = "PropertyGrid"; pG.Width = 400; pG.Height = this.Height; pG.Left = this.Width; pG.PropertyValueChanged += new PropertyValueChangedEventHandler(pG_PropertyValueChanged); this.Controls.Add(pG); } UpdateDisplay(); }
/// <summary> /// Handle our panel being painted /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PanelPaint(object sender, PaintEventArgs e) { try { if (Data_Integration.SimulatorStatus != MM_Simulation_Time.enumSimulationStatus.Running && (DateTime.Now.Second % 2) == 0) { e.Graphics.Clear(Color.FromArgb(50, 0, 0)); } //Determine our zoom e.Graphics.ScaleTransform(ZoomLevel, ZoomLevel); //Draw our header bar Rectangle HeaderRect = new Rectangle(pnlElements.DisplayRectangle.Left, pnlElements.DisplayRectangle.Top, pnlElements.DisplayRectangle.Width, 40); if (HeaderRect.IntersectsWith(e.ClipRectangle)) { MM_OneLine_Element.DrawHeader(e.Graphics, HeaderRect, BaseElement); } e.Graphics.TranslateTransform(pnlElements.AutoScrollPosition.X, pnlElements.AutoScrollPosition.Y); //Draw our arrows if (arrowsToolStripMenuItem.Checked) { foreach (MM_OneLine_Element Elem in DisplayElements.Values) { if (Elem.DescriptorArrow || (Elem.Descriptor != null && Elem.Descriptor.DescriptorArrow)) { if (Elem.ParentElement != null) { MM_OneLine_Element.DrawArrow(e.Graphics, Elem.ParentElement.Bounds, Elem.Bounds); } if (Elem.Descriptor != null) { MM_OneLine_Element.DrawArrow(e.Graphics, Elem.Bounds, Elem.Descriptor.Bounds); } if (Elem.SecondaryDescriptor != null) { MM_OneLine_Element.DrawArrow(e.Graphics, Elem.Bounds, Elem.SecondaryDescriptor.Bounds); } } } } //Write out our node paths foreach (MM_OneLine_Node Node in DisplayNodes.Values) { if (Node.NodePaths != null) { Node.DetermineAssociatedBus(); if (mnuNodeToElementLines.Checked) { foreach (KeyValuePair <MM_OneLine_Element, GraphicsPath> gpNode in Node.NodePaths) { MM_AlarmViolation_Type WorstViol = null; if (IsFlashing && MM_Repository.OverallDisplay.NodeToElementViolations) { foreach (MM_AlarmViolation Viol in gpNode.Key.BaseElement.Violations.Values) { if (WorstViol == null || Viol.Type.Priority < WorstViol.Priority) { WorstViol = Viol.Type; } } MM_Bus NearBus = gpNode.Key.BaseElement.NearBus; MM_Bus FarBus = gpNode.Key.BaseElement.FarBus; if (NearBus != null) { foreach (MM_AlarmViolation Viol in NearBus.Violations.Values) { if (WorstViol == null || Viol.Type.Priority < WorstViol.Priority) { WorstViol = Viol.Type; } } } if (FarBus != null) { foreach (MM_AlarmViolation Viol in FarBus.Violations.Values) { if (WorstViol == null || Viol.Type.Priority < WorstViol.Priority) { WorstViol = Viol.Type; } } } } Color DrawColor = WorstViol == null ? Node.KVLevel.Energized.ForeColor : WorstViol.ForeColor; using (Pen DrawPen = new Pen(DrawColor)) e.Graphics.DrawPath(DrawPen, gpNode.Value); } } } } //Write out our elements, nodes, and unlinked elements foreach (MM_OneLine_Element Elem in DisplayElements.Values) { // if (e.ClipRectangle.IntersectsWith(Elem.Bounds)) Elem.PaintElement(e.Graphics, this, IsFlashing); } foreach (MM_OneLine_Node Node in DisplayNodes.Values) { // if (e.ClipRectangle.IntersectsWith(Node.Bounds)) Node.PaintElement(e.Graphics, this, IsFlashing); } foreach (MM_OneLine_Element UnlinkedElem in UnlinkedElements) { // if (e.ClipRectangle.IntersectsWith(UnlinkedElem.Bounds)) UnlinkedElem.PaintElement(e.Graphics, this, IsFlashing); } //Write out our descriptors and secondary descriptors foreach (MM_OneLine_Element Elem in Descriptors.Values) { // if (e.ClipRectangle.IntersectsWith(Elem.Bounds)) Elem.PaintElement(e.Graphics, this, IsFlashing); } foreach (MM_OneLine_Element Elem in SecondaryDescriptors.Values) { //if (e.ClipRectangle.IntersectsWith(Elem.Bounds)) Elem.PaintElement(e.Graphics, this, IsFlashing); } //If we have a highlighted element, let's make it visible int HighlightRadius = 20; if (HighlightedElement != null) { using (Pen HighlightPen = new Pen(Color.White, 3) { DashStyle = DashStyle.Custom, DashPattern = IsFlashing ? new float[] { 1, 2, 3 } : new float[] { 3, 2, 1 } }) e.Graphics.DrawEllipse(HighlightPen, HighlightedElement.Bounds.Left - HighlightRadius, HighlightedElement.Bounds.Top - HighlightRadius, HighlightedElement.Bounds.Width + HighlightRadius + HighlightRadius, HighlightedElement.Bounds.Height + HighlightRadius + HighlightRadius); } //Highlight any elements with pending changes MM_OneLine_Element FoundElem; if (ValueChanges.Count > 0) { using (Pen HighlightPen = new Pen(Color.White, 3)) foreach (MM_Element Elem in ValueChanges.Keys.ToArray()) { if (DisplayElements.TryGetValue(Elem, out FoundElem)) { e.Graphics.DrawRectangle(HighlightPen, FoundElem.Bounds.Left - HighlightRadius, FoundElem.Bounds.Top - HighlightRadius, FoundElem.Bounds.Width + HighlightRadius + HighlightRadius, FoundElem.Bounds.Height + HighlightRadius + HighlightRadius); e.Graphics.DrawLine(HighlightPen, FoundElem.Bounds.Left - HighlightRadius, FoundElem.Bounds.Top - HighlightRadius, FoundElem.Bounds.Left, FoundElem.Bounds.Top); e.Graphics.DrawLine(HighlightPen, FoundElem.Bounds.Right + HighlightRadius, FoundElem.Bounds.Top - HighlightRadius, FoundElem.Bounds.Right, FoundElem.Bounds.Top); e.Graphics.DrawLine(HighlightPen, FoundElem.Bounds.Left - HighlightRadius, FoundElem.Bounds.Bottom + HighlightRadius, FoundElem.Bounds.Left, FoundElem.Bounds.Bottom); e.Graphics.DrawLine(HighlightPen, FoundElem.Bounds.Right + HighlightRadius, FoundElem.Bounds.Bottom + HighlightRadius, FoundElem.Bounds.Right, FoundElem.Bounds.Bottom); } } } e.Graphics.TranslateTransform(-pnlElements.AutoScrollPosition.X, -pnlElements.AutoScrollPosition.Y); } catch { } }
/// <summary> /// Load a one-line into memory /// </summary> /// <param name="BaseElement">The base element to be highlighting</param> /// <param name="HighlightElem">The element to highlight (e.g., line from the other substation)</param> public void LoadOneLine(MM_Element BaseElement, MM_Element HighlightElem) { OneLineIsLoading = true; if (!cmbSubstation.Items.Contains(BaseElement)) { cmbSubstation.Items.Add(BaseElement.Name); } cmbSubstation.SelectedIndex = cmbSubstation.Items.IndexOf(BaseElement.Name); //First, clear all of our elements ShutDownQuery(); DisplayElements.Clear(); DisplayNodes.Clear(); UnlinkedElements.Clear(); Descriptors.Clear(); SecondaryDescriptors.Clear(); pnlElements.Controls.Clear(); DisplayComponents.Clear(); this.BaseElement = BaseElement; ElementsByTEID.Clear(); //Now, load our one-line MM_OneLine_Data OLData = MM_Server_Interface.LoadOneLine(BaseElement); if (OLData.OneLineXml == null) { MessageBox.Show("The one line for " + BaseElement.ToString() + " could not be found.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Now, parse our elements XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(OLData.OneLineXml); //Load in our elements if (xDoc.DocumentElement["Elements"] != null) { foreach (XmlElement xElem in xDoc.DocumentElement["Elements"]) { MM_OneLine_Element Elem = new MM_OneLine_Element(xElem); if (Elem.Descriptor != null) { DisplayComponents.Add(Elem.Descriptor); Descriptors.Add(Elem.BaseElement, Elem.Descriptor); } if (Elem.SecondaryDescriptor != null) { DisplayComponents.Add(Elem.SecondaryDescriptor); SecondaryDescriptors.Add(Elem.BaseElement, Elem.SecondaryDescriptor); } DisplayComponents.Add(Elem); ElementsByTEID.Add(Elem.BaseElement.TEID, Elem); if (Elem.BaseElement is MM_Tie) { ElementsByTEID.Add(((MM_Tie)Elem.BaseElement).AssociatedLine.TEID, Elem); } DisplayElements.Add(Elem.BaseElement, Elem); Elem.BaseElement.ValuesChanged += ElemValueChange; } } //Load in our nodes if (xDoc.DocumentElement["Nodes"] != null) { foreach (XmlElement xElem in xDoc.DocumentElement["Nodes"]) { MM_OneLine_Node Node = new MM_OneLine_Node(xElem, ElementsByTEID); if (Node.Descriptor != null) { DisplayComponents.Add(Node.Descriptor); Descriptors.Add(Node.BaseElement, Node.Descriptor); } if (Node.SecondaryDescriptor != null) { SecondaryDescriptors.Add(Node.BaseElement, Node.SecondaryDescriptor); DisplayComponents.Add(Node.SecondaryDescriptor); } ElementsByTEID.Add(Node.BaseElement.TEID, Node); DisplayComponents.Add(Node); DisplayNodes.Add(Node.BaseElement, Node); Node.BaseElement.ValuesChanged += ElemValueChange; foreach (MM_OneLine_Node[] Pokes in Node.NodeTargets.Values) { foreach (MM_OneLine_Node Poke in Pokes) { DisplayComponents.Add(Poke); if (Poke.ElemType == MM_OneLine_Element.enumElemTypes.PricingVector || Poke.IsJumper) { UnlinkedElements.Add(Poke); } if (Poke.Descriptor != null) { DisplayComponents.Add(Poke.Descriptor); Descriptors.Add(Poke.BaseElement, Poke.Descriptor); } if (Poke.SecondaryDescriptor != null) { SecondaryDescriptors.Add(Poke.BaseElement, Poke.SecondaryDescriptor); DisplayComponents.Add(Poke.SecondaryDescriptor); } } } } } if (xDoc.DocumentElement["Unlinked_Elements"] != null) { foreach (XmlElement xElem in xDoc.DocumentElement["Unlinked_Elements"].ChildNodes) { MM_OneLine_Element UnlinkedElement = new MM_OneLine_Element(xElem); DisplayComponents.Add(UnlinkedElement); UnlinkedElements.Add(UnlinkedElement); } } HighlightElement(HighlightElem); //Track our positions for our scroller, and create a new pseudo-element in the bottom right to make scrolling work MaxX = 0; MaxY = 0; foreach (MM_OneLine_Element Elem in DisplayComponents) { MaxX = Math.Max(MaxX, Elem.Bounds.Right); MaxY = Math.Max(MaxY, Elem.Bounds.Bottom); } HighlightElement(HighlightElem); //If we have an element, let's show it UpdateZoom(); if (HighlightedElement != null) { using (Control ctl = new Control()) { Rectangle TargetBounds = HighlightedElement.Bounds; if (HighlightedElement.Descriptor != null) { TargetBounds = Rectangle.Union(TargetBounds, HighlightedElement.Descriptor.Bounds); } if (HighlightedElement.SecondaryDescriptor != null) { TargetBounds = Rectangle.Union(TargetBounds, HighlightedElement.SecondaryDescriptor.Bounds); } ctl.Bounds = TargetBounds; pnlElements.Controls.Add(ctl); pnlElements.ScrollControlIntoView(ctl); pnlElements.Controls.Remove(ctl); } } if (OneLineLoadCompleted != null) { OneLineLoadCompleted(this, EventArgs.Empty); } tmrUpdate.Enabled = true; pnlElements.Refresh(); OneLineIsLoading = false; }
/// <summary> /// Initialize a new transformer winding by cloning its parent /// </summary> /// <param name="BaseWinding"></param> public MM_OneLine_TransformerWinding(MM_OneLine_TransformerWinding BaseWinding, MM_OneLine_Element ParentElement) : base(null) { if (BaseWinding != null) { foreach (FieldInfo fI in typeof(MM_OneLine_TransformerWinding).GetFields()) { if (fI.Name == "ParentElement") { fI.SetValue(this, ParentElement); } else { try { fI.SetValue(this, fI.GetValue(BaseWinding)); } catch (Exception ex) { } } } } }