Пример #1
0
        protected override void OnMouseEnter(ref RoutedEventContext context)
        {
            pressedByMouse  = (Screen.MouseDevice.MouseState.LeftButton == ButtonState.Pressed);
            context.Handled = true;

            base.OnMouseEnter(ref context);
        }
Пример #2
0
        void OnModeButtonClick(Control sender, ref RoutedEventContext context)
        {
            tab.SelectedIndex = modeMenuIndex;

            switch (ViewModel.ViewerViewModel.ViewMode)
            {
            case ViewMode.Camera:
                cameraModeButton.Focus();
                break;

            case ViewMode.DirectionalLight0:
                light0ModeButton.Focus();
                break;

            case ViewMode.DirectionalLight1:
                light1ModeButton.Focus();
                break;

            case ViewMode.DirectionalLight2:
                light2ModeButton.Focus();
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Пример #3
0
        protected override void OnMouseLeave(ref RoutedEventContext context)
        {
            pressedByMouse  = false;
            context.Handled = true;

            base.OnMouseLeave(ref context);
        }
Пример #4
0
        void OnFileButtonClick(Control sender, ref RoutedEventContext context)
        {
            if (confirmationDialog == null)
            {
                confirmationDialog = new ConfirmationDialog(Screen)
                {
                    Message = new TextBlock(Screen)
                    {
                        Text = Strings.OpenFileConfirmation,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        ForegroundColor     = Color.White,
                        BackgroundColor     = Color.Black,
                        ShadowOffset        = new Vector2(2)
                    }
                };
                confirmationDialog.Closed += OnOpenFileConfirmationDialogClosed;
            }

            // 仮選択。
            ViewModel.SelectedFileName = (sender.DataContext as ViewerViewModel).MeshName;

            confirmationDialog.Show();

            context.Handled = true;
        }
Пример #5
0
        void OnRootKeyDown(Control sender, ref RoutedEventContext context)
        {
            // フェード効果が終わるまでキー操作は無効になります。
            if (!canHandleKey)
            {
                return;
            }

            if (KeyboardDevice.IsKeyPressed(Keys.Y))
            {
                if (!mainMenuWindow.Visible)
                {
                    var sound = GetSound(SoundKey.Click);
                    if (sound != null)
                    {
                        if (sound.State != SoundState.Stopped)
                        {
                            sound.Stop();
                        }
                        sound.Play();
                    }

                    mainMenuWindow.Show();
                }
            }
        }
Пример #6
0
        void OnFileNameButtonKeyDown(Control sender, ref RoutedEventContext context)
        {
            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Left))
            {
                var sound = Screen.GetSound(SoundKey.FocusNavigation);
                if (sound != null)
                {
                    if (sound.State != SoundState.Stopped)
                    {
                        sound.Stop();
                    }
                    sound.Play();
                }

                ViewModel.BackPage();
                context.Handled = true;
            }
            else if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right))
            {
                var sound = Screen.GetSound(SoundKey.FocusNavigation);
                if (sound != null)
                {
                    if (sound.State != SoundState.Stopped)
                    {
                        sound.Stop();
                    }
                    sound.Play();
                }

                ViewModel.ForwardPage();
                context.Handled = true;
            }
        }
Пример #7
0
        protected override void OnPreviewKeyUp(ref RoutedEventContext context)
        {
            base.OnPreviewKeyUp(ref context);
            if (context.Handled)
            {
                return;
            }

            if (Screen.KeyboardDevice.IsKeyReleased(Keys.Enter) ||
                Screen.KeyboardDevice.IsKeyReleased(Keys.Space))
            {
                pressedByKey = false;
                if (Enabled && !Pressed)
                {
                    var sound = Screen.GetSound(SoundKey.Click);
                    if (sound != null)
                    {
                        if (sound.State != SoundState.Stopped)
                        {
                            sound.Stop();
                        }
                        sound.Play();
                    }

                    RaiseEvent(null, ClickEvent);
                }
            }
        }
