コード例 #1
0
        /// <summary>
        /// Handle the left mouse double-click by opening up our one-line
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lvHistory_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo hti = lvHistory.HitTest(e.Location);

            if (hti.Item == null || e.Button != MouseButtons.Left)
            {
                return;
            }
            MM_UserInteraction FoundInteraction = hti.Item as MM_UserInteraction;
            MM_Substation      FoundSub         = FoundInteraction.Elem.Substation;

            if (FoundSub == null)
            {
                return;
            }
            MM_Form_Builder.OneLine_Display(FoundSub, Program.MM.ctlNetworkMap);
        }
コード例 #2
0
ファイル: MM_Pipe.cs プロジェクト: sylvainr/MacomberMap
        /// <summary>
        /// Process the command
        /// </summary>
        /// <param name="InLine"></param>
        private static void ProcessCommand(String[] InLine)
        {
            MM_Element Element = null;

            if (InLine.Length == 3)
            {
                if (InLine[1].Equals("Substation", StringComparison.CurrentCultureIgnoreCase))
                {
                    MM_Substation FoundSub;
                    if (MM_Repository.Substations.TryGetValue(InLine[2], out FoundSub))
                    {
                        Element = FoundSub;
                    }
                    else
                    {
                        foreach (MM_Substation Sub in MM_Repository.Substations.Values)
                        {
                            if (Sub.LongName.Equals(InLine[2], StringComparison.CurrentCultureIgnoreCase))
                            {
                                Element = Sub;
                                break;
                            }
                        }
                    }
                }
                else if (InLine[1].Equals("Line", StringComparison.CurrentCultureIgnoreCase))
                {
                    Element = MM_Repository.Lines[InLine[2]];
                }
                else if (InLine[1].Equals("Contingency", StringComparison.CurrentCultureIgnoreCase))
                {
                    Element = MM_Repository.Contingencies[InLine[2]];
                }
                else
                {
                    Element = MM_Repository.LocateElement(InLine[2].Split('.')[0], InLine[2].Split('.')[1], InLine[1], "");
                }
            }
            else if (InLine.Length == 2)
            {
                Int32 TryNum;
                if (!Int32.TryParse(InLine[1], out TryNum) || !MM_Repository.TEIDs.TryGetValue(TryNum, out Element))
                {
                    return;
                }
            }


            if (InLine[0].Equals("Search", StringComparison.CurrentCultureIgnoreCase))
            {
                MM_Form_Builder.SearchDisplay(Map.ctlNetworkMap, InLine[1], false, false);
            }
            else if (InLine[0].Equals("Message", StringComparison.CurrentCultureIgnoreCase))
            {
                MM_System_Interfaces.MessageBox("Message received: " + String.Join(" ", InLine, 1, InLine.Length - 1), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (InLine[0].Equals("Zoom", StringComparison.CurrentCultureIgnoreCase))
            {
                if (Element is MM_AlarmViolation)
                {
                    Element = (Element as MM_AlarmViolation).ViolatedElement;
                }
                if (Element is MM_Substation)
                {
                    Map.ctlNetworkMap.Coordinates.Center = ((Element as MM_Substation).LngLat);
                    Map.ctlNetworkMap.Coordinates.UpdateZoom(MM_Repository.OverallDisplay.StationZoomLevel);
                }
                else if (Element is MM_Line)
                {
                    Map.ctlNetworkMap.Coordinates.Center = (((Element as MM_Line).Midpoint));
                    Map.ctlNetworkMap.Coordinates.UpdateZoom(MM_Repository.OverallDisplay.StationZoomLevel);
                }
                else if (Element.Substation != null)
                {
                    Map.ctlNetworkMap.Coordinates.Center = (Element.Substation.LngLat);
                    Map.ctlNetworkMap.Coordinates.UpdateZoom(MM_Repository.OverallDisplay.StationZoomLevel);
                }
            }
            else if (InLine[0].Equals("Property", StringComparison.CurrentCultureIgnoreCase))
            {
                MM_Form_Builder.PropertyPage(Element, Map.ctlNetworkMap);
            }
            else if (InLine[0].Equals("OneLine", StringComparison.CurrentCultureIgnoreCase))
            {
                MM_Form_Builder.OneLine_Display(Element, Map.ctlNetworkMap);
            }
        }
コード例 #3
0
        /// <summary>
        /// Perform the actual searching
        /// </summary>
        /// <param name="ControlPressed">Whether to return just substations with one item</param>
        /// <param name="AltPressed">Whether alt is pressed</param>
        /// <returns>True if a succesful match has been found</returns>
        public bool PerformSearch(bool ControlPressed, bool AltPressed)
        {
            picAbort.Visible = true;
            BaseData.Data.Tables.Clear();
            this.lvSearch.Items.Clear();
            this.Cursor = Cursors.WaitCursor;

            //First, see if the string is a TEID, and if so, just popup the property page.
            Int32      TEIDTest = 0;
            MM_Element FoundElem;

            if (ItemSelectionChanged == null && Int32.TryParse(SearchText.Trim(), out TEIDTest))
            {
                if (MM_Repository.TEIDs.TryGetValue(TEIDTest, out FoundElem))
                {
                    if (ControlPressed)
                    {
                        if (FoundElem is MM_Substation)
                        {
                            nMap.Coordinates.Center = ((FoundElem as MM_Substation).LngLat);
                        }
                        else if (FoundElem is MM_Line)
                        {
                            nMap.Coordinates.Center = ((FoundElem as MM_Line).Midpoint);
                        }
                        else if (FoundElem.Substation != null)
                        {
                            nMap.Coordinates.Center = (FoundElem.Substation.LngLat);
                        }
                        else
                        {
                            MM_Form_Builder.PropertyPage(MM_Repository.TEIDs[TEIDTest], nMap);
                            return(false);
                        }
                        nMap.Coordinates.UpdateZoom(MM_Repository.OverallDisplay.StationZoomLevel);
                    }
                    else
                    {
                        MM_Form_Builder.PropertyPage(MM_Repository.TEIDs[TEIDTest], nMap);
                    }
                    return(false);
                }

                else
                {
                    return(FailError("Unable to find TEID #" + TEIDTest.ToString() + "!"));
                }
            }


            //Split apart the string
            List <String> Words = new List <string>();

            //Define the parameters we might be looking for.
            MM_KVLevel      KVLevel  = null;
            MM_Element_Type ElemType = null;

            if (ItemSelectionChanged != null && int.TryParse(SearchText, out TEIDTest) && MM_Repository.TEIDs.TryGetValue(TEIDTest, out FoundElem))
            {
                AddElement(FoundElem);
            }

            //Go through each word, and test it.
            foreach (String Word in SearchText.Split(new char[] { ' ', '\t', '_' }, StringSplitOptions.RemoveEmptyEntries))
            {
                Object FoundWord = FindWord(Word);
                if (FoundWord == null)
                {
                    Words.Add(Word);
                }
                else if (FoundWord is MM_KVLevel)
                {
                    if (KVLevel != null)
                    {
                        return(FailError("Please only specify one KV Level in the search query.\nFound " + KVLevel.Name + " and " + (FoundWord as MM_KVLevel).Name));
                    }
                    else
                    {
                        KVLevel = FoundWord as MM_KVLevel;
                    }
                }
                else if (FoundWord is MM_Element_Type)
                {
                    if (ElemType != null)
                    {
                        return(FailError("Please only specify one element type in the search query.\nFound " + ElemType.Name + " and " + (FoundWord as MM_Element_Type).Name));
                    }
                    else
                    {
                        ElemType = FoundWord as MM_Element_Type;
                    }
                }
            }

            //If we're doing a control, add 'substation'
            if (ElemType == null && (ControlPressed || AltPressed))
            {
                ElemType = MM_Repository.FindElementType("Substation");
            }


            //Now go through all elements, searching for results
            Dictionary <String, bool> ElementWords = new Dictionary <string, bool>(StringComparer.CurrentCultureIgnoreCase);

            //int tempref = 0; /////nataros this is for a catch test, to remove later
            foreach (MM_Element Elem in new List <MM_Element>(MM_Repository.TEIDs.Values))
            {
                if (Elem.Name != null && Elem.TEID > 0)
                {
                    if (Elem is MM_Blackstart_Corridor_Element == false)
                    {
                        if (Elem.Permitted && CheckElement(Elem, KVLevel, ElemType, Words, ElementWords) && Elem.ElemType != null)
                        {
                            AddElement(Elem);
                        }
                        if (AbortSearch)
                        {
                            AbortSearch = false;
                            return(lvSearch.Items.Count > 0);
                        }
                    }
                    else
                    {
                        //catch test, to remove this else case later, needed break pt and counter for test - nataros

                        //tempref = tempref++;
                    }
                }
            }

            this.lvSearch.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            this.Cursor = Cursors.Default;

            if (viewSummary != null)
            {
                viewSummary.SetControls(BaseData);
            }

            picAbort.Visible = false;
            if (lvSearch.Items.Count == 0)
            {
                return(FailError("No results found for: " + this.SearchText));
            }
            else if (ControlPressed)
            {
                MM_Element SelectedElement = null;
                bool       OnlyOneElement  = lvSearch.Items.Count == 1;
                if (lvSearch.Items.Count == 1)
                {
                    SelectedElement = lvSearch.Items[0].Tag as MM_Element;
                }
                else
                {
                    foreach (ListViewItem lvi in lvSearch.Items)
                    {
                        if ((lvi.Tag as MM_Element).Name.Equals(SearchText.Trim(), StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (SelectedElement != null)
                            {
                                OnlyOneElement = false;
                            }
                            else if (SelectedElement == null)
                            {
                                SelectedElement = lvi.Tag as MM_Element;
                                OnlyOneElement  = true;
                            }
                        }
                    }
                }

                if (OnlyOneElement)
                {
                    if (SelectedElement is MM_Substation)
                    {
                        nMap.Coordinates.Center = ((SelectedElement as MM_Substation).LngLat);
                        nMap.Coordinates.UpdateZoom(MM_Repository.OverallDisplay.StationZoomLevel);
                        nMap.Coordinates.Center = ((SelectedElement as MM_Substation).LngLat);
                    }
                    else if (SelectedElement is MM_Line)
                    {
                        nMap.Coordinates.Center = (((SelectedElement as MM_Line).Midpoint));
                        nMap.Coordinates.UpdateZoom(MM_Repository.OverallDisplay.StationZoomLevel);
                        nMap.Coordinates.Center = (((SelectedElement as MM_Line).Midpoint));
                    }
                    else if (SelectedElement.Substation != null)
                    {
                        nMap.Coordinates.Center = (SelectedElement.Substation.LngLat);
                        nMap.Coordinates.UpdateZoom(MM_Repository.OverallDisplay.StationZoomLevel);
                        nMap.Coordinates.Center = (SelectedElement.Substation.LngLat);
                    }
                    return(false);
                }
            }
            else if (AltPressed)
            {
                MM_Element SelectedElement = null;
                bool       OnlyOneElement  = lvSearch.Items.Count == 1;
                if (lvSearch.Items.Count == 1)
                {
                    SelectedElement = lvSearch.Items[0].Tag as MM_Element;
                }
                else
                {
                    foreach (ListViewItem lvi in lvSearch.Items)
                    {
                        if ((lvi.Tag as MM_Element).Name.Equals(SearchText.Trim(), StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (SelectedElement != null)
                            {
                                OnlyOneElement = false;
                            }
                            else if (SelectedElement == null)
                            {
                                SelectedElement = lvi.Tag as MM_Element;
                                OnlyOneElement  = true;
                            }
                        }
                    }
                }
                if (Data_Integration.Permissions.ShowOneLines == true && OnlyOneElement)
                {
                    if (SelectedElement is MM_Substation)
                    {
                        MM_Form_Builder.OneLine_Display(SelectedElement, nMap);
                    }
                    else if (SelectedElement is MM_Line)
                    {
                        MM_Form_Builder.OneLine_Display(SelectedElement, nMap);
                    }
                    else if (SelectedElement.Substation != null)
                    {
                        MM_Form_Builder.OneLine_Display(SelectedElement.Substation, nMap);
                    }
                    return(false);
                }
            }

            //If we have results, select them
            if (ItemSelectionChanged != null && lvSearch.Items.Count > 0)
            {
                lvSearch.Items[0].Selected = true;
            }
            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Assign controls to the search results window
        /// </summary>
        /// <param name="nMap">Network Map</param>
        /// <param name="violView">Violations view</param>
        /// <param name="miniMap">The mini-map</param>
        /// <param name="SearchText">Search Text</param>
        /// <param name="Parent">The parent builder</param>
        /// <param name="BaseData">The base data tables</param>
        /// <param name="ControlPressed">Whether the control button is pressed</param>
        /// <param name="viewSummary"></param>
        /// <param name="AltPressed">Whether the alt button is pressed</param>
        public bool SetControls(MM_Network_Map_DX nMap, MM_Violation_Viewer violView, MM_Mini_Map miniMap, String SearchText, MM_Form_Builder Parent, out MM_DataSet_Base BaseData, MM_Element_Summary viewSummary, bool ControlPressed, bool AltPressed)
        {
            MM_Repository.ViewChanged += new MM_Repository.ViewChangedDelegate(Repository_ViewChanged);
            this.nMap        = nMap;
            this.miniMap     = miniMap;
            this.violView    = violView;
            this.viewSummary = viewSummary;
            ConfigureSearch();
            this.txtSearch.Text = SearchText;
            this.SearchText     = SearchText;
            bool Resp = PerformSearch(ControlPressed, AltPressed);

            BaseData = this.BaseData;
            return(Resp);
        }