Пример #1
0
            /// <summary>
            /// Loads the property from an XML Text
            /// </summary>
            /// <param name="XML_Text">The XML Text</param>
            /// <returns>True if the property was found and loaded</returns>
            public bool LoadProperty(string XML_Text, bool TestMode)
            {
                object prop_value    = this.DefaultValueOnFailLoad;
                string SourceTag     = "";
                bool   IfPerfectLoad = true;

                try
                {
                    SourceTag = StaticMethods.GetValueOfTags("" + this.LOAD_ORDER, XML_Text)[0];

                    if (this.PropertyToSaveLoad != UIStateProperty.CheckBoxListItems)
                    {
                        prop_value = StaticMethods.GetValueOfTags(UIState.ControlUIState.ValueTag, SourceTag)[0];
                    }

                    switch (this.PropertyToSaveLoad)
                    {
                    case UIStateProperty.Checked:
                        prop_value = bool.Parse("" + prop_value);
                        if (TestMode == false)
                        {
                            StaticMethods.SetValueOfPublicPropertyInObject(this.Control, "" + this.PropertyToSaveLoad, prop_value);
                        }
                        break;

                    case UIStateProperty.Text:
                        prop_value = StaticMethods.ConvertFromEscapedXMLTags("" + prop_value);
                        if (TestMode == false)
                        {
                            StaticMethods.SetValueOfPublicPropertyInObject(this.Control, "" + this.PropertyToSaveLoad, prop_value);
                        }
                        break;

                    case UIStateProperty.CheckBoxListItems:
                        string[] Items = StaticMethods.GetValueOfTags(UIState.ControlUIState.ItemTag, SourceTag);
                        //For each of the items we must load them onto the CheckBox
                        ArrayList ArrLisNames   = new ArrayList(Items.Length);
                        ArrayList ArrLisChecked = new ArrayList(Items.Length);
                        //We must parse the string / and the boolean
                        for (int index = 0; index < Items.Length; index++)
                        {
                            string Item = StaticMethods.ConvertFromEscapedXMLTags(Items[index]);
                            ArrLisNames.Add(StaticMethods.GetValueOfTags(UIState.ControlUIState.NameTag, Item)[0]);
                            ArrLisChecked.Add(bool.Parse(StaticMethods.GetValueOfTags(UIState.ControlUIState.ValueTag, Item)[0]));
                        }

                        if (TestMode == false)
                        {
                            //If we reached upto here, clear all the collection that the checkbox has
                            CheckedListBox CheckLisBox = this.Control as CheckedListBox;
                            CheckLisBox.Items.Clear();
                            //Lets add the items::
                            for (int index = 0; index < ArrLisNames.Count; index++)
                            {
                                CheckLisBox.Items.Add(ArrLisNames[index], ((bool)ArrLisChecked[index]));
                            }
                        }
                        break;
                    }
                }
                catch
                {
                    IfPerfectLoad = false;
                }

                if ((this.PropertyToSaveLoad == UIStateProperty.Checked || this.PropertyToSaveLoad == UIStateProperty.Text) && TestMode == false)
                {
                    StaticMethods.SetValueOfPublicPropertyInObject(this.Control, "" + this.PropertyToSaveLoad, prop_value);
                }

                return(IfPerfectLoad);
            }