33using SharpCompress . Archives . Zip ;
44using SharpCompress . Common ;
55using SharpCompress . Readers ;
6- using File = System . IO . File ;
76
87namespace FlashpointInstaller
98{
@@ -23,26 +22,17 @@ public partial class Install : Form
2322
2423 private async void Install_Load ( object sender , EventArgs e )
2524 {
26- downloader . DownloadStarted += OnDownloadStarted ;
2725 downloader . DownloadProgressChanged += OnDownloadProgressChanged ;
2826
29- stream = await downloader . DownloadFileTaskAsync ( "http ://localhost/Flashpoint%2011%20Infinity.7z " ) ;
30- //stream = File.OpenRead(@"E:\Flashpoint 11 Infinity.zip");
27+ stream = await downloader . DownloadFileTaskAsync ( "https ://bluepload.unstable.life/selif/flashpointdummy.zip " ) ;
28+ //stream = System.IO. File.OpenRead(@"E:\Flashpoint 11 Infinity.zip");
3129
3230 if ( ! downloader . IsCancelled )
3331 {
3432 await Task . Run ( ExtractTask ) ;
3533 }
3634 }
3735
38- private void OnDownloadStarted ( object ? sender , DownloadStartedEventArgs e )
39- {
40- Info . Invoke ( ( MethodInvoker ) delegate
41- {
42- Info . Text = $ "Downloaded 0MB of { e . TotalBytesToReceive / 1000000 } MB";
43- } ) ;
44- }
45-
4636 private void OnDownloadProgressChanged ( object ? sender , DownloadProgressChangedEventArgs e )
4737 {
4838 Progress . Invoke ( ( MethodInvoker ) delegate
@@ -52,7 +42,7 @@ private void OnDownloadProgressChanged(object? sender, DownloadProgressChangedEv
5242
5343 Info . Invoke ( ( MethodInvoker ) delegate
5444 {
55- Info . Text = $ "Downloaded { e . ReceivedBytesSize / 1000000 } MB of { e . TotalBytesToReceive / 1000000 } MB";
45+ Info . Text = $ "1/2: Downloading archive - { e . ReceivedBytesSize / 1000000 } MB of { e . TotalBytesToReceive / 1000000 } MB";
5646 } ) ;
5747 }
5848
@@ -62,8 +52,8 @@ private void ExtractTask()
6252 {
6353 using ( reader = archive . ExtractAllEntries ( ) )
6454 {
65- int extractedFiles = 0 ;
66- int totalFiles = archive . Entries . Where ( entry => ! entry . IsDirectory ) . Count ( ) ;
55+ long extractedSize = 0 ;
56+ long totalSize = archive . TotalUncompressSize ;
6757
6858 while ( ! reader . Cancelled && reader . MoveToNextEntry ( ) )
6959 {
@@ -72,20 +62,20 @@ private void ExtractTask()
7262 continue ;
7363 }
7464
75- reader . WriteEntryToDirectory ( mainForm . FolderText . Text , new ExtractionOptions { ExtractFullPath = true , Overwrite = true } ) ;
65+ reader . WriteEntryToDirectory ( mainForm . FolderTextBox . Text , new ExtractionOptions { ExtractFullPath = true , Overwrite = true } ) ;
7666
77- extractedFiles ++ ;
67+ extractedSize += reader . Entry . Size ;
7868
7969 try
8070 {
8171 Progress . Invoke ( ( MethodInvoker ) delegate
8272 {
83- Progress . Value = ( Progress . Maximum / 2 ) + ( ( int ) ( ( double ) extractedFiles / totalFiles * ( Progress . Maximum / 2 ) ) ) ;
73+ Progress . Value = ( Progress . Maximum / 2 ) + ( int ) ( ( double ) extractedSize / totalSize * ( Progress . Maximum / 2 ) ) ;
8474 } ) ;
8575
8676 Info . Invoke ( ( MethodInvoker ) delegate
8777 {
88- Info . Text = $ "Extracted { extractedFiles } of { totalFiles } files ";
78+ Info . Text = $ "2/2: Extracting files - { extractedSize / 1000000 } MB of { totalSize / 1000000 } MB ";
8979 } ) ;
9080 }
9181 catch { }
@@ -105,23 +95,31 @@ private void ExtractTask()
10595
10696 private void FinishInstallation ( )
10797 {
108- if ( mainForm . ShortcutsDesktop . Checked )
98+ if ( mainForm . Shortcut . Checked )
10999 {
110- string desktopPath = Environment . GetFolderPath ( Environment . SpecialFolder . Desktop ) ;
111-
112- IWshShortcut shortcut = new WshShell ( ) . CreateShortcut ( Path . Combine ( desktopPath , "Flashpoint Infinity.lnk" ) ) ;
113- shortcut . TargetPath = Path . Combine ( mainForm . FolderText . Text , @"Flashpoint 11 Infinity\Launcher\Flashpoint.exe" ) ;
100+ IWshShortcut shortcut = new WshShell ( ) . CreateShortcut ( Path . Combine (
101+ Environment . GetFolderPath ( Environment . SpecialFolder . Desktop ) ,
102+ "Flashpoint Infinity.lnk"
103+ ) ) ;
104+ shortcut . TargetPath = Path . Combine ( mainForm . FolderTextBox . Text , @"Flashpoint 11 Infinity\Launcher\Flashpoint.exe" ) ;
105+ shortcut . WorkingDirectory = Path . Combine ( mainForm . FolderTextBox . Text , @"Flashpoint 11 Infinity\Launcher" ) ;
106+ shortcut . Description = "Shortcut to Flashpoint Infinity" ;
114107 shortcut . Save ( ) ;
115108 }
116109
117- Finish FinishWindow = new ( ) ;
118- FinishWindow . ShowDialog ( ) ;
110+ Invoke ( ( MethodInvoker ) delegate
111+ {
112+ Hide ( ) ;
113+ mainForm . Hide ( ) ;
114+
115+ Finish FinishWindow = new ( ) ;
116+ FinishWindow . ShowDialog ( ) ;
117+ } ) ;
119118 }
120119
121120 private async void Cancel_Click ( object sender , EventArgs e )
122121 {
123122 Cancel . Enabled = false ;
124- Info . Text = "Cancelling installation..." ;
125123
126124 if ( downloader . IsBusy )
127125 {
@@ -133,7 +131,14 @@ private async void Cancel_Click(object sender, EventArgs e)
133131
134132 await Task . Run ( ( ) =>
135133 {
134+ Info . Invoke ( ( MethodInvoker ) delegate
135+ {
136+ Info . Text = $ "Cancelling installation...";
137+ } ) ;
138+
136139 while ( ! finishedWriting ) { }
140+
141+ Directory . Delete ( Path . Combine ( mainForm . FolderTextBox . Text , "Flashpoint 11 Infinity" ) , true ) ;
137142 } ) ;
138143 }
139144
0 commit comments