コード例 #1
0
        public MaterialEditWindow(Screen screen)
            : base(screen)
        {
            DataContext = new MaterialEdit();

            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;

            diffuseColorButton = new LightColorButton(screen);
            diffuseColorButton.NameTextBlock.Text = "Diffuse color";
            diffuseColorButton.Click += OnDiffuseColorButtonClick;
            stackPanel.Children.Add(diffuseColorButton);

            specularColorButton = new LightColorButton(screen);
            specularColorButton.NameTextBlock.Text = "Specular color";
            specularColorButton.Click += OnSpecularColorButtonClick;
            stackPanel.Children.Add(specularColorButton);
        }
コード例 #2
0
ファイル: LodWindow.cs プロジェクト: willcraftia/Blocks
        Control CreateLodControl(int levelOfDetail)
        {
            var stackPanel = new StackPanel(Screen)
            {
                Orientation = Orientation.Vertical,
                Padding = new Thickness(4)
            };

            var textBlock = new TextBlock(Screen)
            {
                Text = string.Format(Strings.LevelOfDetailLabel, levelOfDetail),
                FontStretch = new Vector2(0.7f),
                ForegroundColor = Color.White,
                HorizontalAlignment = HorizontalAlignment.Left,
                TextHorizontalAlignment = HorizontalAlignment.Left
            };
            stackPanel.Children.Add(textBlock);

            var viewModel = WorkspaceViewModel.CreateLodViewerViewModel(levelOfDetail);

            var meshView = new BlockMeshView(Screen)
            {
                Width = 32 * 2,
                Height = 32 * 2,
                DataContext = viewModel
            };
            stackPanel.Children.Add(meshView);

            return stackPanel;
        }
コード例 #3
0
ファイル: BlockEditWindow.cs プロジェクト: willcraftia/Blocks
        public BlockEditWindow(Screen screen)
            : base(screen)
        {
            var stackPanel = new StackPanel(screen)
            {
                Orientation = Orientation.Vertical,
                Padding = new Thickness(8)
            };
            Content = stackPanel;

            sectionControl = new SectionControl(screen)
            {
                DataContext = (DataContext as Workspace).Section
            };
            stackPanel.Children.Add(sectionControl);

            var selectedMaterialControl = new SelectedMaterialControl(screen)
            {
                Width = 64,
                Height = 64
            };
            stackPanel.Children.Add(selectedMaterialControl);

            sectionControl.Focus();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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();
        }
コード例 #6
0
ファイル: MaterialWindow.cs プロジェクト: willcraftia/Blocks
 public MaterialWindow(Screen screen)
     : base(screen)
 {
     var stackPanel = new StackPanel(screen)
     {
     };
     Content = stackPanel;
 }
コード例 #7
0
        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;
        }
コード例 #8
0
ファイル: FinishTabItem.cs プロジェクト: willcraftia/Blocks
        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;
        }
コード例 #9
0
ファイル: StartMenuWindow.cs プロジェクト: willcraftia/Blocks
        /// <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();
        }
コード例 #10
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);
        }
コード例 #11
0
ファイル: LodWindow.cs プロジェクト: willcraftia/Blocks
        public LodWindow(Screen screen)
            : base(screen)
        {
            // この Window はアクティブにできません。
            Activatable = false;

            ShadowOffset = new Vector2(4);
            Padding = new Thickness(8);

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

            for (int i = 0; i < 4; i++)
            {
                var lodControl = CreateLodControl(i);
                stackPanel.Children.Add(lodControl);
            }
        }
コード例 #12
0
ファイル: SectionControl.cs プロジェクト: willcraftia/Blocks
        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);
        }
コード例 #13
0
ファイル: MainMenuWindow.cs プロジェクト: willcraftia/Blocks
        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;
        }
コード例 #14
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);
        }
コード例 #15
0
            public FileButton(Screen screen)
                : base(screen)
            {
                Padding = new Thickness(8);
                HorizontalAlignment = HorizontalAlignment.Stretch;

                var stackPanel = new StackPanel(screen)
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch
                };
                Content = stackPanel;

                blockMeshView = new BlockMeshView(screen)
                {
                    Width = 64,
                    Height = 64
                };
                stackPanel.Children.Add(blockMeshView);

                fileNameTextBlock = new TextBlock(screen)
                {
                    ForegroundColor = Color.White,
                    BackgroundColor = Color.Black,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    TextHorizontalAlignment = HorizontalAlignment.Left,
                    ShadowOffset = new Vector2(2)
                };
                stackPanel.Children.Add(fileNameTextBlock);
            }
コード例 #16
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);
            }
コード例 #17
0
            public LightColorButton(Screen screen)
                : base(screen)
            {
                var stackPanel = new StackPanel(screen)
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Padding = new Thickness(16, 0, 16, 0)
                };
                Content = stackPanel;

                NameTextBlock = new TextBlock(screen)
                {
                    Width = 140,
                    ForegroundColor = Color.White,
                    BackgroundColor = Color.Black,
                    ShadowOffset = new Vector2(2),
                    TextHorizontalAlignment = HorizontalAlignment.Left
                };
                stackPanel.Children.Add(NameTextBlock);

                ColorCanvas = new Canvas(screen)
                {
                    Width = 28,
                    Height = 28,
                    Margin = new Thickness(4)
                };
                stackPanel.Children.Add(ColorCanvas);

                // ControlUtil では対応できないので固有で設定します。
                PopupFontOnGotFocus();
            }
コード例 #18
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;
            }
コード例 #19
0
                public ItemButton(Screen screen)
                    : base(screen)
                {
                    var stackPanel = new StackPanel(screen)
                    {
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        Padding = new Thickness(16, 0, 16, 0)
                    };
                    Content = stackPanel;

                    NameTextBlock = new TextBlock(screen)
                    {
                        Width = 200,
                        ForegroundColor = Color.White,
                        BackgroundColor = Color.Black,
                        ShadowOffset = new Vector2(2),
                        TextHorizontalAlignment = HorizontalAlignment.Left
                    };
                    stackPanel.Children.Add(NameTextBlock);

                    ColorCanvas = new Canvas(screen)
                    {
                        Width = 124,
                        Height = 30,
                        Margin = new Thickness(2)
                    };
                    stackPanel.Children.Add(ColorCanvas);
                }
コード例 #20
0
        /// <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);
        }
コード例 #21
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();
            }
コード例 #22
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();
            }
コード例 #23
0
            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;
                    }
                }
            }
コード例 #24
0
ファイル: MainMenuWindow.cs プロジェクト: willcraftia/Blocks
        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;
        }
コード例 #25
0
            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]);
                }
            }
コード例 #26
0
ファイル: MainMenuWindow.cs プロジェクト: willcraftia/Blocks
        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;
        }
コード例 #27
0
ファイル: MainMenuWindow.cs プロジェクト: willcraftia/Blocks
        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();
        }
コード例 #28
0
            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();
            }