Пример #1
0
        /// <summary>
        /// Import d'un service
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="e">The <see cref="Microsoft.VisualStudio.Modeling.Diagrams.DiagramDragEventArgs"/> instance containing the event data.</param>
        internal static void OnDragDropOnLayer(NodeShape shape, DiagramDragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.Text))
            {
                string txt = (string)e.Data.GetData(DataFormats.Text);
                using (
                    Transaction transaction =
                        shape.ModelElement.Store.TransactionManager.BeginTransaction("Import interface"))
                {
                    // On ne veut pas que les assistants soient appelés
                    shape.ModelElement.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.
                    ContextInfo[StrategyManager.IgnoreStrategyWizards] = true;

                    IImportInterfaceHelper importer = ServiceLocator.Instance.GetService <IImportInterfaceHelper>();
                    if (importer == null)
                    {
                        return;
                    }
                    if (importer.ImportOperations(shape.ModelElement as SoftwareLayer, null, txt))
                    {
                        shape.RebuildShape();
                        transaction.Commit();
                    }
                }

                using (
                    Transaction transaction =
                        shape.ModelElement.Store.TransactionManager.BeginTransaction("Arrange ports"))
                {
                    LayerHelper.ArrangePorts(shape, typeof(ServiceContractShape));
                    transaction.Commit();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Import d'un service
        /// </summary>
        /// <param name="e">The diagram drag event arguments.</param>
        public override void OnDragDrop(DiagramDragEventArgs e)
        {
            base.OnDragDrop(e);

            if (e.Data.GetDataPresent(DataFormats.Text))
            {
                string txt = (string)e.Data.GetData(DataFormats.Text);
                using (
                    Transaction transaction = ModelElement.Store.TransactionManager.BeginTransaction("Import interface")
                    )
                {
                    IImportInterfaceHelper importer = ServiceLocator.Instance.GetService <IImportInterfaceHelper>();
                    if (importer == null)
                    {
                        return;
                    }
                    if (importer.ImportOperations(ModelElement as Layer, null, txt))
                    {
                        RebuildShape();
                        transaction.Commit();
                    }
                }
            }
        }