|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Diagnostics; |
| 4 | +using System.IO; |
| 5 | +using System.IO.Compression; |
| 6 | +using System.Net; |
| 7 | +using System.Text; |
| 8 | +using System.Windows; |
| 9 | +using System.Windows.Controls; |
| 10 | +using System.Windows.Data; |
| 11 | +using System.Windows.Documents; |
| 12 | +using System.Windows.Input; |
| 13 | +using System.Windows.Media; |
| 14 | +using System.Windows.Media.Imaging; |
| 15 | +using System.Windows.Navigation; |
| 16 | +using System.Windows.Shapes; |
| 17 | + |
| 18 | +namespace NCX_Installer |
| 19 | +{ |
| 20 | + /// <summary> |
| 21 | + /// Interaction logic for XWareNews.xaml |
| 22 | + /// </summary> |
| 23 | + public partial class XWareNews : Page |
| 24 | + { |
| 25 | + static readonly string SavePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); |
| 26 | + |
| 27 | + public XWareNews() |
| 28 | + { |
| 29 | + InitializeComponent(); |
| 30 | + } |
| 31 | + |
| 32 | + private void Button_Click_2(object sender, RoutedEventArgs e) |
| 33 | + { |
| 34 | + XWareHome page = new XWareHome(); |
| 35 | + NavigationService.Navigate(page); |
| 36 | + } |
| 37 | + |
| 38 | + private void Button_Click(object sender, RoutedEventArgs e) |
| 39 | + { |
| 40 | + string url = "https://github.com/NinjaCheetah/NCX-XWare"; |
| 41 | + Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); |
| 42 | + } |
| 43 | + |
| 44 | + private void Button_Click_1(object sender, RoutedEventArgs e) |
| 45 | + { |
| 46 | + string url = "https://github.com/NinjaCheetah"; |
| 47 | + Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); |
| 48 | + } |
| 49 | + |
| 50 | + private void Button_Click_4(object sender, RoutedEventArgs e) |
| 51 | + { |
| 52 | + if (Directory.Exists(System.IO.Path.Combine(SavePath, "NCX-Core/"))) |
| 53 | + { |
| 54 | + if (Directory.Exists(System.IO.Path.Combine(SavePath,"NCX-Core/NCXNewsPlus/"))) |
| 55 | + { |
| 56 | + using (WebClient wc = new WebClient()) |
| 57 | + { |
| 58 | + btn5.Visibility = Visibility.Hidden; |
| 59 | + label1.Visibility = Visibility.Visible; |
| 60 | + wc.DownloadProgressChanged += wc_DownloadProgressChanged; |
| 61 | + wc.DownloadFileCompleted += DownloadCompleted; |
| 62 | + wc.DownloadFileAsync( |
| 63 | + // Param1 = Link of file |
| 64 | + new System.Uri("https://github.com/NinjaCheetah/NCX-XWare/releases/latest/download/NCXNewsPlus.zip"), |
| 65 | + // Param2 = Path to save |
| 66 | + System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus/NCXNewsPlus.zip") |
| 67 | + ); |
| 68 | + } |
| 69 | + } |
| 70 | + else |
| 71 | + { |
| 72 | + Directory.CreateDirectory(System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus")); |
| 73 | + using (WebClient wc = new WebClient()) |
| 74 | + { |
| 75 | + btn5.Visibility = Visibility.Hidden; |
| 76 | + label1.Visibility = Visibility.Visible; |
| 77 | + wc.DownloadFileCompleted += DownloadCompleted; |
| 78 | + wc.DownloadFileAsync( |
| 79 | + // Param1 = Link of file |
| 80 | + new System.Uri("https://github.com/NinjaCheetah/NCX-XWare/releases/latest/download/NCXNewsPlus.zip"), |
| 81 | + // Param2 = Path to save |
| 82 | + System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus/NCXNewsPlus.zip") |
| 83 | + ); |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + else |
| 88 | + { |
| 89 | + Directory.CreateDirectory(System.IO.Path.Combine(SavePath, "NCX-Core")); |
| 90 | + Directory.CreateDirectory(System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus")); |
| 91 | + Directory.CreateDirectory(System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus")); |
| 92 | + using (WebClient wc = new WebClient()) |
| 93 | + { |
| 94 | + wc.DownloadFileCompleted += DownloadCompleted; |
| 95 | + wc.DownloadFileAsync( |
| 96 | + // Param1 = Link of file |
| 97 | + new System.Uri("https://github.com/NinjaCheetah/NCX-XWare/releases/latest/download/NCXNewsPlus.zip"), |
| 98 | + // Param2 = Path to save |
| 99 | + System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus/NCXNewsPlus.zip") |
| 100 | + ); |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + public void DownloadCompleted(object sender, EventArgs e) |
| 106 | + { |
| 107 | + ZipFile.ExtractToDirectory(System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus/NCXNewsPlus.zip"), System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus"), true); |
| 108 | + File.Delete(System.IO.Path.Combine(SavePath, "NCX-Core/NCXNewsPlus/NCXNewsPlus.zip")); |
| 109 | + label1.Content = "Download Complete"; |
| 110 | + } |
| 111 | + |
| 112 | + void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) |
| 113 | + { |
| 114 | + progressBar1.Value = e.ProgressPercentage; |
| 115 | + } |
| 116 | + |
| 117 | + private void btn6_Click(object sender, RoutedEventArgs e) |
| 118 | + { |
| 119 | + if (File.Exists("C:/Program Files/NCX/CSharp Collection/CSharpCollectionVol1.exe")) |
| 120 | + { |
| 121 | + Process.Start("C:/Program Files/NCX/CSharp Collection/CSharpCollectionVol1.exe"); |
| 122 | + } |
| 123 | + } |
| 124 | + } |
| 125 | +} |
0 commit comments