/// <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()); if (controller is Altaxo.Gui.Scripting.IScriptController) { var dlgctrl = new Altaxo.Gui.Scripting.ScriptExecutionDialog((Altaxo.Gui.Scripting.IScriptController)controller); dlgctrl.Owner = TopmostModalWindow; dlgctrl.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual; dlgctrl.Top = TopmostModalWindow.Top; dlgctrl.Left = TopmostModalWindow.Left; return (true == InternalShowModalWindow(dlgctrl)); } else if (controller.ViewObject is System.Windows.UIElement) { var dlgview = new DialogShellViewWpf((System.Windows.UIElement)controller.ViewObject); dlgview.Owner = TopmostModalWindow; dlgview.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual; dlgview.Top = TopmostModalWindow.Top; dlgview.Left = TopmostModalWindow.Left; 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); */ } }
/// <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)); } }