public void AddContent(Content content, StringCollection next, StringCollection previous, StringCollection nextAll, StringCollection previousAll) { int nextIndex = 0; int previousIndex = 0; TabStub nextTabStub = null; TabStub previousTabStub = null; TabStub nextAllTabStub = null; TabStub previousAllTabStub = null; int controlCount = this.Controls.Count; // Process each TabStub in turn for(int controlIndex=controlCount-1; controlIndex>=0; controlIndex--) { TabStub ts = this.Controls[controlIndex] as TabStub; // Process each Page in the TabStub foreach(Crownwood.Magic.Controls.TabPage page in ts.TabPages) { Content c = page.Tag as Content; // Always use the last 'previous' discovered if (previous.Contains(c.Title)) { previousIndex = ts.TabPages.IndexOf(page); previousTabStub = ts; } // Only remember the first 'next' discovered if (next.Contains(c.Title)) { if (nextTabStub == null) { nextIndex = ts.TabPages.IndexOf(page); nextTabStub = ts; } } // Always use the last 'previousAll' discovered if (previousAll.Contains(c.Title)) previousAllTabStub = ts; // Only remember the first 'next' discovered if (nextAll.Contains(c.Title)) { if (nextAllTabStub == null) nextAllTabStub = ts; } } } // If no matches at all found if ((previousTabStub == null) && (nextTabStub == null)) { // Default to inserting at end of list int insertIndex = Controls.Count; // If found some friends contents, then insert relative to them if (previousAllTabStub != null) insertIndex = Controls.IndexOf(previousAllTabStub); else { if (nextAllTabStub != null) insertIndex = Controls.IndexOf(nextAllTabStub) + 1; } ContentCollection cs = new ContentCollection(); cs.Add(content); // Add at end of current list of TabStubs AddContentsAsGroup(cs, insertIndex); } else { if (previousTabStub != null) AddContentIntoTabStub(content, previousTabStub, previousIndex + 1); else AddContentIntoTabStub(content, nextTabStub, nextIndex); } }
public RestoreContentFloatingAffinity(Restore child, State state, Content content, StringCollection best, StringCollection associates) : base(child, state, content) { // Remember parameters _best = best; _associates = associates; _size = content.DisplaySize; _location = content.DisplayLocation; // Remove target from collection of friends if (_best.Contains(content.Title)) _best.Remove(content.Title); // Remove target from collection of associates if (_associates.Contains(content.Title)) _associates.Remove(content.Title); }