예제 #1
0
        public override bool DragAndDrop_HandleDrop(Package p, int x, int y)
        {
            Point pos = CanvasPosToLocal(new Point(x, y));
            Pos   dir = GetDroppedTabDirection(pos.X, pos.Y);

            DockedTabControl addTo = m_DockedTabControl;

            if (dir == Pos.Fill && addTo == null)
            {
                return(false);
            }

            if (dir != Pos.Fill)
            {
                DockBase dock = GetChildDock(dir);
                addTo = dock.m_DockedTabControl;

                if (!m_DropFar)
                {
                    dock.BringToFront();
                }
                else
                {
                    dock.SendToBack();
                }
            }

            if (p.Name == "TabButtonMove")
            {
                TabButton tabButton = DragAndDrop.SourceControl as TabButton;
                if (null == tabButton)
                {
                    return(false);
                }

                addTo.AddPage(tabButton);
            }

            if (p.Name == "TabWindowMove")
            {
                DockedTabControl tabControl = DragAndDrop.SourceControl as DockedTabControl;
                if (null == tabControl)
                {
                    return(false);
                }

                if (tabControl == addTo)
                {
                    return(false);
                }

                tabControl.MoveTabsTo(addTo);
            }

            Invalidate();

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Gets an inner docked control for the specified position.
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        protected virtual DockBase GetChildDock(Dock pos)
        {
            // todo: verify
            DockBase dock = null;

            switch (pos)
            {
            case Dock.Left:
                if (m_Left == null)
                {
                    m_Left       = new DockBase(this);
                    m_Left.Width = 200;
                    m_Left.SetupChildDock(pos);
                }
                dock = m_Left;
                break;

            case Dock.Right:
                if (m_Right == null)
                {
                    m_Right       = new DockBase(this);
                    m_Right.Width = 200;
                    m_Right.SetupChildDock(pos);
                }
                dock = m_Right;
                break;

            case Dock.Top:
                if (m_Top == null)
                {
                    m_Top        = new DockBase(this);
                    m_Top.Height = 200;
                    m_Top.SetupChildDock(pos);
                }
                dock = m_Top;
                break;

            case Dock.Bottom:
                if (m_Bottom == null)
                {
                    m_Bottom        = new DockBase(this);
                    m_Bottom.Height = 200;
                    m_Bottom.SetupChildDock(pos);
                }
                dock = m_Bottom;
                break;
            }

            if (dock != null)
            {
                dock.IsCollapsed = false;
            }

            return(dock);
        }
        /// <summary>
        /// Gets an inner docked control for the specified position.
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        protected virtual DockBase GetChildDock(Pos pos)
        {
            // todo: verify
            DockBase dock = null;

            switch (pos)
            {
            case Pos.Left:
                if (m_Left == null)
                {
                    m_Left = new DockBase(this);
                    m_Left.SetupChildDock(pos);
                }
                dock = m_Left;
                break;

            case Pos.Right:
                if (m_Right == null)
                {
                    m_Right = new DockBase(this);
                    m_Right.SetupChildDock(pos);
                }
                dock = m_Right;
                break;

            case Pos.Top:
                if (m_Top == null)
                {
                    m_Top = new DockBase(this);
                    m_Top.SetupChildDock(pos);
                }
                dock = m_Top;
                break;

            case Pos.Bottom:
                if (m_Bottom == null)
                {
                    m_Bottom = new DockBase(this);
                    m_Bottom.SetupChildDock(pos);
                }
                dock = m_Bottom;
                break;
            }

            if (dock != null)
            {
                dock.IsHidden = false;
            }

            return(dock);
        }
예제 #4
0
        /// <summary>
        /// Gets an inner docked control for the specified position.
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        protected virtual DockBase getChildDock(Pos pos)
        {
            // todo: verify
            DockBase dock = null;

            switch (pos)
            {
            case Pos.Left:
                if (left == null)
                {
                    left = new DockBase(this);
                    left.setupChildDock(pos);
                }
                dock = left;
                break;

            case Pos.Right:
                if (right == null)
                {
                    right = new DockBase(this);
                    right.setupChildDock(pos);
                }
                dock = right;
                break;

            case Pos.Top:
                if (top == null)
                {
                    top = new DockBase(this);
                    top.setupChildDock(pos);
                }
                dock = top;
                break;

            case Pos.Bottom:
                if (bottom == null)
                {
                    bottom = new DockBase(this);
                    bottom.setupChildDock(pos);
                }
                dock = bottom;
                break;
            }

            if (dock != null)
            {
                dock.IsHidden = false;
            }

            return(dock);
        }
        protected virtual void DoRedundancyCheck()
        {
            if (!IsEmpty)
            {
                return;
            }

            DockBase pDockParent = Parent as DockBase;

            if (null == pDockParent)
            {
                return;
            }

            pDockParent.OnRedundantChildDock(this);
        }
 protected virtual void OnRedundantChildDock(DockBase dock)
 {
     dock.IsHidden = true;
     DoRedundancyCheck();
     DoConsolidateCheck();
 }
예제 #7
0
 protected virtual void OnRedundantChildDock(DockBase dock)
 {
     dock.IsHidden = true;
     DoRedundancyCheck();
     DoConsolidateCheck();
 }
예제 #8
0
        /// <summary>
        /// Gets an inner docked control for the specified position.
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        protected virtual DockBase GetChildDock(Pos pos)
        {
            // todo: verify
            DockBase dock = null;
            switch (pos)
            {
                case Pos.Left:
                    if (m_Left == null)
                    {
                        m_Left = new DockBase(this);
                        m_Left.SetupChildDock(pos);
                    }
                    dock = m_Left;
                    break;

                case Pos.Right:
                    if (m_Right == null)
                    {
                        m_Right = new DockBase(this);
                        m_Right.SetupChildDock(pos);
                    }
                    dock = m_Right;
                    break;

                case Pos.Top:
                    if (m_Top == null)
                    {
                        m_Top = new DockBase(this);
                        m_Top.SetupChildDock(pos);
                    }
                    dock = m_Top;
                    break;

                case Pos.Bottom:
                    if (m_Bottom == null)
                    {
                        m_Bottom = new DockBase(this);
                        m_Bottom.SetupChildDock(pos);
                    }
                    dock = m_Bottom;
                    break;
            }

            if (dock != null)
                dock.IsHidden = false;

            return dock;
        }
예제 #9
0
        private void InitializeUI()
        {
            settings = NavMeshGenerationSettings.Default;
            areaSettings = new AreaIdGenerationSettings();

            DockBase dock = new DockBase(gwenCanvas);
            dock.Dock = Pos.Fill;
            dock.SetSize(Width, Height);
            dock.RightDock.Width = 280;
            dock.BottomDock.Height = 150;

            statusBar = new StatusBar(gwenCanvas);

            Label genTime = new Label(statusBar);
            genTime.Name = "GenTime";
            genTime.Text = "Generation Time: 0ms";
            genTime.Dock = Pos.Left;

            LabeledCheckBox catchCheckBox = new LabeledCheckBox(statusBar);
            catchCheckBox.Text = "Intercept and log exceptions";
            catchCheckBox.Dock = Pos.Right;
            catchCheckBox.CheckChanged += (s, e) => interceptExceptions = catchCheckBox.IsChecked;
            catchCheckBox.IsChecked = true;

            Base genBase = new Base(dock);
            dock.RightDock.TabControl.AddPage("NavMesh Generation", genBase);

            Button generateButton = new Button(genBase);
            generateButton.Text = "Generate!";
            generateButton.Height = 30;
            generateButton.Dock = Pos.Top;
            generateButton.Released += (s, e) => GenerateNavMesh();

            GroupBox displaySettings = new GroupBox(genBase);
            displaySettings.Text = "Display";
            displaySettings.Dock = Pos.Top;
            displaySettings.Height = 60;

            Base levelCheckBase = new Base(displaySettings);
            levelCheckBase.Dock = Pos.Top;

            Label levelCheckLabel = new Label(levelCheckBase);
            levelCheckLabel.Text = "Level";
            levelCheckLabel.Dock = Pos.Left;

            CheckBox levelCheckBox = new CheckBox(levelCheckBase);
            levelCheckBox.Dock = Pos.Right;
            levelCheckBox.Checked += (s, e) => displayLevel = true;
            levelCheckBox.UnChecked += (s, e) => displayLevel = false;
            levelCheckBox.IsChecked = true;

            levelCheckBase.SizeToChildren();

            Base displayModeBase = new Base(displaySettings);
            displayModeBase.Dock = Pos.Top;
            displayModeBase.Padding = new Padding(0, 4, 0, 0);

            Label displayModeLabel = new Label(displayModeBase);
            displayModeLabel.Text = "Generation Step";
            displayModeLabel.Dock = Pos.Left;
            displayModeLabel.Padding = new Padding(0, 0, 4, 0);

            ComboBox displayModes = new ComboBox(displayModeBase);
            displayModes.Dock = Pos.Top;
            displayModes.AddItem("None", "", DisplayMode.None);
            displayModes.AddItem("Heightfield", "", DisplayMode.Heightfield);
            displayModes.AddItem("Compact Heightfield", "", DisplayMode.CompactHeightfield);
            displayModes.AddItem("Distance Field", "", DisplayMode.DistanceField);
            displayModes.AddItem("Regions", "", DisplayMode.Regions);
            displayModes.AddItem("Contours", "", DisplayMode.Contours);
            displayModes.AddItem("Polygon Mesh", "", DisplayMode.PolyMesh);
            displayModes.AddItem("Polygon Mesh Detail", "", DisplayMode.PolyMeshDetail);
            displayModes.AddItem("NavMesh", "", DisplayMode.NavMesh);
            displayModes.AddItem("Pathfinding", "", DisplayMode.Pathfinding);
            displayModes.ItemSelected += (s, e) => displayMode = (DisplayMode)e.SelectedItem.UserData;

            displayModes.SelectByUserData(DisplayMode.PolyMeshDetail);

            displayModeBase.SizeToChildren();
            displayModeBase.Height += 4; //accounts for the padding, GWEN.NET should do this

            const int leftMax = 125;
            const int rightMax = 20;

            GroupBox areaSetting = new GroupBox(genBase);
            areaSetting.Text = "Area";
            areaSetting.Dock = Pos.Top;
            areaSetting.Height = 90;

            var levelTris = level.GetTriangles();
            BBox3 bounds = TriangleEnumerable.FromTriangle(levelTris, 0, levelTris.Length).GetBoundingBox();

            Base maxTriSlope = CreateSliderOption(areaSetting, "Max Tri Slope:", 0.0001f, 3.14f, 3.14f, "N2", leftMax, rightMax, v => areaSettings.MaxTriSlope = v);
            Base minLevelHeight = CreateSliderOption(areaSetting, "Min Height:", bounds.Min.Y, bounds.Max.Y, bounds.Min.Y, "N0", leftMax, rightMax, v => areaSettings.MinLevelHeight = v);
            Base maxLevelHeight = CreateSliderOption(areaSetting, "Max Height:", bounds.Min.Y, bounds.Max.Y, bounds.Max.Y, "N0", leftMax, rightMax, v => areaSettings.MaxLevelHeight = v);

            GroupBox rsSettings = new GroupBox(genBase);
            rsSettings.Text = "Rasterization";
            rsSettings.Dock = Pos.Top;
            rsSettings.Height = 90;

            Base cellSizeSetting = CreateSliderOption(rsSettings, "Cell Size:", 0.1f, 2.0f, 0.3f, "N2", leftMax, rightMax, v => settings.CellSize = v);
            Base cellHeightSetting = CreateSliderOption(rsSettings, "Cell Height:", 0.1f, 2f, 0.2f, "N2", leftMax, rightMax, v => settings.CellHeight = v);

            GroupBox agentSettings = new GroupBox(genBase);
            agentSettings.Text = "Agent";
            agentSettings.Dock = Pos.Top;
            agentSettings.Height = 115;

            Base maxSlopeSetting = CreateSliderOption(agentSettings, "Max Climb:", 0.1f, 5.0f, 0.9f, "N0", leftMax, rightMax, v => settings.MaxClimb = v);
            Base maxHeightSetting = CreateSliderOption(agentSettings, "Height:", 0.1f, 5.0f, 2.0f, "N0", leftMax, rightMax, v => settings.AgentHeight = v);
            Base erodeRadius = CreateSliderOption(agentSettings, "Radius:", 0.0f, 5.0f, 0.6f, "N1", leftMax, rightMax, v => { settings.AgentRadius = v; agentCylinder.Radius = v; });
            Base addRemoveAgent = CreateAddRemoveButton(agentSettings, "Count", leftMax, rightMax, 0, MAX_AGENTS, () => { numActiveAgents++; GenerateCrowd(); }, () => { numActiveAgents--; GenerateCrowd(); });

            GroupBox regionSettings = new GroupBox(genBase);
            regionSettings.Text = "Region";
            regionSettings.Dock = Pos.Top;
            regionSettings.Height = 65;

            Base minRegionSize = CreateSliderOption(regionSettings, "Min Region Size:", 0f, 150f, 8f, "N0", leftMax, rightMax, v => settings.MinRegionSize = (int)Math.Round(v));
            Base mrgRegionSize = CreateSliderOption(regionSettings, "Merged Region Size:", 0f, 150f, 20f, "N0", leftMax, rightMax, v => settings.MergedRegionSize = (int)Math.Round(v));

            GroupBox navMeshSettings = new GroupBox(genBase);
            navMeshSettings.Text = "NavMesh";
            navMeshSettings.Dock = Pos.Top;
            navMeshSettings.Height = 90;

            Base maxEdgeLength = CreateSliderOption(navMeshSettings, "Max Edge Length:", 0f, 50f, 12f, "N0", leftMax, rightMax, v => settings.MaxEdgeLength = (int)Math.Round(v));
            Base maxEdgeErr = CreateSliderOption(navMeshSettings, "Max Edge Error:", 0f, 3f, 1.8f, "N1", leftMax, rightMax, v => settings.MaxEdgeError = v);
            Base vertsPerPoly = CreateSliderOption(navMeshSettings, "Verts Per Poly:", 3f, 12f, 6f, "N0", leftMax, rightMax, v => settings.VertsPerPoly = (int)Math.Round(v));

            GroupBox navMeshDetailSettings = new GroupBox(genBase);
            navMeshDetailSettings.Text = "NavMeshDetail";
            navMeshDetailSettings.Dock = Pos.Top;
            navMeshDetailSettings.Height = 65;

            Base sampleDistance = CreateSliderOption(navMeshDetailSettings, "Sample Distance:", 0f, 16f, 6f, "N0", leftMax, rightMax, v => settings.SampleDistance = (int)Math.Round(v));
            Base maxSampleError = CreateSliderOption(navMeshDetailSettings, "Max Sample Error:", 0f, 16f, 1f, "N0", leftMax, rightMax, v => settings.MaxSampleError = (int)Math.Round(v));

            Base logBase = new Base(dock);
            dock.BottomDock.TabControl.AddPage("Log", logBase);

            ListBox logBox = new ListBox(logBase);
            logBox.Dock = Pos.Fill;
            logBox.AllowMultiSelect = false;
            logBox.EnableScroll(true, true);
            Console.SetOut(new GwenTextWriter(logBox));
        }