示例#1
0
        public ErrorDialog(Screen screen)
            : base(screen)
        {
            ShadowOffset = new Vector2(4);
            Padding      = new Thickness(16);

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

            Content = stackPanel;

            messageContainer = new DialogMessageContainer(screen)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch
            };
            stackPanel.Children.Add(messageContainer);

            var separator = ControlUtil.CreateDefaultSeparator(screen);

            stackPanel.Children.Add(separator);

            var okButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.OKButton);

            stackPanel.Children.Add(okButton);
            RegisterOKButton(okButton);

            okButton.Focus();
        }
示例#2
0
        Button CreateMenuButton(String text)
        {
            float buttonHeight = 32;

            var button = new Button(Screen)
            {
                Height = buttonHeight,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Padding             = new Thickness(4),

                Content = new TextBlock(Screen)
                {
                    Text                    = text,
                    ForegroundColor         = Color.White,
                    BackgroundColor         = Color.Black,
                    HorizontalAlignment     = HorizontalAlignment.Stretch,
                    TextHorizontalAlignment = HorizontalAlignment.Left,
                    Margin                  = new Thickness(16, 0, 0, 0),
                    ShadowOffset            = new Vector2(2)
                }
            };

            ControlUtil.SetDefaultBehavior(button);

            return(button);
        }
示例#3
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();
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
        /// <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);
        }
示例#7
0
        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 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();
        }