Skip to content

Commit

Permalink
Fix duplicate entries in the file pool
Browse files Browse the repository at this point in the history
Make it more clear when a path entry is toggled
Reset timer when manually changing length
Update file pool on path settings window closing instead of path toggling
Refresh memory usage when it matters; not every second
Fix child windows under parent when Always On Top
  • Loading branch information
gokiburikin committed May 8, 2015
1 parent 3bc14aa commit 2f6ef81
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 58 deletions.
10 changes: 7 additions & 3 deletions gokiRegeas/GokiRegeas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ static GokiRegeas()
startTime = DateTime.Now;
pauseTime = DateTime.Now;
length = lengths[2];
runningTime = new TimeSpan();
timeRemaining = new TimeSpan();
runningTime = TimeSpan.FromMilliseconds(length);
timeRemaining = TimeSpan.FromMilliseconds(0);
paths = new List<string>();
sessionPaths = new List<string>();
paths.Add(@".\img\");
Expand Down Expand Up @@ -162,6 +162,7 @@ internal static void loadSettings()
{
lastUsedTime = reader.readDouble();
length = lastUsedTime;
runningTime = TimeSpan.FromMilliseconds(length);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -215,7 +216,10 @@ internal static void fillFilePool()
{
if (GokiRegeas.fileFilter.IsMatch(file.ToLower()))
{
filePool.Add(file);
if (!filePool.Contains(file))
{
filePool.Add(file);
}
}
}
}
Expand Down
55 changes: 38 additions & 17 deletions gokiRegeas/MainForm.Designer.cs

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

35 changes: 25 additions & 10 deletions gokiRegeas/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace gokiRegeas
public partial class frmMain : Form
{
internal static System.Windows.Forms.Timer timer;
internal static System.Windows.Forms.Timer memoryTimer;
internal static int clickX;
internal static int clickY;
internal static bool dragging;
Expand All @@ -40,10 +39,6 @@ public frmMain()
GokiRegeas.loadSettings();
GokiRegeas.fillFilePool();
FormClosed += frmMain_FormClosed;
memoryTimer = new Timer();
memoryTimer.Tick += memoryTimer_Tick;
memoryTimer.Interval = 1000;
memoryTimer.Start();
timer = new Timer();
timer.Tick += timer_Tick;
timer.Interval = 35;
Expand All @@ -70,7 +65,7 @@ public frmMain()
this.TopMost = GokiRegeas.alwaysOnTop;
}

void memoryTimer_Tick(object sender, EventArgs e)
void refreshMemory()
{
GokiRegeas.process.Refresh();
Text = String.Format("gokiRegeas - {0:N0}KB", GokiRegeas.process.PrivateMemorySize64 / 1024);
Expand Down Expand Up @@ -295,14 +290,17 @@ void pnlDraw_Paint(object sender, PaintEventArgs e)
private void pathsToolStripMenuItem_Click(object sender, EventArgs e)
{
frmPathSettings pathSettingsForm = new frmPathSettings();
pathSettingsForm.TopMost = this.TopMost;
pathSettingsForm.ShowDialog();
}

private void chooseRandomImage()
{
if (GokiRegeas.filePool.Count > 0)
{
GokiRegeas.currentFilePath = GokiRegeas.filePool[GokiRegeas.random.Next(GokiRegeas.filePool.Count)];
int random = GokiRegeas.random.Next(GokiRegeas.filePool.Count);
lblStatus.Text = "File " + random + "/" + GokiRegeas.filePool.Count;
GokiRegeas.currentFilePath = GokiRegeas.filePool[random];
try
{
if (GokiRegeas.currentFileBitmap != null)
Expand All @@ -316,7 +314,7 @@ private void chooseRandomImage()
pnlDraw.Invalidate();
updateStatusStrip();
//GokiRegeas.unpause();
lblStatus.Text = "";
refreshMemory();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -353,6 +351,7 @@ private void historyNext()
}
GokiRegeas.currentFileBitmap = (Bitmap)Image.FromFile(GokiRegeas.currentFilePath);
updateStatusStrip();
refreshMemory();
}
else
{
Expand Down Expand Up @@ -388,6 +387,7 @@ private void historyPrevious()
pnlDraw.Invalidate();
GokiRegeas.startTime = now;
updateStatusStrip();
refreshMemory();
}
if (GokiRegeas.paused)
{
Expand Down Expand Up @@ -448,6 +448,8 @@ private void previousToolStripMenuItem_Click(object sender, EventArgs e)
private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e)
{
frmColorSelection colorSelectionForm = new frmColorSelection();
colorSelectionForm.TopMost = this.TopMost;

colorSelectionForm.setColor(GokiRegeas.backColor);
if (colorSelectionForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Expand All @@ -459,13 +461,14 @@ private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e)
private void btnToolStripLengths_ButtonClick(object sender, EventArgs e)
{
frmCustomLength customLengthForm = new frmCustomLength();
customLengthForm.numSeconds.Value = (decimal)GokiRegeas.length/1000;
customLengthForm.TopMost = this.TopMost;
customLengthForm.numSeconds.Value = (decimal)GokiRegeas.length / 1000;
if ( customLengthForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
GokiRegeas.length = (int)customLengthForm.numSeconds.Value * 1000;
GokiRegeas.lastUsedTime = GokiRegeas.length;
GokiRegeas.runningTime = TimeSpan.FromMilliseconds(0);
updateToolStrip();
GokiRegeas.startTime = DateTime.Now;
}
}

Expand Down Expand Up @@ -494,5 +497,17 @@ private void mnuViewAlwaysOnTop_Click(object sender, EventArgs e)
this.TopMost = GokiRegeas.alwaysOnTop;
updateMenuStrip();
}

private void donateToolStripMenuItem_Click(object sender, EventArgs e)
{
string url = @"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=gokiburikin%40gmail%2ecom&lc=CA&item_name=gokiRegeas&amount=2%2e00&currency_code=CAD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted";
System.Diagnostics.Process.Start(url);
}

private void byGokiburikinToolStripMenuItem_Click(object sender, EventArgs e)
{
string url = @"https://github.com/gokiburikin";
System.Diagnostics.Process.Start(url);
}
}
}
42 changes: 14 additions & 28 deletions gokiRegeas/PathSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,37 +67,25 @@ void dragDrop(object sender, DragEventArgs e)
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
GokiRegeas.fillFilePool();
GokiRegeas.saveSettings();
}

