Skip to content

Commit d46bdfa

Browse files
- added wait cursor
- fixed hanging delete "Portugal 79" route - inserted "Auto Installed" route added to "Manually Installed" grid also - deleted route from "Auto Installed" also deleted from "Manually Installed" grid
1 parent 2b79de1 commit d46bdfa

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

Source/Menu/ContentForm.cs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -644,16 +644,18 @@ private bool downloadRoute(string installPathRoute)
644644

645645
while (downloadThread.IsAlive)
646646
{
647-
Stopwatch sw = Stopwatch.StartNew();
648-
649647
TotalBytes = 0;
648+
650649
sumMB(installPathRoute);
651650
AutoInstallSynchronizationContext.Post(new SendOrPostCallback(o =>
652651
{
652+
((MainForm)Owner).Cursor = Cursors.WaitCursor;
653+
653654
dataGridViewAutoInstall.CurrentRow.Cells[1].Value =
654655
string.Format("Downloaded: {0} kB", (string)o);
655656
}), (TotalBytes / 1024).ToString("N0"));
656657

658+
Stopwatch sw = Stopwatch.StartNew();
657659
while ((downloadThread.IsAlive) && (sw.ElapsedMilliseconds <= 1000)) { }
658660
}
659661

@@ -671,16 +673,17 @@ private bool downloadRoute(string installPathRoute)
671673

672674
while (installThread.IsAlive)
673675
{
674-
Stopwatch sw = Stopwatch.StartNew();
675-
676676
TotalBytes = -bytesZipfile;
677677
sumMB(installPathRoute);
678678
AutoInstallSynchronizationContext.Post(new SendOrPostCallback(o =>
679679
{
680+
((MainForm)Owner).Cursor = Cursors.WaitCursor;
681+
680682
dataGridViewAutoInstall.CurrentRow.Cells[1].Value =
681683
string.Format("Installed: {0} kB", (string)o);
682684
}), (TotalBytes / 1024).ToString("N0"));
683685

686+
Stopwatch sw = Stopwatch.StartNew();
684687
while ((installThread.IsAlive) && (sw.ElapsedMilliseconds <= 1000)) { }
685688
}
686689
}
@@ -838,6 +841,15 @@ private bool insertRowInOptions(string installPathRoute)
838841
AutoInstallRoutes[AutoInstallRouteName].ContentName = routeName;
839842
AutoInstallRoutes[AutoInstallRouteName].ContentDirectory = installPathRouteReal;
840843

844+
// insert into Manually Installed data grid
845+
int indexAdded = dataGridViewManualInstall.Rows.Add(new string[] {
846+
routeName,
847+
installPathRouteReal
848+
});
849+
dataGridViewManualInstall.Rows[indexAdded].Cells[1].ToolTipText = installPathRouteReal;
850+
dataGridViewManualInstall.Rows[indexAdded].DefaultCellStyle.ForeColor = Color.Gray;
851+
dataGridViewManualInstall.Sort(dataGridViewManualInstall.Columns[0], ListSortDirection.Ascending);
852+
841853
return true;
842854
}
843855

@@ -954,6 +966,11 @@ private async void buttonAutoInstallDelete_Click(object sender, EventArgs e)
954966
if (Settings.Folders.Folders[route.ContentName] == route.ContentDirectory)
955967
{
956968
Settings.Folders.Folders.Remove(route.ContentName);
969+
int index = findIndexDgvManualInstall(route.ContentName);
970+
if (index > -1)
971+
{
972+
dataGridViewManualInstall.Rows.RemoveAt(index);
973+
}
957974
}
958975
Settings.Folders.Save();
959976
}
@@ -991,19 +1008,21 @@ private void deleteRoute(string directoryInstalledIn)
9911008
// this will stop the delete until the sum is done
9921009
AutoInstallDoingTheSumOfTheFileBytes = true;
9931010

994-
Stopwatch sw = Stopwatch.StartNew();
9951011
TotalBytes = 0;
9961012
if (sumMB(directoryInstalledIn))
9971013
{
9981014
AutoInstallSynchronizationContext.Post(new SendOrPostCallback(o =>
9991015
{
1016+
((MainForm)Owner).Cursor = Cursors.WaitCursor;
1017+
10001018
dataGridViewAutoInstall.CurrentRow.Cells[1].Value =
10011019
string.Format("Left: {0} kB", (string)o);
10021020
}), (TotalBytes / 1024).ToString("N0"));
10031021
}
10041022

10051023
AutoInstallDoingTheSumOfTheFileBytes = false;
10061024

1025+
Stopwatch sw = Stopwatch.StartNew();
10071026
while (deleteThread.IsAlive && (sw.ElapsedMilliseconds <= 1000)) { }
10081027
}
10091028
}
@@ -1032,8 +1051,7 @@ private void setCursorToWaitCursor()
10321051
{
10331052
AutoInstallClosingBlocked = true;
10341053

1035-
MainForm mainForm = (MainForm)Owner;
1036-
mainForm.Cursor = Cursors.WaitCursor;
1054+
((MainForm)Owner).Cursor = Cursors.WaitCursor;
10371055
}
10381056

10391057
private void EnableAutoInstalButtons()
@@ -1055,8 +1073,7 @@ private void EnableAutoInstalButtons()
10551073

10561074
private void setCursorToDefaultCursor()
10571075
{
1058-
MainForm mainForm = (MainForm)Owner;
1059-
mainForm.Cursor = Cursors.Default;
1076+
((MainForm)Owner).Cursor = Cursors.Default;
10601077

10611078
AutoInstallClosingBlocked = false;
10621079
}
@@ -1632,6 +1649,18 @@ private string findPathInDgvManualInstall(string route)
16321649
return "";
16331650
}
16341651

1652+
private int findIndexDgvManualInstall(string route)
1653+
{
1654+
for (int i = 0; i < dataGridViewManualInstall.Rows.Count; i++)
1655+
{
1656+
if (dataGridViewManualInstall.Rows[i].Cells[0].Value.ToString().Equals(route))
1657+
{
1658+
return i;
1659+
}
1660+
}
1661+
return - 1;
1662+
}
1663+
16351664
private void DownloadContentForm_FormClosing(object sender, FormClosingEventArgs formClosingEventArgs)
16361665
{
16371666
if (AutoInstallClosingBlocked)

Source/ORTS.Settings/ContentRouteSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private static void directoryRemoveReadOnlyFlagsAndDeleteFile(string directoryNa
268268
{
269269
while (doingTheSumOfTheFileBytes)
270270
{
271-
// stop deleteing file while summing in progress,
271+
// stop deleting file while summing in progress,
272272
// sum is for feedback to the user
273273
System.Threading.Thread.Sleep(10);
274274
}

0 commit comments

Comments
 (0)