Example #1
0
 public virtual void LoadData(AppTypes.StrategyTypes type, bool onlyEnableItem, bool checkAll)
 {
     this.strategyClb.LoadData(type);
     this.strategyCatCb.LoadData(true);
     //Check all
     //strategyClb.CheckAll(selectAllChk.Checked);
 }
Example #2
0
 /// <summary>
 ///  Create menu listing all strategies with click events.
 /// - strategy having category existed in strategyCat table are grouped to that category
 /// - strategy having category NOT existed in strategyCat are placed under the category menus
 /// </summary>
 /// <param name="toMenu">Menu where strategy menus are added</param>
 /// <param name="handler">Function fired on Click Event</param>
 public static void CreateMenu(AppTypes.StrategyTypes strategyType,
                               ToolStripMenuItem toMenu, System.EventHandler handler)
 {
     if (toMenu != null)
     {
         CreateMenu(Data.MetaList, strategyType, toMenu, handler);
     }
 }
Example #3
0
        /// <summary>
        ///  Create menu listing all strategies with click events.
        /// - strategy having category existed in strategyCat table are grouped to that category
        /// - strategy having category NOT existed in strategyCat are placed under the category menus
        /// </summary>
        /// <param name="Metas">Meta infomation of plug-in strategy</param>
        /// <param name="toMenu">Menu where strategy menus are added</param>
        /// <param name="handler">Function fired on Click Event</param>
        private static void CreateMenu(common.DictionaryList Metas, AppTypes.StrategyTypes strategyType,
                                       ToolStripMenuItem toMenu, System.EventHandler handler)

        {
            for (int idx1 = 0; idx1 < Data.myCatList.Count; idx1++)
            {
                Meta[] tmpMetas = FindMetaByCat(Metas, strategyType, Data.myCatList[idx1].Code);
                if (tmpMetas == null || tmpMetas.Length == 0)
                {
                    continue;
                }

                ToolStripMenuItem catMenuItem = new ToolStripMenuItem();
                catMenuItem.Name = toMenu.Name + "-group-" + Data.myCatList[idx1].Code;
                catMenuItem.Text = Data.myCatList[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];
                    menuItem.Text = tmpMetas[idx2].Name;
                    if (handler != null)
                    {
                        menuItem.Click += new System.EventHandler(handler);
                    }
                    catMenuItem.DropDownItems.Add(menuItem);
                }
            }
            Meta meta;

            for (int idx2 = 0; idx2 < Metas.Values.Length; idx2++)
            {
                meta = (Meta)Metas.Values[idx2];
                if (meta.Type != strategyType)
                {
                    continue;
                }
                if (Data.myCatList.Find(meta.Category.Trim()) != null)
                {
                    continue;
                }
                ToolStripMenuItem menuItem = new ToolStripMenuItem();
                menuItem.Name = toMenu.Name + "-group-" + meta.ClassType.Name;
                menuItem.Tag  = meta;
                menuItem.Text = meta.Name;
                toMenu.DropDownItems.Add(menuItem);
                if (handler != null)
                {
                    menuItem.Click += new System.EventHandler(handler);
                }
            }
        }
Example #4
0
 /// <summary>
 ///  Find/Get all strategy of the same category
 /// </summary>
 /// <param name="metasList">List keeps meta data </param>
 /// <param name="category">What category to find/get </param>
 /// <returns></returns>
 private static Meta[] FindMetaByCat(common.DictionaryList metasList, AppTypes.StrategyTypes strategyType, string category)
 {
     Meta[] retMetas = new Meta[0];
     category = category.Trim().ToLower();
     for (int idx = 0; idx < metasList.Values.Length; idx++)
     {
         Meta meta = (Meta)metasList.Values[idx];
         if ((meta.Type != strategyType) ||
             (meta.Category.Trim().ToLower() != category))
         {
             continue;
         }
         Array.Resize(ref retMetas, retMetas.Length + 1);
         retMetas[retMetas.Length - 1] = meta;
     }
     return(retMetas);
 }
Example #5
0
        //Load strategy to table
        public static void LoadStrategy(data.tmpDS.codeListDataTable tbl, AppTypes.StrategyTypes type)
        {
            Meta meta;

            data.tmpDS.codeListRow row;
            for (int idx = 0; idx < Data.MetaList.Values.Length; idx++)
            {
                meta = (Meta)Data.MetaList.Values[idx];
                if (meta.Type != type)
                {
                    continue;
                }
                row             = tbl.NewcodeListRow();
                row.code        = ((Meta)Data.MetaList.Values[idx]).Code;
                row.description = ((Meta)Data.MetaList.Values[idx]).Name;
                tbl.AddcodeListRow(row);
            }
        }
