コード例 #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>
        /// Paste's the clipboard into the active context</summary>
        public void Paste()
        {
            IInstancingContext instancingContext = m_contextRegistry.GetActiveContext <IInstancingContext>();

            if (instancingContext != null &&
                instancingContext.CanInsert(Clipboard))
            {
                ITransactionContext transactionContext = instancingContext.As <ITransactionContext>();
                transactionContext.DoTransaction(
                    delegate
                {
                    instancingContext.Insert(Clipboard);
                }, CommandInfo.EditPaste.MenuText);

                OnPasted(EventArgs.Empty);
            }
        }