コード例 #1
0
 private void btnCheckVersion_Click(object sender, EventArgs e)
 {
     if (!GitHubUpdate.QueryAllReleases())
     {
         MessageBox.Show("An error occurred during update check!", "Check for update failed!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (GitHubUpdate.NewVersionDialog(this) == DialogResult.Yes)
     {
         GitHubUpdate.WebOpenLatestRelease();
     }
 }
コード例 #2
0
 private void btnGoToDownloadPage_Click(object sender, EventArgs e)
 {
     GitHubUpdate.WebOpenLatestRelease();
 }
コード例 #3
0
 private void CheckForUpdates(object sender, EventArgs e)
 {
     GitHubUpdate.QueryAllReleases();
     lblVersionLatest.Text = GitHubUpdate.GetLatestVersionName();
     txtChangelog.Text     = GitHubUpdate.GetChangelog();
 }
コード例 #4
0
        /// <summary>
        /// Loads user data from XML
        /// </summary>
        private void LoadSettings()
        {
            int  baseVersion  = -1;
            bool isKeyInvalid = false;

            sm        = new SaveModule <SettingsRoot>(Application.ProductName + "Save.xml");
            _settings = sm.ReadXML(true);

            if (null == _settings)
            {
                // When no user save file is available, try loading the init file instead to provide predefined profiles and settings
                _settings = sm.ReadXML(false, Application.ProductName + "Init.xml");
            }
            if (null != _settings)
            {
                baseVersion = _settings.Version; // successfully loaded Save or Init file, so remember original version for upgrade
            }
            else
            {
                _settings = new SettingsRoot();

                // prepare defaults..
                _settings.Version              = 0;
                _settings.MainWidth            = 559;
                _settings.MainHeight           = 723;
                _settings.HotKeyMethod         = (int)Shortcuts.SC_HotKeyMethod.SC_HotKeyMethod_Async;
                _settings.ShortcutResetEnable  = false;
                _settings.ShortcutResetKeyCode = 0x10000 | 0x75; // Shift F6
                _settings.ShortcutHitEnable    = false;
                _settings.ShortcutHitKeyCode   = 0x10000 | 0x76; // Shift F7
                _settings.ShortcutSplitEnable  = false;
                _settings.ShortcutSplitKeyCode = 0x10000 | 0x77; // Shift F8
                _settings.Inputfile            = "HitCounter.template";
                _settings.OutputFile           = "HitCounter.html";
                _settings.ProfileSelected      = "Unnamed";
            }
            if (_settings.Version == 0) // Coming from version 1.9 or older
            {
                _settings.Version                 = 1;
                _settings.ShowAttemptsCounter     = true;
                _settings.ShowHeadline            = true;
                _settings.ShowSplitsCountFinished = 999;
                _settings.ShowSplitsCountUpcoming = 999;
                _settings.StyleUseHighContrast    = false;
                _settings.StyleUseCustom          = false;
                _settings.StyleCssUrl             = "stylesheet_pink.css";
                _settings.StyleFontUrl            = "https://fonts.googleapis.com/css?family=Fontdiner%20Swanky";
            }
            if (_settings.Version == 1) // Coming from version 1.10
            {
                _settings.Version             = 2;
                _settings.MainWidth          += 31; // added "SP" checkbox to datagrid
                _settings.ShowSessionProgress = true;
                _settings.StyleDesiredWidth   = 0;
            }
            if (_settings.Version == 2) // Coming from version 1.11 - 1.14
            {
                _settings.Version = 3;
                _settings.ShortcutHitUndoEnable    = false;
                _settings.ShortcutHitUndoKeyCode   = 0x10000 | 0x78; // Shift F9
                _settings.ShortcutSplitPrevEnable  = false;
                _settings.ShortcutSplitPrevKeyCode = 0x10000 | 0x79; // Shift F10
            }
            if (_settings.Version == 3)                              // Coming from version 1.15
            {
                _settings.Version       = 4;
                _settings.StyleFontName = "Fontdiner Swanky";
            }
            if (_settings.Version == 4) // Coming from version 1.16
            {
                _settings.Version                   = 5;
                _settings.MainWidth                += 50;             // added "WayHits" textbox to datagrid (50)
                _settings.MainHeight               += 13 + 70;        // added second line to datagrid column header(13) and "Succession" group box
                _settings.ShortcutWayHitEnable      = false;
                _settings.ShortcutWayHitKeyCode     = 0x10000 | 0x74; // Shift F5
                _settings.ShortcutWayHitUndoEnable  = false;
                _settings.ShortcutWayHitUndoKeyCode = 0x10000 | 0x7A; // Shift F11
                _settings.ShortcutPBEnable          = false;
                _settings.ShortcutPBKeyCode         = 0x10000 | 0x73; // Shift F4
                _settings.ShowFooter                = true;
                _settings.ShowHitsCombined          = true;
                _settings.ShowNumbers               = true;
                _settings.ShowPB   = true;
                _settings.Purpose  = (int)OutModule.OM_Purpose.OM_Purpose_SplitCounter;
                _settings.Severity = (int)OutModule.OM_Severity.OM_Severity_AnyHitsCritical;
                _settings.StyleUseHighContrastNames = false;
                _settings.SuccessionTitle           = "Predecessors";
                _settings.SuccessionHits            = 0;
                _settings.SuccessionHitsWay         = 0;
                _settings.SuccessionHitsPB          = 0;

                if (baseVersion < 0)
                {
                    // Use different hot keys when loaded without any previous settings
                    // (we don't have to take care of previous user/default settings)
                    _settings.ShortcutHitKeyCode        = 0x10000 | 0x70; // Shift F1
                    _settings.ShortcutWayHitKeyCode     = 0x10000 | 0x71; // Shift F2
                    _settings.ShortcutSplitKeyCode      = 0x10000 | 0x72; // Shift F3
                    _settings.ShortcutPBKeyCode         = 0x10000 | 0x73; // Shift F4
                    _settings.ShortcutHitUndoKeyCode    = 0x10000 | 0x74; // Shift F5
                    _settings.ShortcutWayHitUndoKeyCode = 0x10000 | 0x75; // Shift F6
                    _settings.ShortcutSplitPrevKeyCode  = 0x10000 | 0x76; // Shift F7
                    _settings.ShortcutResetKeyCode      = 0x10000 | 0x77; // Shift F8
                }
            }
            if (_settings.Version == 5) // Coming from version 1.17
            {
                _settings.Version     = 6;
                _settings.MainHeight -= 59; // "Succession" group box starts collapsed
                _settings.AlwaysOnTop = false;

                // Only enable progress bar when new settings were created
                _settings.ShowProgressBar = (baseVersion < 0 ? true : false);
                // Introduced with true in version 5, keep user setting when this version was used
                _settings.StyleProgressBarColored = (baseVersion == 5 ? true : false);
            }
            if (_settings.Version == 6) // Coming from version 1.18
            {
                _settings.Version       = 7;
                _settings.MainWidth    += 6;  // added tabs (6)
                _settings.MainHeight   += 27; // added tabs (27)
                _settings.MainPosX      = this.Left;
                _settings.MainPosY      = this.Top;
                _settings.ReadOnlyMode  = false;
                _settings.StyleUseRoman = false;
                _settings.StyleHightlightCurrentSplit = false;
                // Only enable progress bar integration of succession when new settings were created
                _settings.Succession.IntegrateIntoProgressBar = (baseVersion < 0 ? true : false);
                // Create succession with only one entry (there was only one available in older versions)
                SuccessionEntry suc_entry = new SuccessionEntry();
                suc_entry.ProfileSelected = _settings.ProfileSelected;
                _settings.Succession.SuccessionList.Add(suc_entry);
                // Introduced with false in version 6, keep user setting when this version was used
                _settings.StyleProgressBarColored = (baseVersion == 6 ? false : true);
            }
            if (_settings.Version == 7) // Coming from version 1.19
            {
                _settings.Version = 8;
                _settings.CheckUpdatesOnStartup = false;
                _settings.DarkMode = OsLayer.IsDarkModeActive();
                // Only use latest hot key method as default when new settings were created
                if (baseVersion < 0)
                {
                    _settings.HotKeyMethod = (int)Shortcuts.SC_HotKeyMethod.SC_HotKeyMethod_LLKb;
                }
                // Only enable time column when new settings were created
                _settings.ShowTimeCurrent           = (baseVersion < 0 ? true : false);
                _settings.ShowHits                  = true;
                _settings.ShowDiff                  = _settings.ShowPB; // was combined in previous versions
                _settings.ShowTimePB                = false;
                _settings.ShowTimeDiff              = false;
                _settings.ShowTimeFooter            = false;
                _settings.ShortcutTimerStartEnable  = false;
                _settings.ShortcutTimerStartKeyCode = 0x10000 | 0x6B; // Shift Add-Num
                _settings.ShortcutTimerStopEnable   = false;
                _settings.ShortcutTimerStopKeyCode  = 0x10000 | 0x6D; // Shift Subtract-Num
            }

            // Check for updates..
            if (_settings.CheckUpdatesOnStartup)
            {
                if (GitHubUpdate.QueryAllReleases())
                {
                    if (GitHubUpdate.GetLatestVersionName() != Application.ProductVersion.ToString())
                    {
                        if (GitHubUpdate.NewVersionDialog(this) == DialogResult.Yes)
                        {
                            GitHubUpdate.WebOpenLatestRelease();
                        }
                    }
                }
            }

            // Apply settings..

            // Setup window appearance..
            if (_settings.MainWidth < this.MinimumSize.Width)
            {
                _settings.MainWidth = this.MinimumSize.Width;
            }
            if (_settings.MainHeight < this.MinimumSize.Height)
            {
                _settings.MainHeight = this.MinimumSize.Height;
            }
            // set window size and when possible also set location (just make sure window is not outside of screen)
            this.SetBounds(_settings.MainPosX, _settings.MainPosY, _settings.MainWidth, _settings.MainHeight,
                           Program.IsOnScreen(_settings.MainPosX, _settings.MainPosY, _settings.MainWidth) ? BoundsSpecified.All : BoundsSpecified.Size);
            SetReadOnlyMode(_settings.ReadOnlyMode);
            SetAlwaysOnTop(_settings.AlwaysOnTop);
            Program.DarkMode = _settings.DarkMode;

            // Load profile data..
            if (_settings.Profiles.ProfileList.Count == 0)
            {
                // There is no profile at all, initially create a clean one
                Profile unnamed = new Profile();
                unnamed.Name = "Unnamed";
                _settings.Profiles.ProfileList.Add(unnamed);
            }
            if (_settings.Succession.SuccessionList.Count == 0)
            {
                // There is no succession at all create an empty succession
                SuccessionEntry first = new SuccessionEntry();
                first.ProfileSelected = _settings.Profiles.ProfileList[0].Name;
                _settings.Succession.SuccessionList.Add(first);
            }
            if (_settings.Succession.SuccessionList.Count <= _settings.Succession.ActiveIndex)
            {
                _settings.Succession.ActiveIndex = 0;
            }
            profCtrl.InitializeProfilesControl(_settings.Profiles, _settings.Succession);
            profCtrl.om.Settings = _settings;
            profCtrl.om.Update(); // Write first output once after application start

            // Configure hot keys..
            sc.Initialize((Shortcuts.SC_HotKeyMethod)_settings.HotKeyMethod);

            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_Reset, _settings.ShortcutResetKeyCode, _settings.ShortcutResetEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_Hit, _settings.ShortcutHitKeyCode, _settings.ShortcutHitEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_HitUndo, _settings.ShortcutHitUndoKeyCode, _settings.ShortcutHitUndoEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_WayHit, _settings.ShortcutWayHitKeyCode, _settings.ShortcutWayHitEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_WayHitUndo, _settings.ShortcutWayHitUndoKeyCode, _settings.ShortcutWayHitUndoEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_Split, _settings.ShortcutSplitKeyCode, _settings.ShortcutSplitEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_SplitPrev, _settings.ShortcutSplitPrevKeyCode, _settings.ShortcutSplitPrevEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_PB, _settings.ShortcutPBKeyCode, _settings.ShortcutPBEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_TimerStart, _settings.ShortcutTimerStartKeyCode, _settings.ShortcutTimerStartEnable))
            {
                isKeyInvalid = true;
            }
            if (!LoadHotKeySettings(Shortcuts.SC_Type.SC_Type_TimerStop, _settings.ShortcutTimerStopKeyCode, _settings.ShortcutTimerStopEnable))
            {
                isKeyInvalid = true;
            }
            if (isKeyInvalid)
            {
                MessageBox.Show("Not all enabled hot keys could be registered successfully!", "Error setting up hot keys!");
            }
        }
コード例 #5
0
 private void btnWeb_Click(object sender, EventArgs e)
 {
     GitHubUpdate.WebOpenLandingPage();
 }