public void writeCurSettings(Settings settingsForm, IniFile ini) { ini.IniWriteValue("Tab_1", "Cover", (Convert.ToInt32(settingsForm.settings1_1_cover_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_1", "TOC", (Convert.ToInt32(settingsForm.settings1_1_TOC_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_1", "TOC_Load", (Convert.ToInt32(settingsForm.settings1_1_TOCload_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_1", "Vertical", (Convert.ToInt32(settingsForm.settings1_3_vertical_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_1", "Replace", (Convert.ToInt32(settingsForm.settings1_3_replace_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_1", "StT", (Convert.ToInt32(settingsForm.settings1_3_StT_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_1", "TtS", (Convert.ToInt32(settingsForm.settings1_3_TtS_checkbox.Checked)).ToString()); //ini.IniWriteValue("Tab_1", "Drop_Cap", (Convert.ToInt32(settingsForm.settings1_3_dropcap_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_2", "Page_Width", settingsForm.settings2_1_pw_textbox.Text); ini.IniWriteValue("Tab_2", "Page_Height", settingsForm.settings2_1_ph_textbox.Text); ini.IniWriteValue("Tab_2", "Page_Color", convertColorToCode(settingsForm.settings2_1_pc_combobox.Text, 0)); ini.IniWriteValue("Tab_2", "Page_Margin_Up", settingsForm.settings2_2_pmU_textbox.Text); ini.IniWriteValue("Tab_2", "Page_Margin_Down", settingsForm.settings2_2_pmD_textbox.Text); ini.IniWriteValue("Tab_2", "Page_Margin_Left", settingsForm.settings2_2_pmL_textbox.Text); ini.IniWriteValue("Tab_2", "Page_Margin_Right", settingsForm.settings2_2_pmR_textbox.Text); ini.IniWriteValue("Tab_2", "Header_Margin", settingsForm.settings2_3_header_textbox.Text); ini.IniWriteValue("Tab_2", "Footer_Margin", settingsForm.settings2_3_footer_textbox.Text); ini.IniWriteValue("Tab_3", "Title_Font", settingsForm.settings3_1_tfont_combobox.Text); ini.IniWriteValue("Tab_3", "Title_Size", settingsForm.settings3_1_tsize_textbox.Text); ini.IniWriteValue("Tab_3", "Title_Color", convertColorToCode(settingsForm.settings3_1_tcolor_combobox.Text, 1)); ini.IniWriteValue("Tab_3", "Body_Font", settingsForm.settings3_2_bfont_combobox.Text); ini.IniWriteValue("Tab_3", "Body_Size", settingsForm.settings3_2_bsize_textbox.Text); ini.IniWriteValue("Tab_3", "Body_Color", convertColorToCode(settingsForm.settings3_2_bcolor_combobox.Text, 1)); ini.IniWriteValue("Tab_3", "Line_Spacing", settingsForm.settings3_3_linespacing_textbox.Text); ini.IniWriteValue("Tab_3", "Add_Paragraph_Spacing", (Convert.ToInt32(settingsForm.settings3_3_addparagraphspacing_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_4", "Generated_File_Location", settingsForm.settings4_1_filelocation_textbox.Text); ini.IniWriteValue("Tab_4", "Drag_Clear_List", (Convert.ToInt32(settingsForm.settings4_2_dragclearlist_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_4", "Delete_Temp_Files", (Convert.ToInt32(settingsForm.settings4_2_deletetempfiles_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_4", "PDF", (Convert.ToInt32(settingsForm.settings4_2_pdf_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_4", "Save_Time_Mode", (Convert.ToInt32(settingsForm.settings4_2_savetimemode_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_5", "Header", (Convert.ToInt32(settingsForm.settings5_1_header_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_5", "Header_Size", settingsForm.settings5_1_headersize_textbox.Text); ini.IniWriteValue("Tab_5", "Header_Align", convertHanToNum_Align(settingsForm.settings5_1_headeralign_combobox.Text)); ini.IniWriteValue("Tab_5", "Header_Border", (Convert.ToInt32(settingsForm.settings5_1_headerboder_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_5", "Footer", (Convert.ToInt32(settingsForm.settings5_2_footer_checkbox.Checked)).ToString()); ini.IniWriteValue("Tab_5", "Footer_Size", settingsForm.settings5_2_footersize_textbox.Text); ini.IniWriteValue("Tab_5", "Footer_Align", convertHanToNum_Align(settingsForm.settings5_2_footeralign_combobox.Text)); ini.IniWriteValue("Tab_5", "Footer_Style", convertHanToNum_Style(settingsForm.settings5_2_footerstyle_combobox.Text)); ini.IniWriteValue("Tab_5", "Footer_Border", (Convert.ToInt32(settingsForm.settings5_2_footerboder_checkbox.Checked)).ToString()); }
public void loadCurSettings(Settings settingsForm, IniFile ini) { settingsForm.settings1_1_cover_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_1", "Cover"))); settingsForm.settings1_1_TOC_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_1", "TOC"))); settingsForm.settings1_1_TOCload_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_1", "TOC_Load"))); if (!settingsForm.settings1_1_TOC_checkbox.Checked) { settingsForm.settings1_1_TOCload_checkbox.Checked = false; settingsForm.settings1_1_TOCload_checkbox.Enabled = false; settingsForm.settings1_1_TOCload_label.Enabled = false; } settingsForm.settings1_3_vertical_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_1", "Vertical"))); settingsForm.settings1_3_replace_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_1", "Replace"))); settingsForm.settings1_3_StT_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_1", "StT"))); settingsForm.settings1_3_TtS_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_1", "TtS"))); if (settingsForm.settings1_3_StT_checkbox.Checked) { settingsForm.settings1_3_TtS_checkbox.Checked = false; settingsForm.settings1_3_TtS_checkbox.Enabled = false; } if (settingsForm.settings1_3_TtS_checkbox.Checked) { settingsForm.settings1_3_StT_checkbox.Checked = false; settingsForm.settings1_3_StT_checkbox.Enabled = false; } //settingsForm.settings1_3_dropcap_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_1", "Drop_Cap"))); settingsForm.settings2_1_pw_textbox.Text = ini.IniReadValue("Tab_2", "Page_Width"); settingsForm.settings2_1_ph_textbox.Text = ini.IniReadValue("Tab_2", "Page_Height"); settingsForm.settings2_1_pc_combobox.Text = convertCodeToColor(ini.IniReadValue("Tab_2", "Page_Color")); settingsForm.settings2_2_pmU_textbox.Text = ini.IniReadValue("Tab_2", "Page_Margin_Up"); settingsForm.settings2_2_pmD_textbox.Text = ini.IniReadValue("Tab_2", "Page_Margin_Down"); settingsForm.settings2_2_pmL_textbox.Text = ini.IniReadValue("Tab_2", "Page_Margin_Left"); settingsForm.settings2_2_pmR_textbox.Text = ini.IniReadValue("Tab_2", "Page_Margin_Right"); settingsForm.settings2_3_header_textbox.Text = ini.IniReadValue("Tab_2", "Header_Margin"); settingsForm.settings2_3_footer_textbox.Text = ini.IniReadValue("Tab_2", "Footer_Margin"); settingsForm.settings3_1_tfont_combobox.Text = ini.IniReadValue("Tab_3", "Title_Font"); settingsForm.settings3_1_tsize_textbox.Text = ini.IniReadValue("Tab_3", "Title_Size"); settingsForm.settings3_1_tcolor_combobox.Text = convertCodeToColor(ini.IniReadValue("Tab_3", "Title_Color")); settingsForm.settings3_2_bfont_combobox.Text = ini.IniReadValue("Tab_3", "Body_Font"); settingsForm.settings3_2_bsize_textbox.Text = ini.IniReadValue("Tab_3", "Body_Size"); settingsForm.settings3_2_bcolor_combobox.Text = convertCodeToColor(ini.IniReadValue("Tab_3", "Body_Color")); settingsForm.settings3_3_linespacing_textbox.Text = ini.IniReadValue("Tab_3", "Line_Spacing"); settingsForm.settings3_3_addparagraphspacing_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_3", "Add_Paragraph_Spacing"))); settingsForm.settings4_1_filelocation_textbox.Text = ini.IniReadValue("Tab_4", "Generated_File_Location"); settingsForm.settings4_2_dragclearlist_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_4", "Drag_Clear_List"))); settingsForm.settings4_2_deletetempfiles_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_4", "Delete_Temp_Files"))); settingsForm.settings4_2_pdf_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_4", "PDF"))); settingsForm.settings4_2_savetimemode_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_4", "Save_Time_Mode"))); if (settingsForm.settings4_2_savetimemode_checkbox.Checked) { settingsForm.settings4_2_pdf_checkbox.Checked = false; settingsForm.settings4_2_pdf_checkbox.Enabled = false; settingsForm.settings4_2_pdf_label.Enabled = false; } settingsForm.settings5_1_header_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_5", "Header"))); settingsForm.settings5_1_headersize_textbox.Text = ini.IniReadValue("Tab_5", "Header_Size"); settingsForm.settings5_1_headeralign_combobox.Text = convertNumToHan_Align(ini.IniReadValue("Tab_5", "Header_Align")); settingsForm.settings5_1_headerboder_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_5", "Header_Border"))); if (!settingsForm.settings5_1_header_checkbox.Checked) { settingsForm.settings5_1_headersize_textbox.Enabled = false; settingsForm.settings5_1_headeralign_combobox.Enabled = false; settingsForm.settings5_1_headerboder_checkbox.Enabled = false; } settingsForm.settings5_2_footer_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_5", "Footer"))); settingsForm.settings5_2_footersize_textbox.Text = ini.IniReadValue("Tab_5", "Footer_Size"); settingsForm.settings5_2_footeralign_combobox.Text = convertNumToHan_Align(ini.IniReadValue("Tab_5", "Footer_Align")); settingsForm.settings5_2_footerstyle_combobox.Text = convertNumToHan_Style(ini.IniReadValue("Tab_5", "Footer_Style")); settingsForm.settings5_2_footerboder_checkbox.Checked = Convert.ToBoolean(Convert.ToInt32(ini.IniReadValue("Tab_5", "Footer_Border"))); if (!settingsForm.settings5_2_footer_checkbox.Checked) { settingsForm.settings5_2_footersize_textbox.Enabled = false; settingsForm.settings5_2_footeralign_combobox.Enabled = false; settingsForm.settings5_2_footerstyle_combobox.Enabled = false; settingsForm.settings5_2_footerboder_checkbox.Enabled = false; } }
// flag == 0: restore default; flag == 1: save current public void saveSettings(int flag, Settings settingsForm, String iniPath) { IniFile ini = new IniFile(iniPath); FileInfo iniInfo = new FileInfo(iniPath); if (!File.Exists(iniPath) || !iniInfo.IsReadOnly) { if (flag == 0) writeDefaultSettings(ini); else writeCurSettings(settingsForm, ini); loadCurSettings(settingsForm, ini); this.Close(); } else { MessageBox.Show("写入设置文件出错,可能是设置文件被设为只读。\n请取消其只读状态或删除设置文件,并点击“确认”键重试!"); } }
private void menu2_settings_Click(object sender, EventArgs e) { //Settings settingsForm = new Settings(); settingsForm = new Settings(); settingsForm.ShowDialog(); }