Пример #8
0
        protected override void OnMouseMove(ref RoutedEventContext context)
        {
            if (!ViewModel.ViewMovable)
            {
                return;
            }

            var mouseDevice = Screen.MouseDevice;
            var mouseState  = mouseDevice.MouseState;

            if (mouseDevice.IsButtonPressed(MouseButtons.Right))
            {
                // OnMouseDown で判定しようとすると OnMouseMove の後になるため、
                // ここで押下判定を行なっています。
                mouseOffsetX = mouseState.X;
                mouseOffsetY = mouseState.Y;
            }

            if (mouseState.RightButton == ButtonState.Pressed)
            {
                // 指定の角度方向へカメラを移動させます。
                var angleSign = new Vector2
                {
                    X = Math.Sign(mouseState.Y - mouseOffsetY),
                    Y = Math.Sign(mouseState.X - mouseOffsetX)
                };
                ViewModel.MoveView(angleSign);

                mouseOffsetX = mouseState.X;
                mouseOffsetY = mouseState.Y;
            }

            base.OnMouseMove(ref context);
        }
Пример #9
0
            void OnStackedOverlayDialogDemoButtonClick(Control sender, ref RoutedEventContext context)
            {
                var dialog = new SecondOverlayDialog(Screen);

                dialog.Overlay.Opacity = 0.5f;
                dialog.Show();
            }
Пример #10
0
 void OnRightColorButtonKeyDown(Control sender, ref RoutedEventContext context)
 {
     if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right))
     {
         ForwardPage();
         context.Handled = true;
     }
 }
Пример #11
0
            void OnCubeControlMouseEnter(Control sender, ref RoutedEventContext context)
            {
                var cubeControl = sender as CubeControl;

                cubeControl.Scale = 1.5f;

                rotateCubeAnimation.Enabled = true;
            }
Пример #12
0
            void OnCubeControlMouseLeave(Control sender, ref RoutedEventContext context)
            {
                var cubeControl = sender as CubeControl;

                cubeControl.Scale = 1;

                rotateCubeAnimation.Enabled = false;
            }
Пример #13
0
        protected override void OnMouseMove(ref RoutedEventContext context)
        {
            base.OnMouseMove(ref context);

            if (Screen.MouseDevice.MouseState.LeftButton == ButtonState.Pressed)
            {
                SetMaterial();
            }
        }
Пример #14
0
        protected override void OnMouseDown(ref RoutedEventContext context)
        {
            base.OnMouseDown(ref context);

            if (Screen.MouseDevice.IsButtonPressed(MouseButtons.Left))
            {
                SetMaterial();
            }
        }
Пример #15
0
        void OnExitButtonClick(Control sender, ref RoutedEventContext context)
        {
            var overlay = new FadeOverlay(Screen);

            overlay.OpacityAnimation.To         = 1;
            overlay.OpacityAnimation.Duration   = TimeSpan.FromSeconds(1);
            overlay.OpacityAnimation.Completed += (s, e) => Screen.ShowScreen(ScreenNames.Start);
            overlay.Show();
        }
Пример #16
0
        void OnUploadDemoBlocksButtonClick(Control sender, ref RoutedEventContext context)
        {
            var boxIntegration = (Screen.Game as BlockViewerGame).BoxIntegration;

            // 保存されている設定からの BoxSession の復元を試みます。
            viewModel.RestoreSessionAsync(RestoreSessionCallback);

            ShowProgressDialog(Strings.CheckingBoxSettingsMessage);
        }
Пример #17
0
        /// <summary>
        /// 左マウス ボタンが押された場合、IsSelected プロパティの値を反転させます。
        /// </summary>
        /// <param name="context"></param>
        protected override void OnPreviewMouseDown(ref RoutedEventContext context)
        {
            if (Screen.MouseDevice.IsButtonPressed(MouseButtons.Left))
            {
                IsSelected = !IsSelected;
            }

            base.OnPreviewMouseDown(ref context);
        }
