public ConfirmationDialog(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);

            cancelButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.CancelButton);
            stackPanel.Children.Add(cancelButton);
            RegisterCancelButton(cancelButton);
        }
Beispiel #2
0
        public static void SetDefaultBehavior(Button button)
        {
            float focusedTextOpacity = 1;
            float defocusedTextOpacity = 1;

            button.Content.Opacity = defocusedTextOpacity;

            button.GotFocus += (Control s, ref RoutedEventContext c) =>
            {
                button.Content.Opacity = focusedTextOpacity;
            };
            button.LostFocus += (Control s, ref RoutedEventContext c) =>
            {
                button.Content.Opacity = defocusedTextOpacity;
            };

            button.EnabledChanged += (s, e) =>
            {
                if (button.Enabled)
                {
                    button.Content.ForegroundColor = Color.White;
                }
                else
                {
                    button.Content.ForegroundColor = Color.Gray;
                }
            };

            PopupFontOnGotFocus(button);
        }
Beispiel #3
0
        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;
        }
Beispiel #5
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 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);
        }
Beispiel #7
0
        public static Button CreateDefaultMenuButton(Screen screen, String text)
        {
            var button = new Button(screen)
            {
                Height = menuButtonHeight,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Padding = new Thickness(4),

                Content = new TextBlock(screen)
                {
                    Text = text,
                    ForegroundColor = Color.White,
                    BackgroundColor = Color.Black,
                    ShadowOffset = new Vector2(2)
                }
            };

            SetDefaultBehavior(button);

            return button;
        }
Beispiel #8
0
        public SectionControl(Screen screen)
            : base(screen)
        {
            const float cellSize = 16;

            var stackPanel = new StackPanel(screen)
            {
                Orientation = Orientation.Vertical
            };
            Content = stackPanel;

            var selectorPanel = new StackPanel(screen)
            {
                //Margin = new Thickness(8)
            };
            stackPanel.Children.Add(selectorPanel);

            var changeOrientationButton = new Button(screen)
            {
                Width = cellSize,
                Height = cellSize,
                Margin = new Thickness(0, 0, 8, 0)
            };
            changeOrientationButton.Click += OnChangeOrientationButtonClick;
            selectorPanel.Children.Add(changeOrientationButton);

            var indexControl = new SectionIndexControl(screen)
            {
                CellSize = cellSize
            };
            selectorPanel.Children.Add(indexControl);

            var editControl = new SectionEditControl(screen)
            {
                CellSize = cellSize,
                HorizontalAlignment = HorizontalAlignment.Right,
                Margin = new Thickness(0, 8, 0, 0)
            };
            stackPanel.Children.Add(editControl);
        }
        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);
        }
Beispiel #10
0
            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);
            }
Beispiel #11
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;
        }
Beispiel #12
0
        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 MenuWindow(Screen screen)
                : base(screen)
            {
                BackgroundColor = Color.Blue;

                var stackPanel = new StackPanel(screen)
                {
                    Orientation = Orientation.Vertical,
                    Margin = new Thickness(16)
                };
                Content = stackPanel;

                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 MainMenuDemoScreen).SwitchLookAndFeelSource();
                };
                stackPanel.Children.Add(changingLookAndFeelDemoButton);

                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
                    }
                };
                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
                    }
                };
                exitButton.Click += OnExitButtonClick;
                stackPanel.Children.Add(exitButton);

                switchScreenButton.Focus();
            }
Beispiel #15
0
 protected void RegisterOKButton(Button button)
 {
     button.Click += OnOKButtonClick;
 }
            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;
                    }
                }
            }
Beispiel #17
0
 static void PopupFontOnGotFocus(Button button)
 {
     var animation = new Vector2LerpAnimation
     {
         Action = (current) => { button.Content.FontStretch = current; },
         From = Vector2.One,
         To = new Vector2(1.2f),
         Duration = TimeSpan.FromSeconds(0.1f),
         AutoReversed = true
     };
     button.Animations.Add(animation);
     button.GotFocus += (Control s, ref RoutedEventContext c) =>
     {
         animation.Enabled = true;
     };
     button.LostFocus += (Control s, ref RoutedEventContext c) =>
     {
         animation.Enabled = false;
     };
 }
