public Window Add(Window value)
        {
            // Use base class to process actual collection operation
            base.List.Add(value as object);

            return value;
        }
Beispiel #2
0
 public WindowDetail(DockingManager manager)
 {
     // Default the state
     _parentZone = null;
     _parentWindow = null;
     _manager = manager;
     
     // Get correct starting state from manager
     this.BackColor = _manager.BackColor;            
     this.ForeColor = _manager.InactiveTextColor;
 }
Beispiel #3
0
        protected void InternalConstruct(VisualStyle style, Direction direction, bool zoneMinMax)
        {
            // Remember initial state
            _style = style;
            _direction = direction;
            _maximizedWindow = null;
			_suppressReposition = false;
			_zoneMinMax = zoneMinMax;

            // Create the control used to resize the whole Zone
            _resizeBar = new ResizeBar(_direction, this);

            // Place last in the list of child Controls
            Controls.Add(_resizeBar);

            // Start of very small and let first content determine new size
            this.Size = new Size(0,0);		

			// Do not inherit the parent BackColor, we want the .Control color as 
			// this blends in with the way all the docking windows are drawn
			this.BackColor = SystemColors.Control;
			this.ForeColor = SystemColors.ControlText;
        }
Beispiel #4
0
 public virtual void AddedToParent(Window parent) {}
Beispiel #5
0
 public virtual void RemovedFromParent(Window parent) {}
        public override void RemovedFromParent(Window parent)
        {
            if (parent != null)
            {
                Size minSize = parent.MinimalSize;

                // Remove our height from the minimum size of the parent
                minSize.Height -= _fixedLength;
                minSize.Width -= _fixedLength;

                parent.MinimalSize = minSize;
            }
        }
Beispiel #7
0
		public virtual void PerformRestore(Window w) {}
 public void Insert(int index, Window value)
 {
     // Use base class to process actual collection operation
     base.List.Insert(index, value as object);
 }
 public bool Contains(Window value)
 {
     // Use base class to process actual collection operation
     return base.List.Contains(value as object);
 }
Beispiel #10
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 #11
0
        public override void PropogateNameValue(PropogateName name, object value)
        {
            base.PropogateNameValue(name, value);
            
            // Reduce flicker during update
            SuspendLayout();

            if (name == PropogateName.ZoneMinMax)
            {
                if (_zoneMinMax != (bool)value)
                {
                    // Remember the new value
                    _zoneMinMax = (bool)value;
                    
                    // If turning off the min/max ability
                    if (!_zoneMinMax)
                        _maximizedWindow = null;  // no window can be currently maximized
        
                    // Get child windows to retest the maximize capability
                    OnRefreshMaximize(EventArgs.Empty);
                }           
            }
            
            // Update each resize bar control
            foreach(Control c in this.Controls)
            {
                ResizeBar rb = c as ResizeBar;
                
                if (rb != null)
                    rb.PropogateNameValue(name, value);
            }
            
            // Recalculate positions using new values
            RepositionControls();
            
            ResumeLayout();
        }
Beispiel #12
0
		public override Restore RecordRestore(Window w, object child, Restore childRestore)
		{
			Content c = child as Content;

			// We currently only understand Windows that have Content as children
			if (c != null)
			{
				StringCollection best;
				StringCollection next;
				StringCollection previous;

				GetWindowContentFriends(w, out best, out next, out previous); 

				// Create a restore object that will find the correct WindowContent to 
				// place a Content in within a specified Zone, or it will create a new 
				// WindowContent in an appropriate relative ordering
				Restore zoneRestore = new RestoreZoneAffinity(childRestore, c, best, next, previous); 

				if (_state == State.Floating)
				{
					// Create a restore object to find the correct Floating Form to restore inside
					// or it will create a new Floating Form as appropriate
					return new RestoreContentFloatingAffinity(zoneRestore, _state, c, best, ZoneHelper.ContentNames(this));
				}
				else
				{
					StringCollection zoneBest;
					StringCollection zoneNext;
					StringCollection zonePrevious;
					StringCollection zoneNextAll;
					StringCollection zonePreviousAll;

					GetZoneContentFriends(c, out zoneBest, out zoneNext, out zonePrevious, 
														   out zoneNextAll, out zonePreviousAll); 

					// Create a restore object able to find the correct Zone in the appropriate 
					// docking direction and then restore into that Zone. If no appropriate Zone 
					// found then create a new one
					return new RestoreContentDockingAffinity(zoneRestore, _state, c, zoneBest, 
															 zoneNext, zonePrevious,
															 zoneNextAll, zonePreviousAll);
				}
			}

			return null;
		}