Пример #18
0
        void OnLanguageSettingButtonClick(Control sender, ref RoutedEventContext context)
        {
            if (selectLanguageDialog == null)
            {
                selectLanguageDialog = new SelectLanguageDialog(Screen);
            }

            selectLanguageDialog.Show();
        }
Пример #19
0
        void OnSortByNameClick(Control sender, ref RoutedEventContext context)
        {
            PredefinedColors.Sort((x, y) => x.Name.CompareTo(y.Name));

            // ページをリセットしてからリロードします。
            predefinedColorGrid.ResetCurrentPageIndex();
            predefinedColorGrid.ReloadPage();
            predefinedColorList.ResetCurrentPageIndex();
            predefinedColorList.ReloadPage();
        }
Пример #20
0
        protected override void OnKeyDown(ref RoutedEventContext context)
        {
            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Escape))
            {
                Close();
                context.Handled = true;
            }

            base.OnKeyDown(ref context);
        }
Пример #21
0
        /// <summary>
        /// Enter/Space キーが押された場合、IsSelected プロパティの値を反転させます。
        /// </summary>
        /// <param name="context"></param>
        protected override void OnPreviewKeyDown(ref RoutedEventContext context)
        {
            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Enter) ||
                Screen.KeyboardDevice.IsKeyPressed(Keys.Space))
            {
                IsSelected = !IsSelected;
            }

            base.OnPreviewKeyDown(ref context);
        }
Пример #22
0
            void OnListItemButtonClick(Control sender, ref RoutedEventContext context)
            {
                var itemButton = sender as ItemButton;

                if (owner.Selected != null)
                {
                    owner.Selected(itemButton.DataContext as PredefinedColor);
                }

                owner.Close();
            }
Пример #23
0
 void OnLoadButtonClick(Control sender, ref RoutedEventContext context)
 {
     if (loadBlockMeshDialog == null)
     {
         loadBlockMeshDialog = new LoadBlockMeshDialog(Screen)
         {
             DataContext = ViewModel.LoadBlockMeshViewModel
         };
         loadBlockMeshDialog.Closed += new EventHandler(OnLoadBlockMeshDialogClosed);
     }
     loadBlockMeshDialog.Show();
 }
Пример #24
0
        protected override void OnKeyDown(ref RoutedEventContext context)
        {
            base.OnKeyDown(ref context);

            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Escape))
            {
                Result = EscapeKeyDownResult;

                Close();

                context.Handled = true;
            }
        }
Пример #25
0
        /// <summary>
        /// 項目が発生させた Selected イベントを受け取り、
        /// SelectedIndex プロパティを更新します。
        /// SelectionMode プロパティが Single の場合には、
        /// それまで選択されていた項目の IsSelected プロパティは false に設定されます。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="context"></param>
        protected virtual void OnItemSelected(Control sender, ref RoutedEventContext context)
        {
            if (selectionMode == ListBoxSelectionMode.Single)
            {
                var item = SelectedItem as ListBoxItem;
                if (item != null)
                {
                    item.IsSelected = false;
                }
            }

            SelectedIndex = FindFirstSelectedIndex();
        }
Пример #26
0
 void OnListItemButtonKeyDown(Control sender, ref RoutedEventContext context)
 {
     if (Screen.KeyboardDevice.IsKeyPressed(Keys.Left))
     {
         BackPage();
         context.Handled = true;
     }
     else if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right))
     {
         ForwardPage();
         context.Handled = true;
     }
 }
Пример #27
0
        void OnLodButtonClick(Control sender, ref RoutedEventContext context)
        {
            tab.SelectedIndex = lodMenuIndex;

            if (lodWindow != null && lodWindow.Visible)
            {
                showLodButton.Focus();
            }
            else
            {
                hideLodButton.Focus();
            }
        }
