public MessageBoxResult MessageBoxFlyoutShow(string message, string caption, MessageBoxButton buttons, MessageBoxImage image) { var uc = new MessageBoxFlyout(message, caption, buttons, image); StartFlyoverModal(uc); return(uc.Result); }
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { // decode if (e == null || e.Command == null || !(e.Command is RoutedUICommand)) { return; } var cmd = (e.Command as RoutedUICommand).Text.Trim().ToLower(); // decide if (cmd == "new") { if ((!Options.UseFlyovers && MessageBoxResult.Yes == MessageBox.Show("Create new Adminshell environment? This operation can not be reverted!", "AASX", MessageBoxButton.YesNo, MessageBoxImage.Warning)) || (Options.UseFlyovers && MessageBoxResult.Yes == MessageBoxFlyoutShow("Create new Adminshell environment? This operation can not be reverted!", "AASX", MessageBoxButton.YesNo, MessageBoxImage.Warning)) ) { try { // create new AASX package thePackageEnv = new AdminShell.PackageEnv(); // redraw everything RedrawAllAasxElements(); RedrawElementView(); } catch (Exception ex) { Log.Error(ex, "When creating new AASX, an error occurred"); return; } } } if (cmd == "open" || cmd == "openaux") { var dlg = new Microsoft.Win32.OpenFileDialog(); try { dlg.InitialDirectory = System.IO.Path.GetDirectoryName(thePackageEnv.Filename); } catch { } dlg.Filter = "AASX package files (*.aasx)|*.aasx|AAS XML file (*.xml)|*.xml|All files (*.*)|*.*"; if (Options.UseFlyovers) { this.StartFlyover(new EmptyFlyout()); } var res = dlg.ShowDialog(); if (Options.UseFlyovers) { this.CloseFlyover(); } if (res == true) { if (cmd == "open") { UiLoadPackageEnv(dlg.FileName); } if (cmd == "openaux") { UiLoadPackageAux(dlg.FileName); } } } if (cmd == "save") { try { // save thePackageEnv.SaveAs(thePackageEnv.Filename); // as saving changes the structure of pending supplementary files, re-display RedrawAllAasxElements(); } catch (Exception ex) { Log.Error(ex, "When saving AASX, an error occurred"); return; } Log.Info("AASX saved successfully: {0}", thePackageEnv.Filename); } if (cmd == "saveas") { var dlg = new Microsoft.Win32.SaveFileDialog(); try { dlg.InitialDirectory = System.IO.Path.GetDirectoryName(thePackageEnv.Filename); } catch { } dlg.FileName = thePackageEnv.Filename; dlg.DefaultExt = "*.aasx"; dlg.Filter = "AASX package files (*.aasx)|*.aasx|AAS XML file (*.xml)|*.xml|All files (*.*)|*.*"; if (Options.UseFlyovers) { this.StartFlyover(new EmptyFlyout()); } var res = dlg.ShowDialog(); if (Options.UseFlyovers) { this.CloseFlyover(); } if (res == true) { try { // save thePackageEnv.SaveAs(dlg.FileName); // as saving changes the structure of pending supplementary files, re-display RedrawAllAasxElements(); } catch (Exception ex) { Log.Error(ex, "When saving AASX, an error occurred"); return; } Log.Info("AASX saved successfully as: {0}", dlg.FileName); } } if (cmd == "close" && thePackageEnv != null) { if ((!Options.UseFlyovers && MessageBoxResult.Yes == MessageBox.Show(this, "Do you want to close the open package? Please make sure that you have saved before.", "Close Package?", MessageBoxButton.YesNo, MessageBoxImage.Question)) || (Options.UseFlyovers && MessageBoxResult.Yes == MessageBoxFlyoutShow("Do you want to close the open package? Please make sure that you have saved before.", "Close Package?", MessageBoxButton.YesNo, MessageBoxImage.Question)) ) { try { thePackageEnv.Close(); RedrawAllAasxElements(); } catch (Exception ex) { Log.Error(ex, "When closing AASX, an error occurred"); } } } if (cmd == "closeaux" && thePackageAux != null) { try { thePackageAux.Close(); } catch (Exception ex) { Log.Error(ex, "When closing auxiliary AASX, an error occurred"); } } if (cmd == "exit") { /* * if ((!Options.UseFlyovers && MessageBoxResult.Yes == MessageBox.Show(this, "Exit the application? Please make sure that you have saved before.", "Exit Application?", MessageBoxButton.YesNo, MessageBoxImage.Question)) || || (Options.UseFlyovers && MessageBoxResult.Yes == MessageBoxFlyoutShow("Exit the application? Please make sure that you have saved before.", "Exit Application?", MessageBoxButton.YesNo, MessageBoxImage.Question)) || ) */ System.Windows.Application.Current.Shutdown(); } if (cmd == "connect") { if (!Options.UseFlyovers) { MessageBox.Show(this, "In future versions, this feature will allow connecting to an online Administration Shell via OPC UA or similar.\n" + "This feature is scope of the specification 'Details of the Adminstration Shell Part 1 V1.1' and 'Part 2'.", "Connect", MessageBoxButton.OK); } else { MessageBoxFlyoutShow("In future versions, this feature will allow connecting to an online Administration Shell via OPC UA or similar.", "Connect", MessageBoxButton.OK, MessageBoxImage.Hand); } } if (cmd == "about") { var ab = new AboutBox(); ab.ShowDialog(); } if (cmd == "helpgithub") { theBrowser.Address = @"https://github.com/admin-shell/aasx-package-explorer/blob/master/help/index.md"; Dispatcher.BeginInvoke((Action)(() => ElementTabControl.SelectedIndex = 1)); } if (cmd == "editkey") { MenuItemWorkspaceEdit.IsChecked = !MenuItemWorkspaceEdit.IsChecked; } if (cmd == "hintskey") { MenuItemWorkspaceHints.IsChecked = !MenuItemWorkspaceHints.IsChecked; } if (cmd == "editmenu" || cmd == "editkey" || cmd == "hintsmenu" || cmd == "hintskey") { // edit mode affects the total element view RedrawAllAasxElements(); // fake selection RedrawElementView(); } if (cmd == "test") { /* * string err = null; * Log.Append(err + ""); * var p1 = new AdminShell.Property(); * p1.value = "42"; */ /* * var w1 = new AdminShell.SubmodelElementWrapper(); * w1.submodelElement = p1; * var w2 = new AdminShell.SubmodelElementWrapper(w1); */ // var w2 = new AdminShell.SubmodelElementWrapper(p1); var uc = new MessageBoxFlyout("My very long message text!", "Caption", MessageBoxButton.OK, MessageBoxImage.Error); uc.ControlClosed += () => { Log.Info("Yes!"); }; this.StartFlyover(uc); } if (cmd == "queryrepo") { var uc = new SelectFromRepositoryFlyout(); uc.Margin = new Thickness(10); if (uc.LoadAasxRepoFile(Options.AasxRepositoryFn)) { uc.ControlClosed += () => { var fn = uc.ResultFilename; if (fn != null && fn != "") { Log.Info("Switching to {0} ..", fn); UiLoadPackageEnv(fn); } }; this.StartFlyover(uc); } } }