Skip to content

Commit

Permalink
Add maximum suggestions to the settings file
Browse files Browse the repository at this point in the history
Fix a crash when there weren't 10 suggestions to fill the auto suggest window
Improve auto suggest window handling
Add tooltips
Separate memory and cpu usage labels
  • Loading branch information
gokiburikin committed May 18, 2015
1 parent 608d4da commit 85acf0b
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 30 deletions.
2 changes: 2 additions & 0 deletions gokiTagDB/AutoSuggestWindow.Designer.cs

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

7 changes: 7 additions & 0 deletions gokiTagDB/AutoSuggestWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ public frmAutoSuggestWindow()
{
InitializeComponent();
}
protected override bool ShowWithoutActivation
{
get
{
return true;
}
}
}
}
101 changes: 76 additions & 25 deletions gokiTagDB/Form1.Designer.cs

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

39 changes: 34 additions & 5 deletions gokiTagDB/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ void frmMainForm_Load(object sender, EventArgs e)

Move += frmMainForm_Move;


foreach( string entry in Enum.GetNames(typeof(SortType)))
{
ToolStripMenuItem sortModeItem = new ToolStripMenuItem(entry);
Expand Down Expand Up @@ -120,6 +119,9 @@ void frmMainForm_Load(object sender, EventArgs e)
pnlTagList.MouseDown += pnlTagList_MouseDown;
pnlTagList.Resize += pnlTagList_Resize;

txtSearch.LostFocus += txtSearch_LostFocus;
txtTagEditor.LostFocus += txtSearch_LostFocus;

lblStatus4.Click += lblStatus4_Click;

ToolStripMenuItem aboutGokiburi = new ToolStripMenuItem("by gokiburikin");
Expand Down Expand Up @@ -185,6 +187,14 @@ void frmMainForm_Load(object sender, EventArgs e)
updatePanelScrollbar();
}

void txtSearch_LostFocus(object sender, EventArgs e)
{
if (autoSuggestWindow.Visible && (!autoSuggestWindow.Focused && !autoSuggestWindow.lstSuggestions.Focused) )
{
autoSuggestWindow.Hide();
}
}

void frmMainForm_Move(object sender, EventArgs e)
{
autoSuggestWindow.Hide();
Expand Down Expand Up @@ -1047,11 +1057,21 @@ void autoSuggestTextChanged(object sender, EventArgs e)
{
return -firstPair.Value.CompareTo(nextPair.Value);
});
matches.RemoveRange(10, matches.Count - 10);
if (matches.Count > GokiTagDB.settings.MaximumSuggestions)
{
matches.RemoveRange(GokiTagDB.settings.MaximumSuggestions, matches.Count - GokiTagDB.settings.MaximumSuggestions);
}

Control control = (Control)sender;
Point locationOnForm = control.FindForm().PointToClient(control.Parent.PointToScreen(control.Location));
locationOnForm.Y += Size.Height - ClientSize.Height - calculatedFormBorderSize;
if ( control == txtTagEditor)
{
locationOnForm.Y += Size.Height - ClientSize.Height - calculatedFormBorderSize - autoSuggestWindow.Height;
}
else
{
locationOnForm.Y += Size.Height - ClientSize.Height - calculatedFormBorderSize + control.Height;
}
locationOnForm.X += calculatedFormBorderSize;
string message = matches[0].Key + " (" + matches[0].Value + ")";
if (matches.Count > 0)
Expand All @@ -1065,13 +1085,21 @@ void autoSuggestTextChanged(object sender, EventArgs e)
}

Point offset = Location;
autoSuggestWindow.Location = new Point(locationOnForm.X + offset.X, locationOnForm.Y + offset.Y + control.Height);
autoSuggestWindow.Location = new Point(locationOnForm.X + offset.X, locationOnForm.Y + offset.Y );
autoSuggestWindow.Show();
control.Focus();

autoSuggestEntry = matches[0].Key;
isShown = true;
}
else
{
autoSuggestWindow.Hide();
}
}
else
{
autoSuggestWindow.Hide();
}
}
}
Expand Down Expand Up @@ -1173,7 +1201,8 @@ void processTimer_Tick(object sender, EventArgs e)
process.Refresh();
usedMemory = process.PrivateMemorySize64;
double cpuUsage = performanceCounter.NextValue() / Environment.ProcessorCount;
lblStatus5.Text = String.Format("{0:N0}KB - {1:N2}% CPU", usedMemory / 1024f, cpuUsage);
lblMemory.Text = String.Format("{0:N0}KB", usedMemory / 1024f);
lblCpuUsage.Text = String.Format("{0:N2}%", cpuUsage);
}

void invalidateTimer_Tick(object sender, EventArgs e)
Expand Down
3 changes: 3 additions & 0 deletions gokiTagDB/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>236, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>335, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
Loading

0 comments on commit 85acf0b

Please sign in to comment.