/// <summary>
 /// Update the status of our element
 /// </summary>
 /// <param name="SelectedElement"></param>
 public void UpdateElement(MM_Element SelectedElement)
 {
     //Show our element in our selection list
     lblElementValue.Text = SelectedElement.ToString();
     if (SelectedElement is MM_Substation)
     {
         MM_Substation BaseSubstation = SelectedElement as MM_Substation;
         txtSubLatitude.Visible = txtSubLongitude.Visible = true;
         txtSubLongitude.Text   = BaseSubstation.Longitude.ToString();
         txtSubLatitude.Text    = BaseSubstation.Latitude.ToString();
         dgvLineLngLat.Visible  = false;
     }
     else
     {
         MM_Line BaseLine = SelectedElement as MM_Line;
         txtSubLatitude.Visible = txtSubLongitude.Visible = false;
         dgvLineLngLat.Visible  = true;
         LineCoordinates.Rows.Clear();
         for (int a = 0; a < BaseLine.Coordinates.Count; a++)
         {
             LineCoordinates.Rows.Add(a, BaseLine.Coordinates[a].Y, BaseLine.Coordinates[a].X);
         }
     }
 }
示例#2
0
 /// <summary>
 /// Report the name of our string
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(Blackstart_Target.Blackstart_Corridor.Name + "/" + Blackstart_Target.Target + "/" + Action.ToString() + " " + Substation.Name + " " + AssociatedElement.ToString());
 }
示例#3
0
        /// <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;
        }