public static StringCollection ContentNamesInPriority(Zone z, Content c)
        {
            // Container for returned group of found Content objects
            StringCollection sc = new StringCollection();

            // Process each Window in the Zone
            foreach(Window w in z.Windows)
            {
                WindowContent wc = w as WindowContent;

                // Is the Zone a Content derived variation?
                if (wc != null)
                {
                    // Does this contain the interesting Content?
                    if (wc.Contents.Contains(c))
                    {
                        // All Content of this Window are given priority and
                        // added into the start of the collection
                        foreach(Content content in wc.Contents)
                            sc.Insert(0, content.Title);
                    }
                    else
                    {
                        // Lower priority Window and so contents are always
                        // added to the end of the collection
                        foreach(Content content in wc.Contents)
                            sc.Add(content.Title);
                    }
                }
            }

            return sc;
        }
Beispiel #2
0
        public bool Contains(StringCollection values)
        {
			foreach(String c in values)
			{
	            // Use base class to process actual collection operation
				if (Contains(c))
					return true;
			}

			return false;
        }
        public static StringCollection ContentNames(Zone z)
        {
            // Container for returned group of found String objects
            StringCollection sc = new StringCollection();

            // Process each Window in the Zone
            foreach(Window w in z.Windows)
            {
                WindowContent wc = w as WindowContent;

                // Is the Zone a Content derived variation?
                if (wc != null)
                {
                    // Add each Content into the collection
                    foreach(Content c in wc.Contents)
                        sc.Add(c.Title);
                }
            }

            return sc;
        }
Beispiel #4
0
		protected void GetWindowContentFriends(Window match, 
											   out StringCollection best,
											   out StringCollection next,
											   out StringCollection previous)
		{
			best = new StringCollection();
			next = new StringCollection();
			previous = new StringCollection();

			bool before = true;

			foreach(Window w in _windows)
			{
				WindowContent wc = w as WindowContent;

				// Is this the Window we are searching for?
				if (w == match)
				{
					if (wc != null)
					{
						// Best friends are those in the matching Window
						foreach(Content content in wc.Contents)
							best.Add(content.Title);
					}

					before = false;
				}
				else
				{
					if (wc != null)
					{
						// Remember all found Content in appropriate next/previous collection
						foreach(Content content in wc.Contents)
						{
							if (before)
								previous.Add(content.Title);
							else
								next.Add(content.Title);
						}
					}
				}
			}

		}
