public bool InitializeDocument(params object[] args)
        {
            if (args.Length == 0 || (args[0] != null && !(args[0] is GridStyle)))
            {
                return(false);
            }

            bool isVirgin = null == _doc;

            _doc     = (GridStyle)args[0];
            _tempdoc = _doc;

            if (_useDocument == UseDocument.Copy && null != _doc)
            {
                _tempdoc = (GridStyle)_doc.Clone();
            }
            if (null == _doc)
            {
                _doc = _tempdoc = new GridStyle();
                _tempdoc.ShowGrid = false;
                _useDocument      = UseDocument.Directly;
            }

            Initialize(true);
            return(true);
        }
    /// <summary>
    /// Gets an <see cref="IMVCController" />  for a given document type.
    /// </summary>
    /// <param name="creationArgs">The argument list. The first element args[0] is the document for which the controller is searched. The following elements are
    /// optional, and are usually the parents of this document.</param>
    /// <param name="overrideArg0Type">If this parameter is not null, this given type is used instead of determining the type of the <c>arg[0]</c> argument.</param>
    /// <param name="expectedControllerType">Type of controller that you expect to return.</param>
    /// <param name="copyDocument">Determines wether to use the document directly or use a clone of the document.</param>
    /// <returns>The controller for that document when found.</returns>
    public IMVCController GetController(object[] creationArgs, System.Type overrideArg0Type, System.Type expectedControllerType, UseDocument copyDocument)
    {

      if (!ReflectionService.IsSubClassOfOrImplements(expectedControllerType, typeof(IMVCController)))
        throw new ArgumentException("Expected controller type has to be IMVCController or a subclass or derived class of this");

      object result = null;

      // 1st search for all classes that wear the UserControllerForObject attribute
      ReflectionService.IAttributeForClassList list = ReflectionService.GetAttributeInstancesAndClassTypesForClass(typeof(UserControllerForObjectAttribute), creationArgs[0], overrideArg0Type);

      foreach (Type definedType in list.Types)
      {
        if (ReflectionService.IsSubClassOfOrImplements(definedType, typeof(IMVCANController)))
        {
          IMVCANController mvcan = (IMVCANController)Activator.CreateInstance(definedType);
          mvcan.UseDocumentCopy = copyDocument;
          if(mvcan.InitializeDocument(creationArgs))
            result = mvcan;
        }
        else
        {
          result = ReflectionService.CreateInstanceFromList(list, new Type[] { expectedControllerType }, creationArgs);
        }

        if (result is IMVCController)
          break;
      }

      return (IMVCController)result;
    }
        private IMVCANController CreateAxisStyleController(AxisStyle doc, UseDocument useDocumentCopy)
        {
            var result = (AxisStyleController)Current.Gui.GetControllerAndControl(new object[] { doc }, typeof(AxisStyleController), useDocumentCopy);

            result.MadeDirty += EhAxisStyleControllerDirty;
            return(result);
        }
Beispiel #4
0
        private XYPlotLayerController(XYPlotLayer layer, string currentPage, int axisScaleIdx, CSLineID id, UseDocument useDocumentCopy)
        {
            _useDocumentCopy = useDocumentCopy == UseDocument.Copy;
            _currentAxisID   = id;
            _currentScale    = axisScaleIdx;
            _currentPageName = currentPage;

            InitializeDocument(layer);
        }
Beispiel #5
0
 public XYPlotLayerController(XYPlotLayer layer, string currentPage, CSLineID id, UseDocument useDocumentCopy)
     : this(layer, currentPage, id.ParallelAxisNumber, id, useDocumentCopy)
 {
 }
Beispiel #6
0
 public XYPlotLayerController(XYPlotLayer layer, UseDocument useDocumentCopy)
     : this(layer, "Scale", 1, null, useDocumentCopy)
 {
 }
 private static IMVCANController InternalCreateController(TModel doc, UseDocument useDocumentCopy)
 {
     return((IMVCANController)Current.Gui.GetControllerAndControl(new object[] { doc }, typeof(IMVCANController), useDocumentCopy));
 }
    public bool InitializeDocument(params object[] args)
    {
      if (args.Length == 0 || (args[0]!=null && !(args[0] is GridStyle)))
        return false;

      bool isVirgin = null == _doc;
      _doc = (GridStyle)args[0];
      _tempdoc = _doc;

      if(_useDocument == UseDocument.Copy && null!=_doc)
      {
        _tempdoc = (GridStyle)_doc.Clone();
      }
      if (null == _doc)
      {
        _doc = _tempdoc = new GridStyle();
        _tempdoc.ShowGrid = false;
        _useDocument = UseDocument.Directly;
      }

      Initialize(true);
      return true;
    }
