Exemple #1
0
        void Initialize(bool bInit)
        {
            if (_view != null)
            {
                // look for coordinate system types
                Type[] subtypes = Main.Services.ReflectionService.GetNonAbstractSubclassesOf(typeof(G2DCoordinateSystem));

                ListNodeList list = new ListNodeList();
                foreach (Type t in subtypes)
                {
                    list.Add(new ListNode(Current.Gui.GetUserFriendlyClassName(t), t));
                }

                // look for a controller-control
                _view.TypeLabel = "Type";
                _view.InitializeTypeNames(list, list.IndexOfObject(_tempdoc.GetType()));

                // To avoid looping when a dedicated controller is unavailable, we first instantiate the controller alone and compare the types
                _instanceController = (IMVCAController)Current.Gui.GetController(new object[] { _tempdoc }, typeof(IMVCAController));
                if (_instanceController != null && (_instanceController.GetType() != this.GetType()))
                {
                    Current.Gui.FindAndAttachControlTo(_instanceController);
                    if (_instanceController.ViewObject != null)
                    {
                        _view.SetInstanceControl(_instanceController.ViewObject);
                    }
                }
                else
                {
                    _instanceController = null;
                    _view.SetInstanceControl(null);
                }
            }
        }
    void Initialize(bool bInit)
    {
      if (_view != null)
      {
        // look for coordinate system types
        Type[] subtypes = Main.Services.ReflectionService.GetNonAbstractSubclassesOf(typeof(G2DCoordinateSystem));

        ListNodeList list = new ListNodeList();
        foreach(Type t in subtypes)
          list.Add(new ListNode(Current.Gui.GetUserFriendlyClassName(t), t));

        // look for a controller-control
        _view.TypeLabel="Type";
        _view.InitializeTypeNames(list, list.IndexOfObject(_tempdoc.GetType()));

        // To avoid looping when a dedicated controller is unavailable, we first instantiate the controller alone and compare the types
        _instanceController = (IMVCAController)Current.Gui.GetController(new object[] { _tempdoc }, typeof(IMVCAController));
        if (_instanceController != null && (_instanceController.GetType() != this.GetType()))
        {
          Current.Gui.FindAndAttachControlTo(_instanceController);
          if (_instanceController.ViewObject != null)
            _view.SetInstanceControl(_instanceController.ViewObject);
        }
        else
        {
          _instanceController = null;
          _view.SetInstanceControl(null);
        }
      }
    }
Exemple #3
0
        public void InitDetailController(bool bInit)
        {
            if (bInit)
            {
                object providerObject = _doc;

                if (_detailController is IMVCANDController)
                {
                    ((IMVCANDController)_detailController).MadeDirty -= EhDetailsChanged;
                }

                _detailController = (IMVCAController)Current.Gui.GetControllerAndControl(new object[] { providerObject }, typeof(IMVCANController), UseDocument.Directly);

                if (null != _detailController && GetType() == _detailController.GetType()) // the returned controller is of this common type here -> thus no specialized controller seems to exist for this type of color provider
                {
                    _detailController.Dispose();
                    _detailController = null;
                }

                if (_detailController is IMVCANDController)
                {
                    ((IMVCANDController)_detailController).MadeDirty += EhDetailsChanged;
                }
            }
            if (null != _view)
            {
                _detailView = null == _detailController ? null : _detailController.ViewObject;
                _view.SetDetailView(_detailView);
            }
        }
        protected override void Initialize(bool initData)
        {
            base.Initialize(initData);

            if (initData)
            {
                // look for coordinate system types
                if (null == _cosSubTypes)
                {
                    _cosSubTypes = ReflectionService.GetNonAbstractSubclassesOf(typeof(G3DCoordinateSystem));
                }

                if (null == _choiceList)
                {
                    _choiceList = new SelectableListNodeList();
                }
                _choiceList.Clear();
                foreach (Type t in _cosSubTypes)
                {
                    _choiceList.Add(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(t), t, t == _doc.GetType()));
                }
            }

            if (_view != null)
            {
                // look for a controller-control
                _view.TypeLabel = "Type:";
                _view.InitializeTypeNames(_choiceList);

                // To avoid looping when a dedicated controller is unavailable, we first instantiate the controller alone and compare the types
                _instanceController = (IMVCAController)Current.Gui.GetController(new object[] { _doc }, typeof(IMVCAController), UseDocument.Directly);
                if (_instanceController != null && (_instanceController.GetType() != GetType()))
                {
                    Current.Gui.FindAndAttachControlTo(_instanceController);
                    if (_instanceController.ViewObject != null)
                    {
                        _view.SetInstanceControl(_instanceController.ViewObject);
                    }
                }
                else
                {
                    _instanceController = null;
                    _view.SetInstanceControl(null);
                }
            }
        }
    /// <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);
      }
    }
        /// <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);
                 */
            }
        }
		/// <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);
				*/
			}
		}
Exemple #8
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 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));
            }
        }