Exemplo n.º 1
0
        /// <summary>
        /// Alerts listeners when the shape is dragged and dropped.
        /// </summary>
        /// <param name="e">The diagram drag event arguments.</param>
        public override void OnDragDrop(DiagramDragEventArgs e)
        {
            base.OnDragDrop(e);

            bool canArrangeShapes = NestedChildShapes.Count == 0;

            if (DragDropHelper.OnDragDropOnPackage(this, e))
            {
                if (canArrangeShapes)
                {
                    ArrangeShapes();
                }
                return;
            }

            if (e.Data.GetDataPresent(ServerExplorerHelper.DataSourceReferenceFormat))
            {
                if (ServerExplorerHelper.ContainsTable(e.Data))
                {
                    if (ServerExplorerHelper.ImportTables(ModelElement as Package,
                                                          new ServiceProvider(
                                                              (IServiceProvider)
                                                              ModelingPackage.GetGlobalService(typeof(DTE))),
                                                          e.Data))
                    {
                        if (canArrangeShapes)
                        {
                            ArrangeShapes();
                        }
                    }
                }
                if (ServerExplorerHelper.ContainsStoredProcedures(e.Data))
                {
                    if (ServerExplorerHelper.ImportStoredProcedures(ModelElement as Package,
                                                                    new ServiceProvider(
                                                                        (IServiceProvider)
                                                                        ModelingPackage.GetGlobalService(typeof(DTE))),
                                                                    e.Data))
                    {
                        if (canArrangeShapes)
                        {
                            ArrangeShapes();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Alerts listeners when the shape is dragged over its bounds.
        /// </summary>
        /// <param name="e">The diagram drag event arguments.</param>
        public override void OnDragOver(DiagramDragEventArgs e)
        {
            base.OnDragOver(e);

            if (DragDropHelper.OnDragOverPackage(this, e))
            {
                return;
            }

            if (e.Data.GetDataPresent(ServerExplorerHelper.DataSourceReferenceFormat))
            {
                if (ServerExplorerHelper.ContainsTable(e.Data) || ServerExplorerHelper.ContainsStoredProcedures(e.Data))
                {
                    e.Effect = DragDropEffects.Copy;
                }
            }
        }