Beispiel #9
0
        private XYPlotLayerController(XYZPlotLayer layer, string currentPage, int axisScaleIdx, CSLineID id, UseDocument useDocumentCopy)
        {
            if (!id.Is3DIdentifier)
            {
                throw new ArgumentException(nameof(id) + " has to be a 3D identifier!");
            }

            _useDocumentCopy = useDocumentCopy == UseDocument.Copy;
            _currentAxisID   = id;
            _currentScale    = axisScaleIdx;
            _currentPageName = currentPage;

            InitializeDocument(layer);
        }
		private IMVCANController CreateAxisStyleController(AxisStyle doc, UseDocument useDocumentCopy)
		{
			var result = (AxisStyleController)Current.Gui.GetControllerAndControl(new object[] { doc }, typeof(AxisStyleController), useDocumentCopy);
			result.MadeDirty += EhAxisStyleControllerDirty;
			return result;
		}
 /// <summary>
 /// Gets an <see cref="IMVCController" />  for a given document type.
 /// </summary>
 /// <param name="args">The argument list. The first element args[0] is the document for which the controller is searched. The following elements are
 /// optional, and are usually the parents of this document.</param>
 /// <param name="expectedControllerType">Type of controller that you expect to return.</param>
 /// <param name="copyDocument">Determines whether to work directly with the document or use a copy.</param>
 /// <returns>The controller for that document when found. The controller is already initialized with the document. If not found, null is returned.</returns>
 public IMVCController GetController(object[] args, System.Type expectedControllerType, UseDocument copyDocument)
 {
   return GetController(args, null, expectedControllerType, copyDocument);
 }
    /// <summary>
    /// Gets an <see cref="IMVCController" />  for a given document type, and finding the right GUI user control for it.
    /// </summary>
    /// <param name="args">The argument list. The first element args[0] is the document for which the controller is searched. The following elements are
    /// optional, and are usually the parents of this document.</param>
    /// <param name="overrideArg0Type">If this parameter is not null, this given type is used instead of determining the type of the <c>arg[0]</c> argument.</param>
    /// <param name="expectedControllerType">Type of controller that you expect to return.</param>
    /// <param name="copyDocument">Determines whether to use the document directly or a cloned copy.</param>
    /// <returns>The controller for that document when found. The controller is already initialized with the document. If no controller is found for the document, or if no GUI control is found for the controller, the return value is null.</returns>
    public IMVCController GetControllerAndControl(object[] args, System.Type overrideArg0Type, System.Type expectedControllerType, UseDocument copyDocument)
    {

      if (!ReflectionService.IsSubClassOfOrImplements(expectedControllerType, typeof(IMVCController)))
        throw new ArgumentException("Expected controller type has to be IMVCController or a subclass or derived class of this");

      IMVCController controller = GetController(args, overrideArg0Type, typeof(IMVCController), copyDocument);
      if (controller == null)
        return null;

      FindAndAttachControlTo(controller);

      return controller;
    }
Beispiel #13
0
        /// <summary>
        /// Gets an <see cref="IMVCController" />  for a given document type.
        /// </summary>
        /// <param name="creationArgs">The argument list. The first element args[0] is the document for which the controller is searched. The following elements are
        /// optional, and are usually the parents of this document.</param>
        /// <param name="overrideArg0Type">If this parameter is not null, this given type is used instead of determining the type of the <c>arg[0]</c> argument.</param>
        /// <param name="expectedControllerType">Type of controller that you expect to return.</param>
        /// <param name="copyDocument">Determines wether to use the document directly or use a clone of the document.</param>
        /// <returns>The controller for that document when found.</returns>
        public IMVCController GetController(object[] creationArgs, System.Type overrideArg0Type, System.Type expectedControllerType, UseDocument copyDocument)
        {
            if (!ReflectionService.IsSubClassOfOrImplements(expectedControllerType, typeof(IMVCController)))
            {
                throw new ArgumentException("Expected controller type has to be IMVCController or a subclass or derived class of this");
            }

            object result = null;

            // 1st search for all classes that wear the UserControllerForObject attribute
            ReflectionService.IAttributeForClassList list = ReflectionService.GetAttributeInstancesAndClassTypesForClass(typeof(UserControllerForObjectAttribute), creationArgs[0], overrideArg0Type);

            foreach (Type definedType in list.Types)
            {
                if (ReflectionService.IsSubClassOfOrImplements(definedType, typeof(IMVCANController)))
                {
                    IMVCANController mvcan = (IMVCANController)Activator.CreateInstance(definedType);
                    mvcan.UseDocumentCopy = copyDocument;
                    if (mvcan.InitializeDocument(creationArgs))
                    {
                        result = mvcan;
                    }
                }
                else
                {
                    result = ReflectionService.CreateInstanceFromList(list, new Type[] { expectedControllerType }, creationArgs);
                }

                if (result is IMVCController)
                {
                    break;
                }
            }

            return((IMVCController)result);
        }
