public ShoppingItemUI(IItem item, int i, Action whenBought) { _playerAccount = CurrentGameState.State.PlayerAccount; Branch = new ClickUIBranch(item.Name, (int)ClickUIPriorities.Pad); var x = (i % 4) * (Sizes.Item.Width + Sizes.Margin); var y = (i / 4) * (Sizes.Item.Height + Sizes.Margin * 2 + Sizes.Button.Height); _transform = new Transform2(new Vector2((int)x, (int)y)); _productDetails = new ImageWithDescription("Images/Items/" + item.Name.ToLower().Replace(" ", "-").Replace(".", ""), item.Description, new Transform2(Sizes.Item)); _label = new Label { BackgroundColor = Color.Transparent, TextColor = Color.White, Font = "Fonts/14", Transform = new Transform2(new Vector2(0, Sizes.Item.Height + 5), new Size2(Sizes.Item.Width, 30)), RawText = item.Name + " - $" + item.Cost.Amount() }; _amount = item.Cost.Amount(); _button = ImageTextButtonFactory.Create("Buy", new Vector2(0, Sizes.Item.Height + Sizes.SmallMargin + 30), () => { if (_playerAccount.Amount() >= _amount) { whenBought(); } }); _disabledButton = new ImageLabel("Buy", "Images/UI/button-disable", new Transform2(new Vector2(0, Sizes.Item.Height + Sizes.SmallMargin + 30), Sizes.Button)); Branch.Add(_button); Branch.Add(_productDetails); }
public void Init() { _createCharacterLabel = new Label { BackgroundColor = Color.Transparent, TextColor = Color.White, Text = "Create Your Character", Transform = new Transform2(Sizes.LargeLabel) }; _charName = new Label { BackgroundColor = Color.Black, TextColor = Color.White, Text = "Name", Transform = new Transform2(Sizes.MediumLabel) }; _charSexLabel = new Label { BackgroundColor = Color.Black, TextColor = Color.White, Text = "Make", Transform = new Transform2(Sizes.MediumLabel) }; _startGameButton = new ImageTextButton("Start Game", "Images/Menu/button-default", "Images/Menu/button-hover", "Images/Menu/button-pressed", new Transform2(new Vector2(800 - 100, 750 - 22), new Size2(200, 44)), StartGame); _maleButton = new ImageTextButton("Male", "Images/Menu/button-default", "Images/Menu/button-hover", "Images/Menu/button-pressed", new Transform2(new Vector2(800 - 100, 650 - 22), new Size2(200, 44)), () => _sex = CharacterSex.Male); _femaleButton = new ImageTextButton("Female", "Images/Menu/button-default", "Images/Menu/button-hover", "Images/Menu/button-pressed", new Transform2(new Vector2(800 - 100, 600 - 22), new Size2(200, 44)), () => _sex = CharacterSex.Female); _ui = new ClickUI(); _ui.Add(_startGameButton); _ui.Add(_maleButton); _ui.Add(_femaleButton); }
public ExcusesUI() { Branch = new ClickUIBranch("Excuses", (int)ClickUIPriorities.Pad); _excuseButton = ImageTextButtonFactory.Create("Soothe", new Vector2(0, 0), MakeExcuse); World.Subscribe(EventSubscription.Create <CallStarted>(OnCallStart, this)); World.Subscribe(EventSubscription.Create <CallResolved>(x => OnCallResolved(), this)); }
public ReturnsCallReadyUI() { Branch = new ClickUIBranch("Ready Button", (int)ClickUIPriorities.Pad); _button = ImageTextButtonFactory.Create("Ready", Vector2.Zero, StartCall); Branch.Add(_button); World.Subscribe(EventSubscription.Create <CallResolved>(x => AtEndCall(), this)); }
public ViewPurchaseListUI() { Branch = new ClickUIBranch("View List Button", (int)ClickUIPriorities.Pad); _button = ImageTextButtonFactory.Create("Purchases", Vector2.Zero, () => World.Publish(new PurchasesListed())); Branch.Add(_button); World.Subscribe(EventSubscription.Create <PurchaseInspected>(x => OnPurchaseInspected(), this)); World.Subscribe(EventSubscription.Create <PurchasesListed>(x => OnPurchasesListed(), this)); }
public PoliciesApp() { _gameState = CurrentGameState.State; Branch = new ClickUIBranch("Policies App", (int)ClickUIPriorities.Pad); _pageUi = new PolicyPageUI(_gameState.ActivePolicies, 0, 7); _backButton = ImageTextButtonFactory.CreateRotated("<<", new Vector2(Sizes.Margin, 275), NavigateBack); _nextButton = ImageTextButtonFactory.CreateRotated(">>", new Vector2(1600 - Sizes.SideButton.Width - Sizes.Margin, 275), NavigateForward); UpdateNavButtons(); }
public TogglePad() { _open = ImageTextButtonFactory.CreateTrapazoid("Open", Vector2.Zero, () => World.Publish(new PadOpened())); _close = ImageTextButtonFactory.CreateTrapazoid("Close", Vector2.Zero, () => World.Publish(new PadClosed())); Branch = new ClickUIBranch("Toggle Pad", (int)ClickUIPriorities.Overlay); _current = _open; Branch.Add(_open); World.Subscribe(EventSubscription.Create <PadOpened>(x => PadOpened(), this)); World.Subscribe(EventSubscription.Create <PadClosed>(x => PadClosed(), this)); }
public RentApp() { _gameState = CurrentGameState.State; _playerAccount = _gameState.PlayerAccount; _landlord = _gameState.Landlord; Branch = new ClickUIBranch("Rent App", (int)ClickUIPriorities.Pad); _amountDue = new ImageLabel("", "Images/UI/label", new Transform2(new Vector2(-(Sizes.Label.Width / 2), 0), Sizes.Label)); _paymentDueBy = new ImageLabel("", "Images/UI/label", new Transform2(new Vector2(-(Sizes.Label.Width / 2), Sizes.Label.Height + Sizes.Margin), Sizes.Label)); _payButton = ImageTextButtonFactory.Create("PAY", new Vector2(-(Sizes.Button.Width / 2), (Sizes.Label.Height + Sizes.Margin) * 2), () => World.Publish(new RentPaid())); _disabledPayButton = new ImageLabel("PAY", "Images/UI/button-disable", new Transform2(new Vector2(-(Sizes.Button.Width / 2), (Sizes.Label.Height + Sizes.Margin) * 2), Sizes.Button)); }
private Grid CreateCollectionEditor(Record record, Type itemType) { var value = record.GetValue(_object); var items = (IList)value; var subGrid = new Grid { ColumnSpacing = 8, HorizontalAlignment = HorizontalAlignment.Stretch }; subGrid.ColumnsProportions.Add(new Proportion()); subGrid.ColumnsProportions.Add(new Proportion(ProportionType.Fill)); var label = new Label { VerticalAlignment = VerticalAlignment.Center, }; UpdateLabelCount(label, items.Count); subGrid.Widgets.Add(label); var button = new ImageTextButton { Text = "Change...", ContentHorizontalAlignment = HorizontalAlignment.Center, Tag = value, HorizontalAlignment = HorizontalAlignment.Stretch, GridColumn = 1 }; button.Click += (sender, args) => { var collectionEditor = new CollectionEditor(items, itemType); var dialog = Dialog.CreateMessageBox("Edit", collectionEditor); dialog.ButtonOk.Click += (o, eventArgs) => { collectionEditor.SaveChanges(); UpdateLabelCount(label, items.Count); }; dialog.ShowModal(); }; subGrid.Widgets.Add(button); return(subGrid); }
public AmountDialog() : base() { var windowGrid = new Grid(); windowGrid.RowsProportions.Add(new Proportion()); windowGrid.RowsProportions.Add(new Proportion()); Amount = new TextBox(); Amount.GridRow = 0; Amount.ValueChanging += Amount_ValueChanging; var buttonsGrid = new HorizontalStackPanel() { GridRow = 1, Spacing = 8, HorizontalAlignment = HorizontalAlignment.Right }; ButtonOk = new ImageTextButton { Text = "Ok" }; ButtonOk.Click += (sender, args) => { Result = true; Close(); }; buttonsGrid.Widgets.Add(ButtonOk); ButtonCancel = new ImageTextButton { Text = "Cancel", GridColumn = 1 }; ButtonCancel.Click += (sender, args) => { Result = false; Close(); }; buttonsGrid.Widgets.Add(ButtonCancel); windowGrid.Widgets.Add(Amount); windowGrid.Widgets.Add(buttonsGrid); InternalChild.Widgets.Add(windowGrid); }
private void AddGameplayOptions() { var colX = XPos(0.25f); Add(UiLabels.Option("Gameplay", new Vector2(colX, Height(0)))); Add(UiButtons.Menu("Text: Slow", new Vector2(colX, Height(1)), () => CurrentOptions.Update(x => x.MillisPerTextCharacter = 45))); Add(UiButtons.Menu("Text: Normal", new Vector2(colX, Height(2)), () => CurrentOptions.Update(x => x.MillisPerTextCharacter = 30))); Add(UiButtons.Menu("Text: Fast", new Vector2(colX, Height(3)), () => CurrentOptions.Update(x => x.MillisPerTextCharacter = 15))); Add(UiButtons.Menu("Text: Instant", new Vector2(colX, Height(4)), () => CurrentOptions.Update(x => x.MillisPerTextCharacter = 0))); _tutorialsToggle = UiButtons.Menu(GetTutorialText(), new Vector2(colX, Height(6)), ToggleTutorials); Add(_tutorialsToggle); }
public NotificationUI(PlayerNotification notification, List <NotificationUI> items) { Branch = new ClickUIBranch("Notification", (int)ClickUIPriorities.Pad); _label = new Label { BackgroundColor = Color.Transparent, TextColor = Color.White, Transform = new Transform2(new Vector2(Sizes.Margin, 0), new Size2(Sizes.Notification.Width - Sizes.Button.Width - Sizes.Margin * 2, 90)), Text = $"{notification.Time} - {notification.Sender} - {notification.Message}", }; _button = ImageTextButtonFactory.Create("Dismiss", new Vector2(Sizes.Notification.Width - Sizes.Margin - Sizes.Button.Width, Sizes.SmallMargin), () => items.Remove(this)); Branch.Add(_button); }
public void Init() { _btn = new ImageTextButton("New Game", "Images/Menu/button-default", "Images/Menu/button-hover", "Images/Menu/button-pressed", new Transform2(new Vector2(800 - 100, 750 - 22), new Size2(200, 44)), () => World.NavigateToScene("CharacterCreation")); _ui = new ClickUI(); _ui.Add(_btn); Audio.PlayMusic("Music/maintheme"); }
private void SelectNav(object sender, RoutedEventArgs e) { ImageTextButton itb = sender as ImageTextButton; StackPanel sp = itb.Parent as StackPanel; foreach (ImageTextButton it in sp.Children) { if (it != itb) { it.IsChecked = false; } } }
protected override void LoadContent() { base.LoadContent(); MyraEnvironment.Game = this; _root = new Grid(); // Top row is buttons _root.RowsProportions.Add(new Proportion(ProportionType.Auto)); var topRow = new Grid(); topRow.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); topRow.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); var buttonSwitchOrientation = new ImageTextButton { Text = "Switch Orientation" }; buttonSwitchOrientation.Click += (sender, args) => { RebuildSplitPane(_splitPane.Orientation == Orientation.Horizontal ? Orientation.Vertical : Orientation.Horizontal); }; topRow.Widgets.Add(buttonSwitchOrientation); var buttonReset = new ImageTextButton { Text = "Reset", GridColumn = 1 }; buttonReset.Click += (sender, args) => { _splitPane.Reset(); }; topRow.Widgets.Add(buttonReset); _root.Widgets.Add(topRow); RebuildSplitPane(Orientation.Horizontal); _desktop = new Desktop { Root = _root }; }
public ThoughtUI() { Input.On(Control.A, Dismiss); Branch = new ClickUIBranch("Thought", (int)ClickUIPriorities.Thoughts); _label = new Label { TextColor = Color.White, BackgroundColor = Color.Transparent, }; _button = ImageTextButtonFactory.Create("Dismiss", new Vector2(Sizes.LargeLabel.Width - Sizes.SmallMargin - Sizes.Button.Width, Sizes.LargeLabel.Height - Sizes.SmallMargin - Sizes.Button.Height), Dismiss); World.Subscribe(EventSubscription.Create <HadAThought>(Think, this)); }
public MenuBar(ClickUIBranch parentBranch) { _branch = new ClickUIBranch("Menu Bar", (int)ClickUIPriorities.Pad); parentBranch.Add(_branch); _callApp = ImageTextButtonFactory.Create("Calls", new Vector2(Sizes.Margin, Sizes.Margin), () => ChangeApp(App.Call)); _foodApp = ImageTextButtonFactory.Create("Shopping", new Vector2(Sizes.Margin * 2 + Sizes.Button.Width, Sizes.Margin), () => ChangeApp(App.Shopping)); _notificationApp = ImageTextButtonFactory.Create("Notification", new Vector2(Sizes.Margin * 3 + Sizes.Button.Width * 2, Sizes.Margin), () => ChangeApp(App.Notification)); _rentApp = ImageTextButtonFactory.Create("Rent", new Vector2(Sizes.Margin * 4 + Sizes.Button.Width * 3, Sizes.Margin), () => ChangeApp(App.Rent)); _policiesApp = ImageTextButtonFactory.Create("Policies", new Vector2(Sizes.Margin * 5 + Sizes.Button.Width * 4, Sizes.Margin), () => ChangeApp(App.Policies)); _branch.Add(_callApp); _branch.Add(_foodApp); _branch.Add(_notificationApp); _branch.Add(_rentApp); _branch.Add(_policiesApp); }
public ShoppingApp() { Branch = new ClickUIBranch("Item App", (int)ClickUIPriorities.Pad); _companiesBranch = new ClickUIBranch("Companies", (int)ClickUIPriorities.Pad); Branch.Add(_companiesBranch); for (var i = 0; i < _companies.Count; i++) { var company = _companies[i]; var companyUI = new ShoppingCompanyUI(company); var option = new ShoppingCompanyOptionUI(company, i, () => NavigateToCompany(companyUI)); _companyOptionUIs.Add(option); _companiesBranch.Add(option.Branch); } _return = ImageTextButtonFactory.Create("Return", new Vector2(1000, 625), NavigateToCompanySelection); }
private ImageTextButton CreateButton(string Text, float width) { var result = new ImageTextButton() { ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center, Text = Text, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, Width = (int)width, Height = 50 }; return(result); }
public MainMenuScreen(NamelessGame game) { // Panel = new Panel(new Vector2(game.GetSettings().HudWidth(), game.GetActualCharacterHeight()), PanelSkin.Default, Anchor.Center); Panel = new Panel() { HorizontalAlignment = HorizontalAlignment.Center }; var vPanel = new VerticalStackPanel(); NewGame = new ImageTextButton() { Text = "New game", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center }; LoadGame = new ImageTextButton() { Text = "Load", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center };; CreateTimeline = new ImageTextButton() { Text = "Create timeline", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center }; Options = new ImageTextButton() { Text = "Options", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center }; Exit = new ImageTextButton() { Text = "Exit", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center }; NewGame.Click += (sender, args) => { SimpleActions.Add(MainMenuAction.NewGame); }; LoadGame.Click += (sender, args) => { SimpleActions.Add(MainMenuAction.LoadGame); }; CreateTimeline.Click += (sender, args) => { SimpleActions.Add(MainMenuAction.GenerateNewTimeline); }; Options.Click += (sender, args) => { SimpleActions.Add(MainMenuAction.Options); }; Exit.Click += (sender, args) => { SimpleActions.Add(MainMenuAction.Exit); }; vPanel.Widgets.Add(NewGame); vPanel.Widgets.Add(LoadGame); vPanel.Widgets.Add(CreateTimeline); vPanel.Widgets.Add(Options); vPanel.Widgets.Add(Exit); Panel.Widgets.Add(vPanel); game.Desktop.Widgets.Add(Panel); }
public ShoppingCompanyOptionUI(IShoppingCompany company, int i, Action whenBought) { Branch = new ClickUIBranch(company.Name, (int)ClickUIPriorities.Pad); var x = (i % 4) * (Sizes.Item.Width + Sizes.Margin); var y = (i / 4) * (Sizes.Item.Height + Sizes.Margin * 2 + Sizes.Button.Height); _transform = new Transform2(new Vector2((int)x, (int)y)); _productDetails = new ImageWithDescription("Images/Companies/" + company.Name.ToLower().Replace(" ", "-").Replace(".", "").Replace("'", ""), company.Description, new Transform2(Sizes.Item)); _label = new Label { BackgroundColor = Color.Transparent, TextColor = Color.White, Font = "Fonts/14", Transform = new Transform2(new Vector2(0, Sizes.Item.Height + 5), new Size2(Sizes.Item.Width, 30)), RawText = company.Name }; _button = ImageTextButtonFactory.Create("Shop", new Vector2(0, Sizes.Item.Height + Sizes.SmallMargin + 30), whenBought); Branch.Add(_button); Branch.Add(_productDetails); }
protected override void OnInit() { _savingEnabled = CurrentGameState.CurrentLocation != GameResources.MainMenuSceneName; _headerText = UiLabels.FullWidthHeaderLabel("Game", Color.White); _changeModeButton = UiButtons.MenuSmallBlue("Load", new Vector2(840, 960), () => SetMode(_mode == SaveMode.Save ? SaveMode.Load : SaveMode.Save)); if (_savingEnabled) { Add(_changeModeButton); } SetMode(_savingEnabled ? SaveMode.Save : SaveMode.Load); Add(UiButtons.BackBlue(() => Scene.NavigateTo(CurrentGameState.CurrentLocation))); var positions = new[] { new Vector2(320, 200), new Vector2(1120, 200), new Vector2(320, 600), new Vector2(1120, 600), }; for (var i = 0; i < 4; i++) { var s = new SaveSlotView(positions[i], SaveSlot.Create(i), () => _mode); s.Init(); AddUi(s); } }
public ImageScrollButton(string name, int xpos, int ypos, int width, int height, float minVal, float maxVal) { sliderButton = new ImageButton(name + "_slider", true, xpos, ypos, height, height); sliderButton.SetDragAndDrop(true); sliderButton.SetDragBoundingBox(xpos, ypos, xpos + width - height, ypos); sliderTrack = new ImageButton(name + "_slider_track", false, xpos, ypos, width, height); this.initXpos = xpos; this.initYpos = ypos; this.width = width; this.height = height; this.maxVal = maxVal; this.minVal = minVal; sliderTrack.SetBackgroundColor(new Color4(0.2f, 0.2f, 0.2f, 1.0f)); sliderButton.SetSelectedColor(new Color4(0.5f, 0.5f, 0.5f, 0.5f)); sliderButton.SetBackgroundColor(new Color4(1.0f, 1.0f, 1.0f, 0.5f)); labelButton = new ImageTextButton(new Message(name, (int)(height * 0.6f)), false, xpos, ypos, width, height); valueButton = new ImageTextButton(new Message("", (int)(height * 0.6f)), false, xpos + width, ypos, width, height); labelButton.message.SetColor(new Color4(1.0f, 1.0f, 1.0f, 0.7f)); sliderButton.AddObserver(this); labelButton.update(); UpdateText(); }
public void Init() { _nameDataLabel = new Label { Transform = new Transform2(new Vector2(300, 330), new Size2(500, 75)), TextColor = Color.White, Text = GameResources.GetCharacterName(_person.Value) }; _startScanButton = new ImageTextButton(new Transform2(new Vector2(1300, 860), new Size2(220, 74)), BeginScan, "Scan", "Convo/ScanButton", "Convo/ScanButton-Hover", "Convo/ScanButton-Press", () => !_startedScanning) { TextColor = Color.White }; _scanAnimation = new SinglePositionTraverseAnimation( new ImageBox { Image = "Convo/ScanLine", Transform = new Transform2(new Vector2(1200, 400), new Size2(450, 5)) }, new Vector2(0, 530), TimeSpan.FromMilliseconds(1300), TimeSpan.FromMilliseconds(0)); ClickUiBranch.Add(_startScanButton); }
private void BuildUI() { var label1 = new Label(); label1.Text = "Yetiface"; label1.Margin = new Thickness(0, 10); label1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; label1.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Bottom; label1.GridRow = 1; GameLogo = new Image(); GameLogo.Width = 284; GameLogo.Height = 64; GameLogo.Margin = new Thickness(0, 0, 0, 50); GameLogo.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; GameLogo.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Bottom; GameLogo.Id = "GameLogo"; MenuSinglePlayer = new ImageTextButton(); MenuSinglePlayer.Text = "Single Player"; MenuSinglePlayer.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MenuSinglePlayer.Margin = new Thickness(0, 0, 0, 10); MenuSinglePlayer.Padding = new Thickness(10); MenuSinglePlayer.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; MenuSinglePlayer.Background = new SolidBrush("#8d697a"); MenuSinglePlayer.OverBackground = new SolidBrush("#544e68"); MenuSinglePlayer.FocusedBackground = new SolidBrush("#203c56"); MenuSinglePlayer.Id = "MenuSinglePlayer"; MenuMultiPlayer = new ImageTextButton(); MenuMultiPlayer.Text = "Multiplayer"; MenuMultiPlayer.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MenuMultiPlayer.Margin = new Thickness(0, 0, 0, 10); MenuMultiPlayer.Padding = new Thickness(10); MenuMultiPlayer.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; MenuMultiPlayer.Background = new SolidBrush("#8d697a"); MenuMultiPlayer.OverBackground = new SolidBrush("#544e68"); MenuMultiPlayer.FocusedBackground = new SolidBrush("#203c56"); MenuMultiPlayer.Id = "MenuMultiPlayer"; MenuSettings = new ImageTextButton(); MenuSettings.Text = "Settings"; MenuSettings.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MenuSettings.Margin = new Thickness(0, 0, 0, 10); MenuSettings.Padding = new Thickness(10); MenuSettings.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; MenuSettings.Background = new SolidBrush("#8d697a"); MenuSettings.OverBackground = new SolidBrush("#544e68"); MenuSettings.FocusedBackground = new SolidBrush("#203c56"); MenuSettings.Id = "MenuSettings"; MenuQuit = new ImageTextButton(); MenuQuit.Text = "Quit"; MenuQuit.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MenuQuit.Padding = new Thickness(10); MenuQuit.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; MenuQuit.Background = new SolidBrush("#8d697a"); MenuQuit.OverBackground = new SolidBrush("#544e68"); MenuQuit.FocusedBackground = new SolidBrush("#203c56"); MenuQuit.Id = "MenuQuit"; MainPanel = new VerticalStackPanel(); MainPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MainPanel.Width = 200; MainPanel.Padding = new Thickness(10); MainPanel.Id = "MainPanel"; MainPanel.Widgets.Add(MenuSinglePlayer); MainPanel.Widgets.Add(MenuMultiPlayer); MainPanel.Widgets.Add(MenuSettings); MainPanel.Widgets.Add(MenuQuit); StartGameNewGame = new ImageTextButton(); StartGameNewGame.Text = "New Game"; StartGameNewGame.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; StartGameNewGame.Margin = new Thickness(0, 0, 0, 10); StartGameNewGame.Padding = new Thickness(10); StartGameNewGame.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; StartGameNewGame.Background = new SolidBrush("#8d697a"); StartGameNewGame.OverBackground = new SolidBrush("#544e68"); StartGameNewGame.FocusedBackground = new SolidBrush("#203c56"); StartGameNewGame.Id = "StartGameNewGame"; StartGameLoadGame = new ImageTextButton(); StartGameLoadGame.Text = "Load Game"; StartGameLoadGame.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; StartGameLoadGame.Margin = new Thickness(0, 0, 0, 10); StartGameLoadGame.Padding = new Thickness(10); StartGameLoadGame.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; StartGameLoadGame.Background = new SolidBrush("#8d697a"); StartGameLoadGame.OverBackground = new SolidBrush("#544e68"); StartGameLoadGame.FocusedBackground = new SolidBrush("#203c56"); StartGameLoadGame.Id = "StartGameLoadGame"; StartGameBack = new ImageTextButton(); StartGameBack.Text = "Back"; StartGameBack.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; StartGameBack.Padding = new Thickness(10); StartGameBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; StartGameBack.Background = new SolidBrush("#8d697a"); StartGameBack.OverBackground = new SolidBrush("#544e68"); StartGameBack.FocusedBackground = new SolidBrush("#203c56"); StartGameBack.Id = "StartGameBack"; StartGamePanel = new VerticalStackPanel(); StartGamePanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; StartGamePanel.Width = 200; StartGamePanel.Padding = new Thickness(10); StartGamePanel.Visible = false; StartGamePanel.Id = "StartGamePanel"; StartGamePanel.Widgets.Add(StartGameNewGame); StartGamePanel.Widgets.Add(StartGameLoadGame); StartGamePanel.Widgets.Add(StartGameBack); CreateMultiplayerGamePortTextBox = new TextBox(); CreateMultiplayerGamePortTextBox.Text = "25565"; CreateMultiplayerGamePortTextBox.HintText = "Port"; CreateMultiplayerGamePortTextBox.Margin = new Thickness(0, 0, 0, 10); CreateMultiplayerGamePortTextBox.Padding = new Thickness(10); CreateMultiplayerGamePortTextBox.Background = new SolidBrush("#8d697a"); CreateMultiplayerGamePortTextBox.OverBackground = new SolidBrush("#544e68"); CreateMultiplayerGamePortTextBox.FocusedBackground = new SolidBrush("#203c56"); CreateMultiplayerGamePortTextBox.Id = "CreateMultiplayerGamePortTextBox"; CreateMultiplayerGameCreateGame = new ImageTextButton(); CreateMultiplayerGameCreateGame.Text = "Create Game"; CreateMultiplayerGameCreateGame.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; CreateMultiplayerGameCreateGame.Margin = new Thickness(0, 0, 0, 10); CreateMultiplayerGameCreateGame.Padding = new Thickness(10); CreateMultiplayerGameCreateGame.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; CreateMultiplayerGameCreateGame.Background = new SolidBrush("#8d697a"); CreateMultiplayerGameCreateGame.OverBackground = new SolidBrush("#544e68"); CreateMultiplayerGameCreateGame.FocusedBackground = new SolidBrush("#203c56"); CreateMultiplayerGameCreateGame.Id = "CreateMultiplayerGameCreateGame"; CreateMultiplayerGamePanel = new VerticalStackPanel(); CreateMultiplayerGamePanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; CreateMultiplayerGamePanel.Padding = new Thickness(10); CreateMultiplayerGamePanel.Visible = false; CreateMultiplayerGamePanel.Id = "CreateMultiplayerGamePanel"; CreateMultiplayerGamePanel.Widgets.Add(CreateMultiplayerGamePortTextBox); CreateMultiplayerGamePanel.Widgets.Add(CreateMultiplayerGameCreateGame); MultiPlayerCreateGame = new ImageTextButton(); MultiPlayerCreateGame.Text = "Create Game"; MultiPlayerCreateGame.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MultiPlayerCreateGame.Margin = new Thickness(0, 0, 0, 10); MultiPlayerCreateGame.Padding = new Thickness(10); MultiPlayerCreateGame.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; MultiPlayerCreateGame.Background = new SolidBrush("#8d697a"); MultiPlayerCreateGame.OverBackground = new SolidBrush("#544e68"); MultiPlayerCreateGame.FocusedBackground = new SolidBrush("#203c56"); MultiPlayerCreateGame.Id = "MultiPlayerCreateGame"; MultiPlayerJoinByIp = new ImageTextButton(); MultiPlayerJoinByIp.Text = "Join by IP"; MultiPlayerJoinByIp.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MultiPlayerJoinByIp.Margin = new Thickness(0, 0, 0, 10); MultiPlayerJoinByIp.Padding = new Thickness(10); MultiPlayerJoinByIp.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; MultiPlayerJoinByIp.Background = new SolidBrush("#8d697a"); MultiPlayerJoinByIp.OverBackground = new SolidBrush("#544e68"); MultiPlayerJoinByIp.FocusedBackground = new SolidBrush("#203c56"); MultiPlayerJoinByIp.Id = "MultiPlayerJoinByIp"; MultiPlayerJoinBySteam = new ImageTextButton(); MultiPlayerJoinBySteam.Text = "Join by Steam"; MultiPlayerJoinBySteam.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MultiPlayerJoinBySteam.Margin = new Thickness(0, 0, 0, 10); MultiPlayerJoinBySteam.Padding = new Thickness(10); MultiPlayerJoinBySteam.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; MultiPlayerJoinBySteam.Background = new SolidBrush("#8d697a"); MultiPlayerJoinBySteam.OverBackground = new SolidBrush("#544e68"); MultiPlayerJoinBySteam.FocusedBackground = new SolidBrush("#203c56"); MultiPlayerJoinBySteam.Id = "MultiPlayerJoinBySteam"; MultiPlayerBack = new ImageTextButton(); MultiPlayerBack.Text = "Back"; MultiPlayerBack.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MultiPlayerBack.Padding = new Thickness(10); MultiPlayerBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; MultiPlayerBack.Background = new SolidBrush("#8d697a"); MultiPlayerBack.OverBackground = new SolidBrush("#544e68"); MultiPlayerBack.FocusedBackground = new SolidBrush("#203c56"); MultiPlayerBack.Id = "MultiPlayerBack"; MultiPlayerPanel = new VerticalStackPanel(); MultiPlayerPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; MultiPlayerPanel.Width = 200; MultiPlayerPanel.Padding = new Thickness(10); MultiPlayerPanel.Visible = false; MultiPlayerPanel.Id = "MultiPlayerPanel"; MultiPlayerPanel.Widgets.Add(MultiPlayerCreateGame); MultiPlayerPanel.Widgets.Add(MultiPlayerJoinByIp); MultiPlayerPanel.Widgets.Add(MultiPlayerJoinBySteam); MultiPlayerPanel.Widgets.Add(MultiPlayerBack); SettingsBack = new ImageTextButton(); SettingsBack.Text = "Back"; SettingsBack.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; SettingsBack.Padding = new Thickness(10); SettingsBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; SettingsBack.Background = new SolidBrush("#8d697a"); SettingsBack.OverBackground = new SolidBrush("#544e68"); SettingsBack.FocusedBackground = new SolidBrush("#203c56"); SettingsBack.Id = "SettingsBack"; SettingsPanel = new VerticalStackPanel(); SettingsPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; SettingsPanel.Width = 200; SettingsPanel.Padding = new Thickness(10); SettingsPanel.Visible = false; SettingsPanel.Id = "SettingsPanel"; SettingsPanel.Widgets.Add(SettingsBack); IpAddressTextBox = new TextBox(); IpAddressTextBox.HintText = "IP Address"; IpAddressTextBox.Margin = new Thickness(0, 0, 0, 10); IpAddressTextBox.Padding = new Thickness(10); IpAddressTextBox.Background = new SolidBrush("#8d697a"); IpAddressTextBox.OverBackground = new SolidBrush("#544e68"); IpAddressTextBox.FocusedBackground = new SolidBrush("#203c56"); IpAddressTextBox.Id = "IpAddressTextBox"; PortTextBox = new TextBox(); PortTextBox.Text = "25565"; PortTextBox.HintText = "Port"; PortTextBox.Margin = new Thickness(0, 0, 0, 10); PortTextBox.Padding = new Thickness(10); PortTextBox.Background = new SolidBrush("#8d697a"); PortTextBox.OverBackground = new SolidBrush("#544e68"); PortTextBox.FocusedBackground = new SolidBrush("#203c56"); PortTextBox.Id = "PortTextBox"; JoinByIpJoin = new ImageTextButton(); JoinByIpJoin.Text = "Join"; JoinByIpJoin.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; JoinByIpJoin.Margin = new Thickness(0, 0, 0, 10); JoinByIpJoin.Padding = new Thickness(10); JoinByIpJoin.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; JoinByIpJoin.Background = new SolidBrush("#8d697a"); JoinByIpJoin.OverBackground = new SolidBrush("#544e68"); JoinByIpJoin.FocusedBackground = new SolidBrush("#203c56"); JoinByIpJoin.Id = "JoinByIpJoin"; JoinByIpBack = new ImageTextButton(); JoinByIpBack.Text = "Back"; JoinByIpBack.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; JoinByIpBack.Padding = new Thickness(10); JoinByIpBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch; JoinByIpBack.Background = new SolidBrush("#8d697a"); JoinByIpBack.OverBackground = new SolidBrush("#544e68"); JoinByIpBack.FocusedBackground = new SolidBrush("#203c56"); JoinByIpBack.Id = "JoinByIpBack"; JoinByIpPanel = new VerticalStackPanel(); JoinByIpPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; JoinByIpPanel.Width = 200; JoinByIpPanel.Padding = new Thickness(10); JoinByIpPanel.Visible = false; JoinByIpPanel.Id = "JoinByIpPanel"; JoinByIpPanel.Widgets.Add(IpAddressTextBox); JoinByIpPanel.Widgets.Add(PortTextBox); JoinByIpPanel.Widgets.Add(JoinByIpJoin); JoinByIpPanel.Widgets.Add(JoinByIpBack); var verticalStackPanel1 = new VerticalStackPanel(); verticalStackPanel1.GridRow = 1; verticalStackPanel1.Widgets.Add(MainPanel); verticalStackPanel1.Widgets.Add(StartGamePanel); verticalStackPanel1.Widgets.Add(CreateMultiplayerGamePanel); verticalStackPanel1.Widgets.Add(MultiPlayerPanel); verticalStackPanel1.Widgets.Add(SettingsPanel); verticalStackPanel1.Widgets.Add(JoinByIpPanel); var grid1 = new Grid(); grid1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; grid1.Widgets.Add(GameLogo); grid1.Widgets.Add(verticalStackPanel1); Padding = new Thickness(10); Widgets.Add(label1); Widgets.Add(grid1); }
private Grid CreateFileEditor <T>(Record record, bool hasSetter, string filter) { if (Settings.AssetManager == null) { return(null); } var propertyType = record.Type; var value = record.GetValue(_object); var subGrid = new Grid { ColumnSpacing = 8, HorizontalAlignment = HorizontalAlignment.Stretch }; subGrid.ColumnsProportions.Add(new Proportion(ProportionType.Fill)); subGrid.ColumnsProportions.Add(new Proportion()); var baseObject = _object as BaseObject; var path = string.Empty; if (baseObject != null) { baseObject.Resources.TryGetValue(record.Name, out path); } var textBox = new TextBox { Text = path }; subGrid.Widgets.Add(textBox); var button = new ImageTextButton { Text = "Change...", ContentHorizontalAlignment = HorizontalAlignment.Center, Tag = value, HorizontalAlignment = HorizontalAlignment.Stretch, GridColumn = 1 }; subGrid.Widgets.Add(button); if (hasSetter) { button.Click += (sender, args) => { var dlg = new FileDialog(FileDialogMode.OpenFile) { Filter = filter }; if (!string.IsNullOrEmpty(textBox.Text)) { var filePath = textBox.Text; if (!Path.IsPathRooted(filePath) && !string.IsNullOrEmpty(Settings.BasePath)) { filePath = Path.Combine(Settings.BasePath, filePath); } dlg.FilePath = filePath; } else if (!string.IsNullOrEmpty(Settings.BasePath)) { dlg.Folder = Settings.BasePath; } dlg.Closed += (s, a) => { if (!dlg.Result) { return; } try { var newValue = Settings.AssetManager.Load <T>(dlg.FilePath); var filePath = dlg.FilePath; if (!string.IsNullOrEmpty(Settings.BasePath)) { filePath = PathUtils.TryToMakePathRelativeTo(filePath, Settings.BasePath); } textBox.Text = filePath; SetValue(record, _object, newValue); if (baseObject != null) { baseObject.Resources[record.Name] = filePath; } FireChanged(propertyType.Name); } catch (Exception) { } }; dlg.ShowModal(); }; } else { button.Enabled = false; } return(subGrid); }
private Grid CreateBrushEditor(Record record, bool hasSetter) { var propertyType = record.Type; var value = record.GetValue(_object) as SolidBrush; var subGrid = new Grid { ColumnSpacing = 8, HorizontalAlignment = HorizontalAlignment.Stretch }; subGrid.ColumnsProportions.Add(new Proportion()); subGrid.ColumnsProportions.Add(new Proportion(ProportionType.Fill)); var color = Color.Transparent; if (value != null) { color = value.Color; } var image = new Image { Renderable = DefaultAssets.WhiteRegion, VerticalAlignment = VerticalAlignment.Center, Width = 32, Height = 16, Color = color }; subGrid.Widgets.Add(image); var button = new ImageTextButton { Text = "Change...", ContentHorizontalAlignment = HorizontalAlignment.Center, Tag = value, HorizontalAlignment = HorizontalAlignment.Stretch, GridColumn = 1 }; subGrid.Widgets.Add(button); if (hasSetter) { button.Click += (sender, args) => { var dlg = new ColorPickerDialog() { Color = image.Color }; dlg.Closed += (s, a) => { if (!dlg.Result) { return; } image.Color = dlg.Color; SetValue(record, _object, new SolidBrush(dlg.Color)); var baseObject = _object as BaseObject; if (baseObject != null) { baseObject.Resources[record.Name] = dlg.Color.ToHexString(); } FireChanged(propertyType.Name); }; dlg.ShowModal(); }; } else { button.Enabled = false; } return(subGrid); }
private void BuildUI() { var label1 = new Label(); label1.Text = "Button:"; label1.Id = ""; _button = new ImageTextButton(); _button.Text = "Button"; _button.Id = "_button"; _button.PaddingLeft = 8; _button.PaddingRight = 8; _button.GridColumn = 1; _textButtonLabel = new Label(); _textButtonLabel.Text = "Text Button:"; _textButtonLabel.Id = "_textButtonLabel"; _textButtonLabel.GridRow = 1; _textButton = new TextButton(); _textButton.Text = "Button 2"; _textButton.Id = "_textButton"; _textButton.PaddingLeft = 8; _textButton.PaddingRight = 8; _textButton.GridColumn = 1; _textButton.GridRow = 1; var label2 = new Label(); label2.Text = "Image Button:"; label2.Id = ""; label2.GridRow = 2; _imageButton = new ImageButton(); _imageButton.Id = "_imageButton"; _imageButton.PaddingLeft = 8; _imageButton.PaddingRight = 8; _imageButton.GridColumn = 1; _imageButton.GridRow = 2; var checkBox1 = new CheckBox(); checkBox1.Text = "This is checkbox"; checkBox1.ImageWidth = 10; checkBox1.ImageHeight = 10; checkBox1.GridRow = 3; checkBox1.GridColumnSpan = 2; var label3 = new Label(); label3.Text = "Horizontal Slider:"; label3.Id = ""; label3.GridRow = 4; var horizontalSlider1 = new HorizontalSlider(); horizontalSlider1.GridColumn = 1; horizontalSlider1.GridRow = 4; var label4 = new Label(); label4.Text = "Combo Box:"; label4.GridRow = 5; var listItem1 = new ListItem(); listItem1.Id = ""; listItem1.Text = "Red"; listItem1.Color = Color.Red; var listItem2 = new ListItem(); listItem2.Id = null; listItem2.Text = "Green"; listItem2.Color = Color.Lime; var listItem3 = new ListItem(); listItem3.Id = null; listItem3.Text = "Blue"; listItem3.Color = new Color { B = 255, G = 128, R = 0, A = 255, }; var comboBox1 = new ComboBox(); comboBox1.Width = 200; comboBox1.GridColumn = 1; comboBox1.GridRow = 5; comboBox1.Items.Add(listItem1); comboBox1.Items.Add(listItem2); comboBox1.Items.Add(listItem3); var label5 = new Label(); label5.Text = "Text Field:"; label5.GridRow = 6; var textBox1 = new TextBox(); textBox1.Text = ""; textBox1.GridColumn = 1; textBox1.GridRow = 6; var label6 = new Label(); label6.Text = "List Box:"; label6.GridRow = 7; var listItem4 = new ListItem(); listItem4.Id = null; listItem4.Text = "Red"; listItem4.Color = Color.Red; var listItem5 = new ListItem(); listItem5.Id = null; listItem5.Text = "Green"; listItem5.Color = Color.Lime; var listItem6 = new ListItem(); listItem6.Id = null; listItem6.Text = "Blue"; listItem6.Color = Color.Blue; var listBox1 = new ListBox(); listBox1.Width = 200; listBox1.GridColumn = 1; listBox1.GridRow = 7; listBox1.Items.Add(listItem4); listBox1.Items.Add(listItem5); listBox1.Items.Add(listItem6); var label7 = new Label(); label7.Text = "Tree"; label7.GridRow = 8; _gridRight = new Grid(); _gridRight.ColumnSpacing = 8; _gridRight.RowSpacing = 8; _gridRight.DefaultRowProportion = new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }; _gridRight.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); _gridRight.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); _gridRight.Id = "_gridRight"; _gridRight.Widgets.Add(label1); _gridRight.Widgets.Add(_button); _gridRight.Widgets.Add(_textButtonLabel); _gridRight.Widgets.Add(_textButton); _gridRight.Widgets.Add(label2); _gridRight.Widgets.Add(_imageButton); _gridRight.Widgets.Add(checkBox1); _gridRight.Widgets.Add(label3); _gridRight.Widgets.Add(horizontalSlider1); _gridRight.Widgets.Add(label4); _gridRight.Widgets.Add(comboBox1); _gridRight.Widgets.Add(label5); _gridRight.Widgets.Add(textBox1); _gridRight.Widgets.Add(label6); _gridRight.Widgets.Add(listBox1); _gridRight.Widgets.Add(label7); var scrollViewer1 = new ScrollViewer(); scrollViewer1.Content = _gridRight; var label8 = new Label(); label8.Text = "Vertical Slider:"; var verticalSlider1 = new VerticalSlider(); verticalSlider1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; verticalSlider1.GridRow = 1; var grid1 = new Grid(); grid1.RowSpacing = 8; grid1.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); grid1.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); grid1.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); grid1.Widgets.Add(label8); grid1.Widgets.Add(verticalSlider1); var label9 = new Label(); label9.Text = "Progress Bars:"; _horizontalProgressBar = new HorizontalProgressBar(); _horizontalProgressBar.Id = "_horizontalProgressBar"; _horizontalProgressBar.GridRow = 1; _verticalProgressBar = new VerticalProgressBar(); _verticalProgressBar.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; _verticalProgressBar.Id = "_verticalProgressBar"; _verticalProgressBar.GridRow = 2; var grid2 = new Grid(); grid2.RowSpacing = 8; grid2.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); grid2.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); grid2.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); grid2.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); grid2.Widgets.Add(label9); grid2.Widgets.Add(_horizontalProgressBar); grid2.Widgets.Add(_verticalProgressBar); var verticalSplitPane1 = new VerticalSplitPane(); verticalSplitPane1.Widgets.Add(grid1); verticalSplitPane1.Widgets.Add(grid2); GridRow = 1; Widgets.Add(scrollViewer1); Widgets.Add(verticalSplitPane1); }
private void BuildUI() { _menuItemOpenFile = new MenuItem(); _menuItemOpenFile.Text = "&Open"; _menuItemOpenFile.ShortcutText = "Ctrl+O"; _menuItemOpenFile.Id = "_menuItemOpenFile"; _menuItemSaveFile = new MenuItem(); _menuItemSaveFile.Text = "&Save"; _menuItemSaveFile.ShortcutText = "Ctrl+S"; _menuItemSaveFile.Id = "_menuItemSaveFile"; _menuItemChooseFolder = new MenuItem(); _menuItemChooseFolder.Text = "Choose Fol&der"; _menuItemChooseFolder.ShortcutText = "Ctrl+D"; _menuItemChooseFolder.Id = "_menuItemChooseFolder"; _menuItemChooseColor = new MenuItem(); _menuItemChooseColor.Text = "Choose Co&lor"; _menuItemChooseColor.ShortcutText = "Ctrl+L"; _menuItemChooseColor.Id = "_menuItemChooseColor"; var menuSeparator1 = new MenuSeparator(); _menuItemQuit = new MenuItem(); _menuItemQuit.Text = "&Quit"; _menuItemQuit.ShortcutText = "Ctrl+Q"; _menuItemQuit.Id = "_menuItemQuit"; _menuFile = new MenuItem(); _menuFile.Text = "&File"; _menuFile.Id = "_menuFile"; _menuFile.Items.Add(_menuItemOpenFile); _menuFile.Items.Add(_menuItemSaveFile); _menuFile.Items.Add(_menuItemChooseFolder); _menuFile.Items.Add(_menuItemChooseColor); _menuFile.Items.Add(menuSeparator1); _menuFile.Items.Add(_menuItemQuit); _menuItemCopy = new MenuItem(); _menuItemCopy.Text = "&Copy"; _menuItemCopy.ShortcutText = "Ctrl+Insert, Ctrl+C"; _menuItemCopy.Id = "_menuItemCopy"; _menuItemPaste = new MenuItem(); _menuItemPaste.Text = "&Paste"; _menuItemPaste.ShortcutText = "Shift+Insert, Ctrl+V"; _menuItemPaste.Id = "_menuItemPaste"; var menuSeparator2 = new MenuSeparator(); _menuItemUndo = new MenuItem(); _menuItemUndo.Text = "&Undo"; _menuItemUndo.ShortcutText = "Ctrl+Z"; _menuItemUndo.Id = "_menuItemUndo"; _menuItemRedo = new MenuItem(); _menuItemRedo.Text = "&Redo"; _menuItemRedo.ShortcutText = "Ctrl+Y"; _menuItemRedo.Id = "_menuItemRedo"; _menuEdit = new MenuItem(); _menuEdit.Text = "&Edit"; _menuEdit.Id = "_menuEdit"; _menuEdit.Items.Add(_menuItemCopy); _menuEdit.Items.Add(_menuItemPaste); _menuEdit.Items.Add(menuSeparator2); _menuEdit.Items.Add(_menuItemUndo); _menuEdit.Items.Add(_menuItemRedo); _menuItemAbout = new MenuItem(); _menuItemAbout.Text = "&About"; _menuItemAbout.Id = "_menuItemAbout"; _menuHelp = new MenuItem(); _menuHelp.Text = "&Help"; _menuHelp.Id = "_menuHelp"; _menuHelp.Items.Add(_menuItemAbout); _mainMenu = new HorizontalMenu(); _mainMenu.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Stretch; _mainMenu.Id = "_mainMenu"; _mainMenu.Items.Add(_menuFile); _mainMenu.Items.Add(_menuEdit); _mainMenu.Items.Add(_menuHelp); var label1 = new Label(); label1.Text = "Button:"; _buttonSaveFile = new ImageTextButton(); _buttonSaveFile.Text = "Save File"; _buttonSaveFile.Padding = new Thickness(8, 0); _buttonSaveFile.GridColumn = 1; _buttonSaveFile.Id = "_buttonSaveFile"; _textSaveFile = new TextBox(); _textSaveFile.GridColumn = 2; _textSaveFile.Id = "_textSaveFile"; var label2 = new Label(); label2.Text = "Another Button:"; label2.GridRow = 1; _buttonOpenFile = new ImageTextButton(); _buttonOpenFile.Text = "Open File"; _buttonOpenFile.Padding = new Thickness(8, 0); _buttonOpenFile.GridColumn = 1; _buttonOpenFile.GridRow = 1; _buttonOpenFile.Id = "_buttonOpenFile"; _textOpenFile = new TextBox(); _textOpenFile.GridColumn = 2; _textOpenFile.GridRow = 1; _textOpenFile.Id = "_textOpenFile"; var label3 = new Label(); label3.Text = "Blue Button:"; label3.GridRow = 2; _buttonChooseFolder = new ImageTextButton("blue"); _buttonChooseFolder.Text = "Choose Folder"; _buttonChooseFolder.Padding = new Thickness(8, 0); _buttonChooseFolder.GridColumn = 1; _buttonChooseFolder.GridRow = 2; _buttonChooseFolder.Id = "_buttonChooseFolder"; _textChooseFolder = new TextBox(); _textChooseFolder.GridColumn = 2; _textChooseFolder.GridRow = 2; _textChooseFolder.Id = "_textChooseFolder"; _textButtonLabel = new Label(); _textButtonLabel.Text = "Text Button:"; _textButtonLabel.GridRow = 3; _textButtonLabel.Id = "_textButtonLabel"; _buttonChooseColor = new TextButton(); _buttonChooseColor.Text = "Choose Color"; _buttonChooseColor.Padding = new Thickness(8, 0); _buttonChooseColor.GridColumn = 1; _buttonChooseColor.GridRow = 3; _buttonChooseColor.Id = "_buttonChooseColor"; var label4 = new Label(); label4.Text = "Image Button:"; label4.GridRow = 4; _imageButton = new ImageButton(); _imageButton.Padding = new Thickness(8, 0); _imageButton.GridColumn = 1; _imageButton.GridRow = 4; _imageButton.Id = "_imageButton"; var checkBox1 = new CheckBox(); checkBox1.Text = "This is checkbox"; checkBox1.ImageWidth = 10; checkBox1.ImageHeight = 10; checkBox1.GridRow = 5; checkBox1.GridColumnSpan = 2; var label5 = new Label(); label5.Text = "Horizontal Slider:"; label5.GridRow = 6; var horizontalSlider1 = new HorizontalSlider(); horizontalSlider1.GridColumn = 1; horizontalSlider1.GridRow = 6; horizontalSlider1.GridColumnSpan = 2; var label6 = new Label(); label6.Text = "Combo Box:"; label6.GridRow = 7; var listItem1 = new ListItem(); listItem1.Text = "Red"; listItem1.Color = Color.Red; var listItem2 = new ListItem(); listItem2.Text = "Green"; listItem2.Color = Color.Lime; var listItem3 = new ListItem(); listItem3.Text = "Blue"; listItem3.Color = ColorStorage.CreateColor(0, 128, 255, 255); var comboBox1 = new ComboBox(); comboBox1.Width = 200; comboBox1.GridColumn = 1; comboBox1.GridRow = 7; comboBox1.GridColumnSpan = 2; comboBox1.Items.Add(listItem1); comboBox1.Items.Add(listItem2); comboBox1.Items.Add(listItem3); var label7 = new Label(); label7.Text = "Text Field:"; label7.GridRow = 8; var textBox1 = new TextBox(); textBox1.GridColumn = 1; textBox1.GridRow = 8; textBox1.GridColumnSpan = 2; var label8 = new Label(); label8.Text = "Spin Button:"; label8.GridRow = 9; var spinButton1 = new SpinButton(); spinButton1.Value = 1; spinButton1.Width = 100; spinButton1.GridColumn = 1; spinButton1.GridRow = 9; var label9 = new Label(); label9.Text = "List Box:"; label9.GridRow = 10; var listItem4 = new ListItem(); listItem4.Text = "Red"; listItem4.Color = Color.Red; var listItem5 = new ListItem(); listItem5.Text = "Green"; listItem5.Color = Color.Lime; var listItem6 = new ListItem(); listItem6.Text = "Blue"; listItem6.Color = Color.Blue; var listBox1 = new ListBox(); listBox1.Width = 200; listBox1.GridColumn = 1; listBox1.GridRow = 10; listBox1.GridColumnSpan = 2; listBox1.Items.Add(listItem4); listBox1.Items.Add(listItem5); listBox1.Items.Add(listItem6); var label10 = new Label(); label10.Text = "Vertical Menu:"; label10.GridRow = 11; var menuItem1 = new MenuItem(); menuItem1.Text = "Start New Game"; var menuItem2 = new MenuItem(); menuItem2.Text = "Options"; var menuItem3 = new MenuItem(); menuItem3.Text = "Quit"; var verticalMenu1 = new VerticalMenu(); verticalMenu1.GridColumn = 1; verticalMenu1.GridRow = 11; verticalMenu1.Items.Add(menuItem1); verticalMenu1.Items.Add(menuItem2); verticalMenu1.Items.Add(menuItem3); var label11 = new Label(); label11.Text = "Tree"; label11.GridRow = 12; _gridRight = new Grid(); _gridRight.ColumnSpacing = 8; _gridRight.RowSpacing = 8; _gridRight.DefaultRowProportion = new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }; _gridRight.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); _gridRight.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); _gridRight.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); _gridRight.Id = "_gridRight"; _gridRight.Widgets.Add(label1); _gridRight.Widgets.Add(_buttonSaveFile); _gridRight.Widgets.Add(_textSaveFile); _gridRight.Widgets.Add(label2); _gridRight.Widgets.Add(_buttonOpenFile); _gridRight.Widgets.Add(_textOpenFile); _gridRight.Widgets.Add(label3); _gridRight.Widgets.Add(_buttonChooseFolder); _gridRight.Widgets.Add(_textChooseFolder); _gridRight.Widgets.Add(_textButtonLabel); _gridRight.Widgets.Add(_buttonChooseColor); _gridRight.Widgets.Add(label4); _gridRight.Widgets.Add(_imageButton); _gridRight.Widgets.Add(checkBox1); _gridRight.Widgets.Add(label5); _gridRight.Widgets.Add(horizontalSlider1); _gridRight.Widgets.Add(label6); _gridRight.Widgets.Add(comboBox1); _gridRight.Widgets.Add(label7); _gridRight.Widgets.Add(textBox1); _gridRight.Widgets.Add(label8); _gridRight.Widgets.Add(spinButton1); _gridRight.Widgets.Add(label9); _gridRight.Widgets.Add(listBox1); _gridRight.Widgets.Add(label10); _gridRight.Widgets.Add(verticalMenu1); _gridRight.Widgets.Add(label11); var scrollViewer1 = new ScrollViewer(); scrollViewer1.Content = _gridRight; var label12 = new Label(); label12.Text = "Vertical Slider:"; var verticalSlider1 = new VerticalSlider(); verticalSlider1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; verticalSlider1.GridRow = 1; var grid1 = new Grid(); grid1.RowSpacing = 8; grid1.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); grid1.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); grid1.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); grid1.Widgets.Add(label12); grid1.Widgets.Add(verticalSlider1); var label13 = new Label(); label13.Text = "Progress Bars:"; _horizontalProgressBar = new HorizontalProgressBar(); _horizontalProgressBar.GridRow = 1; _horizontalProgressBar.Id = "_horizontalProgressBar"; _verticalProgressBar = new VerticalProgressBar(); _verticalProgressBar.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center; _verticalProgressBar.GridRow = 2; _verticalProgressBar.Id = "_verticalProgressBar"; var grid2 = new Grid(); grid2.RowSpacing = 8; grid2.ColumnsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); grid2.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); grid2.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); grid2.RowsProportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); grid2.Widgets.Add(label13); grid2.Widgets.Add(_horizontalProgressBar); grid2.Widgets.Add(_verticalProgressBar); var verticalSplitPane1 = new VerticalSplitPane(); verticalSplitPane1.Widgets.Add(grid1); verticalSplitPane1.Widgets.Add(grid2); var horizontalSplitPane1 = new HorizontalSplitPane(); horizontalSplitPane1.Widgets.Add(scrollViewer1); horizontalSplitPane1.Widgets.Add(verticalSplitPane1); Spacing = 8; Proportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Auto, }); Proportions.Add(new Proportion { Type = Myra.Graphics2D.UI.ProportionType.Fill, }); Widgets.Add(_mainMenu); Widgets.Add(horizontalSplitPane1); }
public CollectionEditor(IList collection, Type type) { Width = 500; Height = 400; _collection = collection; _type = type; InternalChild = new Grid { Margin = new Thickness(8), ColumnSpacing = 8, RowSpacing = 8 }; InternalChild.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); InternalChild.ColumnsProportions.Add(new Proportion(ProportionType.Fill)); InternalChild.RowsProportions.Add(new Proportion(ProportionType.Fill)); InternalChild.RowsProportions.Add(new Proportion(ProportionType.Auto)); _listItems = new ListBox { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; _listItems.SelectedIndexChanged += ListItemsOnSelectedIndexChanged; // Add initial items foreach (var item in _collection) { _listItems.Items.Add(new ListItem(BuildItemText(item), null, item)); } InternalChild.Widgets.Add(_listItems); _propertyGrid = new PropertyGrid { GridColumn = 1 }; _propertyGrid.PropertyChanged += PropertyGridOnPropertyChanged; InternalChild.Widgets.Add(_propertyGrid); var buttonsGrid = new Grid { GridRow = 1, ColumnSpacing = 4 }; buttonsGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); buttonsGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); buttonsGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); buttonsGrid.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); var buttonNew = new ImageTextButton { Text = "New" }; buttonNew.Click += ButtonNewOnUp; buttonsGrid.Widgets.Add(buttonNew); _buttonDelete = new ImageTextButton { Text = "Delete", GridColumn = 1 }; _buttonDelete.Click += ButtonDeleteOnUp; buttonsGrid.Widgets.Add(_buttonDelete); _buttonMoveUp = new ImageTextButton { Text = "Up", GridColumn = 2 }; _buttonMoveUp.Click += ButtonMoveUpOnUp; buttonsGrid.Widgets.Add(_buttonMoveUp); _buttonMoveDown = new ImageTextButton { Text = "Down", GridColumn = 3 }; _buttonMoveDown.Click += ButtonMoveDownOnUp; buttonsGrid.Widgets.Add(_buttonMoveDown); InternalChild.Widgets.Add(buttonsGrid); UpdateButtonsEnabled(); }
protected override void LoadContent() { base.LoadContent(); MyraEnvironment.Game = this; _desktop = new Desktop(); // Widget.DrawFrames = true; var grid = new Grid { RowSpacing = 3, ColumnSpacing = 3, // DrawLines = true }; grid.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); grid.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); grid.ColumnsProportions.Add(new Proportion(ProportionType.Part, 1.0f)); grid.ColumnsProportions.Add(new Proportion(ProportionType.Part, 2.0f)); grid.ColumnsProportions.Add(new Proportion(ProportionType.Pixels, 150.0f)); grid.ColumnsProportions.Add(new Proportion(ProportionType.Auto)); grid.ColumnsProportions.Add(new Proportion(ProportionType.Fill)); grid.RowsProportions.Add(new Proportion(ProportionType.Auto)); grid.RowsProportions.Add(new Proportion(ProportionType.Auto)); grid.RowsProportions.Add(new Proportion(ProportionType.Part, 1.0f)); grid.RowsProportions.Add(new Proportion(ProportionType.Part, 1.0f)); grid.RowsProportions.Add(new Proportion(ProportionType.Pixels, 200.0f)); grid.RowsProportions.Add(new Proportion(ProportionType.Auto)); grid.RowsProportions.Add(new Proportion(ProportionType.Fill)); // Create headers for (var i = 1; i < grid.ColumnsProportions.Count; ++i) { var header = new Label { Text = grid.ColumnsProportions[i].ToString(), GridColumn = i, GridRow = 0 }; grid.Widgets.Add(header); } // Combo var combo = new ComboBox { GridColumn = 1, GridRow = 1 }; combo.Items.Add(new ListItem("Red", Color.Red)); combo.Items.Add(new ListItem("Green", Color.Green)); combo.Items.Add(new ListItem("Blue", Color.Blue)); grid.Widgets.Add(combo); // Button var button = new ImageTextButton { GridColumn = 2, GridRow = 1, GridColumnSpan = 2, GridRowSpan = 1, HorizontalAlignment = HorizontalAlignment.Stretch, Text = "This is 2 columns button" }; button.Click += (s, a) => { var messageBox = Dialog.CreateMessageBox("2C", "2 Columns Button pushed!"); messageBox.ShowModal(_desktop); }; grid.Widgets.Add(button); // Button var button2 = new TextButton { GridColumn = 2, GridRow = 2, GridColumnSpan = 1, GridRowSpan = 2, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Text = "This is 2 rows button" }; button2.Click += (s, a) => { var messageBox = Dialog.CreateMessageBox("2R", "2 Rows Button pushed!"); messageBox.ShowModal(_desktop); }; grid.Widgets.Add(button2); var text = @"Lorem ipsum \c[green]dolor sit amet, \c[red]consectetur adipisicing elit," + @" sed do eiusmod \c[#AAAAAA]tempor incididunt ut labore et dolore magna aliqua. " + @"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip " + @"ex ea commodo consequat. \c[white]Duis aute irure dolor in reprehenderit in voluptate " + "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " + "proident, sunt in culpa qui officia deserunt mollit anim id est laborum!"; var label = new Label { Text = text, VerticalSpacing = 0, TextColor = Color.AntiqueWhite, Wrap = true }; var pane = new ScrollViewer { Content = label, Width = 200, Height = 200 }; _window = new Window { Title = "Text", Content = pane }; var button3 = new ImageTextButton { Text = "Show Window", GridColumn = 4, GridRow = 3 }; grid.Widgets.Add(button3); button3.Click += (sender, args) => { _window.ShowModal(_desktop); }; // Horizontal slider var hslider = new HorizontalSlider { GridColumn = 3, GridRow = 2 }; grid.Widgets.Add(hslider); // Horizontal slider value var hsliderValue = new Label { GridColumn = 4, GridRow = 2, Text = "HSlider Value: 0" }; hslider.ValueChanged += (sender, args) => { hsliderValue.Text = string.Format("HSlider Value: {0:0.00}", hslider.Value); }; grid.Widgets.Add(hsliderValue); var textBlock = new Label { Width = 125, Text = "This is textblock which spans for several lines to demonstrate row proportion set to Auto", GridColumn = 4, GridRow = 1, Wrap = true }; grid.Widgets.Add(textBlock); var checkBox = new CheckBox { Text = "This is a checkbox", GridColumn = 3, GridRow = 3, }; grid.Widgets.Add(checkBox); // Spin buttons var textField = new TextBox { GridColumn = 5, GridRow = 1, Width = 100 }; grid.Widgets.Add(textField); var spinButton2 = new SpinButton { GridColumn = 5, GridRow = 2, Width = 100, Integer = true }; grid.Widgets.Add(spinButton2); // Progress bars _horizontalProgressBar = new HorizontalProgressBar { GridColumn = 5, GridRow = 3, Width = 100 }; grid.Widgets.Add(_horizontalProgressBar); _verticalProgressBar = new VerticalProgressBar { GridColumn = 6, GridRow = 1, Height = 100 }; grid.Widgets.Add(_verticalProgressBar); // List box var list = new ListBox { GridColumn = 5, GridRow = 4 }; list.Items.Add(new ListItem("Red", Color.Red)); list.Items.Add(new ListItem("Green", Color.Green)); list.Items.Add(new ListItem("Blue", Color.Blue)); grid.Widgets.Add(list); // Vertical slider var vslider = new VerticalSlider { GridColumn = 2, GridRow = 4 }; grid.Widgets.Add(vslider); // Vertical slider value var vsliderValue = new Label { GridColumn = 4, GridRow = 4, Text = "VSlider Value: 0" }; vslider.ValueChanged += (sender, args) => { vsliderValue.Text = string.Format("VSlider Value: {0:0.00}", vslider.Value); }; grid.Widgets.Add(vsliderValue); var tree = new Tree { HasRoot = false, GridColumn = 3, GridRow = 4 }; var node1 = tree.AddSubNode("node1"); var node2 = node1.AddSubNode("node2"); var node3 = node2.AddSubNode("node3"); node3.AddSubNode("node4"); node3.AddSubNode("node5"); node2.AddSubNode("node6"); grid.Widgets.Add(tree); var textBlock2 = new Label { Text = "This is long textblock", GridColumn = 1, GridRow = 4 }; grid.Widgets.Add(textBlock2); var hsplitPane = new HorizontalSplitPane { GridColumn = 1, GridRow = 5 }; var hsplitPaneLabel1 = new Label { Text = "Left" }; hsplitPane.Widgets.Add(hsplitPaneLabel1); var hsplitPaneLabel2 = new Label { Text = "Right" }; hsplitPane.Widgets.Add(hsplitPaneLabel2); grid.Widgets.Add(hsplitPane); var vsplitPane = new VerticalSplitPane { GridColumn = 6, GridRow = 4 }; var vsplitPaneLabel1 = new Label { Text = "Top" }; vsplitPane.Widgets.Add(vsplitPaneLabel1); var vsplitPaneLabel2 = new Label { Text = "Bottom" }; vsplitPane.Widgets.Add(vsplitPaneLabel2); grid.Widgets.Add(vsplitPane); for (var i = 1; i < grid.RowsProportions.Count; ++i) { var header = new Label { Text = grid.RowsProportions[i].ToString(), GridColumn = 0, GridRow = i }; grid.Widgets.Add(header); } _desktop.Root = grid; }