Beispiel #18
0
            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();
            }
Beispiel #19
0
            public SecondOverlayDialog(Screen screen)
                : base(screen)
            {
                BackgroundColor = Color.Brown;
                Padding = new Thickness(16);

                var closeButton = new Button(screen)
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Padding = new Thickness(8),

                    Content = new TextBlock(screen)
                    {
                        Text = "Close",
                        TextHorizontalAlignment = HorizontalAlignment.Left,
                        ForegroundColor = Color.White,
                        BackgroundColor = Color.Black
                    }
                };
                Content = closeButton;
                closeButton.Click += (Control s, ref RoutedEventContext c) => Close();
                closeButton.Focus();
            }
Beispiel #20
0
            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();
            }
Beispiel #21
0
            public FirstOverlayDialog(Screen screen)
                : base(screen)
            {
                BackgroundColor = Color.Green;
                Opacity = 0.8f;

                var stackPanel = new StackPanel(screen)
                {
                    Margin = new Thickness(8),
                    Orientation = Orientation.Horizontal
                };
                Content = stackPanel;

                var stackedOverlayDialogDemoButton = new Button(screen)
                {
                    Padding = new Thickness(8),
                    HorizontalAlignment = HorizontalAlignment.Left,

                    Content = new TextBlock(screen)
                    {
                        Text = "Stacked overlay dialog demo",
                        TextHorizontalAlignment = HorizontalAlignment.Left,
                        ForegroundColor = Color.White,
                        BackgroundColor = Color.Black
                    }
                };
                stackPanel.Children.Add(stackedOverlayDialogDemoButton);
                stackedOverlayDialogDemoButton.Click += OnStackedOverlayDialogDemoButtonClick;
                stackedOverlayDialogDemoButton.Focus();

                var closeButton = new Button(screen)
                {
                    Padding = new Thickness(8),
                    HorizontalAlignment = HorizontalAlignment.Left,

                    Content = new TextBlock(screen)
                    {
                        Text = "Close",
                        TextHorizontalAlignment = HorizontalAlignment.Left,
                        ForegroundColor = Color.White,
                        BackgroundColor = Color.Black
                    }
                };
                stackPanel.Children.Add(closeButton);
                closeButton.Click += OnCloseButtonClick;
            }
Beispiel #22
0
 protected void RegisterNoButton(Button button)
 {
     button.Click += OnNoButtonClick;
 }
Beispiel #23
0
        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;
        }
        /// <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);
        }
Beispiel #25
0
        Control CreateMainMenuPanel()
        {
            var stackPanel = new StackPanel(Screen)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Top,
                Orientation = Orientation.Vertical
            };

            loadButton = CreateMenuButton(Strings.LoadButton);
            loadButton.Click += OnLoadButtonClick;
            stackPanel.Children.Add(loadButton);

            modeButton = CreateMenuButton(Strings.ModeButton);
            modeButton.Click += OnModeButtonClick;
            stackPanel.Children.Add(modeButton);

            lodButton = CreateMenuButton(Strings.LodButton);
            lodButton.Click += OnLodButtonClick;
            stackPanel.Children.Add(lodButton);

            changeLookAndFeelButton = CreateMenuButton("Look & Feel [Debug]");
            changeLookAndFeelButton.Click += OnChangeLookAndFeelButtonClick;
            stackPanel.Children.Add(changeLookAndFeelButton);

            var exitButton = CreateMenuButton(Strings.ExitButton);
            exitButton.Click += OnExitButtonClick;
            stackPanel.Children.Add(exitButton);

            var closeButton = CreateMenuButton(Strings.CloseButton);
            closeButton.Click += OnCloseButtonClick;
            stackPanel.Children.Add(closeButton);

            return stackPanel;
        }
Beispiel #26
0
 protected void RegisterCancelButton(Button button)
 {
     button.Click += OnCancelButtonClick;
 }
Beispiel #27
0
 protected void RegisterYesButton(Button button)
 {
     button.Click += OnYesButtonClick;
 }