Пример #28
0
 void OnViewModeButtonClick(Control sender, ref RoutedEventContext context)
 {
     if (tab.SelectedIndex == 0)
     {
         tab.SelectedIndex = 1;
         (viewModeButton.Content as TextBlock).Text = Strings.GridViewModeButton;
     }
     else
     {
         tab.SelectedIndex = 0;
         (viewModeButton.Content as TextBlock).Text = Strings.ListViewModeButton;
     }
 }
Пример #29
0
        void OnChangeLookAndFeelButtonClick(Control sender, ref RoutedEventContext context)
        {
            var startScreen = Screen as MainScreen;

            if (startScreen.SelectedLookAndFeelSourceIndex == MainScreen.DefaultLookAndFeelIndex)
            {
                startScreen.SelectedLookAndFeelSourceIndex          = MainScreen.DebugLookAndFeelIndex;
                (changeLookAndFeelButton.Content as TextBlock).Text = "Look & Feel [Default]";
            }
            else
            {
                startScreen.SelectedLookAndFeelSourceIndex          = MainScreen.DefaultLookAndFeelIndex;
                (changeLookAndFeelButton.Content as TextBlock).Text = "Look & Feel [Debug]";
            }
        }
Пример #30
0
        protected override void OnPreviewMouseDown(ref RoutedEventContext context)
        {
            var state = Screen.MouseDevice.MouseState;
            var point = new Vector2
            {
                X = state.X,
                Y = state.Y
            };

            point = PointFromScreen(point);

            Section.Index   = (int)(point.X / CellSize);
            context.Handled = true;

            base.OnMouseDown(ref context);
        }
Пример #31
0
            void OnExitButtonClick(Control sender, ref RoutedEventContext context)
            {
                var overlay = new Overlay(Screen);

                overlay.Show();

                var opacityAnimation = new FloatLerpAnimation
                {
                    Action   = (current) => { overlay.Opacity = current; },
                    To       = 1,
                    Duration = TimeSpan.FromSeconds(0.5d),
                    Enabled  = true
                };

                opacityAnimation.Completed += (s, e) => Screen.Game.Exit();
                Animations.Add(opacityAnimation);
            }
Пример #32
0
 /// <summary>
 /// ボタンがクリックされると呼びだされます。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="context"></param>
 /// <param name="result"></param>
 protected virtual void OnButtonClick(Control sender, ref RoutedEventContext context, MessageBoxResult result)
 {
     Result = result;
     Close();
 }
Пример #33
0
        /// <summary>
        /// 項目が発生させた Selected イベントを受け取り、
        /// SelectedIndex プロパティを更新します。
        /// SelectionMode プロパティが Single の場合には、
        /// それまで選択されていた項目の IsSelected プロパティは false に設定されます。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="context"></param>
        protected virtual void OnItemSelected(Control sender, ref RoutedEventContext context)
        {
            if (selectionMode == ListBoxSelectionMode.Single)
            {
                var item = SelectedItem as ListBoxItem;
                if (item != null) item.IsSelected = false;
            }

            SelectedIndex = FindFirstSelectedIndex();
        }
Пример #34
0
 /// <summary>
 /// Unselected イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnUnselected(ref RoutedEventContext context)
 {
 }
Пример #35
0
        protected override void OnKeyDown(ref RoutedEventContext context)
        {
            var keyboardDevice = Screen.KeyboardDevice;
            var keyboardState = keyboardDevice.KeyboardState;

            // 先に Shift キーの押下を判定します。
            bool shiftPressed = keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift);

            bool handled = false;
            foreach (var key in keyboardState.GetPressedKeys())
            {
                // Shift キーは除外します。
                if (key == Keys.LeftShift || key == Keys.RightShift) continue;

                if (key == Keys.Back)
                {
                    stringBuilder.Remove(stringBuilder.Length - 1, 1);
                    handled = true;
                    continue;
                }

                // 押されたキーに対応する文字を取得します。
                char c;
                if (KeyboardHelper.KeyToCharacter(key, shiftPressed, out c))
                {
                    stringBuilder.Append(c);
                    handled = true;
                }
            }

            // イベントのバブル アップを停止させます。
            if (handled) context.Handled = true;

            base.OnKeyDown(ref context);
        }
