Ejemplo n.º 1
0
    /// <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 override 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.ScriptExecutionDialogWin((Altaxo.Gui.Scripting.IScriptController)controller);
        return (System.Windows.Forms.DialogResult.OK == dlgctrl.ShowDialog(MainWindow));
      }
      else
      {
        DialogShellView dlgview = new DialogShellView((System.Windows.Forms.UserControl)controller.ViewObject);
        DialogShellController dlgctrl = new DialogShellController(dlgview, controller, title, showApplyButton);
        return DialogResult.OK == dlgview.ShowDialog(MainWindow);
      }
    }
Ejemplo n.º 2
0
    /// <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;
      }
    }
Ejemplo n.º 3
0
		/// <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);
				*/
			}
		}