Пример #1
0
        private void Delete(string commandName)
        {
            OnDeleting(EventArgs.Empty);

            IInstancingContext instancingContext = m_contextRegistry.GetActiveContext <IInstancingContext>();

            if (instancingContext != null &&
                instancingContext.CanDelete())
            {
                ITransactionContext transactionContext = instancingContext.As <ITransactionContext>();
                transactionContext.DoTransaction(
                    delegate
                {
                    instancingContext.Delete();

                    ISelectionContext selectionContext = instancingContext.As <ISelectionContext>();
                    if (selectionContext != null)
                    {
                        selectionContext.Clear();
                    }
                }, commandName);
            }

            OnDeleted(EventArgs.Empty);
        }
Пример #2
0
        /// <summary>
        /// Returns a value indicating if the active context can delete the selection</summary>
        /// <returns>True iff the active context can delete the selection</returns>
        public bool CanDelete()
        {
            IInstancingContext instancingContext = m_contextRegistry.GetActiveContext <IInstancingContext>();

            return
                (instancingContext != null &&
                 instancingContext.CanDelete());
        }
        /// <summary>
        /// Checks whether the client can do the command, if it handles it</summary>
        /// <param name="commandTag">Command to be done</param>
        /// <returns>True iff client can do the command</returns>
        bool ICommandClient.CanDoCommand(object commandTag)
        {
            bool canDo = false;

            IInstancingContext instancingContext = m_contextRegistry.GetActiveContext <IInstancingContext>();

            switch ((StandardCommand)commandTag)
            {
            case StandardCommand.EditCut:
                canDo =
                    instancingContext != null &&
                    instancingContext.CanCopy() &&
                    instancingContext.CanDelete();
                break;

            case StandardCommand.EditDelete:
                canDo =
                    instancingContext != null &&
                    instancingContext.CanDelete();
                break;

            case StandardCommand.EditCopy:
                canDo =
                    instancingContext != null &&
                    instancingContext.CanCopy();
                break;

            case StandardCommand.EditPaste:
                canDo =
                    instancingContext != null &&
                    CanPaste();
                break;
            }

            return(canDo);
        }