Example #6
0
        /// <summary>
        ///  Load all strategies of scpecific type.
        /// - strategy having category existed in strategyCat table are grouped to that category
        /// - strategy having category NOT existed in strategyCat are placed under the category menus
        /// </summary>
        /// <param name="strategyType"></param>
        /// <param name="toObj"></param>
        public static void LoadStrategy(AppTypes.StrategyTypes strategyType, ToolStripComboBox toObj)
        {
            common.DictionaryList Metas = Data.MetaList;

            toObj.Items.Clear();
            for (int idx1 = 0; idx1 < Data.myCatList.Count; idx1++)
            {
                Meta[] tmpMetas = FindMetaByCat(Metas, strategyType, Data.myCatList[idx1].Code);
                if (tmpMetas == null || tmpMetas.Length == 0)
                {
                    continue;
                }

                toObj.Items.Add(new common.myComboBoxItem("--" + Data.myCatList[idx1].Description.Trim() + "--", ""));
                for (int idx2 = 0; idx2 < tmpMetas.Length; idx2++)
                {
                    toObj.Items.Add(new common.myComboBoxItem(tmpMetas[idx2].Name, tmpMetas[idx2].Code));
                }
            }
            //Donot have category
            Meta meta;
            bool flag = true;

            for (int idx2 = 0; idx2 < Metas.Values.Length; idx2++)
            {
                if (flag)
                {
                    toObj.Items.Add(new common.myComboBoxItem("--" + Languages.Libs.GetString("others") + "--", ""));
                    flag = false;
                }
                meta = (Meta)Metas.Values[idx2];
                if (meta.Type != strategyType)
                {
                    continue;
                }
                if (Data.myCatList.Find(meta.Category.Trim()) != null)
                {
                    continue;
                }
                toObj.Items.Add(new common.myComboBoxItem(meta.Name, meta.Code));
            }
        }
Example #7
0
 public void LoadData(AppTypes.StrategyTypes type)
 {
     application.Strategy.StrategyLibs.LoadStrategy(type, this);  
     if (this.Items.Count > 0)
     {
         this.SelectedIndex = 0;
         this.MaxDropDownItems = this.Items.Count;
     }
     this.myDataType = type;
 }
Example #8
0
 protected void LoadData(AppTypes.StrategyTypes type,string catCode)
 {
     this.strategyType = type;
     string[] keys = application.Strategy.StrategyData.MetaList.Keys;
     object[] values = application.Strategy.StrategyData.MetaList.Values;
     this.Items.Clear();
     for (int idx = 0; idx < keys.Length; idx++)
     {
         application.Strategy.StrategyMeta meta = (application.Strategy.StrategyMeta)values[idx];
         if (meta.Type != type) continue;
         if (catCode==null || meta.Category == catCode) 
             this.Items.Add(new common.myComboBoxItem(meta.Name,meta.Code));
     }
 }
Example #9
0
        //Swicth language. Note that the order of items must be preserved
        public static void SetLanguage(ComboBox.ObjectCollection items, Type type)
        {
            StringCollection saveKeys = new StringCollection();

            for (int idx = 0; idx < items.Count; idx++)
            {
                common.myComboBoxItem item = (common.myComboBoxItem)items[idx];
                saveKeys.Add(item.Value);
            }
            if (type == typeof(AppTypes.TimeScale))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindTimeScaleByCode(saveKeys[idx]);
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.TimeScale item = (AppTypes.TimeScale)obj;
                    items.Add(new common.myComboBoxItem(item.Description, item.Code));
                }
                return;
            }

            if (type == typeof(AppTypes.TradeActions))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.TradeActions));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.TradeActions item = (AppTypes.TradeActions)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }


            if (type == typeof(AppTypes.TimeRanges))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.TimeRanges));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.TimeRanges item = (AppTypes.TimeRanges)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.StrategyTypes))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.StrategyTypes));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.StrategyTypes item = (AppTypes.StrategyTypes)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.Sex))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.Sex));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.Sex item = (AppTypes.Sex)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.CommonStatus))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.CommonStatus));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.CommonStatus item = (AppTypes.CommonStatus)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.ChartTypes))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.ChartTypes));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.ChartTypes item = (AppTypes.ChartTypes)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
            if (type == typeof(AppTypes.BizSectorTypes))
            {
                items.Clear();
                for (int idx = 0; idx < saveKeys.Count; idx++)
                {
                    object obj = FindCodeInEnum(saveKeys[idx], typeof(AppTypes.BizSectorTypes));
                    if (obj == null)
                    {
                        continue;
                    }
                    AppTypes.BizSectorTypes item = (AppTypes.BizSectorTypes)obj;
                    items.Add(new common.myComboBoxItem(AppTypes.Type2Text(item), item.ToString()));
                }
                return;
            }
        }
Example #10
0
 /// <summary>
 /// Find/Get all strategy of the same category
 /// </summary>
 /// <param name="name">What category to find/get</param>
 /// <returns></returns>
 public static Meta[] FindMetaByCat(string name, AppTypes.StrategyTypes strategyType)
 {
     return(FindMetaByCat(Data.MetaList, strategyType, name));
 }
Example #11
0
 public virtual void LoadData(AppTypes.StrategyTypes type, bool onlyEnableItem, bool checkAll)
 {
     this.strategyClb.LoadData(type);
     this.strategyCatCb.LoadData(true);
 }