internal void MovePageToLeaf(TabGroupLeaf leaf) { // Remember original auto compact mode bool autoCompact = _tabbedGroups.AutoCompact; // Turn mode off as it interferes with reorganisation _tabbedGroups.AutoCompact = false; // Get the requested tab page to be moved to new leaf TabPage tp = _tabControl.SelectedTab; // Remove page from ourself _tabControl.TabPages.Remove(tp); // Add into the new leaf leaf.TabPages.Add(tp); // Make new leaf the active one _tabbedGroups.ActiveLeaf = leaf; TabControl tc = leaf.GroupControl as Controls.TabControl; // Select the newly added page tc.SelectedTab = tp; // Reset compacting mode as we have updated the structure _tabbedGroups.AutoCompact = autoCompact; // Do we need to compact? if (_tabbedGroups.AutoCompact) { _tabbedGroups.Compact(); } }
public TGContextMenuEventArgs(TabGroupLeaf tgl, Controls.TabControl tc, Controls.TabPage tp, PopupMenu contextMenu) : base(tgl, tc, tp) { // Definie initial state _contextMenu = contextMenu; }
public Target(Rectangle hotRect, Rectangle drawRect, TabGroupLeaf leaf, TargetActions action) { // Define state _hotRect = hotRect; _drawRect = drawRect; _leaf = leaf; _action = action; }
public TGCloseRequestEventArgs(TabGroupLeaf tgl, Controls.TabControl tc, Controls.TabPage tp) { // Definie initial state _tgl = tgl; _tc = tc; _tp = tp; _cancel = false; }
internal void NewHorizontalGroup(TabGroupLeaf sourceLeaf, bool before) { TabGroupSequence tgs = this.Parent as TabGroupSequence; // We must have a parent sequence! if (tgs != null) { tgs.Direction = Direction.Horizontal; AddGroupToSequence(tgs, sourceLeaf, before); } }
internal void OnMoveNext(object sender, EventArgs e) { // Find the previous leaf node TabGroupLeaf next = _tabbedGroups.NextLeaf(this); // Must always be valid! if (next != null) { MovePageToLeaf(next); } }
internal void OnMovePrevious(object sender, EventArgs e) { // Find the previous leaf node TabGroupLeaf prev = _tabbedGroups.PreviousLeaf(this); // Must always be valid! if (prev != null) { MovePageToLeaf(prev); } }
protected void AddGroupToSequence(TabGroupSequence tgs, TabGroupLeaf sourceLeaf, bool before) { // Remember original auto compact mode bool autoCompact = _tabbedGroups.AutoCompact; // Turn mode off as it interferes with reorganisation _tabbedGroups.AutoCompact = false; // Find our index into parent collection int pos = tgs.IndexOf(this); TabGroupLeaf newGroup = null; // New group inserted before existing one? if (before) { newGroup = tgs.InsertNewLeaf(pos); } else { // No, are we at the end of the collection? if (pos == (tgs.Count - 1)) { newGroup = tgs.AddNewLeaf(); } else { newGroup = tgs.InsertNewLeaf(pos + 1); } } // Get tab control for source leaf Controls.TabControl tc = sourceLeaf.GroupControl as Controls.TabControl; TabPage tp = tc.SelectedTab; // Remove page from ourself tc.TabPages.Remove(tp); // Add into the new leaf newGroup.TabPages.Add(tp); // Reset compacting mode as we have updated the structure _tabbedGroups.AutoCompact = autoCompact; // Do we need to compact? if (_tabbedGroups.AutoCompact) { _tabbedGroups.Compact(); } }
public override bool ContainsProminent(bool recurse) { // Cache the currently selected prominent group TabGroupLeaf prominent = _tabbedGroups.ProminentLeaf; // Valid value to test against? if (prominent != null) { return(this == prominent); } else { return(false); } }
public TargetManager(TabbedGroups host, TabGroupLeaf leaf, Controls.TabControl source) { // Define state _host = host; _leaf = leaf; _source = source; _lastTarget = null; // Create collection to hold generated targets _targets = new TargetCollection(); // Process each potential leaf in turn TabGroupLeaf tgl = host.FirstLeaf(); while (tgl != null) { // Create all possible targets for this leaf CreateTargets(tgl); // Enumerate all leafs tgl = host.NextLeaf(tgl); } }
protected void CreateTargets(TabGroupLeaf leaf) { // Grab the underlying tab control Controls.TabControl tc = leaf.GroupControl as Controls.TabControl; // Get the total size of the tab control itself in screen coordinates Rectangle totalSize = tc.RectangleToScreen(tc.ClientRectangle); // We do not allow a page to be transfered to its own leaf! if (leaf != _leaf) { Rectangle tabsSize = tc.RectangleToScreen(tc.TabsAreaRect); // Give priority to the tabs area being used to transfer page _targets.Add(new Target(tabsSize, totalSize, leaf, Target.TargetActions.Transfer)); } // Can only create new groups if moving relative to a new group // or we have more than one page in the originating group if ((leaf != _leaf) || ((leaf == _leaf) && _leaf.TabPages.Count > 1)) { int horzThird = totalSize.Width / 3; int vertThird = totalSize.Height / 3; // Create the four spacing rectangle Rectangle leftRect = new Rectangle(totalSize.X, totalSize.Y, horzThird, totalSize.Height); Rectangle rightRect = new Rectangle(totalSize.Right - horzThird, totalSize.Y, horzThird, totalSize.Height); Rectangle topRect = new Rectangle(totalSize.X, totalSize.Y, totalSize.Width, vertThird); Rectangle bottomRect = new Rectangle(totalSize.X, totalSize.Bottom - vertThird, totalSize.Width, vertThird); TabGroupSequence tgs = _leaf.Parent as TabGroupSequence; // Can only create new groups in same direction, unless this is the only leaf if (tgs.Count <= 1) { // Add each new target _targets.Add(new Target(leftRect, leftRect, leaf, Target.TargetActions.GroupLeft)); _targets.Add(new Target(rightRect, rightRect, leaf, Target.TargetActions.GroupRight)); _targets.Add(new Target(topRect, topRect, leaf, Target.TargetActions.GroupTop)); _targets.Add(new Target(bottomRect, bottomRect, leaf, Target.TargetActions.GroupBottom)); } else { if (tgs.Direction == Direction.Vertical) { _targets.Add(new Target(topRect, topRect, leaf, Target.TargetActions.GroupTop)); _targets.Add(new Target(bottomRect, bottomRect, leaf, Target.TargetActions.GroupBottom)); } else { _targets.Add(new Target(leftRect, leftRect, leaf, Target.TargetActions.GroupLeft)); _targets.Add(new Target(rightRect, rightRect, leaf, Target.TargetActions.GroupRight)); } } } // We do not allow a page to be transfered to its own leaf! if (leaf != _leaf) { // Any remaining space is used to _targets.Add(new Target(totalSize, totalSize, leaf, Target.TargetActions.Transfer)); } }