//保存设置 public void SaveSetting() { CheckBox[] m_aCheckBoxTop = { cb1Top, cb2Top, cb3Top, cb3Top }; CheckBox[] m_aCheckBoxView = { cb1View, cb2View, cb3View, cb3View }; string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", ""); string striniFile = System.IO.Path.Combine(path, "_setting.ini"); for (int i = 0; i < 4; i++) { IniIO.IniWriteValue(i.ToString(), "cb_view", m_aCheckBoxView[i].Checked.ToString(), striniFile); IniIO.IniWriteValue(i.ToString(), "cb_top", m_aCheckBoxTop[i].Checked.ToString(), striniFile); IniIO.IniWriteValue(i.ToString(), "left", m_aRect[i].left.ToString(), striniFile); IniIO.IniWriteValue(i.ToString(), "top", m_aRect[i].top.ToString(), striniFile); IniIO.IniWriteValue(i.ToString(), "width", m_aRect[i].right.ToString(), striniFile); IniIO.IniWriteValue(i.ToString(), "height", m_aRect[i].bottom.ToString(), striniFile); IniIO.IniWriteValue(i.ToString(), "filepath", aFileNames[i], striniFile); } IniIO.IniWriteValue("other", "savepos", aFileNames[4], striniFile); //兼容旧版本 IniIO.IniWriteValue("client", "filepath", aFileNames[3], striniFile); IniIO.IniWriteValue("other", "left", this.Left.ToString(), striniFile); IniIO.IniWriteValue("other", "top", this.Top.ToString(), striniFile); }
private void ReadSetting() { CheckBox[] m_aCheckBoxTop = { cb1Top, cb2Top, cb3Top, cb3Top }; CheckBox[] m_aCheckBoxView = { cb1View, cb2View, cb3View, cb3View }; string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", ""); string striniFile = System.IO.Path.Combine(path, "_setting.ini"); try { for (int i = 0; i < 4; i++) { m_aCheckBoxView[i].Checked = Convert.ToBoolean(IniIO.IniReadValue(i.ToString(), "cb_view", striniFile)); m_aCheckBoxTop[i].Checked = Convert.ToBoolean(IniIO.IniReadValue(i.ToString(), "cb_top", striniFile)); m_aRect[i].left = Int32.Parse(IniIO.IniReadValue(i.ToString(), "left", striniFile)); m_aRect[i].top = Int32.Parse(IniIO.IniReadValue(i.ToString(), "top", striniFile)); m_aRect[i].right = Int32.Parse(IniIO.IniReadValue(i.ToString(), "width", striniFile)); m_aRect[i].bottom = Int32.Parse(IniIO.IniReadValue(i.ToString(), "height", striniFile)); aFileNames[i] = IniIO.IniReadValue(i.ToString(), "filepath", striniFile); //if (m_aRect[i].left < 0) m_aRect[i].left = 0; //if (m_aRect[i].top < 0) m_aRect[i].top = 0; } aFileNames[4] = IniIO.IniReadValue("other", "savepos", striniFile); //兼容旧版本 if (aFileNames[3] == "") { aFileNames[3] = IniIO.IniReadValue("client", "filepath", striniFile); } this.Left = Int32.Parse(IniIO.IniReadValue("other", "left", striniFile)); this.Top = Int32.Parse(IniIO.IniReadValue("other", "top", striniFile)); } catch (Exception ex) { //读不到就算了吧 } }