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))));
}
}
}
diff --git a/Forms/MainWindow.Designer.cs b/Forms/MainWindow.Designer.cs
index ba941b1..b43cfec 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();
@@ -91,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();
@@ -144,7 +146,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 +161,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
//
@@ -537,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";
@@ -552,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
//
@@ -653,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;
@@ -666,7 +683,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 +723,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..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();
@@ -403,6 +408,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..1e2737a 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
@@ -721,6 +727,12 @@
Support Us
+
+ 152, 22
+
+
+ Regex Reference
+
149, 6
@@ -989,6 +1001,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
@@ -1277,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