Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        protected override void OnMouseMove(ref RoutedEventContext context)
        {
            base.OnMouseMove(ref context);

            if (Screen.MouseDevice.MouseState.LeftButton == ButtonState.Pressed)
            {
                SetMaterial();
            }
        }
Ejemplo n.º 3
0
        protected override void OnMouseDown(ref RoutedEventContext context)
        {
            base.OnMouseDown(ref context);

            if (Screen.MouseDevice.IsButtonPressed(MouseButtons.Left))
            {
                SetMaterial();
            }
        }
Ejemplo n.º 4
0
        protected override void OnKeyDown(ref RoutedEventContext context)
        {
            base.OnKeyDown(ref context);

            if (context.Handled)
            {
                return;
            }

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

                itemButton.Padding = new Thickness(4);
            }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 13
0
        protected override void OnKeyDown(ref RoutedEventContext context)
        {
            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Escape))
            {
                Close();
                context.Handled = true;
            }

            base.OnKeyDown(ref context);
        }
Ejemplo n.º 14
0
        void OnSwitchLightButtonClick(Control sender, ref RoutedEventContext context)
        {
            ViewModel.Enabled = !ViewModel.Enabled;

            UpdateSwitchLightButtonText();
        }
Ejemplo n.º 15
0
 void OnSpecularColorButtonClick(Control sender, ref RoutedEventContext context)
 {
     ShowPredefinedColorDialog(PredefinedColorSelectedForSpecular);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// PreviewMouseLeave イベントの到達で呼び出されます。
 /// </summary>
 /// <param name="context">RoutedEventContext。</param>
 protected virtual void OnPreviewMouseLeave(ref RoutedEventContext context) { }
Ejemplo n.º 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]";
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// PreviewMouseDown イベントの到達で呼び出されます。
        /// </summary>
        /// <param name="context">RoutedEventContext。</param>
        protected virtual void OnPreviewMouseDown(ref RoutedEventContext context)
        {
            // TODO
            // ここだけ既定実装があるのは嫌だけど、
            // フォーカス設定を制御できる所がルーティング イベントしか思いつかない。

            // フォーカスを設定します。
            Focus();
        }
Ejemplo n.º 22
0
        void OnLanguageSettingButtonClick(Control sender, ref RoutedEventContext context)
        {
            if (selectLanguageDialog == null)
                selectLanguageDialog = new SelectLanguageDialog(Screen);

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

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

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