コード例 #1
0
        /// <summary>
        /// Handle our drop-down item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTrendHistory_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Tag == null || e.ClickedItem.Tag is MemberInfo == false)
            {
                return;
            }
            MM_Element_Type ElemType = (MM_Element_Type)(((ToolStripItem)sender).Tag);
            MemberInfo      mI       = (MemberInfo)e.ClickedItem.Tag;

            btnTrendHistory.Text = ElemType.Name + " " + mI.Name + " " + e.ClickedItem.OwnerItem.OwnerItem.Text;


            flwMain.Controls.Clear();
            MM_LoadGen_Tracking_Operator FoundOperator;
            SortedDictionary <String, MM_LoadGen_Tracking_Operator> Trackers = new SortedDictionary <string, MM_LoadGen_Tracking_Operator>();

            foreach (MM_Element Elem in MM_Repository.TEIDs.Values)
            {
                if (Elem.ElemType == ElemType)
                {
                    //Determine our key
                    String Key = "";
                    if (e.ClickedItem.OwnerItem.OwnerItem == byOperatorToolStripMenuItem)
                    {
                        Key = Elem.Operator.Alias;
                    }
                    else if (e.ClickedItem.OwnerItem.OwnerItem == byCountyToolStripMenuItem)
                    {
                        if (Elem.Substation == null || Elem.Substation.County == null)
                        {
                            Key = "Unknown";
                        }
                        else
                        {
                            Key = Elem.Substation.County.Name;
                        }
                    }


                    if (!Trackers.TryGetValue(Key, out FoundOperator))
                    {
                        Trackers.Add(Key, FoundOperator = new MM_LoadGen_Tracking_Operator(Key, ElemType, mI));
                    }
                    FoundOperator.Elements.Add(Elem);
                }
            }
            foreach (MM_LoadGen_Tracking_Operator Oper in Trackers.Values)
            {
                Oper.BeginTracking();
            }
            flwMain.Controls.AddRange(Trackers.Values.ToArray());
        }