コード例 #1
0
ファイル: MainForm.cs プロジェクト: ilegendC/FuwanViewer
        public MainForm()
        {
            InitializeComponent();

            try
            {
                var parser = new IniParser("settings.ini");
                if (int.Parse(parser.GetSetting("window", "WindowState")) == 1)
                    WindowState = FormWindowState.Maximized;
                Size = new Size(int.Parse(parser.GetSetting("window", "WindowWidth")), int.Parse(parser.GetSetting("window", "WindowHeight")));

                settings["WINDOWSTATE"] = int.Parse(parser.GetSetting("window", "WindowState"));
                settings["WINDOWHEIGHT"] = int.Parse(parser.GetSetting("window", "WindowHeight"));
                settings["WINDOWWIDTH"] = int.Parse(parser.GetSetting("window", "WindowWidth"));
            }
            catch
            {
                File.WriteAllText("settings.ini", "[WINDOW]\r\nWINDOWSTATE=0\r\nWINDOWHEIGHT=320\r\nWINDOWWIDTH=620");
                settings["WINDOWSTATE"] = 0;
                settings["WINDOWHEIGHT"] = 320;
                settings["WINDOWWIDTH"] = 620;
            }

            Text = String.Format("FuwanViewer by ilegend (Last Updated: {0})", Resources.FUWANVIEWER_LAST_UPDATED_DATE);
            genreComboBox.SelectedIndex = upcomingComboBox.SelectedIndex = 0;

            using (var bgWorker = new BackgroundWorker { WorkerReportsProgress = true })
            {
                bgWorker.DoWork += BgWorkerDoWork;
                bgWorker.ProgressChanged += BgWorkerProgressChanged;
                bgWorker.RunWorkerCompleted += BgWorkerRunWorkerCompleted;
                bgWorker.RunWorkerAsync();
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: ilegendC/FuwanViewer
        private void MainFormFormClosing(object sender, FormClosingEventArgs e)
        {
            int windowState = WindowState == FormWindowState.Maximized ? 1 : 0;
            int windowHeight = Size.Height;
            int windowWidth = Size.Width;

            if (settings["WINDOWSTATE"] == windowState && windowState == 1)
                return;

            if (settings["WINDOWSTATE"] == windowState && windowState == 0 &&
                settings["WINDOWHEIGHT"] == windowHeight && settings["WINDOWWIDTH"] == windowWidth)
                    return;

            var parser = new IniParser("settings.ini");
            if (WindowState == FormWindowState.Maximized)
            {
                parser.AddSetting("window", "WindowState", "1");
                parser.AddSetting("window", "WindowHeight", settings["WINDOWHEIGHT"].ToString());
                parser.AddSetting("window", "WindowWidth", settings["WINDOWWIDTH"].ToString());
            }
            else
            {
                parser.AddSetting("window", "WindowState", "0");
                parser.AddSetting("window", "WindowHeight", Convert.ToString(Size.Height));
                parser.AddSetting("window", "WindowWidth", Convert.ToString(Size.Width));
            }
            parser.SaveSettings();
        }