public bool Contains(ContentCollection values)
        {
            foreach(Content c in values)
            {
                // Use base class to process actual collection operation
                if (Contains(c))
                    return true;
            }

            return false;
        }
Example #2
0
        public WindowContent(DockingManager manager, VisualStyle vs)
            : base(manager)
        {
            // Remember state
            _style = vs;
        
            // Create collection of window details
            _contents = new ContentCollection();

            // We want notification when contents are added/removed/cleared
            _contents.Clearing += new CollectionClear(OnContentsClearing);
            _contents.Inserted += new CollectionChange(OnContentInserted);
            _contents.Removing += new CollectionChange(OnContentRemoving);
            _contents.Removed += new CollectionChange(OnContentRemoved);
        }
Example #3
0
		public static ContentCollection Contents(Zone z)
		{
			// Container for returned group of found Content objects
			ContentCollection cc = new ContentCollection();

			// 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)
						cc.Add(c);
				}
			}

			return cc;
		}
		public ContentCollection Copy()
		{
			ContentCollection clone = new ContentCollection();

			// Copy each reference across
            foreach(Content c in base.List)
				clone.Add(c);

			return clone;
		}
Example #5
0
 public override void PerformRestore(DockingManager dm)
 {
     // Create collection of Contents to auto hide
     ContentCollection cc = new ContentCollection();
     
     // In this case, there is only one
     cc.Add(_content);
 
     // Add to appropriate AutoHidePanel based on _state
     dm.AutoHideContents(cc, _state);
 }
Example #6
0
        protected virtual void OnRestore(object sender, EventArgs e)
        {
            WindowDetailCaption wdc = sender as WindowDetailCaption;

            // Was Restore generated by a Caption detail?
            if (wdc != null)
            {
                RemoveAnyFillStyle();

                WindowContent wc = wdc.ParentWindow as WindowContent;

                // Is the Caption part of a WindowContent object?
                if (wc != null)
                {
                    ContentCollection copy = new ContentCollection();

                    // Make every Content of the WindowContent record its
                    // current position and remember it for when the future
                    foreach(Content c in wc.Contents)
                    {
                        c.RecordRestore();

                        // Invert docked status
                        c.Docked = (c.Docked == false);

                        copy.Add(c);
                    }

                    int copyCount = copy.Count;

                    // Must have at least one!
                    if (copyCount >= 1)
                    {
                        // Remove from current WindowContent and restore its position
                        HideContent(copy[0], false, true);
                        ShowContent(copy[0]);

                        // Any other content to be moved along with it?
                        if (copyCount >= 2)
                        {
                            WindowContent newWC = copy[0].ParentWindowContent;

                            if (newWC != null)
                            {
                                // Transfer each one to its new location
                                for(int index=1; index<copyCount; index++)
                                {
                                    HideContent(copy[index], false, true);
                                    newWC.Contents.Add(copy[index]);
                                }
                            }
                        }
                    }
                }

                AddInnerFillStyle();
            }
        }
Example #7
0
        protected virtual void OnInvertAutoHide(object sender, EventArgs e)
        {
            // Do not generate hiding/hidden/shown events
            _surpressVisibleEvents++;

            WindowDetail detail = sender as WindowDetail;

            // Get access to Content that initiated AutoHide for its Window
            WindowContent wc = detail.ParentWindow as WindowContent;

            // Create a collection of the Content in the same window
            ContentCollection cc = new ContentCollection();

            // Add all Content into collection
            foreach(Content c in wc.Contents)
                cc.Add(c);

            // Add to the correct AutoHidePanel
            AutoHideContents(cc, wc.State);

            // Enable generate hiding/hidden/shown events
            _surpressVisibleEvents--;
        }
Example #8
0
        internal void AutoHideContents(ContentCollection cc, State state)
        {
            // Hide all the Content instances. This will cause the restore objects to be
            // created and so remember the docking positions for when they are restored
            foreach(Content c in cc)
                HideContent(c);

            AutoHidePanel ahp = AutoHidePanelForState(state);

            // Pass management of Contents into the panel
            ahp.AddContentsAsGroup(cc);
        }
