예제 #1
0
 private void HandleProcessChange(ProcessDetails process, bool remove)
 {
     if (process == null)
     {
         return;
     }
     if (remove)
     {
         this.PerformSafely(() => lstProcesses.Items.Remove(process));
     }
     else
     {
         this.PerformSafely(() => lstProcesses.Items.Add(process));
     }
     this.PerformSafely(() => statusLabel.Text = $@"{LanguageManager.Data("moreOptionsLabel")} {DateTime.Now}");
 }
예제 #2
0
        /// <summary>
        ///     Sets up the form
        /// </summary>
        private void MainWindow_Load(object sender, EventArgs e)
        {
            // set the title
            Text = "Borderless Gaming " + Assembly.GetExecutingAssembly().GetName().Version.ToString(3) + ((Uac.Elevated) ? " [Administrator]" : "");

            var settings = Config.Instance.AppSettings;

            // load up settings
            toolStripRunOnStartup.Checked           = settings.RunOnStartup;
            toolStripGlobalHotkey.Checked           = settings.UseGlobalHotkey;
            toolStripCheckForUpdates.Checked        = settings.CheckForUpdates;
            toolStripMouseLock.Checked              = settings.UseMouseLockHotkey;
            toolStripMouseHide.Checked              = settings.UseMouseHideHotkey;
            toolStripMinimizedToTray.Checked        = settings.StartMinimized;
            toolStripHideBalloonTips.Checked        = settings.HideBalloonTips;
            toolStripCloseToTray.Checked            = settings.CloseToTray;
            toolStripViewFullProcessDetails.Checked = settings.ViewAllProcessDetails;
            toolStripSlowWindowDetection.Checked    = settings.SlowWindowDetection;

            // minimize the window if desired (hiding done in Shown)
            if (settings.StartMinimized || Config.Instance.StartupOptions.Minimize)
            {
                WindowState = FormWindowState.Minimized;
            }
            else
            {
                WindowState = FormWindowState.Normal;
            }

            if (SteamApi.IsLoaded && _toolStripDisableSteamIntegration == null)
            {
                _toolStripDisableSteamIntegration =
                    new ToolStripMenuItem
                {
                    Name         = "toolStripDisableSteamIntegration",
                    Size         = new Size(254, 22),
                    Text         = LanguageManager.Data("toolStripDisableSteamIntegration"),
                    ToolTipText  = LanguageManager.Data("steamHint"),
                    Checked      = settings.DisableSteamIntegration,
                    CheckOnClick = true
                };
                // let's do this before registering the CheckedChanged event
                _toolStripDisableSteamIntegration.CheckedChanged +=
                    ToolStripDisableSteamIntegrationCheckChanged;
                toolsToolStripMenuItem.DropDownItems.Insert(0, _toolStripDisableSteamIntegration);
            }
        }
예제 #3
0
        private void setWindowTitleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstProcesses.SelectedItem == null)
            {
                return;
            }

            var pd = (ProcessDetails)lstProcesses.SelectedItem;

            if (!pd.Manageable)
            {
                return;
            }

            Native.SetWindowText(pd.WindowHandle,
                                 InputText(LanguageManager.Data("setWindowTitleTitle"), LanguageManager.Data("setWindowTitlePrompt"),
                                           Native.GetWindowTitle(pd.WindowHandle)));
        }