Beispiel #13
0
        public void RestoreWindow()
        {
            // Remember the newly maximized Window
            _maximizedWindow = null;

            // Inform all interested parties of change
            OnRefreshMaximize(EventArgs.Empty);

            RepositionControls();
        }
Beispiel #14
0
 public bool IsWindowMaximized(Window w)
 {
     return (w == _maximizedWindow);
 }
Beispiel #15
0
        protected void RemoveWindowSpace(Window w)
        {
            // Is there only a single Window left?
            if (_windows.Count == 1)
            {
                // Give it all the space
                _windows[0].ZoneArea = 100m;
            }
            else
            {
                // Is there any space to reallocate?
                if (w.ZoneArea > 0)
                {
                    // Total up all the values
                    Decimal totalAllocated = 0m;

                    // How much space should we add to each of the others
                    Decimal freedSpace = w.ZoneArea / (_windows.Count - 1);

                    foreach(Window entry in _windows)
                    {
                        if (entry != w)
                        {
                            // We only retain a sensible level of precision
                            Decimal newSpace = Decimal.Round(entry.ZoneArea + freedSpace, _spacePrecision);                            

                            // Assign back new space
                            entry.ZoneArea = newSpace;
                            
                            // Total up all space so far 
                            totalAllocated += newSpace;
                        }
                    }

                    // Look for minor errors due not all fractions can be accurately represented in binary!
                    if (totalAllocated > 100m)
                    {
                        Decimal correction = totalAllocated - 100m;

                        // Remove from first entry
                        foreach(Window entry in _windows)
                        {
                            if (entry != w)
                            {
                                // Apply correction to this window
                                entry.ZoneArea = totalAllocated - 100m;
                                break;
                            }
                        }
                    }
                    else if (totalAllocated < 100m)
                    {
                        Decimal correction = 100m - totalAllocated;

                        // Remove from first entry
                        foreach(Window entry in _windows)
                        {
                            if (entry != w)
                            {
                                // Apply correction to this window
                                entry.ZoneArea += 100m - totalAllocated;
                                break;
                            }
                        }
                    }

                    // Window no longer has any space
                    w.ZoneArea = 0m;
                }
            }
        }
Beispiel #16
0
		public void ModifyWindowSpace(Window w, Decimal newSpace)
		{
			// Double check this Window is a member of the collection
			if (_windows.Contains(w))
			{
				// Cannot reallocate space if it is the only element
				if (_windows.Count > 1)
				{
					int otherWindows = _windows.Count - 1; 

					// Limit the resize allowed
					if (newSpace > 100m)
						newSpace = 100m;
						
					if (newSpace <= 0m)
						newSpace = 0m;		

					if (newSpace != w.ZoneArea)
					{
						// How much needs to be reallocated to other windows
						Decimal diff = w.ZoneArea - newSpace;					

						// Reducing the amount of space?
						if (diff > 0m)
						{
							// How much to give each of the other windows
							Decimal extra = diff / otherWindows;

							// Looping counters
							Decimal allocated = 0m;
							int found = 0;

							foreach(Window target in _windows)
							{
								// We only process the other windows
								if (target != w)
								{
									// Allocate it extra space
									target.ZoneArea += extra;

									// Keep count of total extra allocated
									allocated += extra;

									// Count number of others processed
									found++;

									// The last window to be allocated needs to also be given any rouding 
									// errors that occur from previous division, to ensure that the total 
									// space it always exactly equal to 100.
									if (found == otherWindows)
										target.ZoneArea += (diff - allocated);
								}
							}
						}
						else
						{
							// Easier to work with positive than negative numbers
							diff = -diff;

							while(diff > 0m)
							{
								// How much to grab from each of the other windows
								Decimal extra = diff / otherWindows;

								foreach(Window target in _windows)
								{
									// We only process the other windows
									if (target != w)
									{
										if (target.ZoneArea > 0m)
										{
											if (target.ZoneArea < extra)
											{
												// Keep count of total left to grab
												diff -= target.ZoneArea;
		
												// Window no longer has any ZoneArea											
												target.ZoneArea = 0m;
											}
											else
											{
												// Allocate it extra space
												target.ZoneArea -= extra;

												// Keep count of total left to grab
												diff -= extra;
											}
										}
									}
								}
							}
						}

						w.ZoneArea = newSpace;
					}
				}
			}

			// Recalculate the size and position of each Window and resize bar
			RepositionControls();
		}