Пример #36
0
        /// <summary>
        /// Enter/Space キーが押された場合、IsSelected プロパティの値を反転させます。
        /// </summary>
        /// <param name="context"></param>
        protected override void OnPreviewKeyDown(ref RoutedEventContext context)
        {
            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Enter) ||
                Screen.KeyboardDevice.IsKeyPressed(Keys.Space))
            {
                IsSelected = !IsSelected;
            }

            base.OnPreviewKeyDown(ref context);
        }
Пример #37
0
 /// <summary>
 /// No ボタンがクリックされると呼び出されます。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="context"></param>
 protected virtual void OnNoButtonClick(Control sender, ref RoutedEventContext context)
 {
     OnButtonClick(sender, ref context, MessageBoxResult.No);
 }
Пример #38
0
        protected override void OnMouseLeave(ref RoutedEventContext context)
        {
            pressedByMouse = false;
            context.Handled = true;

            base.OnMouseLeave(ref context);
        }
Пример #39
0
 void OnStackedOverlayDialogDemoButtonClick(Control sender, ref RoutedEventContext context)
 {
     var dialog = new SecondOverlayDialog(Screen);
     dialog.Overlay.Opacity = 0.5f;
     dialog.Show();
 }
Пример #40
0
            void OnSwitchScreenButtonClick(Control sender, ref RoutedEventContext context)
            {
                var overlay = new Overlay(Screen);
                overlay.Show();

                var opacityAnimation = new FloatLerpAnimation
                {
                    Action = (current) => { overlay.Opacity = current; },
                    To = 1,
                    Duration = TimeSpan.FromSeconds(0.5d),
                    Enabled = true
                };
                opacityAnimation.Completed += (s, e) =>
                {
                    var uiService = Screen.Game.Services.GetRequiredService<IUIService>();
                    uiService.Show("WindowDemoScreen");
                };
                Animations.Add(opacityAnimation);
            }
Пример #41
0
 /// <summary>
 /// 項目が発生させた Unselected イベントを受け取り、
 /// SelectedIndex プロパティを更新します。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="context"></param>
 protected virtual void OnItemUnselected(Control sender, ref RoutedEventContext context)
 {
     SelectedIndex = FindFirstSelectedIndex();
 }
Пример #42
0
        protected override void OnPreviewKeyUp(ref RoutedEventContext context)
        {
            base.OnPreviewKeyUp(ref context);
            if (context.Handled) return;

            if (Screen.KeyboardDevice.IsKeyReleased(Keys.Enter) ||
                Screen.KeyboardDevice.IsKeyReleased(Keys.Space))
            {
                pressedByKey = false;
                if (Enabled && !Pressed)
                {
                    var sound = Screen.GetSound(SoundKey.Click);
                    if (sound != null)
                    {
                        if (sound.State != SoundState.Stopped) sound.Stop();
                        sound.Play();
                    }

                    RaiseEvent(null, ClickEvent);
                }
            }
        }
Пример #43
0
        protected override void OnPreviewKeyDown(ref RoutedEventContext context)
        {
            base.OnPreviewKeyDown(ref context);
            if (context.Handled) return;

            // 機能が無効に設定されているならば、イベントを無視します。
            if (!Enabled) return;

            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Enter) ||
                Screen.KeyboardDevice.IsKeyPressed(Keys.Space))
            {
                pressedByKey = true;
            }
        }