예제 #4
0
        /// <summary>
        ///     Sets up the Favorite-ContextMenu according to the current state
        /// </summary>
        private void mnuFavoritesContext_Opening(object sender, CancelEventArgs e)
        {
            if (lstFavorites.SelectedItem == null)
            {
                e.Cancel = true;
                return;
            }

            var fav = (Favorite)lstFavorites.SelectedItem;

            toolStripFullScreen.Checked = fav.Size == FavoriteSize.FullScreen;

            toolStripMuteInBackground.Checked   = fav.MuteInBackground;
            toolStripAutomaximize.Checked       = fav.ShouldMaximize;
            toolStripAlwaysOnTop.Checked        = fav.TopMost;
            toolStripHideMouseCursor.Checked    = fav.HideMouseCursor;
            toolStripHideWindowsTaskbar.Checked = fav.HideWindowsTaskbar;
            toolStripRemoveMenus.Checked        = fav.RemoveMenus;

            toolStripAutomaximize.Enabled       = fav.Size == FavoriteSize.FullScreen;
            toolStripAdjustWindowBounds.Enabled = fav.Size == FavoriteSize.FullScreen && !fav.ShouldMaximize;
            toolStripSetSetWindowSize.Enabled   = fav.Size != FavoriteSize.FullScreen;
            toolStripSetSetWindowSize.Checked   = fav.Size == FavoriteSize.SpecificSize;
            toolStripNoSizeChange.Checked       = fav.Size == FavoriteSize.NoChange;

            if (Screen.AllScreens.Length < 2)
            {
                contextFavScreen.Visible = false;
            }
            else
            {
                contextFavScreen.Visible = true;

                if (contextFavScreen.HasDropDownItems)
                {
                    contextFavScreen.DropDownItems.Clear();
                }

                var superSize = Screen.PrimaryScreen.Bounds;

                foreach (var screen in Screen.AllScreens)
                {
                    superSize = Tools.GetContainingRectangle(superSize, screen.Bounds);

                    // fix for a .net-bug on Windows XP
                    var idx             = screen.DeviceName.IndexOf('\0');
                    var fixedDeviceName = idx > 0 ? screen.DeviceName.Substring(0, idx) : screen.DeviceName;

                    var label = fixedDeviceName + (screen.Primary ? " (P)" : string.Empty);
                    var index = contextFavScreen.DropDownItems.Add(new ToolStripMenuItem
                    {
                        Text         = label,
                        CheckOnClick = true,
                        Checked      = fav.FavScreen?.Equals(PRectangle.ToPRectangle(screen.Bounds)) ?? false
                    });
                    contextFavScreen.DropDownItems[index].Click += (s, ea) =>
                    {
                        var tt = (ToolStripMenuItem)s;
                        fav.FavScreen = tt.Checked ? PRectangle.ToPRectangle(screen.Bounds) : new PRectangle();
                        Config.Save();
                    };
                }
                // add supersize Option
                var superIndex = contextFavScreen.DropDownItems.Add(new ToolStripMenuItem
                {
                    Text         = LanguageManager.Data("superSize"),
                    CheckOnClick = true,
                    Checked      = fav.FavScreen?.Equals(PRectangle.ToPRectangle(superSize)) ?? false
                });
                contextFavScreen.DropDownItems[superIndex].Click += (s, ea) =>
                {
                    fav.FavScreen = PRectangle.ToPRectangle(superSize);
                    Config.Save();
                };
            }
        }
