private static Rectangle GetPositionBounds(ViewDockGrid grid, AnchorStyles side) { var bounds = grid.RectangleToScreen(grid.ClientRectangle); int cx, cy; switch (side) { case AnchorStyles.Left: cx = bounds.X + 20 + ViewConstants.Spacing; cy = bounds.Y + bounds.Height / 2; break; case AnchorStyles.Top: cx = bounds.X + bounds.Width / 2; cy = bounds.Y + 20 + ViewConstants.Spacing; break; case AnchorStyles.Right: cx = bounds.X + bounds.Width - 20 - ViewConstants.Spacing; cy = bounds.Y + bounds.Height / 2; break; case AnchorStyles.Bottom: cx = bounds.X + bounds.Width / 2; cy = bounds.Y + bounds.Height - 20 - ViewConstants.Spacing; break; default: throw new ArgumentException( "Unknown AnchorStyles value: {0}".UseAsFormat(side), "side"); } return(new Rectangle(cx - 20, cy - 20, 40, 40)); }
public void Commit(Point location) { Verify.State.IsTrue(IsActive); _isActive = false; bool docking = false; location = _viewHost.PointToScreen(location); if (_hoveredGrid != null) { var dockResult = _hoveredGrid.DockMarkers.HitTest(location); if (_hoveredGrid.CanDock(_viewHost, dockResult)) { docking = true; _hoveredGrid.PerformDock(_viewHost, dockResult); } _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = null; } if (_hoveredHost != null) { var host = _hoveredHost; if (!docking) { var dockResult = host.DockMarkers.HitTest(location); if (host.CanDock(_viewHost, dockResult)) { host.PerformDock(_viewHost, dockResult); } } host.DockMarkers.Hide(); host = null; } }
/// <summary>Initializes a new instance of the <see cref="ViewDockSide"/> class.</summary> /// <param name="grid">Host grid.</param> /// <param name="side">Align side.</param> public ViewDockSide(ViewDockGrid grid, AnchorStyles side) { Verify.Argument.IsNotNull(grid, nameof(grid)); switch (side) { case AnchorStyles.Left: case AnchorStyles.Right: _orientation = Orientation.Vertical; break; case AnchorStyles.Top: case AnchorStyles.Bottom: _orientation = Orientation.Horizontal; break; default: throw new ArgumentException( "Unknown AnchorStyles value: {0}".UseAsFormat(side), "side"); } _grid = grid; _side = side; _dockedHosts = new List <ViewHost>(); _tabs = new List <ViewDockSideTab>(); _tabHover = new TrackingService <ViewDockSideTab>(OnTabHoverChanged); _tabPress = new TrackingService <ViewDockSideTab>(OnTabPressChanged); _autoShowTimer = new Timer() { Interval = 500 }; _autoHideTimer = new Timer() { Interval = 500 }; _autoShowTimer.Tick += OnAutoShowTimerTick; _autoHideTimer.Tick += OnAutoHideTimerTick; SetStyle( ControlStyles.ContainerControl | ControlStyles.Selectable | ControlStyles.SupportsTransparentBackColor, false); SetStyle( ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); MinimumSize = new Size(1, 1); }
public ViewDockService(IWorkingEnvironment environment, ViewDockGrid grid, Section section) { Verify.Argument.IsNotNull(environment, nameof(environment)); Verify.Argument.IsNotNull(grid, nameof(grid)); Verify.Argument.IsNotNull(section, nameof(section)); _environment = environment; Grid = grid; _section = section; _factories = new Dictionary <Guid, IViewFactory>(); RegisterFactory(new WebBrowserViewFactory()); }
public void Dispose() { if (_hoveredGrid != null) { _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = null; } if (_hoveredHost != null) { _hoveredHost.DockMarkers.Hide(); _hoveredHost = null; } _isActive = false; }
public void Dispose() { if (HoveredDockGrid != null) { HoveredDockGrid.DockMarkers.Hide(); HoveredDockGrid = null; } if (HoveredViewHost != null) { HoveredViewHost.DockMarkers.Hide(); HoveredViewHost = null; } IsActive = false; }
public void Cancel() { Verify.State.IsTrue(IsActive); IsActive = false; if (HoveredDockGrid != null) { HoveredDockGrid.DockMarkers.Hide(); HoveredDockGrid = null; } if (HoveredViewHost != null) { HoveredViewHost.DockMarkers.Hide(); HoveredViewHost = null; } }
public void Cancel() { Verify.State.IsTrue(IsActive); _isActive = false; if (_hoveredGrid != null) { _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = null; } if (_hoveredHost != null) { _hoveredHost.DockMarkers.Hide(); _hoveredHost = null; } }
/// <summary>Initializes a new instance of the <see cref="FloatingViewForm"/> class.</summary> /// <param name="viewHost">Floating <see cref="ViewHost"/>.</param> public FloatingViewForm(ViewDockGrid dockGrid, ViewHost viewHost) { Verify.Argument.IsNotNull(dockGrid, "dockGrid"); Verify.Argument.IsNotNull(viewHost, "viewHost"); Font = GitterApplication.FontManager.UIFont; Text = viewHost.Text; FormBorderStyle = FormBorderStyle.None; BackColor = Renderer.BackgroundColor; StartPosition = FormStartPosition.Manual; Padding = new Padding(Renderer.FloatBorderSize); Bounds = GetBoundsForControl(viewHost); if (viewHost.Width < ViewConstants.MinimumHostWidth) { if (viewHost.Height < ViewConstants.MinimumHostHeight) { viewHost.Size = new Size(ViewConstants.MinimumHostWidth, ViewConstants.MinimumHostHeight); } else { viewHost.Width = ViewConstants.MinimumHostWidth; } } else if (viewHost.Height < ViewConstants.MinimumHostHeight) { viewHost.Height = ViewConstants.MinimumHostHeight; } ; MinimumSize = new Size( ViewConstants.MinimumHostWidth + Renderer.FloatBorderSize * 2, ViewConstants.MinimumHostHeight + Renderer.FloatBorderSize * 2); ShowInTaskbar = false; ShowIcon = false; ControlBox = false; MinimizeBox = false; MaximizeBox = true; _rootControl = viewHost; _dockGrid = dockGrid; _dockGrid.AddFloatingForm(this); }
/// <summary>Initializes a new instance of the <see cref="FloatingViewForm"/> class.</summary> /// <param name="viewHost">Floating <see cref="ViewHost"/>.</param> public FloatingViewForm(ViewDockGrid dockGrid, ViewHost viewHost) { Verify.Argument.IsNotNull(dockGrid, "dockGrid"); Verify.Argument.IsNotNull(viewHost, "viewHost"); Font = GitterApplication.FontManager.UIFont; Text = viewHost.Text; FormBorderStyle = FormBorderStyle.None; BackColor = Renderer.BackgroundColor; StartPosition = FormStartPosition.Manual; Padding = new Padding(Renderer.FloatBorderSize); Bounds = GetBoundsForControl(viewHost); if(viewHost.Width < ViewConstants.MinimumHostWidth) { if(viewHost.Height < ViewConstants.MinimumHostHeight) { viewHost.Size = new Size(ViewConstants.MinimumHostWidth, ViewConstants.MinimumHostHeight); } else { viewHost.Width = ViewConstants.MinimumHostWidth; } } else if(viewHost.Height < ViewConstants.MinimumHostHeight) { viewHost.Height = ViewConstants.MinimumHostHeight; }; MinimumSize = new Size( ViewConstants.MinimumHostWidth + Renderer.FloatBorderSize * 2, ViewConstants.MinimumHostHeight + Renderer.FloatBorderSize * 2); ShowInTaskbar = false; ShowIcon = false; ControlBox = false; MinimizeBox = false; MaximizeBox = true; _rootControl = viewHost; _dockGrid = dockGrid; _dockGrid.AddFloatingForm(this); }
public bool Start(Point location) { Verify.State.IsFalse(IsActive); _isActive = true; location = _viewHost.PointToScreen(location); var grid = HitTestGrid(location); if (grid != null) { _hoveredGrid = grid; grid.DockMarkers.Show(_viewHost); grid.DockMarkers.UpdateHover(location); } var host = HitTestViewHost(location); if (host != null) { _hoveredHost = host; host.DockMarkers.Show(_viewHost); host.DockMarkers.UpdateHover(location); } return(true); }
public void Dispose() { if(_hoveredGrid != null) { _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = null; } if(_hoveredHost != null) { _hoveredHost.DockMarkers.Hide(); _hoveredHost = null; } _isActive = false; }
public GridDockMarker(ViewDockGrid grid, ViewHost viewHost, AnchorStyles side) : base(grid, viewHost, new[] { GetButton(side) }, Border, GetPositionBounds(grid, side)) { _grid = grid; _side = side; }
public void Update(Point location) { Verify.State.IsTrue(IsActive); bool gridHit = false; location = _viewHost.PointToScreen(location); var grid = HitTestGrid(location); if (grid != null) { if (_hoveredGrid != null) { if (_hoveredGrid != grid) { _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = grid; grid.DockMarkers.Show(_viewHost); } } else { _hoveredGrid = grid; grid.DockMarkers.Show(_viewHost); } gridHit = grid.DockMarkers.UpdateHover(location); } else { if (_hoveredGrid != null) { _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = null; } } var host = HitTestViewHost(location); if (host != null) { if (_hoveredHost != null) { if (_hoveredHost != host) { _hoveredHost.DockMarkers.Hide(); _hoveredHost = host; host.DockMarkers.Show(_viewHost); } } else { _hoveredHost = host; host.DockMarkers.Show(_viewHost); } if (!gridHit) { host.DockMarkers.UpdateHover(location); } else { host.DockMarkers.Unhover(); } } else { if (_hoveredHost != null) { _hoveredHost.DockMarkers.Hide(); _hoveredHost = null; } } }
public void Commit(Point location) { Verify.State.IsTrue(IsActive); _isActive = false; bool docking = false; location = _viewHost.PointToScreen(location); if(_hoveredGrid != null) { var dockResult = _hoveredGrid.DockMarkers.HitTest(location); if(_hoveredGrid.CanDock(_viewHost, dockResult)) { docking = true; _hoveredGrid.PerformDock(_viewHost, dockResult); } _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = null; } if(_hoveredHost != null) { var host = _hoveredHost; if(!docking) { var dockResult = host.DockMarkers.HitTest(location); if(host.CanDock(_viewHost, dockResult)) { host.PerformDock(_viewHost, dockResult); } } host.DockMarkers.Hide(); host = null; } }
public void Cancel() { Verify.State.IsTrue(IsActive); _isActive = false; if(_hoveredGrid != null) { _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = null; } if(_hoveredHost != null) { _hoveredHost.DockMarkers.Hide(); _hoveredHost = null; } }
public void Update(Point location) { Verify.State.IsTrue(IsActive); bool gridHit = false; location = _viewHost.PointToScreen(location); var grid = HitTestGrid(location); if(grid != null) { if(_hoveredGrid != null) { if(_hoveredGrid != grid) { _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = grid; grid.DockMarkers.Show(_viewHost); } } else { _hoveredGrid = grid; grid.DockMarkers.Show(_viewHost); } gridHit = grid.DockMarkers.UpdateHover(location); } else { if(_hoveredGrid != null) { _hoveredGrid.DockMarkers.Hide(); _hoveredGrid = null; } } var host = HitTestViewHost(location); if(host != null) { if(_hoveredHost != null) { if(_hoveredHost != host) { _hoveredHost.DockMarkers.Hide(); _hoveredHost = host; host.DockMarkers.Show(_viewHost); } } else { _hoveredHost = host; host.DockMarkers.Show(_viewHost); } if(!gridHit) { host.DockMarkers.UpdateHover(location); } else { host.DockMarkers.Unhover(); } } else { if(_hoveredHost != null) { _hoveredHost.DockMarkers.Hide(); _hoveredHost = null; } } }
public bool Start(Point location) { Verify.State.IsFalse(IsActive); _isActive = true; location = _viewHost.PointToScreen(location); var grid = HitTestGrid(location); if(grid != null) { _hoveredGrid = grid; grid.DockMarkers.Show(_viewHost); grid.DockMarkers.UpdateHover(location); } var host = HitTestViewHost(location); if(host != null) { _hoveredHost = host; host.DockMarkers.Show(_viewHost); host.DockMarkers.UpdateHover(location); } return true; }
public GridDockMarkers(ViewDockGrid grid) { Grid = grid; }
/// <summary>Initializes a new instance of the <see cref="ViewHost"/> class.</summary> /// <param name="grid">Host grid.</param> /// <param name="isRoot">if set to <c>true</c> disables host auto-destruction on losing all hosted views.</param> /// <param name="isDocumentWell">if set to <c>true</c> uses advanced layout features for hosting variable size documents.</param> /// <param name="views">Hosted views.</param> internal ViewHost(ViewDockGrid grid, bool isRoot, bool isDocumentWell, IEnumerable<ViewBase> views) { Verify.Argument.IsNotNull(grid, "grid"); SetStyle(ControlStyles.ContainerControl, true); SetStyle( ControlStyles.SupportsTransparentBackColor | ControlStyles.Selectable, false); _grid = grid; _isRoot = isRoot; _isDocumentWell = isDocumentWell; _views = new List<ViewBase>(); var size = new Size(ViewConstants.MinimumHostWidth, ViewConstants.MinimumHostHeight); if(views != null) { foreach(var view in views) { Verify.Argument.IsTrue(view != null, "views", "List of views contains invalid arguments."); _views.Add(view); view.TextChanged += OnViewTextChanged; view.Host = this; var ts = view.Size; if(ts.Width > size.Width) { size.Width = ts.Width; } if(ts.Height > size.Height) { size.Height = ts.Height; } } } if(_views.Count > 0) { if(isDocumentWell) { size.Height += Renderer.TabHeight + Renderer.TabFooterHeight + Renderer.FooterHeight; } else { size.Height += Renderer.HeaderHeight; if(_views.Count > 1) { size.Height += Renderer.TabHeight; } } } _dockMarkers = new ViewHostDockMarkers(this); _dockingProcess = new ViewHostDockingProcess(this); _resizingProcess = new ViewHostResizingProcess(this); BackColor = Renderer.BackgroundColor; SuspendLayout(); int bottomOffset; int topOffset; if(_views.Count != 0) { _activeView = _views[0]; if(isDocumentWell) { SpawnTabs(size); topOffset = _tabs.Height; SpawnFooter(size); bottomOffset = Renderer.FooterHeight; } else { SpawnHeader(size); topOffset = _header.Height; if(_views.Count > 1) { SpawnTabs(size); bottomOffset = _tabs.Height; } else { bottomOffset = 0; } } } else { topOffset = 0; bottomOffset = 0; } _viewContainer = new Panel() { Bounds = new Rectangle(0, topOffset, size.Width, size.Height - topOffset - bottomOffset), Anchor = ViewConstants.AnchorAll, }; if(_activeView != null) { _activeView.Bounds = new Rectangle(Point.Empty, _viewContainer.Size); _activeView.Anchor = ViewConstants.AnchorAll; _activeView.Parent = _viewContainer; } Size = size; _viewContainer.Parent = this; ResumeLayout(true); lock(_viewHosts) { _viewHosts.AddLast(this); } }
private static Rectangle GetPositionBounds(ViewDockGrid grid, AnchorStyles side) { var bounds = grid.RectangleToScreen(grid.ClientRectangle); int cx, cy; switch(side) { case AnchorStyles.Left: cx = bounds.X + 20 + ViewConstants.Spacing; cy = bounds.Y + bounds.Height / 2; break; case AnchorStyles.Top: cx = bounds.X + bounds.Width / 2; cy = bounds.Y + 20 + ViewConstants.Spacing; break; case AnchorStyles.Right: cx = bounds.X + bounds.Width - 20 - ViewConstants.Spacing; cy = bounds.Y + bounds.Height / 2; break; case AnchorStyles.Bottom: cx = bounds.X + bounds.Width / 2; cy = bounds.Y + bounds.Height - 20 - ViewConstants.Spacing; break; default: throw new ArgumentException( "Unknown AnchorStyles value: {0}".UseAsFormat(side), "side"); } return new Rectangle(cx - 20, cy - 20, 40, 40); }