Beispiel #14
0
 /// <summary>
 /// Gets an <see cref="IMVCController" />  for a given document type.
 /// </summary>
 /// <param name="args">The argument list. The first element args[0] is the document for which the controller is searched. The following elements are
 /// optional, and are usually the parents of this document.</param>
 /// <param name="expectedControllerType">Type of controller that you expect to return.</param>
 /// <param name="copyDocument">Determines whether to work directly with the document or use a copy.</param>
 /// <returns>The controller for that document when found. The controller is already initialized with the document. If not found, null is returned.</returns>
 public IMVCController GetController(object[] args, System.Type expectedControllerType, UseDocument copyDocument)
 {
     return(GetController(args, null, expectedControllerType, copyDocument));
 }
Beispiel #15
0
        /// <summary>
        /// Gets an <see cref="IMVCController" />  for a given document type, and finding the right GUI user control for it.
        /// </summary>
        /// <param name="args">The argument list. The first element args[0] is the document for which the controller is searched. The following elements are
        /// optional, and are usually the parents of this document.</param>
        /// <param name="overrideArg0Type">If this parameter is not null, this given type is used instead of determining the type of the <c>arg[0]</c> argument.</param>
        /// <param name="expectedControllerType">Type of controller that you expect to return.</param>
        /// <param name="copyDocument">Determines whether to use the document directly or a cloned copy.</param>
        /// <returns>The controller for that document when found. The controller is already initialized with the document. If no controller is found for the document, or if no GUI control is found for the controller, the return value is null.</returns>
        public IMVCController GetControllerAndControl(object[] args, System.Type overrideArg0Type, System.Type expectedControllerType, UseDocument copyDocument)
        {
            if (!ReflectionService.IsSubClassOfOrImplements(expectedControllerType, typeof(IMVCController)))
            {
                throw new ArgumentException("Expected controller type has to be IMVCController or a subclass or derived class of this");
            }

            IMVCController controller = GetController(args, overrideArg0Type, typeof(IMVCController), copyDocument);

            if (controller == null)
            {
                return(null);
            }

            FindAndAttachControlTo(controller);

            return(controller);
        }
Beispiel #16
0
        /// <summary>
        /// Gets an <see cref="IMVCController" />  for a given document type, and finding the right GUI user control for it.
        /// </summary>
        /// <param name="args">The argument list. The first element args[0] is the document for which the controller is searched. The following elements are
        /// optional, and are usually the parents of this document.</param>
        /// <param name="overrideArg0Type">If this parameter is not null, this given type is used instead of determining the type of the <c>arg[0]</c> argument.</param>
        /// <param name="expectedControllerType">Type of controller that you expect to return.</param>
        /// <param name="copyDocument">Determines whether to use the document directly or a cloned copy.</param>
        /// <returns>The controller for that document when found. The controller is already initialized with the document. If no controller is found for the document, or if no GUI control is found for the controller, the return value is null.</returns>
        public IMVCController GetControllerAndControl(object[] args, System.Type overrideArg0Type, System.Type expectedControllerType, UseDocument copyDocument)
        {
            if (!typeof(IMVCController).IsAssignableFrom(expectedControllerType))
            {
                throw new ArgumentException("Expected controller type has to be IMVCController or a subclass or derived class of this");
            }

            IMVCController controller = GetController(args, overrideArg0Type, expectedControllerType, copyDocument);

            if (controller == null)
            {
                return(null);
            }

            FindAndAttachControlTo(controller);
            return(controller);
        }