Exemple #1
0
        protected override void OnDragEnter(DragEventArgs de)
        {
            ((MgTabControl)this.Control).IsDragging = true;
            this.ForwardOnDrag = false;
            /*"System.Windows.Forms.Design.Behavior.DropSourceBehavior.BehaviorDataObject"*/
            // DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject;
            Object data = de.Data;

            if (data != null && ReflecionDesignHelper.IsAssignableFrom(data, "System.Windows.Forms.Design.Behavior.DropSourceBehavior+BehaviorDataObject", ReflecionDesignHelper.FormsAssembly))
            {
                int primaryControlIndex = -1;
                //ArrayList sortedDragControls = data.GetSortedDragControls(ref primaryControlIndex);


                //Use reflection
                Type type = ReflecionDesignHelper.GetType("System.Windows.Forms.Design.Behavior.DropSourceBehavior+BehaviorDataObject", ReflecionDesignHelper.FormsAssembly);
                System.Reflection.MethodInfo method = type.GetMethod("GetSortedDragControls", BindingFlags.NonPublic | BindingFlags.Instance);
                object[] args = new object[1];
                args[0] = primaryControlIndex;
                ArrayList sortedDragControls = (ArrayList)method.Invoke(data, args);

                if (sortedDragControls != null)
                {
                    for (int i = 0; i < sortedDragControls.Count; i++)
                    {
                        if (!(sortedDragControls[i] is Control) || ((sortedDragControls[i] is Control) && !(sortedDragControls[i] is TabPage)))
                        {
                            this.ForwardOnDrag = true;
                            break;
                        }
                    }
                }
            }
            else
            {
                this.ForwardOnDrag = true;
            }
            if (this.ForwardOnDrag)
            {
                TabPageDesigner selectedTabPageDesigner = this.GetSelectedTabPageDesigner();
                if (selectedTabPageDesigner != null)
                {
                    selectedTabPageDesigner.OnDragEnterInternal(de);
                }
            }
            else
            {
                base.OnDragEnter(de);
            }
        }
Exemple #2
0
        protected TabPageDesigner GetSelectedTabPageDesigner()
        {
            TabPageDesigner designer    = null;
            TabPage         selectedTab = ((TabControl)base.Component).SelectedTab;

            if (selectedTab != null)
            {
                IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost));
                if (service != null)
                {
                    designer = service.GetDesigner(selectedTab) as TabPageDesigner;
                }
            }
            return(designer);
        }
Exemple #3
0
 protected override void OnGiveFeedback(GiveFeedbackEventArgs e)
 {
     if (this.ForwardOnDrag)
     {
         TabPageDesigner selectedTabPageDesigner = this.GetSelectedTabPageDesigner();
         if (selectedTabPageDesigner != null)
         {
             selectedTabPageDesigner.OnGiveFeedbackInternal(e);
         }
     }
     else
     {
         base.OnGiveFeedback(e);
     }
 }
Exemple #4
0
        protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize)
        {
            TabControl control = (TabControl)this.Control;

            if (control.SelectedTab == null)
            {
                throw new ArgumentException("TabControlInvalidTabPageType");
            }
            IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (service != null)
            {
                TabPageDesigner toInvoke = (TabPageDesigner)service.GetDesigner(control.SelectedTab);
                ParentControlDesigner.InvokeCreateTool(toInvoke, tool);
            }
            return(null);
        }
Exemple #5
0
 protected override void OnDragLeave(EventArgs e)
 {
     if (this.ForwardOnDrag)
     {
         TabPageDesigner selectedTabPageDesigner = this.GetSelectedTabPageDesigner();
         if (selectedTabPageDesigner != null)
         {
             selectedTabPageDesigner.OnDragLeaveInternal(e);
         }
     }
     else
     {
         base.OnDragLeave(e);
     }
     this.ForwardOnDrag = false;
     ((MgTabControl)this.Control).IsDragging = false;
 }
Exemple #6
0
 protected override void OnDragOver(DragEventArgs de)
 {
     if (this.ForwardOnDrag)
     {
         TabControl control = (TabControl)this.Control;
         Point      pt      = this.Control.PointToClient(new Point(de.X, de.Y));
         if (!control.DisplayRectangle.Contains(pt))
         {
             de.Effect = DragDropEffects.None;
         }
         else
         {
             TabPageDesigner selectedTabPageDesigner = this.GetSelectedTabPageDesigner();
             if (selectedTabPageDesigner != null)
             {
                 selectedTabPageDesigner.OnDragOverInternal(de);
             }
         }
     }
     else
     {
         base.OnDragOver(de);
     }
 }