private void OnSelectionChanged(object sender, EventArgs e) { ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService)); this.TabControlSelected = false; if (service != null) { ICollection selectedComponents = service.GetSelectedComponents(); TabControl component = (TabControl)base.Component; foreach (object obj2 in selectedComponents) { if (obj2 == component) { this.TabControlSelected = true; } TabPage tabPageOfComponent = GetTabPageOfComponent(obj2); if ((tabPageOfComponent != null) && (tabPageOfComponent.Parent == component)) { this.TabControlSelected = false; component.SelectedTab = tabPageOfComponent; //Use reflection object selectionManager = this.GetService(ReflecionDesignHelper.GetType("System.Windows.Forms.Design.Behavior.SelectionManager", ReflecionDesignHelper.DesignAssembly)); ReflecionDesignHelper.InvokeMethod(selectionManager, "Refresh"); //((SelectionManager)this.GetService(typeof(SelectionManager))).Refresh(); break; } } } }
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); } }
private void OnGotFocus(object sender, EventArgs e) { //Use reflection Type eventHandlerService = ReflecionDesignHelper.GetType("System.Windows.Forms.Design.IEventHandlerService", ReflecionDesignHelper.DesignAssembly); object service = this.GetService(eventHandlerService); if (service != null) { Control focusWindow = (Control)ReflecionDesignHelper.InvokeProperty(service, "FocusWindow");; if (focusWindow != null) { focusWindow.Focus(); } } }