private void CreateMainMenuUI() { var paradoxLogo = new ImageElement { Source = uiImages["pdx_logo"] }; paradoxLogo.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f)); paradoxLogo.SetCanvasRelativeSize(new Vector3(0.5f, 0.5f, 1f)); paradoxLogo.SetCanvasRelativePosition(new Vector3(0.5f, 0.3f, 1f)); StartButton = new Button { Content = new TextBlock { Font = spriteFont, Text = "Touch to Start", TextColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center}, NotPressedImage = buttonImage, PressedImage = buttonImage, MouseOverImage = buttonImage, Padding = new Thickness(80, 27, 25, 35), MinimumWidth = 250f, }; StartButton.SetCanvasPinOrigin(new Vector3(0.5f, 0.5f, 1f)); StartButton.SetCanvasRelativePosition(new Vector3(0.5f, 0.7f, 0f)); var mainMenuCanvas = new Canvas(); mainMenuCanvas.Children.Add(paradoxLogo); mainMenuCanvas.Children.Add(StartButton); mainMenuRoot = new ModalElement { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Content = mainMenuCanvas }; }
private UIElement CreateMainScreneTopBar() { // Create Life bar lifeBarGaugeImage = mainScreneImages["life_bar"]; var lifeBarCoverImage = mainScreneImages["character_frame"]; gaugeBarRegion = lifeBarGaugeImage.Region; var lifebarGauge = new ImageElement { Name = "LifeBarBackground", Source = lifeBarGaugeImage, StretchType = StretchType.Fill, }; lifebarGauge.SetGridColumn(1); lifeBarGrid = new Grid(); lifeBarGrid.Children.Add(lifebarGauge); lifeBarGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, lifeBarCoverImage.Borders.X)); lifeBarGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 0)); lifeBarGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 100)); lifeBarGrid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, lifeBarCoverImage.Borders.Y)); lifeBarGrid.RowDefinitions.Add(new StripDefinition()); lifeBarGrid.LayerDefinitions.Add(new StripDefinition()); lifeBarGrid.SetCanvasRelativePosition(new Vector3(0f, 0.185f, 0f)); lifeBarGrid.SetCanvasRelativeSize(new Vector3(1f, 0.25f, 1f)); lifeBarGrid.SetPanelZIndex(-1); var lifebarForeground = new ImageElement { Name = "LifeBarForeGround", Source = lifeBarCoverImage, StretchType = StretchType.Fill, }; lifebarForeground.SetGridColumnSpan(3); lifebarForeground.SetGridRowSpan(3); lifebarForeground.SetCanvasRelativeSize(new Vector3(1f, 1f, 1f)); // Life count lifeCounter = new TextBlock { Text = CreateLifeCountText(), TextColor = Color.Gold, Font = westernFont, TextSize = 32, HorizontalAlignment = HorizontalAlignment.Left }; lifeCounter.SetCanvasAbsolutePosition(new Vector3(lifeBarCoverImage.Borders.X, float.NaN, float.NaN)); lifeCounter.SetCanvasRelativePosition(new Vector3(float.NaN, 0.44f, 0f)); lifeCounter.SetPanelZIndex(1); LifeStatus = 3; // Bonus items var bonusIcon = new ImageElement { Source = mainScreneImages["gold_icon"], Name = "bonus Icon", VerticalAlignment = VerticalAlignment.Center }; bonusCounter = new TextBlock { Text = CreateBonusCountText(), TextColor = Color.White, TextSize = 27, Font = westernFont, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(10, 0, 0, 0) }; // Money var moneyIcon = new ImageElement { Source = mainScreneImages["money_icon"], Name = "money Icon", Margin = new Thickness(20, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center }; moneyCounter = new TextBlock { Text = CreateMoneyCountText(), TextColor = Color.White, TextSize = 27, Font = westernFont, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(10, 0, 0, 0) }; // Stack panel containing the bonus and money counters var moneyBonusStackPanel = new StackPanel { Name = "MoneyBonusStackPanel", Orientation = Orientation.Horizontal, }; moneyBonusStackPanel.Children.Add(bonusIcon); moneyBonusStackPanel.Children.Add(bonusCounter); moneyBonusStackPanel.Children.Add(moneyIcon); moneyBonusStackPanel.Children.Add(moneyCounter); moneyBonusStackPanel.SetCanvasRelativePosition(new Vector3(0.93f, 0.44f, 0f)); moneyBonusStackPanel.SetCanvasRelativeSize(new Vector3(float.NaN, 0.4f, 1f)); moneyBonusStackPanel.SetCanvasPinOrigin(new Vector3(1f, 0f, 0f)); moneyBonusStackPanel.SetPanelZIndex(1); // the main grid of the top bar var mainLayer = new Canvas { VerticalAlignment = VerticalAlignment.Top, MaximumHeight = 150 }; mainLayer.Children.Add(lifeBarGrid); mainLayer.Children.Add(lifebarForeground); mainLayer.Children.Add(lifeCounter); mainLayer.Children.Add(moneyBonusStackPanel); return mainLayer; }