Пример #1
0
        private void SaveConfig(string filename)
        {
            StringBuilder  buff         = new StringBuilder();
            List <Control> control_list = new List <Control>();

            GetAllControl(this, ref control_list);

            buff.Append("version\t" + program_version_.ToString() + "\r\n");
            for (int i = 0; i < control_list.Count; ++i)
            {
                if (control_list[i] is TextBox)
                {
                    TextBox c = (TextBox)control_list[i];
                    if (c.Name == "textBoxUploadText" || c.Name == "textBoxUser" ||
                        c.Name == "textBoxPassword" || c.Name == "textBoxInfo" || c.Name == "textBoxEditRankFile" ||
                        c.Name == "textBoxEditExclusionList" || c.Name == "textBoxMencWatching"
                        )
                    {
                        continue;
                    }
                    if (c.Name == "")
                    {
                        continue;
                    }
                    buff.Append("text");
                    buff.Append('\t');
                    buff.Append(c.Name);
                    buff.Append('\t');
                    buff.Append(IJStringUtil.EscapeForConfig(c.Text));
                    buff.Append("\r\n");
                }
                else if (control_list[i] is RadioButton)
                {
                    RadioButton c = (RadioButton)control_list[i];
                    buff.Append("radio");
                    buff.Append('\t');
                    buff.Append(c.Name);
                    buff.Append('\t');
                    buff.Append(c.Checked.ToString());
                    buff.Append("\r\n");
                }
                else if (control_list[i] is CheckBox)
                {
                    CheckBox c = (CheckBox)control_list[i];
                    if (c.Name == "checkBoxTimer1" || c.Name == "checkBoxTimer2" || c.Name == "checkBoxDailyTimer" || c.Name == "checkBoxTimerNews")
                    {
                        continue;
                    }
                    buff.Append("checkBox");
                    buff.Append('\t');
                    buff.Append(c.Name);
                    buff.Append('\t');
                    buff.Append(c.Checked.ToString());
                    buff.Append("\r\n");
                }
                else if (control_list[i] is ListBox && !(control_list[i] is CheckedListBox))
                {
                    ListBox c = (ListBox)control_list[i];
                    buff.Append("listBox");
                    buff.Append('\t');
                    buff.Append(c.Name);
                    buff.Append('\t');
                    buff.Append(c.SelectedIndex.ToString());
                    buff.Append("\r\n");
                }
                else if (control_list[i] is DateTimePicker)
                {
                    DateTimePicker c = (DateTimePicker)control_list[i];
                    buff.Append("dateTimePicker");
                    buff.Append('\t');
                    buff.Append(c.Name);
                    buff.Append('\t');
                    buff.Append(NicoUtil.DateToString(c.Value));
                    buff.Append("\r\n");
                }
                else if (control_list[i] is ComboBox)
                {
                    ComboBox c = (ComboBox)control_list[i];
                    buff.Append("comboBox");
                    buff.Append('\t');
                    buff.Append(c.Name);
                    buff.Append('\t');
                    buff.Append(c.SelectedIndex.ToString());
                    buff.Append("\r\n");
                }
                else if (control_list[i] is NumericUpDown)
                {
                    NumericUpDown c = (NumericUpDown)control_list[i];
                    buff.Append("numericUpDown");
                    buff.Append('\t');
                    buff.Append(c.Name);
                    buff.Append('\t');
                    buff.Append(c.Value.ToString());
                    buff.Append("\r\n");
                }
            }
            if (form_trans_option_ != null)
            {
                trans_detail_option_ = form_trans_option_.GetAppOption();
            }
            buff.Append(trans_detail_option_.SaveData());

            buff.Append("dlrank_category\t").Append(category_manager_.GetSaveString()).Append("\r\n");

            IJFile.Write(filename, buff.ToString());
        }