Beispiel #17
0
 public virtual Restore RecordRestore(Window w, object child, Restore childRestore)
 {
     return null;
 }
Beispiel #18
0
        protected override void OnWindowsClearing()
        {
            base.OnWindowsClearing();

            // Make sure no Window is recorded as maximized
            _maximizedWindow = null;

            // Remove all child controls
            Controls.Clear();

            if (!this.AutoDispose)
            {
                // Add back the Zone resize bar
                Controls.Add(_resizeBar);

                Invalidate();
            }
        }
 public void AddRange(Window[] values)
 {
     // Use existing method to add each array entry
     foreach(Window page in values)
         Add(page);
 }
Beispiel #20
0
        protected override void OnWindowRemoving(int index, object value)
        {
            base.OnWindowRemoving(index, value);

            Window w = value as Window;

            // If the Window being removed the maximized one?
            if (_maximizedWindow == w)
                _maximizedWindow = null;

            // Is this the only Window entry?
            if (_windows.Count == 1)
            {
                // Remove Window from appearance

				// Use helper method to circumvent form Close bug
				ControlHelper.RemoveAt(this.Controls, 0);
            }
            else
            {
                int pos = 0;

                // Calculate position of Window to remove				
                if (index != 0)
                    pos = index * 2 - 1;

                // Remove Window and bar 

				// Use helper method to circumvent form Close bug
				ControlHelper.RemoveAt(this.Controls, pos);
				ControlHelper.RemoveAt(this.Controls, pos);
            }

            // Redistribute space taken up by Window to other windows
            RemoveWindowSpace(w);
        }
 public int IndexOf(Window value)
 {
     // Find the 0 based index of the requested entry
     return base.List.IndexOf(value);
 }
Beispiel #22
0
        protected void AllocateWindowSpace(Window w)
        {
            // Is this the only Window?
            if (_windows.Count == 1)
            {
                // Give it all the space
                w.ZoneArea = 100m;
            }
            else
            {
                // Calculate how much space it should have
                Decimal newSpace = 100m / _windows.Count;

                // How much space should we steal from each of the others
                Decimal reduceSpace = newSpace / (_windows.Count - 1);

                // Actual space acquired
                Decimal allocatedSpace = 0m;

                foreach(Window entry in _windows)
                {
                    if (entry != w)
                    {
                        // How much space the entry currently has
                        Decimal currentSpace = entry.ZoneArea;

                        // How much space to steal from it
                        Decimal xferSpace = reduceSpace;

                        // Does it have at least the requested amount of space?
                        if (currentSpace < xferSpace)
                            xferSpace = currentSpace;

                        // Transfer the space across
                        currentSpace -= xferSpace;

                        // Round the sensible number of decimal places
                        currentSpace = Decimal.Round(currentSpace, _spacePrecision);

                        // Update window with new space allocation
                        entry.ZoneArea = currentSpace;

                        allocatedSpace += currentSpace;
                    }
                }

                // Assign allocated space to new window
                w.ZoneArea = 100m - allocatedSpace;
            }
        }
 public void Remove(Window value)
 {
     // Use base class to process actual collection operation
     base.List.Remove(value as object);
 }