Beispiel #5
0
		protected void GetZoneContentFriends(Content c,
											 out StringCollection zoneBest,
											 out StringCollection zoneNext,
											 out StringCollection zonePrevious,
											 out StringCollection zoneNextAll,
											 out StringCollection zonePreviousAll)
		{

			// Out best friends are all those Content inside this Zone but with the ones
			// in the same Window as the first in list and so the highest priority
			zoneBest = ZoneHelper.ContentNamesInPriority(this,c);

			zoneNext = new StringCollection();
			zonePrevious = new StringCollection();
			zoneNextAll = new StringCollection();
			zonePreviousAll = new StringCollection();

			bool before = true;

			foreach(Control control in _manager.Container.Controls)
			{
				Zone z = control as Zone;

				if (z != null)
				{
					if (z == this)
						before = false;
					else
					{
						ContentCollection newContent = ZoneHelper.Contents(z);

						foreach(Content content in newContent)
						{
							if (before)
							{
								if (z.State == this.State)
									zonePrevious.Add(content.Title);

								zonePreviousAll.Add(content.Title);
							}
							else
							{
								if (z.State == this.State)
									zoneNext.Add(content.Title);

								zoneNextAll.Add(content.Title);
							}
						}

						newContent.Clear();
					}
				}
			}
		}
        public Restore RestoreObjectForContent(Content c)
        {
            StringCollection next = new StringCollection();
            StringCollection previous = new StringCollection();
            StringCollection nextAll = new StringCollection();
            StringCollection previousAll = new StringCollection();

            // Which group has the marked content?
            TabStub marked = TabStubForContent(c);

            // Have we found the marked group yet?
            bool foundGroup = false;

            // Found the content in the marked group yet?
            bool foundContent = false;

            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 content = page.Tag as Content;

                    // Is this the marked group
                    if (marked == ts)
                    {
                        // Add into the 'nextAll' rather than 'previousAll' groups from now on
                        foundGroup = true;

                        // No need to save ourself in our best friends list!
                        if (content.Title == c.Title)
                        {
                            // Add into the 'next' rather than 'previous' contents now
                            foundContent = true;
                        }
                        else
                        {
                            if (!foundContent)
                                previous.Add(content.Title);
                            else
                                next.Add(content.Title);
                        }
                    }
                    else
                    {
                        if (!foundGroup)
                            previousAll.Add(content.Title);
                        else
                            nextAll.Add(content.Title);
                    }
                }
            }

            // Calculate state from docking value
            State windowState = State.DockLeft;

            // Define stub settings based on our docking position
            switch(this.Dock)
            {
                case DockStyle.Left:
                    windowState = State.DockLeft;
                    break;
                case DockStyle.Right:
                    windowState = State.DockRight;
                    break;
                case DockStyle.Top:
                    windowState = State.DockTop;
                    break;
                case DockStyle.Bottom:
                    windowState = State.DockBottom;
                    break;
            }

            return new RestoreAutoHideAffinity(null, windowState, c, next, previous, nextAll, previousAll);
        }
        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 override Restore RecordRestore(object child) 
        {
            // Child of a WindowContent must be a Content object
            Content c = child as Content;

            StringCollection next = new StringCollection();
            StringCollection previous = new StringCollection();

            bool before = true;

            // Fill collections with list of Content before and after parameter
            foreach(Content content in _contents)
            {
                if (content == c)
                    before = false;
                else
                {
                    if (before)
                        previous.Add(content.Title);
                    else
                        next.Add(content.Title);
                }
            }

            bool selected = false;

            // Is there a selected tab?
            if (_tabControl.SelectedIndex != -1)
            {
                // Get access to the selected Content
                Content selectedContent = _tabControl.SelectedTab.Tag as Content;

                // Need to record if it is selected
                selected = (selectedContent == c);
            }

            // Create a Restore object to handle this WindowContent
            Restore thisRestore = new RestoreWindowContent(null, c, next, previous, selected);

            // Do we have a Zone as our parent?
            if (_parentZone != null)
            {
                // Get the Zone to prepend its own Restore knowledge
                thisRestore = _parentZone.RecordRestore(this, child, thisRestore);
            }

            return thisRestore;
        }
 public RestoreAutoHideAffinity(Restore child, 
     State state,
     Content content,
     StringCollection next,
     StringCollection previous,
     StringCollection nextAll,
     StringCollection previousAll)
     : base(child, state, content)
 {
     // Remember parameters
     _next = next;
     _previous = previous;
     _nextAll = nextAll;
     _previousAll = previousAll;
 }
 public RestoreWindowContent(Restore child, 
     Content content,
     StringCollection next,
     StringCollection previous,
     bool selected)
     : base(child, content)
 {
     // Remember parameters
     _selected = selected;
     _next = next;
     _previous = previous;
 }
 public RestoreWindowContent()
     : base()
 {
     // Must always point to valid reference
     _selected = false;
     _next = new StringCollection();
     _previous = new StringCollection();
 }
        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);
        }
 public RestoreContentFloatingAffinity()
     : base()
 {
     // Must always point to valid reference
     _best = new StringCollection();
     _associates = new StringCollection();
 }
 public RestoreContentDockingAffinity(Restore child, 
     State state,
     Content content,
     StringCollection best,
     StringCollection next,
     StringCollection previous,
     StringCollection nextAll,
     StringCollection previousAll)
     : base(child, state, content)
 {
     // Remember parameters
     _best = best;
     _next = next;
     _previous = previous;
     _nextAll = nextAll;
     _previousAll = previousAll;
     _size = content.DisplaySize;
     _location = content.DisplayLocation;
 }
 public RestoreContentDockingAffinity()
     : base()
 {
     // Must always point to valid reference
     _best = new StringCollection();
     _next = new StringCollection();
     _previous = new StringCollection();
     _nextAll = new StringCollection();
     _previousAll = new StringCollection();
 }
        public bool Contains(StringCollection values)
        {
            foreach(String s in values)
                if (Contains(s))
                    return true;

            return false;
        }
        public RestoreZoneAffinity()
            : base()
        {
            // Default state
            _space = 50m;

            // Must always point to valid reference
            _best = new StringCollection();
            _next = new StringCollection();
            _previous = new StringCollection();
        }
        public RestoreZoneAffinity(Restore child, 
            Content content,
            StringCollection best,
            StringCollection next,
            StringCollection previous)
            : base(child, content)
        {
            // Remember parameters
            _best = best;
            _next = next;
            _previous = previous;

            if (content.Visible)
                _space = content.ParentWindowContent.ZoneArea;
            else
                _space = 50m;
        }
 public RestoreAutoHideAffinity()
     : base()
 {
     // Must always point to valid reference
     _next = new StringCollection();
     _previous = new StringCollection();
     _nextAll = new StringCollection();
     _previousAll = new StringCollection();
 }