Пример #1
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);
        }
Пример #2
0
        protected override void OnMouseMove(ref RoutedEventContext context)
        {
            base.OnMouseMove(ref context);

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

            if (Screen.MouseDevice.IsButtonPressed(MouseButtons.Left))
            {
                SetMaterial();
            }
        }
Пример #4
0
        protected override void OnKeyDown(ref RoutedEventContext context)
        {
            base.OnKeyDown(ref context);

            if (context.Handled)
            {
                return;
            }

            // フォーカス移動を処理します。
            MoveFocus();
        }
Пример #5
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();
            }
Пример #6
0
            void OnItemButtonLostFocus(Control sender, ref RoutedEventContext context)
            {
                var itemButton = sender as ItemButton;

                itemButton.Padding = new Thickness(4);
            }
Пример #7
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();
        }
Пример #8
0
 void OnStartButtonClick(Control sender, ref RoutedEventContext context)
 {
     var overlay = new FadeOverlay(Screen);
     overlay.OpacityAnimation.To = 1;
     overlay.OpacityAnimation.Duration = TimeSpan.FromSeconds(0.5d);
     overlay.OpacityAnimation.Completed += (s, e) => Screen.ShowScreen(ScreenNames.Main);
     overlay.Show();
 }
Пример #9
0
        void OnInstallDemoBlocksButtonClick(Control sender, ref RoutedEventContext context)
        {
            if (confirmInstallDialog == null)
            {
                confirmInstallDialog = new ConfirmationDialog(Screen)
                {
                    Message = new TextBlock(Screen)
                    {
                        Width = 320,
                        Text = Strings.InstallDemoBlocksConfirmation,
                        TextWrapping = TextWrapping.Wrap,
                        TextHorizontalAlignment = HorizontalAlignment.Left,
                        ForegroundColor = Color.White,
                        BackgroundColor = Color.Black
                    }
                };
                confirmInstallDialog.Closed += OnConfirmInstallDialogClosed;
            }

            confirmInstallDialog.Show();
        }
Пример #10
0
 /// <summary>
 /// RoutedEventHandler を呼び出します。
 /// </summary>
 /// <param name="eventName">イベント名。</param>
 /// <param name="context">RoutedEventContext。</param>
 void InvokeHandlers(string eventName, ref RoutedEventContext context)
 {
     List<RoutedEventHandler> handlers;
     if (handlerMap.TryGetValue(eventName, out handlers))
     {
         foreach (RoutedEventHandler handler in handlers)
         {
             handler(this, ref context);
             if (context.Handled) return;
         }
     }
 }
Пример #11
0
        /// <summary>
        /// Tunnel イベントを発生させます。
        /// </summary>
        /// <param name="eventName">イベント名。</param>
        /// <param name="context">RoutedEventContext。</param>
        protected void RaiseTunnelEvent(string eventName, ref RoutedEventContext context)
        {
            if (Parent != null)
            {
                Parent.RaiseTunnelEvent(eventName, ref context);
                if (context.Handled) return;
            }

            InvokeHandlers(eventName, ref context);
        }
Пример #12
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;
        }
Пример #13
0
        protected override void OnKeyDown(ref RoutedEventContext context)
        {
            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Escape))
            {
                Close();
                context.Handled = true;
            }

            base.OnKeyDown(ref context);
        }
Пример #14
0
        void OnSwitchLightButtonClick(Control sender, ref RoutedEventContext context)
        {
            ViewModel.Enabled = !ViewModel.Enabled;

            UpdateSwitchLightButtonText();
        }
Пример #15
0
 void OnSpecularColorButtonClick(Control sender, ref RoutedEventContext context)
 {
     ShowPredefinedColorDialog(PredefinedColorSelectedForSpecular);
 }
