Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        private void FindAppropriateViewHost(IViewFactory factory, ViewBase view)
        {
            var host = _grid.RootHost;

            if (!factory.IsSingleton)
            {
                foreach (var v in factory.CreatedViews)
                {
                    if (v.Host != null && v.Host.IsDocumentWell)
                    {
                        host = v.Host;
                    }
                }
                host.AddView(view);
            }
            else
            {
                switch (factory.DefaultViewPosition)
                {
                case ViewPosition.SecondaryDocumentHost:
                    lock (ViewHost.ViewHosts)
                    {
                        foreach (var h in ViewHost.ViewHosts)
                        {
                            if (h != host && h.IsDocumentWell)
                            {
                                h.AddView(view);
                                return;
                            }
                        }
                    }
                    host = new ViewHost(_grid, false, true, new[] { view })
                    {
                        Size = _grid.RootHost.Size
                    };
                    _grid.RootHost.PerformDock(host, DockResult.Right);
                    break;

                case ViewPosition.Left:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    _grid.PerformDock(host, DockResult.Left);
                    break;

                case ViewPosition.Top:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    _grid.PerformDock(host, DockResult.Top);
                    break;

                case ViewPosition.Right:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    _grid.PerformDock(host, DockResult.Right);
                    break;

                case ViewPosition.Bottom:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    _grid.PerformDock(host, DockResult.Bottom);
                    break;

                case ViewPosition.LeftAutoHide:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    host.UnpinFromLeft();
                    break;

                case ViewPosition.TopAutoHide:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    host.UnpinFromTop();
                    break;

                case ViewPosition.RightAutoHide:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    host.UnpinFromRight();
                    break;

                case ViewPosition.BottomAutoHide:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    host.UnpinFromBottom();
                    break;

                case ViewPosition.Float:
                    host = new ViewHost(_grid, false, false, new[] { view });
                    var form = host.PrepareFloatingMode();
                    form.Location = _grid.PointToScreen(new Point(20, 20));
                    form.Show(_grid.TopLevelControl);
                    break;

                default:
                    _grid.RootHost.AddView(view);
                    break;
                }
            }
        }