示例#1
0
        public TopBarMenu(TopBar parent, string label, int menuButtonNum = 1)
            : base(parent.parent, (int)parent.parent.UIFontSmall.MeasureString(label).X + 10, parent.Height - 4,
                   parent.GetNextPos((int)parent.parent.UIFontSmall.MeasureString(label).X + 10), Parameters.Filled, parent.parent.BaseColor, null, 0)
        {
            this.label  = label;
            labelOffset = Pos + (new Vector2(Width, Height) - this.parent.UIFontSmall.MeasureString(label)) / 2;
            labelOffset.Floor();

            MenuVisible   = false;
            menuButtons   = new List <TopBarMenuButton>(menuButtonNum);
            buttonOffset  = Pos + new Vector2(0, Height + 3);
            buttonSpacing = new Vector2(0, MenuButtonHeight);

            ConnectInput();
        }
示例#2
0
        public void InitializeUI()
        {
            int topBarHeight = 24;
            int sideBarWidth = 240;

            Parameters parameters = Parameters.Filled;

            TopBar = new TopBar(parent, parent.ScreenWidth / 3, topBarHeight, new Vector2(parent.ScreenWidth / 3, 0), parameters, FillColor);
            FileMenu fileMenu = new FileMenu(TopBar);

            TopBar.AddButton(fileMenu);
            TopBar.AddButton(new EditMenu(TopBar));

            parent.objectHandler.InputStateChanged += TopBar.OnInputStateChanged;

            SideBar leftSideBar = new SideBar(parent, sideBarWidth, parent.ScreenHeight, Vector2.Zero, parameters, FillColor);

            leftSideBar.AddTool(new TextureCatalog(leftSideBar));
            leftSideBar.AddTool(new GridTools(leftSideBar));

            SideBar rightSideBar = new SideBar(parent, sideBarWidth, parent.ScreenHeight, new Vector2(parent.ScreenWidth - sideBarWidth, 0), parameters, FillColor);

            rightSideBar.AddTool(new SpriteScale(rightSideBar));
            rightSideBar.AddTool(new SpriteZValue(rightSideBar));
            rightSideBar.AddTool(new SpriteColorTint(rightSideBar));
            rightSideBar.AddTool(new SpriteRotation(rightSideBar));
            rightSideBar.AddTool(new SpriteFlip(rightSideBar));

            DialogWindow saveDialog = new SaveDialog(parent);

            fileMenu.saveButton.ButtonPressed += saveDialog.Show;

            DialogWindow loadDialog = new LoadDialog(parent);

            fileMenu.loadButton.ButtonPressed += loadDialog.Show;

            DialogWindow newProjectDialog = new NewDialog(parent);

            fileMenu.newProjectButton.ButtonPressed += newProjectDialog.Show;

            uiObjects.Add(TopBar);
            uiObjects.Add(leftSideBar);
            uiObjects.Add(rightSideBar);
            uiObjects.Add(saveDialog);
            uiObjects.Add(loadDialog);
            uiObjects.Add(newProjectDialog);
        }