Ejemplo n.º 1
0
        /// <summary>
        /// Disposes of this object, its toos, dialogs, shelves and workspaces.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                if (_desktopTools != null)
                {
                    _desktopTools.Dispose();
                }

                if (_dialogs != null)
                {
                    (_dialogs as IDisposable).Dispose();
                }

                if (_workspaces != null)
                {
                    (_workspaces as IDisposable).Dispose();
                }

                if (_shelves != null)
                {
                    (_shelves as IDisposable).Dispose();
                }

                // These types of objects (particularly tools) can subscribe to each other's events
                // so we set everything to null at the end to allow objects to unsubscribe on disposal.
                _desktopTools = null;
                _dialogs      = null;
                _workspaces   = null;
                _shelves      = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Dispose pattern.
        /// </summary>
        /// <param name="disposing"></param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_operationEnablementTask != null)
                {
                    _operationEnablementTask.Dispose();
                    _operationEnablementTask = null;
                }

                foreach (var folder in _workflowFolders)
                {
                    folder.Dispose();
                }

                if (_itemTools != null)
                {
                    _itemTools.Dispose();
                    _itemTools = null;
                }
                if (_folderTools != null)
                {
                    _folderTools.Dispose();
                    _folderTools = null;
                }
            }
        }
 protected override IActionSet CreateToolActions()
 {
     if (_toolSet == null)
     {
         _toolSet = new ToolSet(new KeyImageClipboardComponentToolExtensionPoint(), new ClipboardToolContext(this));
     }
     return(_actionSet ?? (_actionSet = new ActionSet(_toolSet.Actions)));
 }
Ejemplo n.º 4
0
 private void InitializeSlaveTools()
 {
     _toolSet = new ToolSet(this.CreateTools(), new ToolContext(this.ImageViewer));
     foreach (T tool in _toolSet.Tools)
     {
         this.OnToolInitialized(tool);
     }
 }
Ejemplo n.º 5
0
 protected virtual IActionSet CreateToolActions()
 {
     if (_toolSet == null)
     {
         _toolSet = new ToolSet(new ClipboardToolExtensionPoint(), new ClipboardToolContext(this));
     }
     return(new ActionSet(_toolSet.Actions));
 }
        /// <summary>
        /// Gets a set of exported <see cref="IAction"/>s.
        /// </summary>
        /// <param name="site">The action model site at which the actions should reside.</param>
        /// <param name="mouseInformation">The mouse input when the action model was requested, such as in response to a context menu request.</param>
        /// <returns>A set of exported <see cref="IAction"/>s.</returns>
        public override IActionSet GetExportedActions(string site, IMouseInformation mouseInformation)
        {
            if (!HitTest(mouseInformation.Location))
            {
                return(new ActionSet());
            }

            if (_toolSet == null)
            {
                _toolSet = new ToolSet(new GraphicToolExtensionPoint(), new GraphicToolContext(this));
            }

            return(base.GetExportedActions(site, mouseInformation).Union(_toolSet.Actions));
        }
Ejemplo n.º 7
0
        private void DisposeSlaveTools()
        {
            this._actionSet   = null;
            this.SelectedTool = null;

            if (_toolSet != null)
            {
                foreach (T tool in _toolSet.Tools)
                {
                    this.OnToolDisposing(tool);
                }
                _toolSet.Dispose();
                _toolSet = null;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates the desktop tools (via <see cref="DesktopToolExtensionPoint"/>) and initializes
        /// the view.
        /// </summary>
        protected override void OnOpened(EventArgs args)
        {
            // note that we can't do this initialize in the Initialize override because the view has not been created yet
            // initialization of desktop tools must occur after the desktop view has been created
            _desktopTools = new ToolSet(new DesktopToolExtensionPoint(), new DesktopToolContext(this));

            // initialize menu and toolbar models
            UpdateView();

            // when the active workspace changes, assume that the menu/toolbar models have also changed
            _workspaces.ItemActivationChanged += delegate(object sender, ItemEventArgs <Workspace> e)
            {
                UpdateView();
                UpdateTitleChangedEventSubscription(e.Item);
            };

            base.OnOpened(args);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Called by the host to initialize the application component.
        /// </summary>
        public override void Start()
        {
            base.Start();

            ClipboardToolContext toolContext = new ClipboardToolContext(this);

            _toolSet = new ToolSet(new ClipboardToolExtensionPoint(), toolContext);

            _resolver = new ApplicationThemeResourceResolver(GetType(), true);
            ActionSet  toolActions       = new ActionSet(_toolSet.Actions);
            ActionSet  deleteToolActions = new ActionSet(GetDeleteActions());
            IActionSet allActions        = toolActions.Union(deleteToolActions);

            _toolbarModel     = ActionModelRoot.CreateModel(typeof(ClipboardComponent).FullName, _toolbarSite, allActions);
            _contextMenuModel = ActionModelRoot.CreateModel(typeof(ClipboardComponent).FullName, _menuSite, allActions);

            _items.BindingList.ListChanged += OnBindingListChanged;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Called by the host when the application component is being terminated.
        /// </summary>
        public override void Stop()
        {
            _items.BindingList.ListChanged -= OnBindingListChanged;

            if (_disposeItemsOnClose)
            {
                foreach (IClipboardItem item in _items)
                {
                    if (item is IDisposable)
                    {
                        ((IDisposable)item).Dispose();
                    }
                }
            }

            _toolSet.Dispose();
            _toolSet = null;

            base.Stop();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Constructs a <see cref="GalleryComponent"/> with the specified data source, automatically adding the actions of
        /// <see cref="GalleryToolExtensionPoint"/>s at the specified action sites.
        /// </summary>
        /// <param name="dataSource">An <see cref="IBindingList"/> of <see cref="IGalleryItem"/>s.</param>
        /// <param name="toolbarSite">The site for toolbar actions.</param>
        /// <param name="contextMenuSite">The site for context menu actions.</param>
        public GalleryComponent(IBindingList dataSource, string toolbarSite, string contextMenuSite)
        {
            _dataSource = dataSource;

            if (toolbarSite != null || contextMenuSite != null)
            {
                GalleryToolExtensionPoint xp = new GalleryToolExtensionPoint();
                ToolContext context          = new ToolContext(this);
                ToolSet     ts = new ToolSet(xp, context);

                if (contextMenuSite != null)
                {
                    _menuModel = ActionModelRoot.CreateModel(typeof(GalleryComponent).FullName, contextMenuSite, ts.Actions);
                }
                if (toolbarSite != null)
                {
                    _toolbarModel = ActionModelRoot.CreateModel(typeof(GalleryComponent).FullName, toolbarSite, ts.Actions);
                }

                _toolSet = ts;
            }
        }
Ejemplo n.º 12
0
		/// <summary>
		/// Gets a set of exported <see cref="IAction"/>s.
		/// </summary>
		/// <param name="site">The action model site at which the actions should reside.</param>
		/// <param name="mouseInformation">The mouse input when the action model was requested, such as in response to a context menu request.</param>
		/// <returns>A set of exported <see cref="IAction"/>s.</returns>
		public override IActionSet GetExportedActions(string site, IMouseInformation mouseInformation)
		{
			if (!HitTest(mouseInformation.Location))
				return new ActionSet();

			if (_toolSet == null)
				_toolSet = new ToolSet(new GraphicToolExtensionPoint(), new GraphicToolContext(this));

			return base.GetExportedActions(site, mouseInformation).Union(_toolSet.Actions);
		}