From 4e498ab5f0fed738ebc0a3e063143746f42b4029 Mon Sep 17 00:00:00 2001 From: secret_online Date: Sun, 2 Aug 2015 15:10:58 +1200 Subject: [PATCH 1/3] Add regex favorite type --- Common/Favorites.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Common/Favorites.cs b/Common/Favorites.cs index 33ffdc7..41dd586 100644 --- a/Common/Favorites.cs +++ b/Common/Favorites.cs @@ -8,6 +8,7 @@ using BorderlessGaming.Utilities; using System.Collections.ObjectModel; using System.Linq; +using System.Text.RegularExpressions; namespace BorderlessGaming.Common { @@ -105,6 +106,7 @@ public enum FavoriteKinds : int { ByBinaryName = 0, ByTitleText = 1, + ByRegexString = 2, } public SizeModes SizeMode = SizeModes.FullScreen; @@ -145,6 +147,8 @@ public override string ToString() // so that the ListView control knows how to d extra_details += " [Process]"; else if (this.Kind != FavoriteKinds.ByTitleText) extra_details += " [?]"; + else if (this.Kind != FavoriteKinds.ByRegexString) + extra_details += " [Regex]"; extra_details += ((this.ShouldMaximize) ? " [Max]" : ""); extra_details += ((this.SizeMode == SizeModes.NoChange) ? " [NoSize]" : ""); @@ -170,8 +174,9 @@ public override string ToString() // so that the ListView control knows how to d public bool Matches(ProcessDetails pd) { - return (((Kind == FavoriteKinds.ByBinaryName) && (pd.BinaryName == SearchText)) || - ((Kind == FavoriteKinds.ByTitleText) && (pd.WindowTitle == SearchText))); + return (((Kind == FavoriteKinds.ByBinaryName) && (pd.BinaryName == SearchText)) || + ((Kind == FavoriteKinds.ByTitleText) && (pd.WindowTitle == SearchText)) || + ((Kind == FavoriteKinds.ByRegexString) && (Regex.IsMatch(pd.WindowTitle, SearchText)))); } } } From b55c00778323994d0b09746baaec9f619ca1f5f4 Mon Sep 17 00:00:00 2001 From: secret_online Date: Sun, 2 Aug 2015 15:40:02 +1200 Subject: [PATCH 2/3] Add ability to add by regex --- Forms/MainWindow.Designer.cs | 19 ++++++++++++++----- Forms/MainWindow.cs | 31 +++++++++++++++++++++++++++++++ Forms/MainWindow.resx | 12 ++++++++++++ 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/Forms/MainWindow.Designer.cs b/Forms/MainWindow.Designer.cs index ba941b1..0d07931 100644 --- a/Forms/MainWindow.Designer.cs +++ b/Forms/MainWindow.Designer.cs @@ -35,7 +35,8 @@ private void InitializeComponent() this.processContext = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextAddToFavs = new System.Windows.Forms.ToolStripMenuItem(); this.byTheWindowTitleTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.byTheProcessBinaryNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.byTheProcessBinaryNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.byTheWindowTitleTextregexToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.contextBorderless = new System.Windows.Forms.ToolStripMenuItem(); this.contextBorderlessOn = new System.Windows.Forms.ToolStripMenuItem(); @@ -144,7 +145,8 @@ private void InitializeComponent() // this.contextAddToFavs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.byTheWindowTitleTextToolStripMenuItem, - this.byTheProcessBinaryNameToolStripMenuItem}); + this.byTheProcessBinaryNameToolStripMenuItem, + this.byTheWindowTitleTextregexToolStripMenuItem}); this.contextAddToFavs.Name = "contextAddToFavs"; resources.ApplyResources(this.contextAddToFavs, "contextAddToFavs"); // @@ -158,7 +160,13 @@ private void InitializeComponent() // this.byTheProcessBinaryNameToolStripMenuItem.Name = "byTheProcessBinaryNameToolStripMenuItem"; resources.ApplyResources(this.byTheProcessBinaryNameToolStripMenuItem, "byTheProcessBinaryNameToolStripMenuItem"); - this.byTheProcessBinaryNameToolStripMenuItem.Click += new System.EventHandler(this.byTheProcessBinaryNameToolStripMenuItem_Click); + this.byTheProcessBinaryNameToolStripMenuItem.Click += new System.EventHandler(this.byTheProcessBinaryNameToolStripMenuItem_Click); + // + // byTheWindowTitleTextregexToolStripMenuItem + // + this.byTheWindowTitleTextregexToolStripMenuItem.Name = "byTheWindowTitleTextregexToolStripMenuItem"; + resources.ApplyResources(this.byTheWindowTitleTextregexToolStripMenuItem, "byTheWindowTitleTextregexToolStripMenuItem"); + this.byTheWindowTitleTextregexToolStripMenuItem.Click += new System.EventHandler(this.byTheWindowTitleTextregexToolStripMenuItem_Click); // // toolStripMenuItem1 // @@ -666,7 +674,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem toolStripGlobalHotkey; private System.Windows.Forms.ToolStripMenuItem toolStripMouseLock; private System.Windows.Forms.ToolStripMenuItem byTheWindowTitleTextToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem byTheProcessBinaryNameToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem byTheProcessBinaryNameToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem byTheWindowTitleTextregexToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; @@ -705,6 +714,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem openDataFolderToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem12; private System.Windows.Forms.ToolStripMenuItem fullApplicationRefreshToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem useSlowerWindowDetectionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem useSlowerWindowDetectionToolStripMenuItem; } } \ No newline at end of file diff --git a/Forms/MainWindow.cs b/Forms/MainWindow.cs index 47083af..aa7658f 100644 --- a/Forms/MainWindow.cs +++ b/Forms/MainWindow.cs @@ -403,6 +403,37 @@ private void byTheProcessBinaryNameToolStripMenuItem_Click(object sender, EventA controller.Favorites.Add(fav); } } + + /// + /// adds the currently selected process to the favorites (by window title text) + /// + private void byTheWindowTitleTextregexToolStripMenuItem_Click(object sender, EventArgs e) + { + if (this.lstProcesses.SelectedItem == null) return; + + ProcessDetails pd = ((ProcessDetails)this.lstProcesses.SelectedItem); + + if (!pd.Manageable) + return; + + //TODO move to controller + if (controller.Favorites.CanAdd(pd.WindowTitle)) + { + InputText it = new InputText(); + it.Text = "Add to favorites by regex string"; + it.Input = pd.WindowTitle; + it.Instructions = "Regex string (reference is in the Help menu)"; + + it.ShowDialog(); + if (it.DialogResult != DialogResult.OK) + return; + + Favorites.Favorite fav = new Favorites.Favorite(); + fav.Kind = Favorites.Favorite.FavoriteKinds.ByTitleText; + fav.SearchText = pd.WindowTitle; + controller.Favorites.Add(fav); + } + } private void addSelectedItem_Click(object sender, EventArgs e) { diff --git a/Forms/MainWindow.resx b/Forms/MainWindow.resx index 2f735c0..0ded790 100644 --- a/Forms/MainWindow.resx +++ b/Forms/MainWindow.resx @@ -195,6 +195,12 @@ ... by the process binary name + + 253, 22 + + + ... by the window title text (regex) + 201, 6 @@ -989,6 +995,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + byTheWindowTitleTextregexToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + toolStripMenuItem1 From b894f4449e0b9fde61465cb50d6151e5603c08dd Mon Sep 17 00:00:00 2001 From: secret_online Date: Sun, 2 Aug 2015 15:48:36 +1200 Subject: [PATCH 3/3] Add regex reference link --- Forms/MainWindow.Designer.cs | 15 ++++++++++++--- Forms/MainWindow.cs | 5 +++++ Forms/MainWindow.resx | 12 ++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Forms/MainWindow.Designer.cs b/Forms/MainWindow.Designer.cs index 0d07931..b43cfec 100644 --- a/Forms/MainWindow.Designer.cs +++ b/Forms/MainWindow.Designer.cs @@ -92,7 +92,8 @@ private void InitializeComponent() this.fullApplicationRefreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripInfo = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripReportBug = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSupportUs = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSupportUs = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripRegexReference = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripAbout = new System.Windows.Forms.ToolStripMenuItem(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); @@ -545,6 +546,7 @@ private void InitializeComponent() this.toolStripInfo.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripReportBug, this.toolStripSupportUs, + this.toolStripRegexReference, this.toolStripMenuItem2, this.toolStripAbout}); this.toolStripInfo.Name = "toolStripInfo"; @@ -560,7 +562,13 @@ private void InitializeComponent() // this.toolStripSupportUs.Name = "toolStripSupportUs"; resources.ApplyResources(this.toolStripSupportUs, "toolStripSupportUs"); - this.toolStripSupportUs.Click += new System.EventHandler(this.toolStripSupportUs_Click); + this.toolStripSupportUs.Click += new System.EventHandler(this.toolStripSupportUs_Click); + // + // toolStripRegexReference + // + this.toolStripRegexReference.Name = "toolStripRegexReference"; + resources.ApplyResources(this.toolStripRegexReference, "toolStripRegexReference"); + this.toolStripRegexReference.Click += new System.EventHandler(this.toolStripRegexReference_Click); // // toolStripMenuItem2 // @@ -661,7 +669,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem toolStripRunOnStartup; private System.Windows.Forms.ToolStripMenuItem toolStripInfo; private System.Windows.Forms.ToolStripMenuItem toolStripReportBug; - private System.Windows.Forms.ToolStripMenuItem toolStripSupportUs; + private System.Windows.Forms.ToolStripMenuItem toolStripSupportUs; + private System.Windows.Forms.ToolStripMenuItem toolStripRegexReference; private System.Windows.Forms.ToolStripMenuItem toolStripAbout; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; diff --git a/Forms/MainWindow.cs b/Forms/MainWindow.cs index aa7658f..ff892bc 100644 --- a/Forms/MainWindow.cs +++ b/Forms/MainWindow.cs @@ -274,6 +274,11 @@ private void toolStripSupportUs_Click(object sender, EventArgs e) Tools.GotoSite("http://store.steampowered.com/app/388080"); } + private void toolStripRegexReference_Click(object sender, EventArgs e) + { + Tools.GotoSite("http://store.steampowered.com/app/388080"); + } + private void toolStripAbout_Click(object sender, EventArgs e) { new AboutForm().ShowDialog(); diff --git a/Forms/MainWindow.resx b/Forms/MainWindow.resx index 0ded790..1e2737a 100644 --- a/Forms/MainWindow.resx +++ b/Forms/MainWindow.resx @@ -727,6 +727,12 @@ Support Us + + 152, 22 + + + Regex Reference + 149, 6 @@ -1289,6 +1295,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + toolStripRegexReference + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + toolStripMenuItem2