Example #9
0
        public void AddContentsAsGroup(ContentCollection contents, int index)
		{
            // Create new TabStub to represent the Contents
            TabStub ts = new TabStub(_manager.Style);

            // Set manager requested settings
            ts.Font = _manager.CaptionFont;
            ts.BackColor = _manager.BackColor;
            ts.ForeColor = _manager.InactiveTextColor;

            // Hook into events
            ts.PageOver += new TabStub.TabStubIndexHandler(OnPageOver);
            ts.PageClicked += new TabStub.TabStubIndexHandler(OnPageClicked);
            ts.PagesLeave += new TabStub.TabStubHandler(OnPagesLeave);
		    
            // Add a page for each Content instance
            foreach(Content c in contents)
            {
                // Create page object
                SharpClient.UI.Controls.TabPage page = new SharpClient.UI.Controls.TabPage();
		        
                // Copy across the visual properties
                page.Title = c.Title;
                page.ImageList = c.ImageList;
                page.ImageIndex = c.ImageIndex;
                
                // Remember reference to Content it represents
                page.Tag = c;
		        
                // Add into the stub
                ts.TabPages.Add(page);
		        
                // Mark Content as being in AutoHide mode
                c.AutoHidePanel = this;
                c.AutoHidden = true;
            }

            State windowState = State.DockLeft;
		    
            // Define stub settings based on our docking position
            switch(this.Dock)
            {
                case DockStyle.Left:
                    windowState = State.DockLeft;
                    ts.Edging = Edge.Left;
                    ts.Dock = DockStyle.Top;
                    break;
                case DockStyle.Right:
                    windowState = State.DockRight;
                    ts.Edging = Edge.Right;
                    ts.Dock = DockStyle.Top;
                    break;
                case DockStyle.Top:
                    windowState = State.DockTop;
                    ts.Edging = Edge.Top;
                    ts.Dock = DockStyle.Left;
                    break;
                case DockStyle.Bottom:
                    windowState = State.DockBottom;
                    ts.Edging = Edge.Bottom;
                    ts.Dock = DockStyle.Left;
                    break;
            }
		    
            // Add stub into the view
            Controls.Add(ts);
            
            // Set correct new position
            Controls.SetChildIndex(ts, index);
		    
            // Each TabStub has a WCT created and ready to be shown when needed
            WindowContentTabbed wct = _manager.CreateWindowForContent(null, new EventHandler(OnPageClose),
                                                                      null, new EventHandler(OnPageAutoHide))as WindowContentTabbed;
				//,                                                                      new ContextHandler(OnPageContextMenu)) as WindowContentTabbed;
            
            // Add each Content instance in turn
            foreach(Content c in contents)
                wct.Contents.Add(c);
                
            // By default the first Content added to a WCT will define the size
            // of the WCT control. We need to override this to use the AutoHideSize
            // from the first Content instead.
            wct.Size = contents[0].AutoHideSize;

            // Ensure Window caption bar reflects correct docking status
            wct.State = windowState;

            // Inform Window it should not allow user initiated redocking
            wct.RedockAllowed = false;

            // Hide tab selection from user
            wct.TabControl.HideTabsMode = SharpClient.UI.Controls.TabControl.HideTabsModes.HideAlways;

            // Associate WCT with matching TabStub
            ts.WindowContentTabbed = wct;
            
            // Make sure this AutoHidePanel is visible
            if (!this.Visible)
			    this.Show();
			    
	        Invalidate();
		}
Example #10
0
 public void AddContentsAsGroup(ContentCollection contents)
 {
     // By default, insert new group at the end of display which is start of list
     AddContentsAsGroup(contents, 0);
 }
Example #11
0
        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(SharpClient.UI.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);
            }
        }
Example #12
0
        protected void OnPageClose(object sender, EventArgs e)
        {
            // Find the TabStub instance for the showing WCT
            foreach(TabStub ts in this.Controls)
            {
                // Does this stub match the one showing?
                if (ts.WindowContentTabbed == _currentWCT)
                {
                    ContentCollection cc = new ContentCollection();
                
                    // Get access to Content instance being hidden
                    Content current = _currentWCT.Contents[ts.SelectedIndex];
                    
                    // Check if the hide button is allowed to work
                    if (!_manager.OnContentHiding(current))
                    {
                        // Are we removing the last entry in the WCT?
                        if (ts.TabPages.Count == 1)
                        {
                            // We need to update AutoHide property for all of them
                            foreach(Content c in _currentWCT.Contents)
                                cc.Add(c);
                        
                            // Remove Panel/WCT from display and stop timers
                            KillDisplayedWindow();

                            // Remove the WCT from the WCT
                            ControlHelper.Remove(ts.Controls, ts.WindowContentTabbed);

                            // Remove the stub from this panel
                            ControlHelper.Remove(this.Controls, ts);                    

                            // Cleanup gracefully
                            ts.Dispose();
                        }
                        else
                        {
                            // Which entry in the stub is currently selected?
                            int index = ts.SelectedIndex;

                            // Need to update AutoHide property for removed content
                            cc.Add(_currentWCT.Contents[index]);

                            // Remove just the selected entry from stub
                            ts.TabPages.RemoveAt(index);
                            
                            // Remove the selected entry from WCT
                            _currentWCT.Contents.RemoveAt(index);
                        }

                        // Content instances no longer in AutoHidden state
                        foreach(Content c in cc)
                        {
                            // Remember this AutoHide state for persistence
                            c.RecordAutoHideRestore();

                            // No longer in the auto hidden mode                    
                            c.AutoHidden = false;
                            c.AutoHidePanel = null;
                        }
                    }
                    
                    // Generate hidden event now content is not visible
                    _manager.OnContentHidden(current);
                    
                    break;
                }
            }
            
            // If no more contents remain then hide
            if (this.Controls.Count == 0)
                this.Hide();
        }