/// <summary> /// Ask the user (before a prediction is made) for the name of the calibration model table and the destination table. /// </summary> /// <param name="modelTableName">On return, contains the name of the table containing the calibration model.</param> /// <param name="destinationTableName">On return, contains the name of the destination table, or null if a new table should be used as destination.</param> /// <returns>True if OK, false if the users pressed Cancel.</returns> public static bool QuestCalibrationModelAndDestinationTable(out string modelTableName, out string destinationTableName) { Altaxo.Worksheet.GUI.PLSPredictValueController ctrl = new Altaxo.Worksheet.GUI.PLSPredictValueController(); Altaxo.Worksheet.GUI.PLSPredictValueControl viewctrl = new PLSPredictValueControl(); ctrl.View = viewctrl; DialogShellController dlgctrl = new DialogShellController( new DialogShellView(viewctrl), ctrl); if (dlgctrl.ShowDialog(Current.MainWindow)) { modelTableName = ctrl.SelectedCalibrationTableName; destinationTableName = ctrl.SelectedDestinationTableName; return(true); } else { modelTableName = null; destinationTableName = null; return(false); } }
/// <summary> /// Shows a configuration dialog for an object. /// </summary> /// <param name="controller">The controller to show in the dialog</param> /// <param name="title">The title of the dialog to show.</param> /// <param name="showApplyButton">If true, the "Apply" button is visible on the dialog.</param> /// <returns>True if the object was successfully configured, false otherwise.</returns> public bool ShowDialog(IMVCAController controller, string title, bool showApplyButton) { if (controller.ViewObject == null) { FindAndAttachControlTo(controller); } if (controller.ViewObject == null) { throw new ArgumentException("Can't find a view object for controller of type " + controller.GetType()); } if (controller is Altaxo.Gui.Scripting.IScriptController) { System.Windows.Forms.Form dlgctrl = new Altaxo.Gui.Scripting.ScriptExecutionDialog((Altaxo.Gui.Scripting.IScriptController)controller); return(System.Windows.Forms.DialogResult.OK == dlgctrl.ShowDialog(Current.MainWindow)); } else { DialogShellController dlgctrl = new DialogShellController(new DialogShellView((System.Windows.Forms.UserControl)controller.ViewObject), controller, title, showApplyButton); return(dlgctrl.ShowDialog(Current.MainWindow)); } }
/// <summary> /// Shows a configuration dialog for an object. /// </summary> /// <param name="controller">The controller to show in the dialog</param> /// <param name="title">The title of the dialog to show.</param> /// <param name="showApplyButton">If true, the "Apply" button is visible on the dialog.</param> /// <returns>True if the object was successfully configured, false otherwise.</returns> private bool InternalShowDialog(IMVCAController controller, string title, bool showApplyButton) { if (controller.ViewObject == null) { FindAndAttachControlTo(controller); } if (controller.ViewObject == null) { throw new ArgumentException("Can't find a view object for controller of type " + controller.GetType()); } double startLocationLeft, startLocationTop; if (TopmostModalWindow.WindowState == System.Windows.WindowState.Maximized) { // if the topmost window is maximized, then the Top and Left property are nonsense // see https://stackoverflow.com/questions/9812756/window-top-and-left-values-are-not-updated-correctly-when-maximizing-a-window-in // about screen see here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/2ca2fab6-b349-4c08-915f-373c71bd636a/show-and-maximize-wpf-window-on-a-specific-screen?forum=wpf var screen = ScreenHandler.GetCurrentScreen(TopmostModalWindow); startLocationLeft = screen.Bounds.X; startLocationTop = screen.Bounds.Y; } else { startLocationTop = TopmostModalWindow.Top; startLocationLeft = TopmostModalWindow.Left; } if (controller.ViewObject is IViewRequiresSpecialShellWindow specialView) { var dlgctrl = (System.Windows.Window)Activator.CreateInstance(specialView.TypeOfShellWindowRequired, controller); dlgctrl.Owner = TopmostModalWindow; dlgctrl.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual; dlgctrl.Top = startLocationTop; dlgctrl.Left = startLocationLeft; return(true == InternalShowModalWindow(dlgctrl)); } if (controller.ViewObject is System.Windows.UIElement) { var dlgview = new DialogShellViewWpf((System.Windows.UIElement)controller.ViewObject) { Owner = TopmostModalWindow, WindowStartupLocation = System.Windows.WindowStartupLocation.Manual, Top = startLocationTop, Left = startLocationLeft }; var dlgctrl = new DialogShellController(dlgview, controller, title, showApplyButton); return(true == InternalShowModalWindow(dlgview)); } else { throw new NotSupportedException("This type of UIElement is not supported: " + controller.ViewObject.GetType().ToString()); /* * DialogShellView dlgview = new DialogShellView((System.Windows.Forms.UserControl)controller.ViewObject); * DialogShellController dlgctrl = new DialogShellController(dlgview, controller, title, showApplyButton); * return System.Windows.Forms.DialogResult.OK == dlgview.ShowDialog(MainWindow); */ } }