private async void Download_Button_Click(object sender, RoutedEventArgs e) { string User = User_textbox.Text; string Pass = Password_textbox.Text; string URL = Link_Textbox.Text; WebClient WClient = new WebClient(); WClient.Credentials = new NetworkCredential(User, Pass); WClient.DownloadFileCompleted += wc_DownloadFinished; WClient.DownloadProgressChanged += WClient_DownloadProgressChanged; try { await Task.Run(() => WClient.DownloadFileAsync(new System.Uri(URL), destinationFile)); } catch (WebException ex) { Corelib.Write(ex.ToString()); Notify.Show(new NotificationContent { Title = "Download failed", Type = NotificationType.Error }); } }
private void window_FormClosing(Object sender, FormClosingEventArgs e) { Program.Export(); Corelib lib = new Corelib(); lib.Write("CLOSING"); }
private void wc_DownloadFinished(object sender, EventArgs e) { this.Dispatcher.Invoke(() => { Download_text.Text = "Installing"; }); Corelib.Write("finished downloading Pakages REPO"); ZipFile.ExtractToDirectory(destinationFile, destinationFolder); Corelib.Write("Extract Complete of Pakages REPO"); foreach (string s in Directory.GetFiles(destinationFolder, "*.json")) { try { File.Move(s, Corelib.PakagesFolder + Path.GetFileName(s)); } catch (IOException ex) { Corelib.Write(ex.ToString()); } } Corelib.ClearDownloadsFolder(); Corelib.Write("pakages are added, finished"); this.Dispatcher.Invoke(() => { Download_text.Text = "Done!"; }); }
private void ImportButtonClicked(object sender, RoutedEventArgs s) { Corelib.Write("Import button clicked"); Corelib.Import(); AddButtons(); Corelib.Write("Import button clicked - finished"); }
private void wc_DownloadFinished(object sender, EventArgs e) { Corelib.Write(Corelib.Downloading.ToString() + "finished downloading"); this.Dispatcher.Invoke(() => { DownloadingBtn.Content = Corelib.Downloading.Name; TaskBarItemInfoMainWindow.ProgressState = TaskbarItemProgressState.Paused; Download_button.Content = "Download app"; }); Corelib.Downloading.Install(Corelib.DownloadsFolder + Corelib.Downloading.JName + ".zip"); this.Dispatcher.Invoke(() => { TaskBarItemInfoMainWindow.ProgressState = TaskbarItemProgressState.None; Notify.Show(new NotificationContent { Title = "Download Finished", Type = NotificationType.Success }); Download_button.IsEnabled = true; UpdateImage(); }); }
private async Task Download() { WebClient WClient = new WebClient(); WClient.Credentials = new NetworkCredential(Corelib.Downloading.User, Corelib.Downloading.Password); WClient.DownloadProgressChanged += wc_DownloadProgressChanged; WClient.DownloadFileCompleted += wc_DownloadFinished; TaskBarItemInfoMainWindow.ProgressState = TaskbarItemProgressState.Normal; try { await Task.Run(() => WClient.DownloadFileAsync ( new System.Uri(Corelib.Downloading.DownloadURL), Corelib.DownloadsFolder + Corelib.Downloading.JName + ".zip" )); Notify.Show(new NotificationContent { Title = "Download Started", Type = NotificationType.Information }); } catch (WebException ex) { Corelib.Write(ex.ToString()); Notify.Show(new NotificationContent { Title = "Download failed", Type = NotificationType.Error }); } }
private async void DownloadButtonClick(object sender, RoutedEventArgs s) { if (!Corelib.Current.IsInstalled) { Download_button.IsEnabled = false; Corelib.Downloading = Corelib.Current; Corelib.Write(Corelib.Downloading.ToString() + " start downloading"); if (!Config.StorePass && Corelib.Current.User != "") { if (Corelib.Current.User != null) { Credentials c = new Credentials(); c.ShowDialog(); } } foreach (Button B in ButtonPanel.Children) { if (B.Name == Corelib.Downloading.JName) { DownloadingBtn = B; } } await Download(); } }
public void UpdateImage() { //Stream AppICON = Application.GetResourceStream(new Uri("/Mstore.ico")).Stream; ImageSource ICON = this.Icon; //System.Drawing.Icon Ico = new System.Drawing.Icon(AppICON); if (Corelib.Current.IsInstalled) { try { var Ico = System.Drawing.Icon.ExtractAssociatedIcon(Corelib.AppsFolder + Corelib.Current.JName + "/" + Corelib.Current.exe); IntPtr i = Ico.ToBitmap().GetHbitmap(); ICON = Imaging.CreateBitmapSourceFromHBitmap( i, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions() ); DeleteObject(i); } catch (Exception e) { Corelib.Write(e.ToString()); } } EXE_Icon.Source = ICON; }
private void OpenFolderBtn_Click(object sender, EventArgs e) { Corelib lib = new Corelib(); try { Process.Start ( Environment.GetEnvironmentVariable("WINDIR") + @"\explorer.exe", Path.GetFullPath(lib.path + "pakages/") ); } catch (System.ComponentModel.Win32Exception q) { lib.Write(" " + lib.path + " "); lib.Write(q.Message); } }
private void wc_DownloadFinished(object sender, EventArgs e) { Corelib lib = new Corelib(); lib.Write("Download done" + Program.Downloading.Name); Invoke(new Action(setIsInstalled)); Program.Downloading.Install(); Invoke(new Action(SetIsInstalled)); lib.ExportList(Program.Pakages); InUse = false; }
private static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); window screen = new window(); windows.Add(screen); Import(); Lib.Write("hello"); Application.Run(screen); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { //setup mstore Corelib.Setup(); Corelib.Write("folder setup"); Corelib.Import(); Corelib.Write("inital import"); AddButtons(); Corelib.ClearDownloadsFolder(); Corelib.Write("downloads cleared"); if (Corelib.Current == null && Corelib.Pakages.Count > 0) { Corelib.Current = Corelib.Pakages[0]; UpdateUI(); } }
private void OpenRepoButtonClick(object sender, RoutedEventArgs s) { try { Process.Start ( Environment.GetEnvironmentVariable("WINDIR") + @"\explorer.exe", Path.GetFullPath(Corelib.PakagesFolder) ); } catch (System.ComponentModel.Win32Exception q) { Corelib.Write(" " + Corelib.PakagesFolder + " "); Corelib.Write(q.Message); } }
private void Click(object sender, RoutedEventArgs s) { String name; if (sender is Button) { name = (sender as Button).Name; foreach (Pakage p in Corelib.Pakages) { if (name == p.JName) { Corelib.Current = p; } } UpdateUI(); } else { Corelib.Write("ERROR: click event not from button"); } }
private void ButtonPanel_Drop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string f in files) { switch (Path.GetExtension(f)) { case ".json": Corelib.ImportF(f); AddButtons(); break; case ".zip": string folder = Corelib.DownloadsFolder + Path.GetFileName(f); ZipFile.ExtractToDirectory(f, folder); foreach (string s in Directory.GetFiles(folder, "*.json")) { try { Corelib.ImportF(s); AddButtons(); } catch (IOException ex) { Corelib.Write(ex.ToString()); } } Corelib.ClearDownloadsFolder(); break; } } Corelib.ExportList(); Notify.Show(new NotificationContent { Title = "Import Finished", Type = NotificationType.Success }); }