Пример #1
0
        private void DialogDemo()
        {
            var dialog = Skin.Create <GuiDialog>("dialog");

            var stackPanel = new GuiStackPanel
            {
                Controls =
                {
                    Skin.Create <GuiLabel>("label",                 c =>
                    {
                        c.Text   = "Are you sure you want to do that?";
                        c.Margin = new Thickness(0,                 20, 0, 0);
                    }),
                    Skin.Create <GuiLabel>("label",                 c => { c.Text = "If you do you'll be in some serious trouble."; }),
                    new GuiStackPanel
                    {
                        Orientation         = GuiOrientation.Horizontal,
                        VerticalAlignment   = VerticalAlignment.Bottom,
                        HorizontalAlignment = HorizontalAlignment.Centre,
                        Controls            =
                        {
                            Skin.Create <GuiButton>("white-button", c =>
                            {
                                c.Text   = "Yes";
                                c.Width  = 100;
                                c.Margin = new Thickness(2);
                                c.Offset = new Vector2(0,                                     20);
                            }),
                            Skin.Create <GuiButton>("white-button", c =>
                            {
                                c.Text   = "No";
                                c.Width  = 100;
                                c.Margin = new Thickness(2);
                                c.Offset = new Vector2(0, 20);
                            })
                        }
                    }
                }
            };

            dialog.Controls.Add(stackPanel);
            dialog.Controls.Add(Skin.Create <GuiLabel>("label", c =>
            {
                c.Text = "Please confirm";
                c.VerticalAlignment   = VerticalAlignment.Top;
                c.HorizontalAlignment = HorizontalAlignment.Centre;
                c.Offset           = new Vector2(0, -30);
                c.BackgroundRegion = Skin.NinePatches.FirstOrDefault(i => i.Name == "progress-bar-blue");
            }));
            dialog.Controls.Add(Skin.Create <GuiButton>("close-button", c =>
            {
                c.HorizontalAlignment = HorizontalAlignment.Right;
                c.VerticalAlignment   = VerticalAlignment.Top;
                c.Offset = new Vector2(20, -20);
            }));

            dialog.Show(this);
        }
Пример #2
0
 private void InitWindow()
 {
     Title = new GuiDockChild()
     {
         Dock    = GuiDock.Top,
         Control = new GuiLabel()
         {
             Text = "My Window 2"
         }
     };
     X       = 150;
     Y       = 100;
     Width   = 500;
     Height  = 400;
     Margin  = new GuiThickness(50);
     Name    = "W2";
     Content = new GuiStackPanel()
     {
         Name        = "Stack",
         Margin      = new GuiThickness(0),
         Orientation = GuiStackPanelOrientation.Horizontal,
         Childs      = new List <GuiStackChild>
         {
             new GuiStackChild()
             {
                 Control = new GuiPanel()
                 {
                     Name                = "Panel Left",
                     BackgroundColor     = Color.White,
                     Width               = 200,
                     HorizontalAlignment = GuiHorizontalAlignment.Left,
                     Content             = new GuiStackPanel()
                     {
                         Name        = "Stack",
                         Margin      = new GuiThickness(0),
                         Orientation = GuiStackPanelOrientation.Vertical,
                         Childs      = new List <GuiStackChild>()
                         {
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 1", Padding = new GuiThickness(2), BackgroundColor = Color.Yellow
                                 }
                             },
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 2", Padding = new GuiThickness(4), BackgroundColor = Color.Yellow
                                 }
                             },
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 3", Padding = new GuiThickness(6), BackgroundColor = Color.Yellow
                                 }
                             },
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 4", Padding = new GuiThickness(8), BackgroundColor = Color.Yellow
                                 }
                             },
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 5", Padding = new GuiThickness(10), BackgroundColor = Color.Yellow
                                 }
                             },
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 6", Padding = new GuiThickness(2), BackgroundColor = Color.Pink, HorizontalAlignment = GuiHorizontalAlignment.Left
                                 }
                             },
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 7", Padding = new GuiThickness(2), BackgroundColor = Color.Pink, HorizontalAlignment = GuiHorizontalAlignment.Right
                                 }
                             },
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 8", Padding = new GuiThickness(2), BackgroundColor = Color.Pink, HorizontalAlignment = GuiHorizontalAlignment.Center
                                 }
                             },
                             new GuiStackChild()
                             {
                                 Control = new GuiLabel()
                                 {
                                     Text = "Line 9", Padding = new GuiThickness(2), BackgroundColor = Color.Pink, HorizontalAlignment = GuiHorizontalAlignment.Stretch
                                 }
                             },
                         }
                     }
                 }
             },
             new GuiStackChild()
             {
                 Control = new GuiPanel()
                 {
                     Name                = "Panel Right",
                     BackgroundColor     = Color.Blue,
                     HorizontalAlignment = GuiHorizontalAlignment.Left,
                 }
             }
         }
     };
 }