public void refreshList()
public void updateList( bool clear = false)
{
lstPaths.SuspendLayout();
foreach (string path in GokiRegeas.paths)
if ( clear )
{
ListViewItem item = lstPaths.FindItemWithText(path);
if ( item != null )
{
if (GokiRegeas.sessionPaths.Contains(path))
{
item.ForeColor = Color.Black;
}
else
{
item.ForeColor = Color.DarkGray;
}
}
lstPaths.Items.Clear();
}
lstPaths.ResumeLayout();
}

public void updateList()
{
lstPaths.SuspendLayout();
lstPaths.Items.Clear();
foreach ( string path in GokiRegeas.paths)
{
ListViewItem item = new ListViewItem(path);
ListViewItem item = lstPaths.FindItemWithText(path);
if ( item == null )
{
item = new ListViewItem(path);
lstPaths.Items.Add(item);
}
if (GokiRegeas.sessionPaths.Contains(path))
{
item.ForeColor = Color.Black;
Expand All @@ -106,7 +94,7 @@ public void updateList()
{
item.ForeColor = Color.DarkGray;
}
lstPaths.Items.Add(item);
lstPaths.SelectedIndices.Clear();
}
lstPaths.ResumeLayout();
}
Expand All @@ -121,7 +109,7 @@ private void btnAddPath_Click(object sender, EventArgs e)
GokiRegeas.paths.Add(folderBrowserDialog.SelectedPath);
}
}
updateList();
updateList(true);
}

private void btnRemovePath_Click(object sender, EventArgs e)
Expand All @@ -134,7 +122,7 @@ private void btnRemovePath_Click(object sender, EventArgs e)
GokiRegeas.paths.Remove(selectedPath);
}
}
updateList();
updateList(true);
}

private void toggleSelectedPaths()
Expand All @@ -150,9 +138,7 @@ private void toggleSelectedPaths()
{
GokiRegeas.sessionPaths.Add(path);
}
///updateList();
refreshList();
GokiRegeas.fillFilePool();
updateList();
}
}

Expand Down

0 comments on commit 2f6ef81

Please sign in to comment.