private void ImportImages(DiscogsRelease discogsRelease) { bool replaceImages = true; if (this.release.Images.Count > 0) { replaceImages = Dialogs.YesNoQuestion("Replace existing release images?"); } if (replaceImages) { foreach (Image image in this.release.Images.ToArray()) { this.imagesEditor.RemoveImage(image); } } WaitWindow waitWindow = new WaitWindow("Downloading images. Please wait."); Progress <double> progress = new Progress <double>(); waitWindow.ShowDialog(this.window, new Task(() => { this.DownloadImagesAsync(discogsRelease, progress); }), progress); }
public void Run() { System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog(); folderDialog.ShowNewFolderButton = true; if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { WaitWindow waitWindow = new WaitWindow("Importing collection..."); waitWindow.ShowDialog(this.ParentWindow, () => { try { using (DirectoryCollectionImporter importer = new DirectoryCollectionImporter(folderDialog.SelectedPath, this.CollectionManager)) { importer.Import(); } } catch (Exception ex) { Utility.WriteToErrorLog("Error importing: " + ex.ToString()); MessageBox.Show("Error importing backup: " + ex.Message); } this.ParentWindow.Dispatcher.BeginInvokeAction(() => { CollectionManagerGlobal.OnCollectionChanged(); }); }); } }
private void OnArtikelInfosAbrufen(Window window) { var errorText = string.Empty; if (!string.IsNullOrWhiteSpace(DatenbankId)) { var index = DatenbankId.IndexOf(':'); if (index > 0) { var produktId = DatenbankId.Substring(index + 1); if (!string.IsNullOrWhiteSpace(produktId)) { var datenbanken = new List <DatenbankDto> { new DatenbankDto { Datenbank = DatenbankAnzeigeString } }; PluginManager.DbManager.GetDatenbankDaten(ref datenbanken); var dialog = new WaitWindow(DatenbankAnzeigeString, datenbanken[0].ApiToken, "", "", produktId) { Owner = window }; dialog.ShowDialog(); if (dialog.Success) { DatenbankInfos = dialog.ResultProduktString; } else { errorText = dialog.ErrorText; } } else { errorText = "Verknüpfung zur Gewichtsdatenbank fehlerhaft."; } } else { errorText = "Verknüpfung zur Gewichtsdatenbank fehlerhaft."; } } else { errorText = "Verknüpfung zur Gewichtsdatenbank fehlerhaft."; } if (!string.IsNullOrWhiteSpace(errorText)) { HilfsFunktionen.ShowMessageBox(window, "Teileliste", errorText, true); } }
private void OnXmlFileDropped(string file) { if (this.DatabaseRelease.Images.Count != 0 || this.DatabaseRelease.AdditionalFiles.Count != 0) { if (!Dialogs.Confirm("This will replace all images, additional files and other data. Continue?")) { return; } } WaitWindow waitWindow = new WaitWindow("Reading release data..."); waitWindow.ShowDialog(this, () => { var tempFactory = new MemorySessionFactory(); var tempManager = tempFactory.CreateCollectionManager(); using (XmlReleaseImporter xmlReleaseImporter = new XmlReleaseImporter(file, tempManager)) { Release release = xmlReleaseImporter.ImportRelease(); this.Dispatcher.InvokeAction(() => { this.LoadDataFromRelease(release, tempManager.ImageHandler); tempManager.Dispose(); tempFactory.Dispose(); }); } }); }
public void Run() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Zip Files (*.zip)|*.zip|" + Utility.AllFilesFilter; if (openFileDialog.ShowDialog() == true) { WaitWindow waitWindow = new WaitWindow("Importing collection..."); waitWindow.ShowDialog(this.ParentWindow, () => { try { using (CollectionImporterBase importer = new ArchivedCollectionImporter(openFileDialog.FileName, this.CollectionManager)) { importer.Import(); } } catch (Exception ex) { Utility.WriteToErrorLog("Error importing: " + ex.ToString()); MessageBox.Show("Error importing backup: " + ex.Message); } this.ParentWindow.Dispatcher.BeginInvokeAction(() => { CollectionManagerGlobal.OnCollectionChanged(); }); }); } }
public void Start() { thread.Start(); if (thread.IsAlive && useWaitWindow) { ww.ShowDialog(); } WaitHandle.WaitAny(new WaitHandle[] { this.autoReset }); }
private void OKCancelBox_OKClicked(object sender, System.EventArgs e) { this.UpdateRelease(); WaitWindow waitWindow = new WaitWindow("Moving files and saving tags..."); Progress <double> progress = new Progress <double>(); waitWindow.ShowDialog(this, new Task(() => { this.SaveChangesAsync(progress); }), progress); }
public void Run() { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Zip Files (*.zip)|*.zip|" + Utility.AllFilesFilter; saveFileDialog.FileName = "Export_" + DateTime.Now.ToString("yyyy_MM_dd") + ".zip"; if (saveFileDialog.ShowDialog() == true) { WaitWindow waitWindow = new WaitWindow("Exporting collection..."); waitWindow.ShowDialog(this.ParentWindow, () => { using (CollectionExporterBase exporter = new ArchivedCollectionExporter(saveFileDialog.FileName, this.CollectionManager)) { exporter.Export(); } }); } }
public void OnSuchen(Window window) { var selectedKategorie = string.Empty; foreach (var item in KategorienList) { selectedKategorie = GetSelectedKategorie(item); if (!string.IsNullOrWhiteSpace(selectedKategorie)) { break; } } var progressWindow = new WaitWindow(AusgewaelteDatenbank, UserApiToken, HerstellerSuchen ? SelectedHersteller.Key : "", KategorieSuchen ? selectedKategorie : "", "") { Owner = window }; progressWindow.ShowDialog(); if (progressWindow.Success) { Datenbankteile.Clear(); foreach (var item in progressWindow.ResultList) { if (AktuellerDatenbankModus == DatenbankModus.NoneSelection) { item.EinbauenAction = EinbauenAction; item.TauschenAction = TauschenAction; item.Differenz = SelectedTeilGewicht == -1 ? 0 : item.Gewicht - SelectedTeilGewicht; } item.PropertyChanged += ContentPropertyChanged; Datenbankteile.Add(item); } SelectedItem = null; UpdateProperty("KeineTeileVisible"); } else { HilfsFunktionen.ShowMessageBox(window, "Teileliste", progressWindow.ErrorText, true); } }
public TOutput DoBackgroundTask <TInput, TOutput>(Func <TInput, TOutput> task, Action cancelAction = null, TInput parameter = default(TInput), bool centerOwner = true, bool returnIfBackgroundTaskIsActive = false, bool handleExceptions = true) { if (_isBackgroundTaskActive) { if (returnIfBackgroundTaskIsActive) { return(default(TOutput)); } throw new Exception("Background task is active!"); } _isBackgroundTaskActive = true; _currentBackgoundTaskWindow = new WaitWindow(p => task((TInput)p), cancelAction, parameter, handleExceptions); if (MainWindowInitialized) { _currentBackgoundTaskWindow.Owner = MainWindow; } _currentBackgoundTaskWindow.WindowStartupLocation = centerOwner ? WindowStartupLocation.CenterOwner : WindowStartupLocation.CenterScreen; _currentBackgoundTaskWindow.InputBindings.AddRange(_globalBindings); _currentBackgoundTaskWindow.ShowDialog(); var res = default(TOutput); if (!(_currentBackgoundTaskWindow.Result is Exception)) { res = (TOutput)_currentBackgoundTaskWindow.Result; } _currentBackgoundTaskWindow = null; _isBackgroundTaskActive = false; return(res); }
public void Run() { System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog(); folderDialog.ShowNewFolderButton = true; if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string path = folderDialog.SelectedPath; if (Directory.GetFiles(path).Length != 0 || Directory.GetDirectories(path).Length != 0) { MessageBoxResult emptyDirectoryResult = Dialogs.YesNoCancelQuestion("Target directory is not empty. Delete directory contents before exporting?"); if (emptyDirectoryResult == MessageBoxResult.Yes) { if (Directory.GetFiles(path, "*", SearchOption.AllDirectories).Any(f => Path.GetExtension(f).ToLower() != ".xml")) { Dialogs.Error("The directory contains files that aren't XML. I refuse to delete them!"); return; } if (!Utility.TryEmptyDirectory(path)) { Dialogs.Error("Error deleting directory contents!"); return; } } else if (emptyDirectoryResult == MessageBoxResult.Cancel) { return; } } WaitWindow waitWindow = new WaitWindow("Exporting collection..."); waitWindow.ShowDialog(this.ParentWindow, () => { using (DirectoryCollectionExporter exporter = new DirectoryCollectionExporter(folderDialog.SelectedPath, this.CollectionManager)) { exporter.Export(); } }); } }
private void OnBlockingOperationsStarted(object sender, EventArgs e) { if (!_isSleeping) { _isSleeping = true; Application.Current.Dispatcher?.Invoke(() => { _waitWindow = new WaitWindow() { Owner = this }; _waitWindow.ShowDialog(); _waitWindow = null; }); _isSleeping = false; } }
private void OnArtikelInfosAbrufen(Window window) { var errorText = string.Empty; var datenbanken = new List <DatenbankDto> { new DatenbankDto { Datenbank = Datenbank } }; PluginManager.DbManager.GetDatenbankDaten(ref datenbanken); var dialog = new WaitWindow(Datenbank, datenbanken[0].ApiToken, "", "", ProduktId) { Owner = window }; dialog.ShowDialog(); if (dialog.Success) { DatenbankInfos = dialog.ResultProduktString; } else { errorText = dialog.ErrorText; } if (!string.IsNullOrWhiteSpace(errorText)) { HilfsFunktionen.ShowMessageBox(window, TitelText, errorText, true); } }
/// <summary> /// Loads all workers. /// </summary> public async void LoadWorkersAsync() { #pragma warning disable CS4014 Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { try { WaitWindow.ShowDialog(); } catch (InvalidOperationException e) { } })); #pragma warning restore CS4014 App.SetConnectionResource(); switch (App.DataSource) { case ConnectionResource.LOCALAPI: Workers = new ObservableCollection <Worker>(await new WebServiceManager <Worker>().GetAllAsync()); break; case ConnectionResource.LOCALMYSQL: using (var ctx = new MysqlDbContext(ConnectionResource.LOCALMYSQL)) { Workers = new ObservableCollection <Worker>(await ctx.DbSetWorkers.Include(w => w.Address).ToListAsync()); } break; default: break; } await Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { WaitWindow.Close(); })); }
private void MessageReceived(NotificationMessage notificationMessage) { Dispatcher.BeginInvoke(new Action(() => { if (notificationMessage.Notification == Messages.ShowWaitWindow) { if (_waitWindow != null) { _waitWindow.Close(); } _connected = false; _waitWindow = new WaitWindow("Logging in, please wait...", true); _waitWindow.Owner = this; _waitWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.NavigateToMainWindow) { _connected = true; if (_waitWindow != null) { _waitWindow.Close(); } Close(); } else if (notificationMessage.Notification == Messages.DismissWaitWindow) { if (_waitWindow != null) { _waitWindow.Close(); _waitWindow = null; } } })); }
public void OnAbrufen(Window window) { var progressWindow = new WaitWindow(AusgewaelteDatenbank, UserApiToken, "", "", "") { Owner = window }; progressWindow.ShowDialog(); if (progressWindow.Success) { SaveDatenbanken(); HerstellerList = new ObservableCollection <KeyValuePair <string, string> >(progressWindow.ResultHerstellerDto.Data); SelectedHersteller = HerstellerList.FirstOrDefault(); KategorienList = new ObservableCollection <KategorienViewModel>(progressWindow.ResultKategorienList); foreach (var item in KategorienList) { SetAction(item); } UpdateProperty("KannSuchen"); } else { HilfsFunktionen.ShowMessageBox(window, "Teileliste", progressWindow.ErrorText, true); } }
private void ImportImages(DiscogsRelease discogsRelease) { bool replaceImages = true; if (this.release.Images.Count > 0) { replaceImages = Dialogs.YesNoQuestion("Replace existing release images?"); } if (replaceImages) { foreach (Image image in this.release.Images.ToArray()) { this.imagesEditor.RemoveImage(image); } } WaitWindow waitWindow = new WaitWindow("Downloading images. Please wait."); Progress<double> progress = new Progress<double>(); waitWindow.ShowDialog(this.window, new Task(() => { this.DownloadImagesAsync(discogsRelease, progress); }), progress); }
private void RunThread() // Opens WaitWindow { window = new WaitWindow(); window.Closed += new EventHandler(WaitingWindowClosed); window.ShowDialog(); // Fix "Поток находился в процессе прерывания" если выпадет исключение, пишите в чат. }
void MessageReceived(NotificationMessage notificationMessage) { Dispatcher.BeginInvoke(new Action(() => { if (notificationMessage.Notification == Messages.ShowWaitWindowLoading) { if (waitWindow != null) { waitWindow.Close(); } waitWindow = new WaitWindow("Loading please wait...") { Owner = this }; waitWindow.Closed += (sender, e) => viewModel.CancelLoading(); waitWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.ShowWaitWindowSaving) { if (waitWindow != null) { waitWindow.Close(); } waitWindow = new WaitWindow("Saving please wait...") { Owner = this }; waitWindow.Closed += (sender, e) => viewModel.CancelLoading(); waitWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.ShowAboutWindow) { if (aboutWindow != null) { aboutWindow.Close(); } aboutWindow = new AboutWindow(viewModel.GetApplicationInformation().ProductName) { DataContext = notificationMessage.Target, Owner = this }; aboutWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.ShowSettings) { if (settingsWindow != null) { settingsWindow.Close(); } settingsWindow = new SettingsWindow { DataContext = notificationMessage.Target, Owner = this }; settingsWindow.ShowDialog(); } else if (notificationMessage.Notification == Messages.DismissWaitWindow) { if (waitWindow != null) { waitWindow.Close(); waitWindow = null; } } else if (notificationMessage.Notification == Messages.DismissSettingsWindow) { if (settingsWindow != null) { settingsWindow.Close(); settingsWindow = null; } } else if (notificationMessage.Notification == Messages.ReValidateAllRows) { RevalidateAllRows(); } else if (notificationMessage.Notification == Messages.RefreshDataGridRowNumbers) { CustumerDataGrid.Items.Refresh(); } })); }
private void InjectCommandImpl() { //Flag to determine whther to color the parent nodes var cancel = false; //Switches on the injection type (new or existing) switch (TabSelectedIndex) { //Inject new case 0: //Checks that the name has been provided if (string.IsNullOrEmpty(this.Name)) { MessageBox.Show("A name is required", "Name required", MessageBoxButton.OK, MessageBoxImage.Error); return; } //Checks that the member has been provided (if needed) if (SelectedInjector.NeedsMember && SelectedMember == null) { MessageBox.Show("A type is required", "Type required", MessageBoxButton.OK, MessageBoxImage.Error); return; } //Checks that the selected type is valid if (SelectedInjector.NeedsMember && !SelectedInjector.MemberFilter(this.SelectedMember)) { MessageBox.Show("The selected type is not valid for '" + this.SelectedInjector.Name + "'", "Type required", MessageBoxButton.OK, MessageBoxImage.Error); return; } //Injects this.SelectedInjector.Inject(_node, this.Name, this.SelectedInjector.NeedsMember ? this.SelectedMember : null); //Break break; //Inject existing case 1: //Checks that there's a selection if (ExistingSelectedMember == null) { MessageBox.Show("Select a valid member to import in '" + _node.Text.ToString() + "'", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } //Cancellation token var cts = new CancellationTokenSource(); var ct = cts.Token; //Starts a new task to perform importing var t = new Task(() => { //Options var options = new Existing.MemberImportingOptions() { ImportAsNestedType = ExistingImportAsNestedTypes, CancellationToken = ct }; //Importing session var destType = !(_node is ModuleTreeNode) ? ((IMemberTreeNode)_node).Member as TypeDefinition : null; var destModule = destType != null ? destType.Module : ((ModuleTreeNode)_node).Module; var destAsm = Helpers.Tree.GetAssemblyNode(Helpers.Tree.GetModuleNode(destModule)).LoadedAssembly.AssemblyDefinition; var session = new ILEdit.Injection.Existing.MemberImportingSession(destAsm, destModule, destType, options); //Imports using (var importer = session.CreateImporter(ExistingSelectedMember)) { //Performs scanning importer.Scan(options); //Checks whether to show the preview if (ExistingPreview) { //Builds the preview var root = new SharpTreeNode(); importer.BuildPreviewNodes(root); //Shows the preview window Application.Current.Dispatcher.Invoke((Action)(() => { cancel = !new Existing.PreviewWindow(root, _node).ShowDialog().GetValueOrDefault(false); }), null); } //Performs importing on the dispatcher thread if (!cancel) { Application.Current.Dispatcher.Invoke((Action)(() => { importer.Import(options, _node); }), null); } } }, ct); t.Start(); t.ContinueWith(task => { //Hides the window Application.Current.Dispatcher.Invoke((Action)WaitWindow.Hide, null); //Checks for any exception if (task.Exception != null) { var text = string.Join(Environment.NewLine + Environment.NewLine, task.Exception.InnerExceptions.Select(x => x.Message).ToArray()); Application.Current.Dispatcher.BeginInvoke((Action)(() => { MessageBox.Show("An exception occurred:" + Environment.NewLine + Environment.NewLine + text, "Error", MessageBoxButton.OK, MessageBoxImage.Error); }), null); } }); //Shows the wait window WaitWindow.ShowDialog("Importing in progress ...", "Please, wait while the importing is in progress ...", cts); break; //Other: exception default: throw new ArgumentException("Invalid value: it can be only 0 or 1", "TabSelectedIndex"); } //Colors the parents of the node if (!cancel) { //Colors the ancestors of this node var parent = (ICSharpCode.TreeView.SharpTreeNode)_node; while (parent != null) { if (parent.Foreground != GlobalContainer.NewNodesBrush) { parent.Foreground = GlobalContainer.ModifiedNodesBrush; } parent = parent.Parent; } //Refreshes the view ICSharpCode.ILSpy.MainWindow.Instance.RefreshDecompiledView(); //Saves the settings var settings = GlobalContainer.InjectionSettings.Element("InjectExistingSettings"); settings.SetAttributeValue("Preview", ExistingPreview); if (ExistingImportAsNestedTypesEnabled) { settings.SetAttributeValue("ImportAsNestedTypes", ExistingImportAsNestedTypes); } GlobalContainer.SettingsManager.Instance.Save(); //Closes the window _window.Close(); } }
/// <summary> /// Loads all products. /// </summary> public async void LoadProductsAsync(bool inStockOnly = false) { #pragma warning disable CS4014 Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { try { WaitWindow.ShowDialog(); } catch (InvalidOperationException e) { } })); #pragma warning restore CS4014 App.SetConnectionResource(); switch (App.DataSource) { case ConnectionResource.LOCALAPI: if (inStockOnly) { CPUs = new ObservableCollection <CPU>(await new WebServiceManager <CPU>().GetAllAsync(true)); GPUs = new ObservableCollection <GPU>(await new WebServiceManager <GPU>().GetAllAsync(true)); Motherboards = new ObservableCollection <Motherboard>(await new WebServiceManager <Motherboard>().GetAllAsync(true)); Rams = new ObservableCollection <Memory>(await new WebServiceManager <Memory>().GetAllAsync(true)); StorageComponents = new ObservableCollection <Storage>(await new WebServiceManager <Storage>().GetAllAsync(true)); PSUs = new ObservableCollection <PSU>(await new WebServiceManager <PSU>().GetAllAsync(true)); Cases = new ObservableCollection <Case>(await new WebServiceManager <Case>().GetAllAsync(true)); } else { try { CPUs = new ObservableCollection <CPU>(await new WebServiceManager <CPU>().GetAllAsync()); GPUs = new ObservableCollection <GPU>(await new WebServiceManager <GPU>().GetAllAsync()); Motherboards = new ObservableCollection <Motherboard>(await new WebServiceManager <Motherboard>().GetAllAsync()); Rams = new ObservableCollection <Memory>(await new WebServiceManager <Memory>().GetAllAsync()); StorageComponents = new ObservableCollection <Storage>(await new WebServiceManager <Storage>().GetAllAsync()); PSUs = new ObservableCollection <PSU>(await new WebServiceManager <PSU>().GetAllAsync()); Cases = new ObservableCollection <Case>(await new WebServiceManager <Case>().GetAllAsync()); } catch (TaskCanceledException e) { LoadProductsAsync(inStockOnly); } } break; case ConnectionResource.LOCALMYSQL: using (var ctx = new MysqlDbContext(ConnectionResource.LOCALMYSQL)) { if (inStockOnly) { CPUs = new ObservableCollection <CPU>(await ctx.DbSetCPUs.Where(cpu => cpu.Stock > 0).ToListAsync()); GPUs = new ObservableCollection <GPU>(await ctx.DbSetGPUs.Where(gpu => gpu.Stock > 0).ToListAsync()); Motherboards = new ObservableCollection <Motherboard>(await ctx.DbSetMotherboards.Where(mb => mb.Stock > 0).ToListAsync()); Rams = new ObservableCollection <Memory>(await ctx.DbSetMemories.Where(ram => ram.Stock > 0).ToListAsync()); StorageComponents = new ObservableCollection <Storage>(await ctx.DbSetStorages.Where(storage => storage.Stock > 0).ToListAsync()); PSUs = new ObservableCollection <PSU>(await ctx.DbSetPSUs.Where(psu => psu.Stock > 0).ToListAsync()); Cases = new ObservableCollection <Case>(await ctx.DbSetCases.Where(pcCase => pcCase.Stock > 0).ToListAsync()); } else { CPUs = new ObservableCollection <CPU>(await ctx.DbSetCPUs.ToListAsync()); GPUs = new ObservableCollection <GPU>(await ctx.DbSetGPUs.ToListAsync()); Motherboards = new ObservableCollection <Motherboard>(await ctx.DbSetMotherboards.ToListAsync()); Rams = new ObservableCollection <Memory>(await ctx.DbSetMemories.ToListAsync()); StorageComponents = new ObservableCollection <Storage>(await ctx.DbSetStorages.ToListAsync()); PSUs = new ObservableCollection <PSU>(await ctx.DbSetPSUs.ToListAsync()); Cases = new ObservableCollection <Case>(await ctx.DbSetCases.ToListAsync()); } } break; default: break; } await Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { WaitWindow.Close(); })); }
private void OKCancelBox_OKClicked(object sender, System.EventArgs e) { this.UpdateRelease(); WaitWindow waitWindow = new WaitWindow("Moving files and saving tags..."); Progress<double> progress = new Progress<double>(); waitWindow.ShowDialog(this, new Task(() => { this.SaveChangesAsync(progress); }), progress); }