void DrawWrappedText(TextBlock textBlock, IDrawContext drawContext) { if (builder == null) builder = new StringBuilder(); var font = textBlock.Font ?? textBlock.Screen.Font; if (font == null) return; var bounds = new Rect(textBlock.RenderSize); bounds.Height = textBlock.WrappedText.MaxMeasuredHeight; var wrappedText = textBlock.WrappedText; for (int i = 0; i < wrappedText.LineCount; i++) { // 行の文字列を取得します。 wrappedText.GetLineText(i, builder); // 空行は文字列描画をスキップします。 if (builder.Length != 0) { // 文字を描画します。 drawContext.DrawString(bounds, font, builder, textBlock.FontStretch, textBlock.TextHorizontalAlignment, textBlock.TextVerticalAlignment, Color.White, textBlock.Padding); } // 描画領域を次の行の位置へ進めます。 bounds.Y += textBlock.WrappedText.MaxMeasuredHeight; // 描画対象の領域を完全に越える行は描画しません。 if (textBlock.RenderSize.Height <= bounds.Y) break; } }
Control CreateLodControl(int levelOfDetail) { var stackPanel = new StackPanel(Screen) { Orientation = Orientation.Vertical, Padding = new Thickness(4) }; var textBlock = new TextBlock(Screen) { Text = string.Format(Strings.LevelOfDetailLabel, levelOfDetail), FontStretch = new Vector2(0.7f), ForegroundColor = Color.White, HorizontalAlignment = HorizontalAlignment.Left, TextHorizontalAlignment = HorizontalAlignment.Left }; stackPanel.Children.Add(textBlock); var viewModel = WorkspaceViewModel.CreateLodViewerViewModel(levelOfDetail); var meshView = new BlockMeshView(Screen) { Width = 32 * 2, Height = 32 * 2, DataContext = viewModel }; stackPanel.Children.Add(meshView); return stackPanel; }
public SelectLanguageDialog(Screen screen) : base(screen) { // 開く際に openAnimation で Width を設定するので 0 で初期化します。 Width = 0; ShadowOffset = new Vector2(4); Padding = new Thickness(16); Overlay.Opacity = 0.5f; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch }; Content = stackPanel; var title = new TextBlock(screen) { Text = Strings.SelectLanguageTitle, Padding = new Thickness(4), ForegroundColor = Color.Yellow, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Stretch, TextHorizontalAlignment = HorizontalAlignment.Left, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(title); var separator = ControlUtil.CreateDefaultSeparator(screen); stackPanel.Children.Add(separator); var jaButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.JaButton); jaButton.Click += OnJaButtonClick; stackPanel.Children.Add(jaButton); var enButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.EnButton); enButton.Click += OnEnButtonClick; stackPanel.Children.Add(enButton); var defaultButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.DefaultButton); defaultButton.Click += OnDefaultButtonClick; stackPanel.Children.Add(defaultButton); var cancelButon = ControlUtil.CreateDefaultMenuButton(screen, Strings.CancelButton); cancelButon.Click += (Control s, ref RoutedEventContext c) => Close(); stackPanel.Children.Add(cancelButon); openAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, From = 0, To = 240, Duration = TimeSpan.FromSeconds(0.1f) }; Animations.Add(openAnimation); cancelButon.Focus(); }
void DrawWrappedText(TextBlock textBlock, IDrawContext drawContext) { if (builder == null) builder = new StringBuilder(); var font = textBlock.Font ?? textBlock.Screen.Font; if (font == null) return; var stretch = textBlock.FontStretch; var padding = textBlock.Padding; var fColor = textBlock.ForegroundColor; var bColor = textBlock.BackgroundColor; var outlineWidth = textBlock.TextOutlineWidth; var hAlign = textBlock.TextHorizontalAlignment; var vAlign = textBlock.TextVerticalAlignment; var shadowOffset = textBlock.ShadowOffset; var bounds = new Rect(textBlock.RenderSize); bounds.Height = textBlock.WrappedText.MaxMeasuredHeight; var wrappedText = textBlock.WrappedText; for (int i = 0; i < wrappedText.LineCount; i++) { // 行の文字列を取得します。 wrappedText.GetLineText(i, builder); // 空行は文字列描画をスキップします。 if (builder.Length != 0) { // 影を描画します。 if (shadowOffset.X != 0 || shadowOffset.Y != 0) { drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding, shadowOffset); } // 文字枠を描画します。 if (0 < outlineWidth) { drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding, new Vector2(-outlineWidth, -outlineWidth)); drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding, new Vector2(-outlineWidth, outlineWidth)); drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding, new Vector2(outlineWidth, -outlineWidth)); drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding, new Vector2(outlineWidth, outlineWidth)); } // 文字を描画します。 drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, fColor, padding); } // 描画領域を次の行の位置へ進めます。 bounds.Y += textBlock.WrappedText.MaxMeasuredHeight; // 描画対象の領域を完全に越える行は描画しません。 if (textBlock.RenderSize.Height <= bounds.Y) break; } }
public FinishTabItem(Screen screen) : base(screen) { var stackPanel = new StackPanel(Screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var titleTextBlock = new TextBlock(Screen) { Text = Strings.BoxWizFinishTitle, ForegroundColor = Color.Yellow, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(titleTextBlock); var messageTextBlock = new TextBlock(Screen) { Text = Strings.BoxWizFinishMessage, TextWrapping = TextWrapping.Wrap, TextHorizontalAlignment = HorizontalAlignment.Left, ForegroundColor = Color.White, BackgroundColor = Color.Black }; stackPanel.Children.Add(messageTextBlock); var separator = ControlUtil.CreateDefaultSeparator(Screen); stackPanel.Children.Add(separator); var buttonPanel = new StackPanel(Screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Bottom }; stackPanel.Children.Add(buttonPanel); var uploadButton = ControlUtil.CreateDefaultDialogButton(Screen, Strings.UploadButton); uploadButton.Click += (Control s, ref RoutedEventContext c) => { UploadSelected(this, EventArgs.Empty); }; buttonPanel.Children.Add(uploadButton); var cancelButton = ControlUtil.CreateDefaultDialogButton(Screen, Strings.CancelButton); cancelButton.Click += (Control s, ref RoutedEventContext c) => { CancelSelected(this, EventArgs.Empty); }; buttonPanel.Children.Add(cancelButton); defaultFocusedButton = uploadButton; }
public AuthorizationTabItem(Screen screen) : base(screen) { var stackPanel = new StackPanel(Screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var titleTextBlock = new TextBlock(Screen) { Text = Strings.BoxWizAuthorizationTitle, ForegroundColor = Color.Yellow, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(titleTextBlock); var messageTextBlock = new TextBlock(Screen) { Text = Strings.BoxWizAuthorizationMessage, TextWrapping = TextWrapping.Wrap, TextHorizontalAlignment = HorizontalAlignment.Left, ForegroundColor = Color.White, BackgroundColor = Color.Black }; stackPanel.Children.Add(messageTextBlock); var separator = ControlUtil.CreateDefaultSeparator(Screen); stackPanel.Children.Add(separator); var buttonPanel = new StackPanel(Screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Bottom }; stackPanel.Children.Add(buttonPanel); var launchWebBrowserButton = ControlUtil.CreateDefaultDialogButton(Screen, Strings.LaunchWebBrowserButton); launchWebBrowserButton.Click += (Control s, ref RoutedEventContext c) => { NextSelected(this, EventArgs.Empty); }; buttonPanel.Children.Add(launchWebBrowserButton); var backButton = ControlUtil.CreateDefaultDialogButton(Screen, Strings.BackButton); backButton.Click += (Control s, ref RoutedEventContext c) => { BackSelected(this, EventArgs.Empty); }; buttonPanel.Children.Add(backButton); defaultFocusedButton = launchWebBrowserButton; }
void DrawText(TextBlock textBlock, IDrawContext drawContext) { var font = textBlock.Font ?? textBlock.Screen.Font; if (font == null) return; // 文字色を白として描画します。 drawContext.DrawString( new Rect(textBlock.RenderSize), font, textBlock.Text, textBlock.FontStretch, textBlock.TextHorizontalAlignment, textBlock.TextVerticalAlignment, Color.White, textBlock.Padding); }
public BoxProgressDialog(Screen scree) : base(scree) { Height = 96; Overlay.Opacity = 0.5f; textBlock = new TextBlock(Screen) { ForegroundColor = Color.White, BackgroundColor = Color.Black, Padding = new Thickness(16) }; Content = textBlock; }
public ImageButton(Screen screen) : base(screen) { canvas = new Canvas(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = canvas; Image = new Image(screen); canvas.Children.Add(Image); TextBlock = new TextBlock(screen); canvas.Children.Add(TextBlock); }
public DirectionalLightWindow(Screen screen) : base(screen) { ShadowOffset = new Vector2(4); Padding = new Thickness(16); HorizontalAlignment = HorizontalAlignment.Left; VerticalAlignment = VerticalAlignment.Top; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch }; Content = stackPanel; titleTextBlock = new TextBlock(screen) { Padding = new Thickness(4), ForegroundColor = Color.Yellow, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Stretch, TextHorizontalAlignment = HorizontalAlignment.Left, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(titleTextBlock); var separator = ControlUtil.CreateDefaultSeparator(screen); stackPanel.Children.Add(separator); switchLightButton = ControlUtil.CreateDefaultDialogButton(screen, ""); switchLightButton.Padding = new Thickness(16, 0, 16, 0); switchLightButton.Click += OnSwitchLightButtonClick; stackPanel.Children.Add(switchLightButton); diffuseColorButton = new LightColorButton(screen); diffuseColorButton.NameTextBlock.Text = Strings.DiffuseColorLabel; diffuseColorButton.Click += OnDiffuseColorButtonClick; stackPanel.Children.Add(diffuseColorButton); specularColorButton = new LightColorButton(screen); specularColorButton.NameTextBlock.Text = Strings.SpecularColorLabel; specularColorButton.Click += OnSpecularColorButtonClick; stackPanel.Children.Add(specularColorButton); }
void DrawText(TextBlock textBlock, IDrawContext drawContext) { var font = textBlock.Font ?? textBlock.Screen.Font; if (font == null) return; var text = textBlock.Text; var stretch = textBlock.FontStretch; var padding = textBlock.Padding; var fColor = textBlock.ForegroundColor; var bColor = textBlock.BackgroundColor; var bounds = new Rect(textBlock.RenderSize); var outlineWidth = textBlock.TextOutlineWidth; var hAlign = textBlock.TextHorizontalAlignment; var vAlign = textBlock.TextVerticalAlignment; // 影を描画します。 var shadowOffset = textBlock.ShadowOffset; if (shadowOffset.X != 0 || shadowOffset.Y != 0) { drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding, shadowOffset); } // 文字枠を描画します。 if (0 < outlineWidth) { drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding, new Vector2(-outlineWidth, -outlineWidth)); drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding, new Vector2(-outlineWidth, outlineWidth)); drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding, new Vector2(outlineWidth, -outlineWidth)); drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding, new Vector2(outlineWidth, outlineWidth)); } // 文字を描画します。 drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, fColor, padding); }
public LoadBlockMeshDialog(Screen screen) : base(screen) { // 開く際に openAnimation で Width を設定するので 0 で初期化します。 Width = 0; ShadowOffset = new Vector2(4); Padding = new Thickness(16); var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch }; Content = stackPanel; var pageButtonPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Right }; stackPanel.Children.Add(pageButtonPanel); var backPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Left, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowLeft") } }; backPageButton.Click += (Control s, ref RoutedEventContext c) => { ViewModel.BackPage(); }; pageButtonPanel.Children.Add(backPageButton); pageTextBlock = new TextBlock(screen) { Width = BlockViewerGame.SpriteSize * 2, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; pageButtonPanel.Children.Add(pageTextBlock); var forwardPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Right, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowRight") } }; forwardPageButton.Click += (Control s, ref RoutedEventContext c) => { ViewModel.ForwardPage(); }; pageButtonPanel.Children.Add(forwardPageButton); var fileListPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch }; stackPanel.Children.Add(fileListPanel); for (int i = 0; i < fileButtons.Length; i++) { fileButtons[i] = new FileButton(screen) { HorizontalAlignment = HorizontalAlignment.Stretch }; fileButtons[i].Click += OnFileButtonClick; fileButtons[i].KeyDown += OnFileNameButtonKeyDown; fileListPanel.Children.Add(fileButtons[i]); } var separator = ControlUtil.CreateDefaultSeparator(screen); stackPanel.Children.Add(separator); cancelButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.CancelButton); cancelButton.Click += (Control s, ref RoutedEventContext c) => Close(); stackPanel.Children.Add(cancelButton); const float windowWidth = 480; openAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, From = 0, To = windowWidth, Duration = TimeSpan.FromSeconds(0.1f) }; Animations.Add(openAnimation); // 閉じる場合には closeAnimation を実行し、その完了で完全に閉じます。 closeAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, From = windowWidth, To = 0, Duration = TimeSpan.FromSeconds(0.1f) }; closeAnimation.Completed += (s, e) => base.Close(); Animations.Add(closeAnimation); }
public FileButton(Screen screen) : base(screen) { Padding = new Thickness(8); HorizontalAlignment = HorizontalAlignment.Stretch; var stackPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Stretch }; Content = stackPanel; blockMeshView = new BlockMeshView(screen) { Width = 64, Height = 64 }; stackPanel.Children.Add(blockMeshView); fileNameTextBlock = new TextBlock(screen) { ForegroundColor = Color.White, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Left, TextHorizontalAlignment = HorizontalAlignment.Left, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(fileNameTextBlock); }
public LightColorButton(Screen screen) : base(screen) { var stackPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(16, 0, 16, 0) }; Content = stackPanel; NameTextBlock = new TextBlock(screen) { Width = 140, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2), TextHorizontalAlignment = HorizontalAlignment.Left }; stackPanel.Children.Add(NameTextBlock); ColorCanvas = new Canvas(screen) { Width = 28, Height = 28, Margin = new Thickness(4) }; stackPanel.Children.Add(ColorCanvas); // ControlUtil では対応できないので固有で設定します。 PopupFontOnGotFocus(); }
public SecondWindow(Screen screen) : base(screen) { Width = unit * 10; Height = unit * 10; HorizontalAlignment = HorizontalAlignment.Right; VerticalAlignment = VerticalAlignment.Bottom; Margin = new Thickness(0, 0, unit, unit); BackgroundColor = Color.Green; Padding = new Thickness(16); Content = new TextBlock(screen) { Text = "2nd Window", ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2), TextOutlineWidth = 1, FontStretch = new Vector2(1.5f), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Bottom, TextHorizontalAlignment = HorizontalAlignment.Right }; var opacityAnimation = new FloatLerpAnimation { Action = (current) => { Opacity = current; }, To = 1, Repeat = Repeat.Forever, Duration = TimeSpan.FromSeconds(2), AutoReversed = true, Enabled = true }; Animations.Add(opacityAnimation); }
public ItemButton(Screen screen) : base(screen) { var stackPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(16, 0, 16, 0) }; Content = stackPanel; NameTextBlock = new TextBlock(screen) { Width = 200, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2), TextHorizontalAlignment = HorizontalAlignment.Left }; stackPanel.Children.Add(NameTextBlock); ColorCanvas = new Canvas(screen) { Width = 124, Height = 30, Margin = new Thickness(2) }; stackPanel.Children.Add(ColorCanvas); }
public PredefinedColorGrid(Screen screen, PredefinedColorDialog owner) : base(screen) { this.owner = owner; paging.ItemCountPerPage = columnCount * rowCount; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var pageButtonPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Right }; stackPanel.Children.Add(pageButtonPanel); var backPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Left, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowLeft") } }; backPageButton.Click += (Control s, ref RoutedEventContext c) => BackPage(); pageButtonPanel.Children.Add(backPageButton); pageTextBlock = new TextBlock(screen) { Width = BlockViewerGame.SpriteSize * 2, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; pageButtonPanel.Children.Add(pageTextBlock); var forwardPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Right, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowRight") } }; forwardPageButton.Click += (Control s, ref RoutedEventContext c) => ForwardPage(); pageButtonPanel.Children.Add(forwardPageButton); var vColorPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center }; stackPanel.Children.Add(vColorPanel); for (int i = 0; i < rowCount; i++) { var hColorPanel = new StackPanel(screen); vColorPanel.Children.Add(hColorPanel); for (int j = i * columnCount; j < (i + 1) * columnCount; j++) { itemButtons[j] = new ItemButton(screen); hColorPanel.Children.Add(itemButtons[j]); int mod = j % columnCount; if (mod == 0) { itemButtons[j].KeyDown += OnLeftColorButtonKeyDown; } else if (mod == columnCount - 1) { itemButtons[j].KeyDown += OnRightColorButtonKeyDown; } itemButtons[j].GotFocus += OnItemButtonGotFocus; itemButtons[j].LostFocus += OnItemButtonLostFocus; itemButtons[j].Click += OnItemButtonClick; } } }
public FirstWindow(Screen screen) : base(screen) { Width = unit * 10; Height = unit * 10; HorizontalAlignment = HorizontalAlignment.Left; VerticalAlignment = VerticalAlignment.Top; Margin = new Thickness(unit, unit, 0, 0); BackgroundColor = Color.Red; Padding = new Thickness(16); Content = new TextBlock(screen) { Text = "1st Window", ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2), TextOutlineWidth = 1, FontStretch = new Vector2(1.5f), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, TextHorizontalAlignment = HorizontalAlignment.Left }; var repeatedWidthAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, To = Width, Repeat = Repeat.Forever, Duration = TimeSpan.FromSeconds(2), Enabled = true }; Animations.Add(repeatedWidthAnimation); var repeatedHeightAnimation = new FloatLerpAnimation { Action = (current) => { Height = current; }, To = Height, Repeat = Repeat.Forever, Duration = TimeSpan.FromSeconds(2), Enabled = true }; Animations.Add(repeatedHeightAnimation); }
void InitializeControls() { Desktop.BackgroundColor = Color.Black; var screenOverlay = new Overlay(this) { Opacity = 1 }; var screenOverlayOpacityAnimation = new FloatLerpAnimation { Action = (current) => { screenOverlay.Opacity = current; }, From = 1, To = 0, Duration = TimeSpan.FromSeconds(0.5d), Enabled = true }; screenOverlayOpacityAnimation.Completed += (s, e) => screenOverlay.Close(); screenOverlay.Animations.Add(screenOverlayOpacityAnimation); var nowLoadingTextBlock = new TextBlock(this) { Text = "NOW LOADING...", ForegroundColor = Color.White, BackgroundColor = Color.Black, FontStretch = new Vector2(2), Padding = new Thickness(8) }; Desktop.Content = nowLoadingTextBlock; screenOverlay.Show(); }
public ListBoxDemoWindow(Screen screen) : base(screen) { Width = 400; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, Padding = new Thickness(16), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var title = new TextBlock(screen) { Text = "ListBox demo", HorizontalAlignment = HorizontalAlignment.Stretch, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2), TextOutlineWidth = 1, FontStretch = new Vector2(1.5f) }; stackPanel.Children.Add(title); var selectedIndexLabel = new TextBlock(screen) { Text = "SelectedIndex: -1", Padding = new Thickness(8), HorizontalAlignment = HorizontalAlignment.Stretch, ForegroundColor = Color.White, BackgroundColor = Color.Black, TextHorizontalAlignment = HorizontalAlignment.Left }; stackPanel.Children.Add(selectedIndexLabel); var listBox = new ListBox(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; listBox.SelectionChanged += (s, e) => { selectedIndexLabel.Text = string.Format("SelectedIndex: {0}", listBox.SelectedIndex); }; stackPanel.Children.Add(listBox); for (int i = 0; i < 5; i++) { var listBoxItem = new ListBoxItem(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = string.Format("Item {0:d2}", i), HorizontalAlignment = HorizontalAlignment.Stretch, ForegroundColor = Color.White, BackgroundColor = Color.Black, TextHorizontalAlignment = HorizontalAlignment.Left } }; listBox.Items.Add(listBoxItem); } var switchSelectionModeButton = new Button(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = "Enable the multiple selection mode", ForegroundColor = Color.White, BackgroundColor = Color.Black } }; switchSelectionModeButton.Click += (Control s, ref RoutedEventContext c) => { var textBlock = switchSelectionModeButton.Content as TextBlock; if (listBox.SelectionMode == ListBoxSelectionMode.Single) { listBox.SelectionMode = ListBoxSelectionMode.Multiple; textBlock.Text = "Disable the multiple selection mode"; } else { listBox.SelectionMode = ListBoxSelectionMode.Single; textBlock.Text = "Enable the multiple selection mode"; } }; stackPanel.Children.Add(switchSelectionModeButton); var closeButton = new Button(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = "Close", ForegroundColor = Color.White, BackgroundColor = Color.Black } }; closeButton.Click += (Control s, ref RoutedEventContext c) => Close(); stackPanel.Children.Add(closeButton); closeButton.Focus(); }
/// <summary> /// インスタンスを生成します。 /// </summary> /// <param name="screen">Screen。</param> public TextButton(Screen screen) : base(screen) { Content = new TextBlock(screen); }
Control CreateModeMenuPanel() { var stackPanel = new StackPanel(Screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, Orientation = Orientation.Vertical }; var subTitle = new TextBlock(Screen) { Text = Strings.ModeMenuTitle, Padding = new Thickness(4), ForegroundColor = Color.LightGreen, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Stretch, TextHorizontalAlignment = HorizontalAlignment.Left, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(subTitle); cameraModeButton = CreateMenuButton(Strings.CameraModeButton); cameraModeButton.Click += (Control s, ref RoutedEventContext c) => { ChangeMode(ViewMode.Camera); }; stackPanel.Children.Add(cameraModeButton); light0ModeButton = CreateMenuButton(Strings.Light0ModeButton); light0ModeButton.Click += (Control s, ref RoutedEventContext c) => { ChangeMode(ViewMode.DirectionalLight0); }; stackPanel.Children.Add(light0ModeButton); light1ModeButton = CreateMenuButton(Strings.Light1ModeButton); light1ModeButton.Click += (Control s, ref RoutedEventContext c) => { ChangeMode(ViewMode.DirectionalLight1); }; stackPanel.Children.Add(light1ModeButton); light2ModeButton = CreateMenuButton(Strings.Light2ModeButton); light2ModeButton.Click += (Control s, ref RoutedEventContext c) => { ChangeMode(ViewMode.DirectionalLight2); }; stackPanel.Children.Add(light2ModeButton); var backButton = CreateMenuButton(Strings.BackButton); backButton.Click += (Control s, ref RoutedEventContext c) => { tab.SelectedIndex = mainMenuIndex; modeButton.Focus(); }; stackPanel.Children.Add(backButton); return stackPanel; }
public PredefinedColorList(Screen screen, PredefinedColorDialog owner) : base(screen) { this.owner = owner; paging.ItemCountPerPage = 5; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var pageButtonPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Right }; stackPanel.Children.Add(pageButtonPanel); var backPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Left, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowLeft") } }; backPageButton.Click += (Control s, ref RoutedEventContext c) => BackPage(); pageButtonPanel.Children.Add(backPageButton); pageTextBlock = new TextBlock(screen) { Width = BlockViewerGame.SpriteSize * 2, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; pageButtonPanel.Children.Add(pageTextBlock); var forwardPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Right, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowRight") } }; forwardPageButton.Click += (Control s, ref RoutedEventContext c) => ForwardPage(); pageButtonPanel.Children.Add(forwardPageButton); for (int i = 0; i < itemButtons.Length; i++) { itemButtons[i] = new ItemButton(screen); itemButtons[i].KeyDown += OnListItemButtonKeyDown; itemButtons[i].Click += OnListItemButtonClick; stackPanel.Children.Add(itemButtons[i]); } }
public MainMenuWindow(Screen screen) : base(screen) { // 開く際に openAnimation で Width を設定するので 0 で初期化します。 Width = 0; Height = 480; Padding = new Thickness(16); var stackPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, Orientation = Orientation.Vertical }; Content = stackPanel; var title = new TextBlock(screen) { Text = Strings.MainMenuTitle, Padding = new Thickness(4), ForegroundColor = Color.Yellow, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Stretch, TextHorizontalAlignment = HorizontalAlignment.Left, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(title); var separator = ControlUtil.CreateDefaultSeparator(screen); stackPanel.Children.Add(separator); tab = new TabControl(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, SelectedIndex = mainMenuIndex }; stackPanel.Children.Add(tab); var mainMenuPanel = CreateMainMenuPanel(); tab.Items.Add(mainMenuPanel); var modeMenuPanel = CreateModeMenuPanel(); tab.Items.Add(modeMenuPanel); var lodMenuPanel = CreateLodMenuPanel(); tab.Items.Add(lodMenuPanel); openAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, From = 0, To = 240, Duration = TimeSpan.FromSeconds(0.1f) }; Animations.Add(openAnimation); // 閉じる場合には closeAnimation を実行し、その完了で完全に閉じます。 closeAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, From = 240, To = 0, Duration = TimeSpan.FromSeconds(0.1f) }; closeAnimation.Completed += (s, e) => { base.Close(); // Screen は最前面の Window をアクティブにするので、 // 強制的に Desktop をアクティブにします。 //Screen.Desktop.Activate(); }; Animations.Add(closeAnimation); // デフォルト フォーカス。 loadButton.Focus(); }
Control CreateLodMenuPanel() { var stackPanel = new StackPanel(Screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Top, Orientation = Orientation.Vertical }; var subTitle = new TextBlock(Screen) { Text = Strings.LodMenuTitle, Padding = new Thickness(4), ForegroundColor = Color.LightGreen, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Stretch, TextHorizontalAlignment = HorizontalAlignment.Left, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(subTitle); showLodButton = CreateMenuButton(Strings.ShowButton); showLodButton.Click += (Control s, ref RoutedEventContext c) => { ChangeLodWindowVisibility(true); }; stackPanel.Children.Add(showLodButton); hideLodButton = CreateMenuButton(Strings.HideButton); hideLodButton.Click += (Control s, ref RoutedEventContext c) => { ChangeLodWindowVisibility(false); }; stackPanel.Children.Add(hideLodButton); var backButton = CreateMenuButton(Strings.BackButton); backButton.Click += (Control s, ref RoutedEventContext c) => { tab.SelectedIndex = mainMenuIndex; lodButton.Focus(); }; stackPanel.Children.Add(backButton); return stackPanel; }
public ThirdWindow(Screen screen) : base(screen) { Width = unit * 15; Height = unit * 10; BackgroundColor = Color.Blue; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = new Thickness(8) }; Content = stackPanel; var title = new TextBlock(screen) { Text = "3rd window", HorizontalAlignment = HorizontalAlignment.Stretch, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2), TextOutlineWidth = 1, FontStretch = new Vector2(1.5f) }; stackPanel.Children.Add(title); var changingLookAndFeelDemoButton = new Button(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = "Changing look & feel demo", ForegroundColor = Color.White, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Left } }; changingLookAndFeelDemoButton.Click += (Control s, ref RoutedEventContext c) => { (screen as WindowDemoScreen).SwitchLookAndFeelSource(); }; stackPanel.Children.Add(changingLookAndFeelDemoButton); var overlayDialogDemoButton = new Button(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = "Overlay dialog demo", ForegroundColor = Color.White, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Left } }; overlayDialogDemoButton.Click += (Control sender, ref RoutedEventContext context) => { var dialog = new FirstOverlayDialog(Screen); dialog.Overlay.Opacity = 0.5f; dialog.Show(); }; stackPanel.Children.Add(overlayDialogDemoButton); var drawing3DDemoButton = new Button(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = "Drawing 3D demo", ForegroundColor = Color.White, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Left } }; drawing3DDemoButton.Click += (Control s, ref RoutedEventContext c) => { var window = new CubeWindow(Screen); window.Show(); }; stackPanel.Children.Add(drawing3DDemoButton); var listBoxDemoButton = new Button(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = "ListBox demo", ForegroundColor = Color.White, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Left } }; listBoxDemoButton.Click += (Control s, ref RoutedEventContext c) => { var window = new ListBoxDemoWindow(screen); window.Show(); }; stackPanel.Children.Add(listBoxDemoButton); var switchScreenButton = new Button(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = "Switch screen", ForegroundColor = Color.White, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Left } }; switchScreenButton.Click += OnSwitchScreenButtonClick; stackPanel.Children.Add(switchScreenButton); var exitButton = new Button(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, Padding = new Thickness(8), Content = new TextBlock(screen) { Text = "Exit", ForegroundColor = Color.White, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Left } }; exitButton.Click += OnExitButtonClick; stackPanel.Children.Add(exitButton); var startWidthAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, To = Width, Duration = TimeSpan.FromSeconds(0.3f), Enabled = true }; Animations.Add(startWidthAnimation); var startHeightAnimation = new FloatLerpAnimation { Action = (current) => { Height = current; }, To = Height, Duration = TimeSpan.FromSeconds(0.3f), Enabled = true }; Animations.Add(startHeightAnimation); overlayDialogDemoButton.Focus(); }