public StartScreen(IScreenManager 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); }
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); }
public SplitScreen(IScreenManager manager) : base(manager) { Background = new BorderBrush(Color.Gray); Button backButton = Button.TextButton(manager, "Back"); backButton.HorizontalAlignment = HorizontalAlignment.Left; backButton.VerticalAlignment = VerticalAlignment.Top; backButton.LeftMouseClick += (s, e) => { manager.NavigateBack(); }; Controls.Add(backButton); }
public StartScreen(IScreenManager manager) : base(manager) { Background = new BorderBrush(Color.DarkRed); Button nextButton = Button.TextButton(manager, "Next", "special"); nextButton.LeftMouseClick += (s, e) => { manager.NavigateToScreen(new SplitScreen(manager)); }; Controls.Add(nextButton); }
public MessageScreen(ScreenComponent manager, string title, string content, string buttonText = "OK", Action<Control, MouseEventArgs> buttonClick = null) : base(manager) { IsOverlay = true; Background = new BorderBrush(Color.Black * 0.5f); Title = title; Texture2D panelBackground = manager.Game.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice); Panel panel = new Panel(manager) { Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Controls.Add(panel); StackPanel spanel = new StackPanel(manager); panel.Controls.Add(spanel); Label headLine = new Label(manager) { Text = title, Font = Skin.Current.HeadlineFont, HorizontalAlignment = HorizontalAlignment.Stretch }; spanel.Controls.Add(headLine); Label contentLabel = new Label(manager) { Text = content, Font = Skin.Current.TextFont, HorizontalAlignment = HorizontalAlignment.Stretch }; spanel.Controls.Add(contentLabel); Button closeButton = Button.TextButton(manager, buttonText); closeButton.HorizontalAlignment = HorizontalAlignment.Stretch; closeButton.LeftMouseClick += (s, e) => { if (buttonClick != null) buttonClick(s, e); else manager.NavigateBack(); }; spanel.Controls.Add(closeButton); }
public Skin(ContentManager content) { ControlSkins = new Dictionary <Type, Action <Control> >(); StyleSkins = new Dictionary <string, Action <Control> >(); SplitterWidth = 4; ScrollbarWidth = 10; ScrollerMinSize = 10; BackgroundColor = new Color(20, 147, 73); LogoColorOrange = new Color(241, 145, 11); LogoColorRed = new Color(225, 7, 22); TextColorBlack = new Color(0, 0, 0); TextColorGray = new Color(86, 86, 86); TextColorWhite = new Color(255, 255, 255); HeadlineFont = content.Load <SpriteFont>("HeadlineFont"); TextFont = content.Load <SpriteFont>("GameFont"); BoldFont = content.Load <SpriteFont>("BoldFont"); FocusFrameBrush = new BorderBrush(LineType.Dotted, Color.Black, 1); ButtonBrush = new BorderBrush(Color.White, LineType.Solid, Color.LightGray, 1); ButtonHoverBrush = new BorderBrush(Color.LightGray, LineType.Solid, Color.LightGray, 1); ButtonPressedBrush = new BorderBrush(Color.LightGray, LineType.Solid, Color.Black, 1); PanelBrush = new BorderBrush(Color.White, LineType.Solid, Color.Black, 1); VerticalScrollBackgroundBrush = new BorderBrush(Color.White, LineType.Solid, Color.Black, 1); HorizontalScrollBackgroundBrush = new BorderBrush(Color.White, LineType.Solid, Color.Black, 1); VerticalScrollForegroundBrush = new BorderBrush(Color.LightGray, LineType.Solid, Color.Black, 1); HorizontalScrollForegroundBrush = new BorderBrush(Color.LightGray, LineType.Solid, Color.Black, 1); HorizontalSplitterBrush = new BorderBrush(Color.White, LineType.Solid, Color.LightGray, 1); VerticalSplitterBrush = new BorderBrush(Color.White, LineType.Solid, Color.LightGray, 1); ProgressBarBrush = new BorderBrush(Color.Blue, LineType.Solid, Color.Black, 1); SelectedItemBrush = new BorderBrush(Color.Red); // ============= // Skin-Methoden // ============= // Control ControlSkins.Add(typeof(Control), (c) => { Control control = c as Control; control.Margin = Border.All(0); control.Padding = Border.All(0); control.HorizontalAlignment = HorizontalAlignment.Center; control.VerticalAlignment = VerticalAlignment.Center; }); // Label ControlSkins.Add(typeof(Label), (c) => { Label label = c as Label; label.VerticalTextAlignment = VerticalAlignment.Center; label.HorizontalTextAlignment = HorizontalAlignment.Left; label.Font = Current.TextFont; label.TextColor = Current.TextColorBlack; label.Padding = Border.All(5); }); // Button ControlSkins.Add(typeof(Button), (c) => { Button button = c as Button; button.Margin = Border.All(2); button.Padding = Border.All(5); button.Background = Current.ButtonBrush; button.HoveredBackground = Current.ButtonHoverBrush; button.PressedBackground = Current.ButtonPressedBrush; }); // Splitter ControlSkins.Add(typeof(Splitter), (c) => { Splitter splitter = c as Splitter; splitter.HorizontalAlignment = HorizontalAlignment.Stretch; splitter.VerticalAlignment = VerticalAlignment.Stretch; splitter.Orientation = Orientation.Horizontal; splitter.SplitterSize = Current.SplitterWidth; splitter.SplitterPosition = 200; splitter.SplitterBrushHorizontal = Current.HorizontalSplitterBrush; splitter.SplitterBrushVertical = Current.VerticalSplitterBrush; }); // Scrollcontainer ControlSkins.Add(typeof(ScrollContainer), (c) => { ScrollContainer scrollContainer = c as ScrollContainer; scrollContainer.HorizontalScrollbarBackground = Current.HorizontalScrollBackgroundBrush; scrollContainer.HorizontalScrollbarForeground = Current.HorizontalScrollForegroundBrush; scrollContainer.VerticalScrollbarBackground = Current.VerticalScrollBackgroundBrush; scrollContainer.VerticalScrollbarForeground = Current.VerticalScrollForegroundBrush; scrollContainer.ScrollbarWidth = Current.ScrollbarWidth; scrollContainer.ScrollerMinSize = Current.ScrollerMinSize; }); // StackPanel ControlSkins.Add(typeof(StackPanel), (c) => { StackPanel stackPanel = c as StackPanel; }); // ListControl ControlSkins.Add(typeof(ListControl <>), (c) => { dynamic listControl = c; listControl.SelectedItemBrush = Current.SelectedItemBrush; }); // Listbox ControlSkins.Add(typeof(Listbox <>), (c) => { dynamic listBox = c; }); // Combobox ControlSkins.Add(typeof(Combobox <>), (c) => { dynamic comboBox = c; comboBox.Background = new BorderBrush(Color.White); }); // Progressbar ControlSkins.Add(typeof(ProgressBar), (c) => { ProgressBar progressBar = c as ProgressBar; progressBar.BarBrush = Current.ProgressBarBrush; }); //Slider ControlSkins.Add(typeof(Slider), (c) => { Slider s = c as Slider; s.Orientation = Orientation.Horizontal; s.SliderBackgroundBrush = new BorderBrush(Color.LightGray); s.SliderForegroundBrush = new BorderBrush(Color.SlateGray); s.SliderWidth = 20; }); ControlSkins.Add(typeof(Checkbox), (c) => { Checkbox checkbox = c as Checkbox; checkbox.BoxBrush = new BorderBrush(Color.Black); checkbox.InnerBoxBrush = new BorderBrush(Color.LightGray); checkbox.HookBrush = new BorderBrush(Color.LawnGreen); checkbox.Width = 20; checkbox.Height = 20; }); ControlSkins.Add(typeof(TabControl), (c) => { TabControl tabControl = c as TabControl; tabControl.TabBrush = new BorderBrush(Color.LightGray); tabControl.TabActiveBrush = new BorderBrush(Color.Gray); tabControl.TabPageBackground = new BorderBrush(Color.Gray); tabControl.TabSpacing = 1; }); }
public Skin(ContentManager content) { ControlSkins = new Dictionary<Type, Action<Control>>(); StyleSkins = new Dictionary<string, Action<Control>>(); SplitterWidth = 4; ScrollbarWidth = 10; ScrollerMinSize = 10; BackgroundColor = new Color(20, 147, 73); LogoColorOrange = new Color(241, 145, 11); LogoColorRed = new Color(225, 7, 22); TextColorBlack = new Color(0, 0, 0); TextColorGray = new Color(86, 86, 86); TextColorWhite = new Color(255, 255, 255); HeadlineFont = content.Load<SpriteFont>("HeadlineFont"); TextFont = content.Load<SpriteFont>("GameFont"); BoldFont = content.Load<SpriteFont>("BoldFont"); FocusFrameBrush = new BorderBrush(LineType.Dotted, Color.Black, 1); ButtonBrush = new BorderBrush(Color.White, LineType.Solid, Color.LightGray, 1); ButtonHoverBrush = new BorderBrush(Color.LightGray, LineType.Solid, Color.LightGray, 1); ButtonPressedBrush = new BorderBrush(Color.LightGray, LineType.Solid, Color.Black, 1); PanelBrush = new BorderBrush(Color.White, LineType.Solid, Color.Black, 1); VerticalScrollBackgroundBrush = new BorderBrush(Color.White, LineType.Solid, Color.Black, 1); HorizontalScrollBackgroundBrush = new BorderBrush(Color.White, LineType.Solid, Color.Black, 1); VerticalScrollForegroundBrush = new BorderBrush(Color.LightGray, LineType.Solid, Color.Black, 1); HorizontalScrollForegroundBrush = new BorderBrush(Color.LightGray, LineType.Solid, Color.Black, 1); HorizontalSplitterBrush = new BorderBrush(Color.White, LineType.Solid, Color.LightGray, 1); VerticalSplitterBrush = new BorderBrush(Color.White, LineType.Solid, Color.LightGray, 1); ProgressBarBrush = new BorderBrush(Color.Blue, LineType.Solid, Color.Black, 1); SelectedItemBrush = new BorderBrush(Color.Red); // ============= // Skin-Methoden // ============= // Control ControlSkins.Add(typeof(Control), (c) => { Control control = c as Control; control.Margin = Border.All(0); control.Padding = Border.All(0); control.HorizontalAlignment = HorizontalAlignment.Center; control.VerticalAlignment = VerticalAlignment.Center; }); // Label ControlSkins.Add(typeof(Label), (c) => { Label label = c as Label; label.VerticalTextAlignment = VerticalAlignment.Center; label.HorizontalTextAlignment = HorizontalAlignment.Left; label.Font = Current.TextFont; label.TextColor = Current.TextColorBlack; label.Padding = Border.All(5); }); // Button ControlSkins.Add(typeof(Button), (c) => { Button button = c as Button; button.Margin = Border.All(2); button.Padding = Border.All(5); button.Background = Current.ButtonBrush; button.HoveredBackground = Current.ButtonHoverBrush; button.PressedBackground = Current.ButtonPressedBrush; }); // Splitter ControlSkins.Add(typeof(Splitter), (c) => { Splitter splitter = c as Splitter; splitter.HorizontalAlignment = HorizontalAlignment.Stretch; splitter.VerticalAlignment = VerticalAlignment.Stretch; splitter.Orientation = Orientation.Horizontal; splitter.SplitterSize = Current.SplitterWidth; splitter.SplitterPosition = 200; splitter.SplitterBrushHorizontal = Current.HorizontalSplitterBrush; splitter.SplitterBrushVertical = Current.VerticalSplitterBrush; }); // Scrollcontainer ControlSkins.Add(typeof(ScrollContainer), (c) => { ScrollContainer scrollContainer = c as ScrollContainer; scrollContainer.HorizontalScrollbarBackground = Current.HorizontalScrollBackgroundBrush; scrollContainer.HorizontalScrollbarForeground = Current.HorizontalScrollForegroundBrush; scrollContainer.VerticalScrollbarBackground = Current.VerticalScrollBackgroundBrush; scrollContainer.VerticalScrollbarForeground = Current.VerticalScrollForegroundBrush; scrollContainer.ScrollbarWidth = Current.ScrollbarWidth; scrollContainer.ScrollerMinSize = Current.ScrollerMinSize; }); // StackPanel ControlSkins.Add(typeof(StackPanel), (c) => { StackPanel stackPanel = c as StackPanel; }); // ListControl //ControlSkins.Add(typeof(ListControl<>), (c) => //{ // dynamic listControl = c; // listControl.SelectedItemBrush = Current.SelectedItemBrush; //}); // Listbox ControlSkins.Add(typeof(Listbox<>), (c) => { dynamic listBox = c; }); // Combobox //ControlSkins.Add(typeof(Combobox<>), (c) => //{ // dynamic comboBox = c; // comboBox.Background = new BorderBrush(Color.White); //}); // Progressbar ControlSkins.Add(typeof(ProgressBar), (c) => { ProgressBar progressBar = c as ProgressBar; progressBar.BarBrush = Current.ProgressBarBrush; }); //Slider ControlSkins.Add(typeof(Slider), (c) => { Slider s = c as Slider; s.Orientation = Orientation.Horizontal; s.SliderBackgroundBrush = new BorderBrush(Color.LightGray); s.SliderForegroundBrush = new BorderBrush(Color.SlateGray); s.SliderWidth = 20; }); ControlSkins.Add(typeof(Checkbox), (c) => { Checkbox checkbox = c as Checkbox; checkbox.BoxBrush = new BorderBrush(Color.Black); checkbox.InnerBoxBrush = new BorderBrush(Color.LightGray); checkbox.HookBrush = new BorderBrush(Color.LawnGreen); checkbox.Width = 20; checkbox.Height = 20; }); ControlSkins.Add(typeof(TabControl), (c) => { TabControl tabControl = c as TabControl; tabControl.TabBrush = new BorderBrush(Color.LightGray); tabControl.TabActiveBrush = new BorderBrush(Color.Gray); tabControl.TabPageBackground = new BorderBrush(Color.Gray); tabControl.TabSpacing = 1; }); }
public DebugControl(ScreenComponent screenManager) : base(screenManager) { framebuffer = new float[buffersize]; Player = screenManager.Player; //Get ResourceManager for further Information later... resMan = ResourceManager.Instance; //Brush for Debug Background BorderBrush bg = new BorderBrush(Color.Black * 0.2f); //The left side of the Screen leftView = new StackPanel(ScreenManager) { Background = bg, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, }; //The right Side of the Screen rightView = new StackPanel(ScreenManager) { Background = bg, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, }; //Creating all Labels devText = new Label(ScreenManager); devText.Text = Languages.OctoClient.DevelopmentVersion; leftView.Controls.Add(devText); loadedChunks = new Label(ScreenManager); leftView.Controls.Add(loadedChunks); loadedInfo = new Label(ScreenManager); leftView.Controls.Add(loadedInfo); position = new Label(ScreenManager); rightView.Controls.Add(position); rotation = new Label(ScreenManager); rightView.Controls.Add(rotation); fps = new Label(ScreenManager); rightView.Controls.Add(fps); controlInfo = new Label(ScreenManager); leftView.Controls.Add(controlInfo); activeTool = new Label(ScreenManager); rightView.Controls.Add(activeTool); flyInfo = new Label(ScreenManager); rightView.Controls.Add(flyInfo); //This Label gets added to the root and is set to Bottom Left box = new Label(ScreenManager); box.VerticalAlignment = VerticalAlignment.Bottom; box.HorizontalAlignment = HorizontalAlignment.Left; box.TextColor = Color.White; Controls.Add(box); //Add the left & right side to the root Controls.Add(leftView); Controls.Add(rightView); //Label Setup - Set Settings for all Labels in one place foreach (Control control in leftView.Controls) { control.HorizontalAlignment = HorizontalAlignment.Left; if (control is Label) { ((Label)control).TextColor = Color.White; } } foreach (Control control in rightView.Controls) { control.HorizontalAlignment = HorizontalAlignment.Right; if (control is Label) { ((Label)control).TextColor = Color.White; } } }
public TargetScreen(ScreenComponent manager, Action<int, int> tp, int x, int y) : base(manager) { IsOverlay = true; Background = new BorderBrush(Color.Black * 0.5f); Title = "Select target"; Texture2D panelBackground = manager.Game.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/panel.png", manager.GraphicsDevice); Panel panel = new Panel(manager) { Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Controls.Add(panel); StackPanel spanel = new StackPanel(manager); panel.Controls.Add(spanel); Label headLine = new Label(manager) { Text = Title, Font = Skin.Current.HeadlineFont, HorizontalAlignment = HorizontalAlignment.Stretch }; spanel.Controls.Add(headLine); StackPanel vstack = new StackPanel(manager); vstack.Orientation = Orientation.Vertical; spanel.Controls.Add(vstack); Textbox xText = new Textbox(manager) { Background = new BorderBrush(Color.Gray), Width = 150, Margin = new Border(10, 10, 10, 10), Text = x.ToString() }; vstack.Controls.Add(xText); Textbox yText = new Textbox(manager) { Background = new BorderBrush(Color.Gray), Width = 150, Margin = new Border(10, 10, 10, 10), Text = y.ToString() }; vstack.Controls.Add(yText); Button closeButton = Button.TextButton(manager, "Teleport"); closeButton.HorizontalAlignment = HorizontalAlignment.Stretch; closeButton.LeftMouseClick += (s, e) => { if (tp != null) tp(int.Parse(xText.Text), int.Parse(yText.Text)); else manager.NavigateBack(); }; spanel.Controls.Add(closeButton); }
public InventoryScreen(ScreenComponent manager) : base(manager) { assets = manager.Game.Assets; foreach (var item in DefinitionManager.Instance.GetItemDefinitions()) { Texture2D texture = manager.Game.Assets.LoadTexture(item.GetType(), item.Icon); toolTextures.Add(item.GetType().FullName, texture); } player = manager.Player; IsOverlay = true; Background = new BorderBrush(Color.Black * 0.5f); backgroundBrush = new BorderBrush(Color.Black); hoverBrush = new BorderBrush(Color.Brown); Texture2D panelBackground = assets.LoadTexture(typeof(ScreenComponent), "panel"); Grid grid = new Grid(manager) { Width = 800, Height = 500, }; grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 600 }); grid.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 200 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); grid.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Fixed, Height = 100 }); Controls.Add(grid); inventory = new InventoryControl(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), }; grid.AddControl(inventory, 0, 0); StackPanel infoPanel = new StackPanel(manager) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), Padding = Border.All(20), Margin = Border.All(10, 0, 0, 0), }; nameLabel = new Label(manager); infoPanel.Controls.Add(nameLabel); massLabel = new Label(manager); infoPanel.Controls.Add(massLabel); volumeLabel = new Label(manager); infoPanel.Controls.Add(volumeLabel); grid.AddControl(infoPanel, 1, 0); Grid toolbar = new Grid(manager) { Margin = Border.All(0, 10, 0, 0), Height = 100, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = NineTileBrush.FromSingleTexture(panelBackground, 30, 30), }; toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); for (int i = 0; i < Player.TOOLCOUNT; i++) toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Fixed, Width = 50 }); toolbar.Columns.Add(new ColumnDefinition() { ResizeMode = ResizeMode.Parts, Width = 1 }); toolbar.Rows.Add(new RowDefinition() { ResizeMode = ResizeMode.Parts, Height = 1 }); images = new Image[Player.TOOLCOUNT]; for (int i = 0; i < Player.TOOLCOUNT; i++) { Image image = images[i] = new Image(manager) { Width = 42, Height = 42, Background = backgroundBrush, HorizontalAlignment = HorizontalAlignment.Center, Tag = i, Padding = Border.All(2), }; image.StartDrag += (e) => { InventorySlot slot = player.ActorHost.Player.Tools[(int)image.Tag]; if (slot != null) { e.Handled = true; e.Icon = toolTextures[slot.Definition.GetType().FullName]; e.Content = slot; e.Sender = toolbar; } }; image.DropEnter += (e) => { image.Background = hoverBrush; }; image.DropLeave += (e) => { image.Background = backgroundBrush; }; image.EndDrop += (e) => { e.Handled = true; if (e.Sender is Grid) // && ShiftPressed { // Swap int targetIndex = (int)image.Tag; InventorySlot targetSlot = player.ActorHost.Player.Tools[targetIndex]; int sourceIndex = -1; InventorySlot sourceSlot = e.Content as InventorySlot; for (int j = 0; j < player.ActorHost.Player.Tools.Length; j++) { if (player.ActorHost.Player.Tools[j] == sourceSlot) { sourceIndex = j; break; } } SetTool(sourceSlot, targetIndex); SetTool(targetSlot, sourceIndex); } else { // Inventory Drop InventorySlot slot = e.Content as InventorySlot; SetTool(slot, (int)image.Tag); } }; toolbar.AddControl(image, i + 1, 0); } grid.AddControl(toolbar, 0, 1, 2); Title = Languages.OctoClient.Inventory; }
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); }