コード例 #1
0
        private void u_moduleCheckListBox_SelectedValueChanged(object sender, EventArgs e)
        {
            if (this.m_init)
            {
                return;
            }

            if (this.u_moduleCheckListBox.CheckedItems.Count == 0)
            {
                this.u_moduleCheckListBox.SetItemChecked(this.u_moduleCheckListBox.SelectedIndex, true);
            }

            try
            {
                this.m_generalDictionary.Remove("ModulesSuppressedFromUI");
            }
            catch { }

            int           i       = 0;
            List <string> modules = new List <string>();

            foreach (KeyValuePair <string, string> kvp in m_modulesDictionary)
            {
                bool itemChecked = u_moduleCheckListBox.GetItemChecked(i);
                if (itemChecked == false)
                {
                    string moduleName = kvp.Key;
                    modules.Add(moduleName);
                }
                i++;
            }
            string serializedString = TakaoHelper.SerializeListToString(modules);

            this.m_generalDictionary.Add("ModulesSuppressedFromUI", serializedString);

            this.u_applyButton.Enabled = true;
        }
コード例 #2
0
        /// <summary>
        /// A helper to generate a dicitonary from a plist(xml) file.
        /// </summary>
        /// <param name="filename">The filename of the xml source.</param>
        /// <returns></returns>
        public static Dictionary <string, string> DictionaryFromFile(string filename)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            if (System.IO.File.Exists(filename))
            {
                try
                {
                    XmlTextReader myReader = new XmlTextReader(filename);
                    myReader.XmlResolver = null;
                    string        myKey   = "";
                    string        myValue = "";
                    List <string> items   = new List <string>();

                    while (myReader.Read())
                    {
                        if (myReader.NodeType == XmlNodeType.Element)
                        {
                            if (myReader.Name == "key")
                            {
                                myReader.Read();
                                myKey = myReader.Value.Trim();
                            }
                            if (myReader.Name == "array")
                            {
                                if (myReader.IsEmptyElement)
                                {
                                    items.Clear();
                                }
                                else
                                {
                                    while (myReader.Read() && !(myReader.NodeType == XmlNodeType.EndElement && myReader.Name == "array"))
                                    {
                                        if (myReader.NodeType == XmlNodeType.Element &&
                                            myReader.Name == "string")
                                        {
                                            myReader.Read();
                                            items.Add(myReader.Value.Trim());
                                        }
                                    }
                                }
                                myValue = TakaoHelper.SerializeListToString(items);
                                TakaoHelper.msg(myValue);
                                if (myKey.Length > 0)
                                {
                                    dictionary.Add(myKey, myValue);
                                }
                                items.Clear();

                                myKey   = "";
                                myValue = "";
                            }

                            if (myReader.Name == "string")
                            {
                                myReader.Read();
                                myValue = myReader.Value.Trim();
                                if (myKey.Length > 0)
                                {
                                    dictionary.Add(myKey, myValue);
                                }
                                myKey   = "";
                                myValue = "";
                            }
                        }
                    }
                    myReader.Close();
                }
                catch {
                }
            }
            return(dictionary);
        }