Beispiel #1
0
        /// <summary>
        /// 从配置文件中恢复窗体和控件状态
        /// </summary>
        public void RecoveryConfiguration()
        {
            FrmReadConfig config = FormConfigManager.GetFrmReadConfig(book);

            if (config != null)
            {
                listBox1.Font      = new Font(new FontFamily(config.ListBoxFontFamilyName), config.ListBoxFontSize);
                listBox1.ForeColor = config.ListBoxForeColor;
                listBox1.BackColor = config.ListBoxBackColor;
                textBox1.Font      = new Font(new FontFamily(config.TextBoxFamilyName), config.TextBoxFontSize);
                textBox1.ForeColor = config.TextBoxForeColor;
                textBox1.BackColor = config.TextBoxBackColor;
                WindowState        = config.FormWindowState;
                Left   = config.FormLeft;
                Top    = config.FormTop;
                Width  = config.FormWidth;
                Height = config.FormHeight;

                listBox1.SelectedIndex = config.ReadIndex;
                listBox1_MouseDoubleClick(null, null);
            }
        }
Beispiel #2
0
        private void FrmRead_FormClosed(object sender, FormClosedEventArgs e)
        {
            //保存窗体和控件状态
            FrmReadConfig config = new FrmReadConfig();

            config.ReadIndex             = CurrentIndex;
            config.ListBoxFontFamilyName = listBox1.Font.Name;
            config.ListBoxFontSize       = listBox1.Font.Size;
            config.ListBoxForeColor      = listBox1.ForeColor;
            config.ListBoxBackColor      = listBox1.BackColor;
            config.TextBoxFamilyName     = textBox1.Font.Name;
            config.TextBoxFontSize       = textBox1.Font.Size;
            config.TextBoxForeColor      = textBox1.ForeColor;
            config.TextBoxBackColor      = textBox1.BackColor;
            config.FormWindowState       = WindowState;
            config.FormLeft   = Left;
            config.FormTop    = Top;
            config.FormWidth  = Width;
            config.FormHeight = Height;

            FormConfigManager.SetFrmReadConfigConfig(config, book);
        }
Beispiel #3
0
        public static void SetFrmReadConfigConfig(FrmReadConfig config, BookInfo book)
        {
            string json = Kit.ToJson(config, true);

            FileUtils.WriteAllText("data/" + userInfo.UserName + "/config/" + book.Name + "-" + book.Author + "/FrmReadConfig.json", json, Encoding.UTF8);
        }