Beispiel #24
0
        protected void ModifyWindowSpace(Window w, int vector)
        {
            // Remove any maximized state
            if (_maximizedWindow != null)
            {
                // Make the maximized Window have all the space
                foreach(Window entry in _windows)
                {
                    if (entry == _maximizedWindow)
                        entry.ZoneArea = 100m;
                    else
                        entry.ZoneArea = 0m; 
                }

                // Remove maximized state
                _maximizedWindow = null;

                // Inform all interested parties of change
                OnRefreshMaximize(EventArgs.Empty);
            }

            Rectangle clientRect = this.ClientRectangle;

            RepositionZoneBar(ref clientRect);

            // Space available for allocation
            int space;

            // New pixel length of the modified Window
            int newLength = vector;
			
            if (_direction == Direction.Vertical)
            {
                space = clientRect.Height;

                // New pixel size is requested change plus original 
                // height minus the minimal size that is always added
                newLength += w.Height;
                newLength -= w.MinimalSize.Height;
            }
            else
            {
                space = clientRect.Width;

                // New pixel size is requested change plus original 
                // width minus the minimal size that is always added
                newLength += w.Width;
                newLength -= w.MinimalSize.Width;
            }

            int barSpace = 0;

            // Create temporary array of working values
            Position[] positions = new Position[Controls.Count - 1];

            // Pass 1, allocate all the space needed for each ResizeBar and the 
            //         minimal amount of space that each Window requests. 
            AllocateMandatorySizes(ref positions, ref barSpace, ref space);

            // What is the new percentage it needs?
            Decimal newPercent = 0m;

            // Is there any room to allow a percentage calculation
            if ((newLength > 0) && (space > 0))
                newPercent = (Decimal)newLength / (Decimal)space * 100;

            // What is the change in area
            Decimal reallocate = newPercent - w.ZoneArea;

            // Find the Window after this one
            Window nextWindow = _windows[_windows.IndexOf(w) + 1];

            if ((nextWindow.ZoneArea - reallocate) < 0m)
                reallocate = nextWindow.ZoneArea;
	
            // Modify the Window in question
            w.ZoneArea += reallocate;

            // Reverse modify the Window afterwards
            nextWindow.ZoneArea -= reallocate;
			
            // Update the visual appearance
            RepositionControls();
        }
Beispiel #25
0
		public override void PerformRestore(Window w)
		{
			// We are only ever called for a WindowContent object
			WindowContent wc = w as WindowContent;

			int bestIndex = -1;

			foreach(String s in _previous)
			{
				if (wc.Contents.Contains(s))
				{
					int previousIndex = wc.Contents.IndexOf(wc.Contents[s]);

					if (previousIndex > bestIndex)
						bestIndex = previousIndex;
				}
			}

			// Did we find a previous Content?
			if (bestIndex >= 0)
			{
				// Great, insert after it
				wc.Contents.Insert(bestIndex + 1, _content);
			}
			else
			{
				bestIndex = wc.Contents.Count;

				foreach(String s in _next)
				{
					if (wc.Contents.Contains(s))
					{
						int nextIndex = wc.Contents.IndexOf(wc.Contents[s]);

						if (nextIndex < bestIndex)
							bestIndex = nextIndex;
					}
				}

				// Insert before the found entry (or at end if non found)
				wc.Contents.Insert(bestIndex, _content);
			}
			
			// Should this content become selected?
			if (_selected)
			    _content.BringToFront();
		}
        public override void RemovedFromParent(Window parent)
        {
            if (parent != null)
            {
                if (this.Dock != DockStyle.None)
                {
                    Size minSize = parent.MinimalSize;

                    if (this.Dock == DockStyle.Left)
                    {
                        // Remove our width from the minimum size of the parent
                        minSize.Width -= _fixedLength;
                    }
                    else
                    {
                        // Remove our height from the minimum size of the parent
                        minSize.Height -= _fixedLength;
                    }

                    parent.MinimalSize = minSize;
                }
            }
        }