Пример #44
0
            void OnSwitchScreenButtonClick(Control sender, ref RoutedEventContext context)
            {
                var overlay = new Overlay(Screen)
                {
                    Opacity = 0,
                    BackgroundColor = Color.Black
                };
                overlay.Show();

                var opacityAnimation = new FloatLerpAnimation
                {
                    Action = (current) => { overlay.Opacity = current; },
                    To = 1,
                    Duration = TimeSpan.FromSeconds(0.5d),
                    Enabled = true
                };
                opacityAnimation.Completed += (s, e) =>
                {
                    Screen.ShowScreen("MainMenuDemoScreen");
                };
                Animations.Add(opacityAnimation);
            }
Пример #45
0
            void OnCubeControlMouseLeave(Control sender, ref RoutedEventContext context)
            {
                var cubeControl = sender as CubeControl;
                cubeControl.Scale = 1;

                rotateCubeAnimation.Enabled = false;
            }
Пример #46
0
            void OnExitButtonClick(Control sender, ref RoutedEventContext context)
            {
                var overlay = new Overlay(Screen);
                overlay.Show();

                var opacityAnimation = new FloatLerpAnimation
                {
                    Action = (current) => { overlay.Opacity = current; },
                    To = 1,
                    Duration = TimeSpan.FromSeconds(0.5d),
                    Enabled = true
                };
                opacityAnimation.Completed += (s, e) => Screen.Game.Exit();
                Animations.Add(opacityAnimation);
            }
Пример #47
0
 /// <summary>
 /// Click イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnClick(ref RoutedEventContext context)
 {
 }
Пример #48
0
 void OnCloseButtonClick(Control sender, ref RoutedEventContext context)
 {
     Close();
 }
Пример #49
0
        protected override void OnMouseEnter(ref RoutedEventContext context)
        {
            pressedByMouse = (Screen.MouseDevice.MouseState.LeftButton == ButtonState.Pressed);
            context.Handled = true;

            base.OnMouseEnter(ref context);
        }
Пример #50
0
        /// <summary>
        /// Content 内部から発生した PreviewMouseDown を捕捉し、
        /// RoutedEventContext の Handled プロパティを true に設定します。
        /// </summary>
        /// <param name="context"></param>
        protected override void OnPreviewMouseDown(ref RoutedEventContext context)
        {
            base.OnPreviewMouseDown(ref context);
            if (context.Handled) return;

            // 機能が無効に設定されているならば、イベントを無視します。
            if (!Enabled) return;

            pressedByMouse = Screen.MouseDevice.IsButtonPressed(MouseButtons.Left);
            context.Handled = true;
        }
Пример #51
0
        /// <summary>
        /// 左マウス ボタンが押された場合、IsSelected プロパティの値を反転させます。
        /// </summary>
        /// <param name="context"></param>
        protected override void OnPreviewMouseDown(ref RoutedEventContext context)
        {
            if (Screen.MouseDevice.IsButtonPressed(MouseButtons.Left))
            {
                IsSelected = !IsSelected;
            }

            base.OnPreviewMouseDown(ref context);
        }
Пример #52
0
        /// <summary>
        /// Content 内部から発生した PreviewMouseUp を捕捉し、Click イベントを発生させ、
        /// RoutedEventContext の Handled プロパティを true に設定します。
        /// </summary>
        /// <param name="context"></param>
        protected override void OnPreviewMouseUp(ref RoutedEventContext context)
        {
            base.OnPreviewMouseUp(ref context);
            if (context.Handled) return;

            // Button が押された状態で機能が無効に設定される場合を考慮し、機能が有効かどうかに関わらず処理を進めます。
            if (Screen.MouseDevice.IsButtonReleased(MouseButtons.Left))
            {
                pressedByMouse = false;
                if (Enabled && !Pressed) RaiseEvent(null, ClickEvent);

                context.Handled = true;
            }
        }
Пример #53
0
            void OnCubeControlMouseEnter(Control sender, ref RoutedEventContext context)
            {
                var cubeControl = sender as CubeControl;
                cubeControl.Scale = 1.5f;

                rotateCubeAnimation.Enabled = true;
            }