Beispiel #1
0
        public void FromString(string Objects)
        {
            using var Trace = new Trace();  //This c# 8.0 using feature will auto dispose when the function is done.

            try
            {
                //take anything before the first semicolon:
                if (Objects.Contains(";"))
                {
                    Objects = Objects.GetWord("", ";");
                }

                this.EnabledCount = 0;
                int order = 0;

                List <string> lst    = Objects.SplitStr(",");
                List <string> deflst = AppSettings.Settings.ObjectPriority.ToLower().SplitStr(",");

                foreach (var obj in lst)
                {
                    ClsRelevantObject ro = new ClsRelevantObject(obj);

                    if (!ObjectDict.Contains(ro.Name.ToLower()))
                    {
                        if (ro.Enabled)
                        {
                            this.EnabledCount++;
                        }

                        order = deflst.IndexOf(ro.Name.ToLower());

                        if (order > -1)
                        {
                            ro.Priority = order + 1;
                        }

                        ObjectDict.Add(ro.Name.ToLower(), ro);
                    }
                }

                AddDefaults();
            }
            catch (Exception ex)
            {
                AITOOL.Log("Error: " + ex.Msg());
            }
        }
Beispiel #2
0
        public bool TryDelete(ClsRelevantObject ro)
        {
            bool ret = false;

            if (ro.IsNull())
            {
                return(false);
            }

            if (ObjectDict.Contains(ro.Name.ToLower()))
            {
                ObjectDict.Remove(ro.Name.ToLower());
                ret = true;
            }

            return(ret);
        }
Beispiel #3
0
        public void AddDefaults()
        {
            //Make sure the default objects are always in the list

            List <string> deflst          = AppSettings.Settings.ObjectPriority.SplitStr(",");
            bool          AlreadyHasItems = ObjectDict.Count > 0;

            for (int i = 0; i < deflst.Count; i++)
            {
                ClsRelevantObject ro = new ClsRelevantObject(deflst[i]);

                if (!ObjectDict.Contains(ro.Name.ToLower()))
                {
                    //if no items are currently in the dictionary, assume we want to ENABLE all the objects
                    //  Otherwise, Disable objects so that existing lists from old versions dont suddenly have everything enabled that shouldnt be
                    if (!AlreadyHasItems)
                    {
                        ro.Enabled = true;
                    }
                    else
                    {
                        ro.Enabled = false;
                    }

                    if (ro.Enabled)
                    {
                        this.EnabledCount++;
                    }

                    ro.Priority = i + 1;

                    ObjectDict.Add(ro.Name.ToLower(), ro);
                }
                else
                {
                    if (!AlreadyHasItems)
                    {
                        ro.Priority = i + 1;
                    }
                }
            }
        }
Beispiel #4
0
        public bool TryAdd(ClsRelevantObject ro, bool Enable)
        {
            bool ret = false;

            if (ro.IsNull())
            {
                return(false);
            }

            if (!ObjectDict.Contains(ro.Name.ToLower()))
            {
                ro.Priority = ObjectDict.Count + 1;
                ro.Enabled  = Enable;

                if (ro.Enabled)
                {
                    this.EnabledCount++;
                }
                ObjectDict.Add(ro.Name.ToLower(), ro);
                ret = true;
            }

            return(ret);
        }