Пример #16
0
        /// <summary>
        /// ルーティング イベントを発生させます。
        /// </summary>
        /// <param name="tunnelEventName">Tunnel イベント名。</param>
        /// <param name="bubbleEventName">Bubble イベント名。</param>
        protected void RaiseEvent(string tunnelEventName, string bubbleEventName)
        {
            var context = new RoutedEventContext(this);

            // tunnelEventName が非 null ならば Tunnel イベントを発生させます。
            if (tunnelEventName != null)
                RaiseTunnelEvent(tunnelEventName, ref context);

            // bubbleEventName が非 null ならば Bubble イベントを発生させます。
            if (!context.Handled && bubbleEventName != null)
                RaiseBubbleEvent(bubbleEventName, ref context);
        }
Пример #17
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;
            }
        }
Пример #18
0
        /// <summary>
        /// Bubble イベントを発生させます。
        /// </summary>
        /// <param name="eventName">イベント名。</param>
        /// <param name="context">RoutedEventContext。</param>
        protected void RaiseBubbleEvent(string eventName, ref RoutedEventContext context)
        {
            //RaiseBubbleEvent(eventName, ref context, this);
            InvokeHandlers(eventName, ref context);

            if (context.Handled) return;

            if (Parent != null) Parent.RaiseBubbleEvent(eventName, ref context);
        }
Пример #19
0
 /// <summary>
 /// PreviewMouseLeave イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnPreviewMouseLeave(ref RoutedEventContext context) { }
Пример #20
0
 void OnChangeLookAndFeelButtonClick(Control sender, ref RoutedEventContext context)
 {
     var startScreen = Screen as StartScreen;
     if (startScreen.SelectedLookAndFeelSourceIndex == StartScreen.DefaultLookAndFeelIndex)
     {
         startScreen.SelectedLookAndFeelSourceIndex = StartScreen.DebugLookAndFeelIndex;
         (changeLookAndFeelButton.Content as TextBlock).Text = "Look & Feel [Default]";
     }
     else
     {
         startScreen.SelectedLookAndFeelSourceIndex = StartScreen.DefaultLookAndFeelIndex;
         (changeLookAndFeelButton.Content as TextBlock).Text = "Look & Feel [Debug]";
     }
 }
Пример #21
0
        /// <summary>
        /// PreviewMouseDown イベントの到達で呼び出されます。
        /// </summary>
        /// <param name="context">RoutedEventContext。</param>
        protected virtual void OnPreviewMouseDown(ref RoutedEventContext context)
        {
            // TODO
            // ここだけ既定実装があるのは嫌だけど、
            // フォーカス設定を制御できる所がルーティング イベントしか思いつかない。

            // フォーカスを設定します。
            Focus();
        }
Пример #22
0
        void OnLanguageSettingButtonClick(Control sender, ref RoutedEventContext context)
        {
            if (selectLanguageDialog == null)
                selectLanguageDialog = new SelectLanguageDialog(Screen);

            selectLanguageDialog.Show();
        }
Пример #23
0
 /// <summary>
 /// MouseUp イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnMouseUp(ref RoutedEventContext context) { }
Пример #24
0
        void OnUploadDemoBlocksButtonClick(Control sender, ref RoutedEventContext context)
        {
            var boxIntegration = (Screen.Game as BlockViewerGame).BoxIntegration;

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

            ShowProgressDialog(Strings.CheckingBoxSettingsMessage);
        }
Пример #25
0
 /// <summary>
 /// PreviewKeyDown イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnPreviewKeyDown(ref RoutedEventContext context) { }
Пример #26
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;
     }
 }
Пример #27
0
 /// <summary>
 /// KeyUp イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnKeyUp(ref RoutedEventContext context) { }
Пример #28
0
 void OnRightColorButtonKeyDown(Control sender, ref RoutedEventContext context)
 {
     if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right))
     {
         ForwardPage();
         context.Handled = true;
     }
 }
Пример #29
0
 /// <summary>
 /// GotFocus イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnGotFocus(ref RoutedEventContext context) { }
Пример #30
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;
     }
 }
Пример #31
0
 /// <summary>
 /// LogicalLostFocus イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnLostLogicalFocus(ref RoutedEventContext context) { }