Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2018-02-22 01:11:32 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2018-02-22 01:11:32 +0300
commit20d8e10dcd6d4136e10976cb3c8b81ffb512f635 (patch)
treedce85066c5a339f2defe1c8f935ffbc9bb8461c9 /MainForm.cs
parentad2caa99e09a20cd3b09b6f319d0abde6d589343 (diff)
Progressbar while loading games
Diffstat (limited to 'MainForm.cs')
-rw-r--r--MainForm.cs61
1 files changed, 15 insertions, 46 deletions
diff --git a/MainForm.cs b/MainForm.cs
index 130677e4..48b74a12 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -158,7 +158,6 @@ namespace com.clusterrr.hakchi_gui
public MainForm()
{
InitializeComponent();
- FormInitialize();
Clovershell = new ClovershellConnection() { AutoReconnect = true, Enabled = true };
Clovershell.OnConnected += Clovershell_OnConnected;
@@ -173,8 +172,11 @@ namespace com.clusterrr.hakchi_gui
FTPToolStripMenuItem_Click(null, null);
if (ConfigIni.TelnetServer)
Clovershell.ShellEnabled = shellToolStripMenuItem.Checked = true;
- alwaysWriteGamesToUSBDriveToolStripMenuItem.Checked = ConfigIni.AlwaysWriteToUSB;
- buttonStart.Text = (Control.ModifierKeys == Keys.Shift) || ConfigIni.AlwaysWriteToUSB ? Resources.SyncronizeUSB : Resources.Syncronize;
+ }
+
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ FormInitialize();
}
void FormInitialize()
@@ -217,6 +219,8 @@ namespace com.clusterrr.hakchi_gui
openFTPInExplorerToolStripMenuItem.Enabled = FTPToolStripMenuItem.Checked = ConfigIni.FtpServer;
openTelnetToolStripMenuItem.Enabled = shellToolStripMenuItem.Checked = ConfigIni.TelnetServer;
+ alwaysWriteGamesToUSBDriveToolStripMenuItem.Checked = ConfigIni.AlwaysWriteToUSB;
+ buttonStart.Text = (Control.ModifierKeys == Keys.Shift) || ConfigIni.AlwaysWriteToUSB ? Resources.SyncronizeUSB : Resources.Syncronize;
}
catch (Exception ex)
{
@@ -276,50 +280,14 @@ namespace com.clusterrr.hakchi_gui
public void LoadGames()
{
- Debug.WriteLine("Loading games");
- var selected = ConfigIni.SelectedGames.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
- Directory.CreateDirectory(NesMiniApplication.GamesDirectory);
- var gameDirs = Directory.GetDirectories(NesMiniApplication.GamesDirectory);
- var games = new List<NesMiniApplication>();
- foreach (var gameDir in gameDirs)
- {
- try
- {
- // Removing empty directories without errors
- try
- {
- var game = NesMiniApplication.FromDirectory(gameDir);
- games.Add(game);
- }
- catch (FileNotFoundException ex) // Remove bad directories if any
- {
- Debug.WriteLine(ex.Message + ex.StackTrace);
- Directory.Delete(gameDir, true);
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex.Message + ex.StackTrace);
- MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
- continue;
- }
- }
-
- var gamesSorted = games.OrderBy(o => o.Name);
- listViewGames.Items.Clear();
- var listViewItem = new ListViewItem(Resources.Default30games);
- listViewItem.Tag = "default";
- listViewItem.Checked = selected.Contains("default");
- listViewGames.Items.Add(listViewItem);
- foreach (var game in gamesSorted)
- {
- listViewItem = new ListViewItem(game.Name);
- listViewItem.Tag = game;
- listViewItem.Checked = selected.Contains(game.Code);
- listViewGames.Items.Add(listViewItem);
- }
+ var workerForm = new WorkerForm(this);
+ workerForm.Text = Resources.LoadingGames;
+ workerForm.Task = WorkerForm.Tasks.LoadGames;
+ workerForm.Start();
RecalculateSelectedGames();
ShowSelected();
+ if (workerForm.DialogResult != DialogResult.OK)
+ Close();
}
public void ShowSelected()
@@ -1242,7 +1210,7 @@ namespace com.clusterrr.hakchi_gui
{
ConfigIni.FcStart = upABStartOnSecondControllerToolStripMenuItem.Checked;
}
-
+
private void enableUSBHostToolStripMenuItem_Click(object sender, EventArgs e)
{
ConfigIni.UsbHost = enableUSBHostToolStripMenuItem.Checked;
@@ -1578,6 +1546,7 @@ namespace com.clusterrr.hakchi_gui
private void timerConnectionCheck_Tick(object sender, EventArgs e)
{
+ if (Clovershell == null) return;
toolStripStatusConnectionIcon.Image = Clovershell.IsOnline ? Resources.green : Resources.red;
toolStripStatusConnectionIcon.ToolTipText = Clovershell.IsOnline ? "Online" : "Offline";
}