예제 #5
0
        private void setWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var fav = (Favorite)lstFavorites.SelectedItem;


            var result =
                MessageBox.Show(
                    LanguageManager.Data("setWindowSizeMousePrompt"),
                    LanguageManager.Data("setWindowSizeMouseTitle"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            if (result == DialogResult.Yes)
            {
                using (var frmSelectArea = new DesktopAreaSelector())
                {
                    if (frmSelectArea.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    // Temporarily disable compiler warning CS1690: http://msdn.microsoft.com/en-us/library/x524dkh4.aspx
                    //
                    // We know what we're doing: everything is safe here.
#pragma warning disable 1690
                    fav.PositionX = frmSelectArea.CurrentTopLeft.X;
                    fav.PositionY = frmSelectArea.CurrentTopLeft.Y;
                    fav.PositionW = frmSelectArea.CurrentBottomRight.X - frmSelectArea.CurrentTopLeft.X;
                    fav.PositionH = frmSelectArea.CurrentBottomRight.Y - frmSelectArea.CurrentTopLeft.Y;
#pragma warning restore 1690
                }
            }
            else // System.Windows.Forms.DialogResult.No
            {
                int.TryParse(
                    InputText(LanguageManager.Data("setWindowSizeTitle"), string.Format(LanguageManager.Data("setWindowSizePixelPrompt"), "X"),
                              fav.PositionX.ToString()), out int favPositionX);
                int.TryParse(
                    InputText(LanguageManager.Data("setWindowSizeTitle"), string.Format(LanguageManager.Data("setWindowSizePixelPrompt"), "Y"),
                              fav.PositionY.ToString()), out int favPositionY);
                int.TryParse(InputText(LanguageManager.Data("setWindowSizeTitle"), LanguageManager.Data("setWindowSizeWidthPrompt"), fav.PositionW.ToString()),
                             out int favPositionW);
                int.TryParse(
                    InputText(LanguageManager.Data("setWindowSizeTitle"), LanguageManager.Data("setWindowSizeHeightPrompt"), fav.PositionH.ToString()),
                    out int favPositionH);
                fav.PositionX = favPositionX;
                fav.PositionH = favPositionH;
                fav.PositionW = favPositionW;
                fav.PositionY = favPositionY;
            }

            Config.Instance.RemoveFavorite(fav, () =>
            {
                lstFavorites.Items.Remove(fav);
            });

            if (fav.PositionW == 0 || fav.PositionH == 0)
            {
                fav.Size = FavoriteSize.FullScreen;
            }
            else
            {
                fav.Size           = FavoriteSize.SpecificSize;
                fav.ShouldMaximize = false;
            }
            RefreshFavoritesList(fav);
        }
예제 #6
0
        private void adjustWindowBoundsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var fav = (Favorite)lstFavorites.SelectedItem;

            Config.Instance.RemoveFavorite(fav, () =>
            {
                lstFavorites.Items.Remove(fav);
            });
            int.TryParse(
                InputText(LanguageManager.Data("adjustWindowBoundsTitle"),
                          string.Format(LanguageManager.Data("adjustWindowBoundsPrompt"), LanguageManager.Data("adjustWindowBoundsLeft")), fav.OffsetL.ToString()),
                out int favOffsetL);
            int.TryParse(
                InputText(LanguageManager.Data("adjustWindowBoundsTitle"),
                          string.Format(LanguageManager.Data("adjustWindowBoundsPrompt"), LanguageManager.Data("adjustWindowBoundsRight")), fav.OffsetR.ToString()),
                out int favOffsetR);
            int.TryParse(
                InputText(LanguageManager.Data("adjustWindowBoundsTitle"),
                          string.Format(LanguageManager.Data("adjustWindowBoundsPrompt"), LanguageManager.Data("adjustWindowBoundsTop")), fav.OffsetT.ToString()),
                out int favOffsetT);
            int.TryParse(
                InputText(LanguageManager.Data("adjustWindowBoundsTitle"),
                          string.Format(LanguageManager.Data("adjustWindowBoundsPrompt"), LanguageManager.Data("adjustWindowBoundsBottom")), fav.OffsetB.ToString()),
                out int favOffsetB);

            fav.OffsetL = favOffsetL;
            fav.OffsetR = favOffsetR;
            fav.OffsetT = favOffsetT;
            fav.OffsetB = favOffsetB;

            RefreshFavoritesList(fav);
        }
예제 #7
0
        private void btnRestoreWindow_MouseHover(object sender, EventArgs e)
        {
            var ttTemp = new ToolTip();

            ttTemp.SetToolTip((Control)sender, LanguageManager.Data("restoreBorders"));
        }
예제 #8
0
        private void btnMakeBorderless_MouseHover(object sender, EventArgs e)
        {
            var ttTemp = new ToolTip();

            ttTemp.SetToolTip((Control)sender, LanguageManager.Data("makeBorderless"));
        }
예제 #9
0
        private void btnRemoveFavorite_MouseHover(object sender, EventArgs e)
        {
            var ttTemp = new ToolTip();

            ttTemp.SetToolTip((Control)sender, LanguageManager.Data("removeFavorite"));
        }
예제 #10
0
        private void addSelectedItem_MouseHover(object sender, EventArgs e)
        {
            var ttTemp = new ToolTip();

            ttTemp.SetToolTip((Control)sender, LanguageManager.Data("addFavorite"));
        }