예제 #1
0
        private void settingsToolStripBtn_Click(object sender, EventArgs e)
        {
            try
            {
                Settings settings = Settings.Instance;

                SettingsFrm frm = new SettingsFrm()
                {
                    SecurityKey                = settings.securitykey,
                    DataFilePath               = settings.datafilepath,
                    FirstWeek                  = settings.firstweek,
                    RotaRange                  = settings.rotarange,
                    WeeksInRotaPeriod          = settings.rotaweekcount,
                    DisplayCallsWithTravelTime = settings.displaycallwithtraveltime
                };


                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Cursor = Cursors.WaitCursor;

                    Loading.Instance.Start();

                    if (settings.datafilepath != frm.DataFilePath ||
                        settings.firstweek != frm.FirstWeek ||
                        settings.rotaweekcount != frm.WeeksInRotaPeriod)
                    {
                        if (CallManager.Instance.Calls.Where(c => c.HasChanges).Count() > 0)
                        {
                            MessageBox.Show("These changes can't be saved until all pending changes have been dealt with.", "Changes Pending", MessageBoxButtons.OK);
                            return;
                        }
                    }

                    settings.ChangeSettings(frm.SecurityKey,
                                            frm.DataFilePath,
                                            frm.FirstWeek,
                                            frm.RotaRange,
                                            frm.WeeksInRotaPeriod,
                                            frm.DisplayCallsWithTravelTime);

                    try
                    {
                        settings.Save();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to save settings");
                    }
                }
            }
            catch (Exception ex)
            {
                Cura.Common.Common.LogError("Failed to Load Cura Settings", ex);
            }

            Loading.Instance.Stop();

            Cursor = Cursors.Default;
        }
예제 #2
0
        private void RepoSettingsMenuItem_Click(object sender, EventArgs e)
        {
            var settingsFrm = new SettingsFrm();

            settingsFrm.ShowDialog(this);
            // 关闭设置后,尝试执行一次Prepare仓库
            Task.Run(() =>
            {
                this.PrepareRepo();
            });
        }
예제 #3
0
        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (TopMost)
            {
                TopMost = false;
            }

            SettingsFrm settingsFrm = new SettingsFrm();

            settingsFrm.ShowDialog();

            //Triggers once settingsFrm is closed and if user clicked 'Save' during runtime
            if (settingsFrm.clickedSave)
            {
                loadSettings();
            }
        }
예제 #4
0
        /// <summary>
        /// Perform the initial settings check
        /// </summary>
        /// <returns></returns>
        private bool PerformSettingsCheck()
        {
            Settings settings = Settings.Instance;

            if (!settings.IsValid)
            {
                SettingsFrm frm = new SettingsFrm();

                frm.DataFilePath               = settings.datafilepath;
                frm.SecurityKey                = settings.securitykey;
                frm.FirstWeek                  = settings.firstweek;
                frm.RotaRange                  = settings.rotarange;
                frm.WeeksInRotaPeriod          = settings.rotaweekcount;
                frm.DisplayCallsWithTravelTime = settings.displaycallwithtraveltime;

                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    //save the settings
                    settings.datafilepath              = frm.DataFilePath;
                    settings.securitykey               = frm.SecurityKey;
                    settings.firstweek                 = frm.FirstWeek;
                    settings.rotarange                 = frm.RotaRange;
                    settings.rotaweekcount             = frm.WeeksInRotaPeriod;
                    settings.displaycallwithtraveltime = frm.DisplayCallsWithTravelTime;

                    try
                    {
                        settings.Save();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to save settings");
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }


            return(true);
        }
예제 #5
0
        private void MainFrm_Load(object sender, EventArgs e)
        {
            var mainFrm = this;

            if (!this.gasBiz.HasGameArchiveStorageRepo())
            {
                this.DelayDo(() =>
                {
                    var settingsFrm = new SettingsFrm();
                    settingsFrm.ShowDialog(mainFrm);
                });
            }
            else
            {
                Task.Run(() =>
                {
                    this.PrepareRepo();
                });
            }
        }