Пример #1
0
        private void loadINI(String filename)
        {
            m_iniFile = new CSettings(filename);
            m_iniFile.LoadSettings();
            tctrlSettings.Controls.Clear();

            var list = m_iniFile.Attributes.Keys.ToList();
            list.Sort();
            foreach (String attrib in list)
            {
                Point topleft = new Point(4, 4);

                if (m_iniFile.Attributes[attrib].Count < 1)
                    continue;
                TabPage page = new TabPage(attrib);
                page.Name = attrib;
                tctrlSettings.TabPages.Add(page);

                Panel panel = new Panel();
                panel.Dock = DockStyle.Fill;
                panel.Name = "pnl" + attrib;
                page.Controls.Add(panel);

                ListBox listbox = new ListBox();
                listbox.Name = "lbx" + attrib;
                listbox.Width = 300;
                listbox.Height = panel.Height - 8;
                panel.Controls.Add(listbox);
                listbox.Location = topleft;
                List<String> boxItems = new List<String>();
                foreach (String setting in m_iniFile.Attributes[attrib].Keys)
                    boxItems.Add(setting);
                boxItems.Sort();
                foreach (String entry in boxItems)
                    listbox.Items.Add(entry);
                listbox.SelectedIndexChanged += listbox_SelectedIndexChanged;

                topleft = new Point(listbox.Right + 4, listbox.Top);

                // examine/edit
                Label lbl = new Label();
                lbl.Name = "lbl" + attrib;
                lbl.Text = "Field Value:";
                lbl.Width = 200;
                lbl.TextAlign = ContentAlignment.MiddleLeft;
                panel.Controls.Add(lbl);
                lbl.Location = topleft;

                topleft.Y += lbl.Height + 4;
                TextBox box = new TextBox();
                box.Width = 300;
                box.Name = "tbx" + attrib;
                panel.Controls.Add(box);
                box.Location = topleft;

                Button btn = new Button();
                topleft.Y = (box.Top - ((btn.Height - box.Height) / 2));
                topleft.X = box.Right + 4;
                btn.Name = "btn" + attrib;
                btn.Text = "Set";
                btn.Click += button_Click;
                panel.Controls.Add(btn);
                btn.Location = topleft;

                // add
                Label lblAdd = new Label();
                lblAdd.Name = "lblAdd" + attrib;
                lblAdd.Text = "Add";
                lblAdd.Width = 200;
                lblAdd.TextAlign = ContentAlignment.MiddleLeft;
                panel.Controls.Add(lblAdd);
                topleft.X = lbl.Left;
                topleft.Y = box.Top + box.Height + 4;
                lblAdd.Location = topleft;

                topleft.Y += lblAdd.Height + 4;
                TextBox boxAddName = new TextBox();
                boxAddName.Width = 200;
                boxAddName.Name = "tbxAdd" + attrib + "Name";
                panel.Controls.Add(boxAddName);
                boxAddName.Location = topleft;

                topleft.X += boxAddName.Width + 4;
                TextBox boxAddVal = new TextBox();
                boxAddVal.Width = 96;
                boxAddVal.Name = "tbxAdd" + attrib + "Value";
                panel.Controls.Add(boxAddVal);
                boxAddVal.Location = topleft;

                Button btnAdd = new Button();
                topleft.Y = (boxAddName.Top - ((btnAdd.Height - boxAddName.Height) / 2));
                topleft.X = boxAddVal.Right + 4;
                btnAdd.Name = "btnAdd" + attrib;
                btnAdd.Text = "Add";
                btnAdd.Click += button_AddClick;
                panel.Controls.Add(btnAdd);
                btnAdd.Location = topleft;

                m_selectedTabIndex = tctrlSettings.SelectedIndex;
            }
        }
 public bool Load()
 {
     bool success = true;
     if (File.Exists("Tables\\parentStatus.txt"))
     {
         m_parents = new CSettings("Tables\\parentStatus.txt");
         if (!m_parents.LoadSettings())
         {
             MessageBox.Show("Unable to load parent status tables.");
             success = false;
         }
     }
     if (File.Exists("Tables\\familyBackground.txt"))
     {
         m_family = new CSettings("Tables\\familyBackground.txt");
         if (!m_family.LoadSettings())
         {
             MessageBox.Show("Unable to load family background tables.");
             success = false;
         }
     }
     if (File.Exists("Tables\\friendsAndEnemies.txt"))
     {
         m_friends = new CSettings("Tables\\friendsAndEnemies.txt");
         if (!m_friends.LoadSettings())
         {
             MessageBox.Show("Unable to load friends and enemies tables.");
             success = false;
         }
     }
     if (File.Exists("Tables\\romanticLife.txt"))
     {
         m_romance = new CSettings("Tables\\romanticLife.txt");
         if (!m_romance.LoadSettings())
         {
             MessageBox.Show("Unable to load romance tables.");
             success = false;
         }
     }
     extractTables();
     return success;
 }