Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
HovKlan-DH committed Sep 20, 2023
1 parent 8ad8c6f commit 7859e73
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 26 deletions.
32 changes: 19 additions & 13 deletions HovText/History.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,13 @@ private void SelectEntry ()
// ###########################################################################################
// Search filter.
// Filter keywords:
// :f[avorite]
// :u[rl]
// :e[mail]
// :f[avorite]
// :i[mage]
// :m[ail]
// :p[icture]
// :u[rl]
// :w[eb]
// ###########################################################################################

private void Search_TextChanged(object sender, System.EventArgs e)
Expand All @@ -1052,14 +1055,17 @@ private void Search_TextChanged(object sender, System.EventArgs e)

// Check if the input contains a word starting with ":u" or ":e"
string favoriteKeyword = searchTexts.FirstOrDefault(text => text.StartsWith(":f"));
string urlKeyword = searchTexts.FirstOrDefault(text => text.StartsWith(":u"));
string emailKeyword = searchTexts.FirstOrDefault(text => text.StartsWith(":e"));
string imageKeyword = searchTexts.FirstOrDefault(text => text.StartsWith(":i"));
string urlKeyword1 = searchTexts.FirstOrDefault(text => text.StartsWith(":u"));
string urlKeyword2 = searchTexts.FirstOrDefault(text => text.StartsWith(":w"));
string emailKeyword1 = searchTexts.FirstOrDefault(text => text.StartsWith(":e"));
string emailKeyword2 = searchTexts.FirstOrDefault(text => text.StartsWith(":m"));
string imageKeyword1 = searchTexts.FirstOrDefault(text => text.StartsWith(":i"));
string imageKeyword2 = searchTexts.FirstOrDefault(text => text.StartsWith(":p"));

bool searchForFavorite = favoriteKeyword != null;
bool searchForUrl = urlKeyword != null;
bool searchForEmail = emailKeyword != null;
bool searchForImage = imageKeyword != null;
bool searchForUrl = urlKeyword1 != null || urlKeyword2 != null;
bool searchForEmail = emailKeyword1 != null || emailKeyword2 != null;
bool searchForImage = imageKeyword1 != null || imageKeyword2 != null;

// If ":f" or ":u" or ":e" or ":i" is found, remove it from the searchTexts array
if (searchForFavorite)
Expand All @@ -1068,19 +1074,19 @@ private void Search_TextChanged(object sender, System.EventArgs e)
}
if (searchForUrl)
{
searchTexts = searchTexts.Where(text => text != urlKeyword).ToArray();
searchTexts = searchTexts.Where(text => text != urlKeyword1 && text != urlKeyword2).ToArray();
}
if (searchForEmail)
{
searchTexts = searchTexts.Where(text => text != emailKeyword).ToArray();
searchTexts = searchTexts.Where(text => text != emailKeyword1 && text != emailKeyword2).ToArray();
}
if (searchForImage)
{
searchTexts = searchTexts.Where(text => text != imageKeyword).ToArray();
searchTexts = searchTexts.Where(text => text != imageKeyword1 && text != imageKeyword2).ToArray();
}

// Remove terms that start with ":" (except for ":u*" and ":e*")
searchTexts = searchTexts.Where(text => !text.StartsWith(":") || text == favoriteKeyword || text == urlKeyword || text == emailKeyword || text == imageKeyword).ToArray();
// Remove terms that start with ":" (except for the special ones)
searchTexts = searchTexts.Where(text => !text.StartsWith(":") || text == favoriteKeyword || text == urlKeyword1 || text == urlKeyword2 || text == emailKeyword1 || text == emailKeyword2 || text == imageKeyword1 || text == imageKeyword2).ToArray();

// Perform a case-insensitive wildcard search using LINQ
var searchResults = Settings.entriesText
Expand Down
4 changes: 2 additions & 2 deletions HovText/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("03fbad69-cd44-4a0c-b4bf-90406561f14f")]
//[assembly: AssemblyVersion("2021.01.23.1")]
[assembly: AssemblyFileVersion("2023.08.02.1")]
[assembly: AssemblyFileVersion("2023.09.20.1")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: NeutralResourcesLanguage("en")]
[assembly: AssemblyVersion("2023.08.02.1")]
[assembly: AssemblyVersion("2023.09.20.1")]
44 changes: 41 additions & 3 deletions HovText/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 31 additions & 5 deletions HovText/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,9 @@ public Settings()

// Set the initial text on the tray icon
UpdateNotifyIconText();

// Update the location of the dynamic labels
UpdateLocationDynamicLabels();
}


Expand Down Expand Up @@ -3015,6 +3018,32 @@ private void HotkeyPasteOnHotkey(object sender, NHotkey.HotkeyEventArgs e)
}


// ###########################################################################################
// Rearrange the dynamic labels for the "interface" hotkeys
// ###########################################################################################

private void UpdateLocationDynamicLabels()
{
Graphics g = GuiSearch.CreateGraphics();
SizeF size = g.MeasureString(GuiSearch.Text, GuiSearch.Font);
label3.Text = "(" + GuiHotkeySearch.Text + ")";
int centeredY = GuiSearch.Location.Y + (GuiSearch.Height - label3.Height) / 2;
label3.Location = new Point(GuiSearch.Location.X + (int)size.Width + 10 + 10, centeredY);

g = GuiInstantSelect.CreateGraphics();
size = g.MeasureString(GuiInstantSelect.Text, GuiInstantSelect.Font);
label5.Text = "(" + GuiHotkeyOlder.Text + ")";
centeredY = GuiInstantSelect.Location.Y + (GuiInstantSelect.Height - label5.Height) / 2;
label5.Location = new Point(GuiInstantSelect.Location.X + (int)size.Width + 10 + 10, centeredY);

g = label3.CreateGraphics();
size = g.MeasureString(label3.Text, label3.Font);
label9.Text = "(" + GuiHotkeyNewer.Text + ")";
centeredY = label5.Location.Y + (label5.Height - label9.Height) / 2;
label9.Location = new Point(label5.Location.X + (int)size.Width + 12, centeredY);
}


// ###########################################################################################
// On "key down" in one of the hotkey fields then convert that in to a string
// ###########################################################################################
Expand Down Expand Up @@ -3075,6 +3104,7 @@ private void GuiHotkeySearch_KeyDown(object sender, KeyEventArgs e)
{
string hotkey = ConvertKeyboardInputToString(e);
GuiHotkeySearch.Text = hotkey;

if (e.Alt)
{
// https://stackoverflow.com/a/3068797/2028935
Expand Down Expand Up @@ -3149,16 +3179,11 @@ private void HotkeyEnable_Enter(object sender, EventArgs e)
}

private void GuiHotkeySearch_Enter(object sender, EventArgs e)
{
}

private void GuiHotkeySearch_Click(object sender, EventArgs e)
{
hotkey = "hotkeySearch";
ModifyHotkey();
}


private void HotkeyOlder_Enter(object sender, EventArgs e)
{
hotkey = "hotkeyOlder";
Expand Down Expand Up @@ -3256,6 +3281,7 @@ public static void RemoveAllHotkeys()
private void ApplyHotkeys_Click(object sender, EventArgs e)
{
SetHotkeys("Apply hotkeys button press");
UpdateLocationDynamicLabels();
}


Expand Down
6 changes: 3 additions & 3 deletions HovText/Update.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7859e73

Please sign in to comment.