Example #1
0
        /// <summary>
        /// インスタンスを生成します。
        /// </summary>
        /// <param name="screen">Screen。</param>
        public StartMenuWindow(Screen screen)
            : base(screen)
        {
            viewModel   = new StartMenuViewModel(screen.Game);
            DataContext = viewModel;

            Width        = 320;
            ShadowOffset = new Vector2(4);
            Padding      = new Thickness(16);

            var stackPanel = new StackPanel(screen)
            {
                Orientation         = Orientation.Vertical,
                HorizontalAlignment = HorizontalAlignment.Stretch
            };

            Content = stackPanel;

            var startButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.StartButton);

            startButton.Click += OnStartButtonClick;
            stackPanel.Children.Add(startButton);

            var selectLanguageButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.SelectLanguageButton);

            selectLanguageButton.Click += OnLanguageSettingButtonClick;
            stackPanel.Children.Add(selectLanguageButton);

            var installDemoBlocksButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.InstallDemoBlocksButton);

            installDemoBlocksButton.Click += OnInstallDemoBlocksButtonClick;
            stackPanel.Children.Add(installDemoBlocksButton);

            var uploadDemoBlocksButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.UploadDemoBlocksButton);

            uploadDemoBlocksButton.Enabled = viewModel.BoxIntegrationEnabled;
            uploadDemoBlocksButton.Click  += OnUploadDemoBlocksButtonClick;
            stackPanel.Children.Add(uploadDemoBlocksButton);

            changeLookAndFeelButton        = ControlUtil.CreateDefaultMenuButton(screen, "Look & Feel [Debug]");
            changeLookAndFeelButton.Click += OnChangeLookAndFeelButtonClick;
            stackPanel.Children.Add(changeLookAndFeelButton);

            var exitButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.ExitButton);

            exitButton.Click += OnExitButtonClick;
            stackPanel.Children.Add(exitButton);

            // デフォルト フォーカス。
            startButton.Focus();
        }
        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();
        }