Basisklasse für alle MonoGame-Komponenten
Inheritance: Microsoft.Xna.Framework.DrawableGameComponent
Exemplo n.º 1
0
        public StartScreen(BaseScreenComponent manager)
            : base(manager)
        {
            Background = new BorderBrush(Color.DarkRed);

            StackPanel stack = new StackPanel(manager);
            Controls.Add(stack);

            // Button zur Controls Demo
            Button controlScreenButton = Button.TextButton(manager, "Controls", "special");          //Button mit speziellen Style erstellen
            controlScreenButton.LeftMouseClick += (s, e) =>                                      //Click Event festlegen
            {
                manager.NavigateToScreen(new SplitScreen(manager));                     //Screen wechseln
            };
            stack.Controls.Add(controlScreenButton);                                                   //Button zu Root hinzufügen

            // Button zur Mouse Capture Demo
            Button capturedMouseButton = Button.TextButton(manager, "Captured Mouse", "special");
            capturedMouseButton.LeftMouseClick += (s, e) => manager.NavigateToScreen(new MouseCaptureScreen(manager));
            stack.Controls.Add(capturedMouseButton);

            Button tabDemoScreen = Button.TextButton(manager, "Tab Demo", "special");
            tabDemoScreen.LeftMouseClick += (s, e) => manager.NavigateToScreen(new TabScreen(manager));
            stack.Controls.Add(tabDemoScreen);

            Button dragDropScreen = Button.TextButton(manager, "Drag & Drop", "special");
            dragDropScreen.LeftMouseClick += (s, e) => manager.NavigateToScreen(new DragDropScreen(manager));
            stack.Controls.Add(dragDropScreen);
        }
