예제 #1
0
        /// <summary>
        ///  Create menu listing all indictors with click events.
        /// - Indicators having category existed in indicatorCat table are grouped to that category
        /// - Indicators having category NOT existed in indicatorCat are placed under the category menus
        /// </summary>
        /// <param name="Metas">Meta infomation of plug-in indicators</param>
        /// <param name="toMenu">Menu where indicator menus are added</param>
        /// <param name="ShowIndicatorHandler">Function fired on Click Event</param>
        private static void CreateIndicatorMenu(common.DictionaryList Metas, ToolStripMenuItem toMenu, System.EventHandler ShowIndicatorHandler)
        {
            for (int idx1 = 0; idx1 < Data.myIndicatorCatList.Count; idx1++)
            {
                Meta[] tmpMetas = Libs.FindMetaByCat(Metas, Data.myIndicatorCatList[idx1].Code);
                if (tmpMetas == null || tmpMetas.Length == 0)
                {
                    continue;
                }

                ToolStripMenuItem catMenuItem = new ToolStripMenuItem();
                catMenuItem.Name = toMenu.Name + "-group-" + Data.myIndicatorCatList[idx1].Code;
                catMenuItem.Text = Data.myIndicatorCatList[idx1].Description;
                toMenu.DropDownItems.Add(catMenuItem);
                for (int idx2 = 0; idx2 < tmpMetas.Length; idx2++)
                {
                    ToolStripMenuItem menuItem = new ToolStripMenuItem();
                    menuItem.Name   = toMenu.Name + "-" + tmpMetas[idx2].ClassType.Name;
                    menuItem.Tag    = tmpMetas[idx2].ClassType.Name;
                    menuItem.Text   = tmpMetas[idx2].Name;
                    menuItem.Click += new System.EventHandler(ShowIndicatorHandler);
                    catMenuItem.DropDownItems.Add(menuItem);
                }
            }
            Meta meta;

            for (int idx2 = 0; idx2 < Metas.Values.Length; idx2++)
            {
                meta = (Meta)Metas.Values[idx2];
                if (Data.myIndicatorCatList.Find(meta.Category.Trim()) != null)
                {
                    continue;
                }
                ToolStripMenuItem menuItem = new ToolStripMenuItem();
                menuItem.Name = toMenu.Name + "-group-" + meta.ClassType.Name;
                menuItem.Tag  = meta.ClassType.Name;
                menuItem.Text = meta.Name;
                toMenu.DropDownItems.Add(menuItem);
                menuItem.Click += new System.EventHandler(ShowIndicatorHandler);
            }
        }
예제 #2
0
 /// <summary>
 /// Find/Get all indicator of the same category
 /// </summary>
 /// <param name="name">What category to find/get</param>
 /// <returns></returns>
 public static Meta[] FindMetaByCat(string name)
 {
     return(Libs.FindMetaByCat(Data.Metas, name));
 }
예제 #3
0
 /// <summary>
 /// Find/Get indicator by name. Return null if not found
 /// </summary>
 /// <param name="name">Indicator name to find</param>///
 /// <returns></returns>
 public static Meta FindMetaByName(string name)
 {
     return(Libs.FindMetaByName(Data.Metas, name));
 }