コード例 #1
0
    public Window(int x, int y, int width, int height, string name, Element windowContent)
        : base(x, y, width, height, true)
    {
        Text text = new Text(name);

        title = new Panel(x, y, width, TITLE_HEIGHT, text, 0, PepesComing.Sprite.DARK_RED);
        close = new Button("X", x + width - CLOSE_WIDTH, y, CLOSE_WIDTH, TITLE_HEIGHT);
        Layout layout = new VerticalLayout(width: width, height: height - TITLE_HEIGHT, padding: 30);

        layout.AddElements(windowContent);
        content = new Panel(x, y + TITLE_HEIGHT, width, height - TITLE_HEIGHT, layout, 30, PepesComing.Sprite.GREY);
        close.AddClickEvent(() => {
            IsVisible = false;
        });
    }
コード例 #2
0
ファイル: UiManager.cs プロジェクト: Swag2k16/MazeSolver
        public UiManager()
        {
            elements = new List <Element>();

            Text title = new Text("Maze Solver");

            // Algorithums
            VerticalLayout algorithms = new VerticalLayout(height: 430, padding: 10);

            WallFollower   = new Button("Wall Follower");
            RandomMouser   = new Button("Random Mouser");
            DeadEndFilling = new Button("Dead-End Filling");
            Recursive      = new Button("Recursive");
            algorithms.AddElements(WallFollower, RandomMouser, DeadEndFilling, Recursive);



            HeightSlider = new Slider(height: 25, steps: 15, currentValue: 7);
            Text             heightText   = new Text("Height: ");
            HorizontalLayout heightLayout = new HorizontalLayout(height: 25);

            heightLayout.AddElements(heightText, HeightSlider);

            WidthSlider = new Slider(height: 25, steps: 15, currentValue: 7);
            Text             widthText   = new Text("Width: ");
            HorizontalLayout widthLayout = new HorizontalLayout(height: 25);

            widthLayout.AddElements(widthText, WidthSlider);

            Regenerate = new Button("Generate", height: 30);
            Regenerate.AddClickEvent(() => {
                mazeResizer.IsVisible = false;
            });

            VerticalLayout windowLayout = new VerticalLayout(padding: 50, maximize: false);

            windowLayout.AddElements(heightLayout, widthLayout, Regenerate);


            mazeResizer = new Window(200, 200, 500, 200, "Choose Maze Size", windowLayout);
            elements.Add(mazeResizer);

            elements.ForEach(e => e.CalculateLayout());

            GenerateMaze = new Button("Generate new maze", height: 100);
            GenerateMaze.AddClickEvent(() => {
                mazeResizer.IsVisible = true;
            });

            Play    = new ToggleButton("Step", "Play");
            Forward = new Button(">");
            HorizontalLayout stepControl = new HorizontalLayout(height: 100, padding: 10);

            stepControl.AddElements(Play, Forward);

            VerticalLayout layout = new VerticalLayout(maximize: false, padding: 10);

            layout.AddElements(title, algorithms, GenerateMaze, stepControl);

            sidebar = new Panel(0, 0, 300, 100, layout, 10, Sprite.GREY);
            elements.Add(sidebar);
        }