Пример #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            fEngine           = new GuiEngine(this, fOptions, fGraphics);
            fEngine.OnResize += FEngine_OnResize;

            fFpsEngine = new FpsEngine(this);

            fInputManager = fEngine.InputManager;// new InputManager(this);

            fWindow1 = new MainWindow(fEngine);
            //fWindow2 = new GuiWindow()
            //{
            //    BackgroundColor = Color.Yellow,
            //    Content = new GuiExpandablePanel()
            //    {
            //        Content = new GuiLabel() { Text = "Now you see me" },
            //        PanelState = GuiExpandablePanelState.Expanded,
            //        Title = new GuiDockChild()
            //        {
            //            Dock = GuiDock.Top,
            //            Control = new GuiLabel() { Text = "Click to expand" }
            //        },
            //    }
            //};

            GuiStackPanel menuPanel = new GuiStackPanel()
            {
                BackgroundColor = new Color(Color.DarkSlateBlue, 0.7f)
            };

            fExPanel = new GuiExpandablePanel()
            {
                Content    = menuPanel,
                PanelState = GuiExpandablePanelState.Collapsed,
                Title      = new GuiDockChild()
                {
                    Dock    = GuiDock.Top,
                    Control = new GuiLabel()
                    {
                        Text = "Click", BackgroundColor = new Color(Color.Black, 0.7f), ForegroundColor = Color.White
                    },
                },
            };

            fWindow2 = new GuiWindow()
            {
                Title = new GuiDockChild()
                {
                    Dock    = GuiDock.Bottom,
                    Control = fExPanel,
                },
                Content = new GuiPanel()
                {
                },                             // Fill upp window
                //Content = new GuiPanel() { Width=0, Height=0},
                Border = new GuiBorder()
                {
                    Border = new GuiThickness(1), BorderColor = Color.Red
                }
            };

            fEngine.AddWindow(fWindow1);
            fEngine.AddWindow(fWindow2);

            //var w = new BasicLines1EngineControlWindow(fEngine);
            //fEngine.AddWindow(w);
            //fEngine.AddWindow(new MainWindow(fEngine));

            this.Components.Add(fEngine);
            this.Components.Add(fFpsEngine);
            //this.Components.Add(fInputManager);

            fContainer           = new EngineContainer(this, fGraphics, fInputManager, fEngine, fFpsEngine);
            fContainer.BackColor = Color.Transparent;

            fEngines = EngineFactory.GetEngines(fContainer);

            foreach (var engine in fEngines)
            {
                engine.DoInitialize();
            }

            var index = 0;

            foreach (var engine in fEngines)
            {
                var label = new GuiLabel()
                {
                    Text            = engine.GetName(),
                    BackgroundColor = new Color(Color.Gray, 0.5f),
                    ForegroundColor = Color.White,
                };
                label.OnClick += Label_OnClick;
                label.Tag      = index++;
                menuPanel.Childs.Add(new GuiStackChild()
                {
                    Control = label
                });
            }

            base.Initialize();
        }