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 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(); }
public FadeOverlay(Screen screen) : base(screen) { OpacityAnimation = new FloatLerpAnimation { Action = (current) => { Opacity = current; }, To = 1 }; Animations.Add(OpacityAnimation); }
protected override void Update(GameTime gameTime) { // LoadedScreen プロパティが null ではなければ、 // 非同期な Screen のロードが完了しています。 if (LoadedScreen != null) { var exitOverlay = new Overlay(this); var animation = new FloatLerpAnimation { Action = (current) => { exitOverlay.Opacity = current; }, To = 1, Duration = TimeSpan.FromSeconds(0.5d), Enabled = true }; animation.Completed += OnExitAnimationCompleted; exitOverlay.Animations.Add(animation); exitOverlay.Show(); } base.Update(gameTime); }
/// <summary> /// インスタンスを生成します。 /// </summary> /// <param name="screen"></param> public PredefinedColorDialog(Screen screen) : base(screen) { PredefinedColors = new List<PredefinedColor>(); PredefinedColors.AddRange(PredefinedColor.PredefinedColors); PredefinedColors.Sort((x, y) => x.Name.CompareTo(y.Name)); // 開く際に 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; tab = new TabControl(screen) { SelectedIndex = 0 }; stackPanel.Children.Add(tab); predefinedColorGrid = new PredefinedColorGrid(screen, this) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; tab.Items.Add(predefinedColorGrid); predefinedColorList = new PredefinedColorList(screen, this) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; tab.Items.Add(predefinedColorList); var separator = ControlUtil.CreateDefaultSeparator(screen); stackPanel.Children.Add(separator); viewModeButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.ListViewModeButton); viewModeButton.Click += OnViewModeButtonClick; stackPanel.Children.Add(viewModeButton); var sortByNameButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.SortByNameButton); sortByNameButton.Click += OnSortByNameClick; stackPanel.Children.Add(sortByNameButton); var sortByColorButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.SortByColorButton); sortByColorButton.Click += OnSortByColorClick; stackPanel.Children.Add(sortByColorButton); cancelButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.CancelButton); cancelButton.Click += (Control s, ref RoutedEventContext c) => Close(); stackPanel.Children.Add(cancelButton); const float windowWidth = 400; 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 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 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(); }
public BoxSetupWizardDialog(Screen screen) : base(screen) { viewModel = new BoxSetupViewModel(screen.Game); DataContext = viewModel; // 開く際に openAnimation で Width を設定するので 0 で初期化します。 Width = 0; ShadowOffset = new Vector2(4); Padding = new Thickness(16); Overlay.Opacity = 0.5f; tabControl = new TabControl(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = tabControl; attentionTabItem = new AttentionTabItem(Screen); attentionTabItem.FocusToDefault(); attentionTabItem.AgreeSelected += OnAttentionTabItemAgreeSelected; attentionTabItem.CancelSelected += OnAttentionTabItemCancelSelected; tabControl.Items.Add(attentionTabItem); tabControl.SelectedIndex = 0; authorizationTabItem = new AuthorizationTabItem(Screen); authorizationTabItem.NextSelected += OnAuthorizationTabItemNextSelected; authorizationTabItem.BackSelected += OnAuthorizationTabItemBackSelected; tabControl.Items.Add(authorizationTabItem); accessTabItem = new AccessTabItem(Screen); accessTabItem.NextSelected += OnAccessTabItemNextSelected; accessTabItem.BackSelected += OnAccessTabItemBackSelected; tabControl.Items.Add(accessTabItem); prepareFolderTreeTabItem = new PrepareFolderTreeTabItem(Screen); prepareFolderTreeTabItem.CreateSelected += OnPrepareFolderTreeTabItemCreateSelected; prepareFolderTreeTabItem.CancelSelected += OnPrepareFolderTreeTabItemCancelSelected; tabControl.Items.Add(prepareFolderTreeTabItem); saveSettingsTabItem = new SaveSettingsTabItem(Screen); saveSettingsTabItem.YesSelected += OnSaveSettingsTabItemYesSelected; saveSettingsTabItem.NoSelected += OnSaveSettingsTabItemNoSelected; tabControl.Items.Add(saveSettingsTabItem); finishTabItem = new FinishTabItem(Screen); finishTabItem.UploadSelected += OnFinishTabItemUploadSelected; finishTabItem.CancelSelected += OnFinishTabItemCancelSelected; tabControl.Items.Add(finishTabItem); openAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, From = 0, To = 480, Duration = TimeSpan.FromSeconds(0.1f) }; Animations.Add(openAnimation); }
void InitializeControls() { var firstWindow = new FirstWindow(this); firstWindow.Show(); var secondWindow = new SecondWindow(this); secondWindow.Show(); var thirdWindow = new ThirdWindow(this); thirdWindow.Show(); var startEffectOverlay = new Overlay(this) { Opacity = 1 }; startEffectOverlay.Show(); var startEffectOverlay_opacityAnimation = new FloatLerpAnimation { Action = (current) => { startEffectOverlay.Opacity = current; }, From = 1, To = 0, Duration = TimeSpan.FromSeconds(0.5d), Enabled = true }; startEffectOverlay_opacityAnimation.Completed += (s, e) => { startEffectOverlay.Close(); thirdWindow.Activate(); }; startEffectOverlay.Animations.Add(startEffectOverlay_opacityAnimation); }
void OnSwitchScreenButtonClick(Control sender, ref RoutedEventContext context) { var overlay = new Overlay(Screen) { Opacity = 0, BackgroundColor = Color.Black }; overlay.Show(); var opacityAnimation = new FloatLerpAnimation { Action = (current) => { overlay.Opacity = current; }, To = 1, Duration = TimeSpan.FromSeconds(0.5d), Enabled = true }; opacityAnimation.Completed += (s, e) => { Screen.ShowScreen("MainMenuDemoScreen"); }; Animations.Add(opacityAnimation); }
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(); }
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 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); }
public CubeWindow(Screen screen) : base(screen) { var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, Margin = new Thickness(8) }; Content = stackPanel; var cubeControl = new CubeControl(screen) { CubePrimitive = CreateCubePrimitive(), ForegroundColor = Color.White, Width = unit * 7, Height = unit * 7, CubeVisible = true }; stackPanel.Children.Add(cubeControl); 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); rotateCubeAnimation = new FloatLerpAnimation { Action = (current) => { cubeControl.Orientation = Matrix.CreateFromYawPitchRoll(current, current, current); }, To = MathHelper.TwoPi, Duration = TimeSpan.FromSeconds(4), Repeat = Repeat.Forever }; cubeControl.MouseEnter += OnCubeControlMouseEnter; cubeControl.MouseLeave += OnCubeControlMouseLeave; Animations.Add(rotateCubeAnimation); }
void OnSwitchScreenButtonClick(Control sender, ref RoutedEventContext context) { var overlay = new Overlay(Screen); overlay.Show(); var opacityAnimation = new FloatLerpAnimation { Action = (current) => { overlay.Opacity = current; }, To = 1, Duration = TimeSpan.FromSeconds(0.5d), Enabled = true }; opacityAnimation.Completed += (s, e) => { var uiService = Screen.Game.Services.GetRequiredService<IUIService>(); uiService.Show("WindowDemoScreen"); }; Animations.Add(opacityAnimation); }
void OnExitButtonClick(Control sender, ref RoutedEventContext context) { var overlay = new Overlay(Screen); overlay.Show(); var opacityAnimation = new FloatLerpAnimation { Action = (current) => { overlay.Opacity = current; }, To = 1, Duration = TimeSpan.FromSeconds(0.5d), Enabled = true }; opacityAnimation.Completed += (s, e) => Screen.Game.Exit(); Animations.Add(opacityAnimation); }