Exemplo n.º 2
0
        public MouseCaptureScreen(BaseScreenComponent manager)
            : base(manager)
        {
            DefaultMouseMode = MouseMode.Captured;

            Background = new BorderBrush(Color.Green);

            StackPanel stack = new StackPanel(manager);
            Controls.Add(stack);

            Label title = new Label(manager)
            {
                TextColor = Color.White,
                Text = "Press ESC to return to Main Screen",
            };

            output = new Label(manager)
            {
                TextColor = Color.White,
                Text = position.ToString(),
            };

            stack.Controls.Add(title);
            stack.Controls.Add(output);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initialisiert einen Standard-Button mit Text-Inhalt
 /// </summary>
 /// <param name="text">Enthaltener Text</param>
 /// <param name="manager">Der <see cref="IScreenManager"/></param>
 /// <param name="style">(Optional) Der zu verwendende Style</param>
 /// <returns>Button-Instanz</returns>
 public static Button TextButton(BaseScreenComponent manager, string text, string style = "")
 {
     return new Button(manager, style)
     {
         Content = new Label(manager) { Text = text }
     };
 }
Exemplo n.º 4
0
 /// <summary>
 /// Erzeugt eine neue Instanz der Klasse Checkbox
 /// </summary>
 /// <param name="manager">Der verwendete <see cref="IScreenManager"/></param>
 public Checkbox(BaseScreenComponent manager)
     : base(manager)
 {
     CanFocus = true;
     TabStop = true;
     ApplySkin(typeof(Checkbox));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Base Constructor
        /// </summary>
        /// <param name="manager">ScreenManager</param>
        public TabControl(BaseScreenComponent manager)
            : base(manager)
        {
            Pages = new ItemCollection<TabPage>();
            Pages.OnInsert += OnInsert;
            Pages.OnRemove += OnRemove;

            tabControlGrid = new Grid(manager)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch
            };
            tabControlGrid.Columns.Add(new ColumnDefinition() {ResizeMode = ResizeMode.Parts, Width = 1});
            tabControlGrid.Rows.Add(new RowDefinition() {ResizeMode = ResizeMode.Auto});
            tabControlGrid.Rows.Add(new RowDefinition() {ResizeMode = ResizeMode.Parts, Height =  1});
            Content = tabControlGrid;

            tabListStack = new StackPanel(manager);
            tabListStack.HorizontalAlignment = HorizontalAlignment.Stretch;
            tabListStack.Orientation = Orientation.Horizontal;
            tabListStack.Background = TabListBackground;
            tabControlGrid.AddControl(tabListStack, 0, 0);

            tabPage = new ContentControl(manager);
            tabPage.HorizontalAlignment = HorizontalAlignment.Stretch;
            tabPage.VerticalAlignment = VerticalAlignment.Stretch;
            tabPage.Background = TabPageBackground;
            tabControlGrid.AddControl(tabPage, 0, 1);

            ApplySkin(typeof(TabControl));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Erzeugt eine neue Instanz der Klasse Button.
        /// </summary>
        /// <param name="manager">Der <see cref="IScreenManager"/></param>
        /// <param name="style">(Optional) der zu verwendende Style</param>
        public Button(BaseScreenComponent manager, string style = "")
            : base(manager, style)
        {
            TabStop = true;
            CanFocus = true;

            ApplySkin(typeof(Button));
        }
Exemplo n.º 7
0
        public Splitter(BaseScreenComponent manager, string style = "")
            : base(manager, style)
        {
            CanFocus = true;
            TabStop = true;

            ApplySkin(typeof(Splitter));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Erzeugt eine neue Instanz der Textbox-Klasse
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="style"></param>
        public Textbox(BaseScreenComponent manager, string style = "")
            : base(manager, style)
        {
            TextColor = Color.Black;
            TabStop = true;
            CanFocus = true;
            Padding = Border.All(5);

            ApplySkin(typeof(Textbox));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Erzeugt einen neuen Slider.
        /// </summary>
        /// <param name="manager">Der verwendete <see cref="IScreenManager"/></param>
        /// <param name="style">(Optional) Der zu verwendende Style.</param>
        public Slider(BaseScreenComponent manager, string style = "")
            : base(manager, style)
        {
            CanFocus = true;
            TabStop = true;

            Range = 100;
            Value = 50;

            ApplySkin(typeof(Slider));
        }
Exemplo n.º 10
0
        public Control(BaseScreenComponent manager, string style = "")
        {
            if (manager == null)
                throw new ArgumentNullException("manager");

            ScreenManager = manager;
            Style = style;

            children = new ControlCollection(this);
            children.OnInsert += ControlCollectionInsert;
            children.OnRemove += ControlCollectionRemove;

            manager.ClientSizeChanged += (s, e) =>
            {
                OnResolutionChanged();
            };

            ApplySkin(typeof(Control));
        }
Exemplo n.º 11
0
        public TabScreen(BaseScreenComponent manager)
            : base(manager)
        {
            //Create Tab Pages
            TabPage tabPage = new TabPage(manager, "Tab 1");
            TabPage tabPage2 = new TabPage(manager, "Tab 2");
            TabPage tabPage3 = new TabPage(manager, "Tab 3");

            //Create Tab Control & Add Pages
            TabControl tab = new TabControl(manager);
            tab.Pages.Add(tabPage);
            tab.Pages.Add(tabPage2);
            tab.Pages.Add(tabPage3);
            tab.VerticalAlignment = VerticalAlignment.Stretch;
            tab.HorizontalAlignment = HorizontalAlignment.Stretch;

            //Add Text to Page 1
            tabPage.Controls.Add(new Label(manager) { Text = "Content on Page 1" });

            //Add "Create Tab" to page 2
            Button createPage = Button.TextButton(manager, "Create Tab");
            createPage.LeftMouseClick += (s, e) =>
            {
                TabPage page = new TabPage(manager, "NEW TAB");
                page.Controls.Add(new Label(manager) { Text = "This is a new tab page" });
                tab.Pages.Add(page);
            };
            tabPage2.Controls.Add(createPage);

            //Add "Remove this page" to page 3
            Button removePage3 = Button.TextButton(manager, "Remove this Page");
            removePage3.LeftMouseClick += (s, e) =>
            {
                tab.Pages.Remove(tabPage3);
            };
            tabPage3.Controls.Add(removePage3);

            Controls.Add(tab);
        }
Exemplo n.º 12
0
 public ContentControl(BaseScreenComponent manager, string style = "")
     : base(manager, style)
 {
     ApplySkin(typeof(ContentControl));
 }
Exemplo n.º 13
0
 internal FlyoutControl(BaseScreenComponent manager)
     : base(manager)
 {
     ApplySkin(typeof(FlyoutControl));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Erzeugt eine neue Instanz eines Bildsteuerlements.
 /// </summary>
 /// <param name="manager">Der verwendete <see cref="IScreenManager"/></param>
 /// <param name="style">(Optional) Der zu verwendende Style.</param>
 public Image(BaseScreenComponent manager, string style = "")
     : base(manager, style)
 {
     ApplySkin(typeof(Image));
 }
Exemplo n.º 15
0
 public Label(BaseScreenComponent manager, string style = "") :
     base(manager, style)
 {
     ApplySkin(typeof(Label));
 }
Exemplo n.º 16
0
 public HealthBarControl(BaseScreenComponent manager, string style = "")
     : base(manager, style)
 {
     Background = Skin.Current.HorizontalScrollBackgroundBrush;
 }
Exemplo n.º 17
0
 public Label(BaseScreenComponent manager, string style = "")
     : base(manager, style)
 {
     ApplySkin(typeof(Label));
 }
Exemplo n.º 18
0
 public ProgressBar(BaseScreenComponent manager, string style = "")
     : base(manager, style)
 {
     ApplySkin(typeof(ProgressBar));
 }
Exemplo n.º 19
0
        public SplitScreen(BaseScreenComponent manager)
            : base(manager)
        {
            Background = new BorderBrush(Color.Gray);                       //Hintergrundfarbe festlegen

            Button backButton = Button.TextButton(manager, "Back");             //Neuen TextButton erzeugen
            backButton.HorizontalAlignment = HorizontalAlignment.Left;          //Links
            backButton.VerticalAlignment = VerticalAlignment.Top;               //Oben
            backButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); }; //KlickEvent festlegen
            Controls.Add(backButton);                                           //Button zum Screen hinzufügen

            //ScrollContainer
            ScrollContainer scrollContainer = new ScrollContainer(manager)  //Neuen ScrollContainer erzeugen
            {
                VerticalAlignment = VerticalAlignment.Stretch,              // 100% Höhe
                HorizontalAlignment = HorizontalAlignment.Stretch           //100% Breite
            };
            Controls.Add(scrollContainer);                                  //ScrollContainer zum Root(Screen) hinzufügen

            //Stackpanel - SubControls werden Horizontal oder Vertikal gestackt
            StackPanel panel = new StackPanel(manager);                 //Neues Stackpanel erzeugen
            panel.VerticalAlignment = VerticalAlignment.Stretch;        //100% Höhe
            scrollContainer.Content = panel;                            //Ein Scroll Container kann nur ein Control beherbergen

            //Label
            Label label = new Label(manager) { Text = "Control Showcase" }; //Neues Label erzeugen
            panel.Controls.Add(label);                                      //Label zu Panel hinzufügen

            Button tB = Button.TextButton(manager, "TEST");
            tB.Background = new TextureBrush(LoadTexture2DFromFile("./test_texture_round.png", manager.GraphicsDevice), TextureBrushMode.Stretch);
            panel.Controls.Add(tB);

            //Button
            Button button = Button.TextButton(manager, "Dummy Button"); //Neuen TextButton erzeugen
            panel.Controls.Add(button);                                 //Button zu Panel hinzufügen

            //Progressbar
            ProgressBar pr = new ProgressBar(manager)                   //Neue ProgressBar erzeugen
            {
                Value = 99,                                             //Aktueller Wert
                Height = 20,                                            //Höhe
                Width = 200                                             //Breite
            };
            panel.Controls.Add(pr);                                     //ProgressBar zu Panel hinzufügen

            //ListBox
            Listbox<string> list = new Listbox<string>(manager);        //Neue ListBox erstellen
            list.TemplateGenerator = (item) =>                          //Template Generator festlegen
            {
                return new Label(manager) { Text = item };              //Control (Label) erstellen
            };
            panel.Controls.Add(list);                                   //Liste zu Panel hinzufügen

            list.Items.Add("Hallo");                                    //Items zur Liste hinzufügen
            list.Items.Add("Welt");                                     //...

            //Combobox
            Combobox<string> combobox = new Combobox<string>(manager)   //Neue Combobox erstellen
            {
                Height = 20,                                            //Höhe 20
                Width = 100                                             //Breite 100
            };
            combobox.TemplateGenerator = (item) =>                      //Template Generator festlegen
            {
                return new Label(manager) { Text = item };              //Control (Label) erstellen
            };
            panel.Controls.Add(combobox);                               //Combobox zu Panel  hinzufügen

            combobox.Items.Add("Combobox");                             //Items zu Combobox hinzufügen
            combobox.Items.Add("Item");
            combobox.Items.Add("Hallo");

            Button clearCombobox = Button.TextButton(manager, "Clear Combobox");
            clearCombobox.LeftMouseClick += (s, e) => {
                combobox.Items.Clear();
                list.Items.Clear();
            };
            panel.Controls.Add(clearCombobox);

            //Slider Value Label
            Label labelSliderHorizontal = new Label(manager);

            //Horizontaler Slider
            Slider sliderHorizontal = new Slider(manager)
            {
                Width = 150,
                Height = 20,
            };
            sliderHorizontal.ValueChanged += (value) => { labelSliderHorizontal.Text = "Value: " + value; }; //Event on Value Changed
            panel.Controls.Add(sliderHorizontal);
            labelSliderHorizontal.Text = "Value: " + sliderHorizontal.Value;                                 //Set Text initially
            panel.Controls.Add(labelSliderHorizontal);

            //Slider Value Label
            Label labelSliderVertical = new Label(manager);

            //Vertikaler Slider
            Slider sliderVertical = new Slider(manager)
            {
                Range = 100,
                Height = 200,
                Width = 20,
                Orientation = Orientation.Vertical
            };
            sliderVertical.ValueChanged += (value) => { labelSliderVertical.Text = "Value: " + value; };
            panel.Controls.Add(sliderVertical);
            labelSliderVertical.Text = "Value: " + sliderVertical.Value;
            panel.Controls.Add(labelSliderVertical);

            Checkbox checkbox = new Checkbox(manager);
            panel.Controls.Add(checkbox);

            //Textbox
            textbox = new Textbox(manager)                      //Neue TextBox erzeugen
            {
                Background = new BorderBrush(Color.LightGray),          //Festlegen eines Backgrounds für ein Control
                HorizontalAlignment = HorizontalAlignment.Stretch,          //100% Breite
                Text = "TEXTBOX!",                                      //Voreingestellter text
                MinWidth = 100                                          //Eine Textbox kann ihre Größe automatisch anpassen
            };

            Button clearTextbox = Button.TextButton(manager, "Clear Textbox");
            clearTextbox.LeftMouseClick += (s, e) =>
            {
                textbox.SelectionStart = 0;
                textbox.Text = "";
            };

            Button disableControls = Button.TextButton(manager, "Toggle Controls disabled");
            disableControls.LeftMouseClick += (s, e) =>
            {
                foreach (var c in panel.Controls)
                {
                    c.Enabled = !c.Enabled;
                }
            };
            panel.Controls.Add(clearTextbox);
            panel.Controls.Add(textbox);                                //Textbox zu Panel hinzufügen
            panel.Controls.Add(disableControls);
        }
Exemplo n.º 20
0
 public CanvasControl(BaseScreenComponent manager, string style = "")
     : base(manager, style)
 {
     ApplySkin(typeof(CanvasControl));
 }
Exemplo n.º 21
0
 public TabPage(BaseScreenComponent manager, string title)
     : base(manager)
 {
     Title = title;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Erzeugt eine neue Instanz der Klasse StackPanel.
 /// </summary>
 /// <param name="manager">Der <see cref="IScreenManager"/></param>
 public StackPanel(BaseScreenComponent manager) : base(manager)
 {
     ApplySkin(typeof(StackPanel));
 }