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); }
protected override void OnMouseMove(ref RoutedEventContext context) { base.OnMouseMove(ref context); if (Screen.MouseDevice.MouseState.LeftButton == ButtonState.Pressed) { SetMaterial(); } }
protected override void OnMouseDown(ref RoutedEventContext context) { base.OnMouseDown(ref context); if (Screen.MouseDevice.IsButtonPressed(MouseButtons.Left)) { SetMaterial(); } }
protected override void OnKeyDown(ref RoutedEventContext context) { base.OnKeyDown(ref context); if (context.Handled) { return; } // フォーカス移動を処理します。 MoveFocus(); }
void OnListItemButtonClick(Control sender, ref RoutedEventContext context) { var itemButton = sender as ItemButton; if (owner.Selected != null) owner.Selected(itemButton.DataContext as PredefinedColor); owner.Close(); }
void OnItemButtonLostFocus(Control sender, ref RoutedEventContext context) { var itemButton = sender as ItemButton; itemButton.Padding = new Thickness(4); }
void OnSortByNameClick(Control sender, ref RoutedEventContext context) { PredefinedColors.Sort((x, y) => x.Name.CompareTo(y.Name)); // ページをリセットしてからリロードします。 predefinedColorGrid.ResetCurrentPageIndex(); predefinedColorGrid.ReloadPage(); predefinedColorList.ResetCurrentPageIndex(); predefinedColorList.ReloadPage(); }
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(); }
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(); }
/// <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; } } }
/// <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); }
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; }
protected override void OnKeyDown(ref RoutedEventContext context) { if (Screen.KeyboardDevice.IsKeyPressed(Keys.Escape)) { Close(); context.Handled = true; } base.OnKeyDown(ref context); }
void OnSwitchLightButtonClick(Control sender, ref RoutedEventContext context) { ViewModel.Enabled = !ViewModel.Enabled; UpdateSwitchLightButtonText(); }
void OnSpecularColorButtonClick(Control sender, ref RoutedEventContext context) { ShowPredefinedColorDialog(PredefinedColorSelectedForSpecular); }
/// <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); }
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; } }
/// <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); }
/// <summary> /// PreviewMouseLeave イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnPreviewMouseLeave(ref RoutedEventContext context) { }
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]"; } }
/// <summary> /// PreviewMouseDown イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnPreviewMouseDown(ref RoutedEventContext context) { // TODO // ここだけ既定実装があるのは嫌だけど、 // フォーカス設定を制御できる所がルーティング イベントしか思いつかない。 // フォーカスを設定します。 Focus(); }
void OnLanguageSettingButtonClick(Control sender, ref RoutedEventContext context) { if (selectLanguageDialog == null) selectLanguageDialog = new SelectLanguageDialog(Screen); selectLanguageDialog.Show(); }
/// <summary> /// MouseUp イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnMouseUp(ref RoutedEventContext context) { }
void OnUploadDemoBlocksButtonClick(Control sender, ref RoutedEventContext context) { var boxIntegration = (Screen.Game as BlockViewerGame).BoxIntegration; // 保存されている設定からの BoxSession の復元を試みます。 viewModel.RestoreSessionAsync(RestoreSessionCallback); ShowProgressDialog(Strings.CheckingBoxSettingsMessage); }
/// <summary> /// PreviewKeyDown イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnPreviewKeyDown(ref RoutedEventContext context) { }
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; } }
/// <summary> /// KeyUp イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnKeyUp(ref RoutedEventContext context) { }
void OnRightColorButtonKeyDown(Control sender, ref RoutedEventContext context) { if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right)) { ForwardPage(); context.Handled = true; } }
/// <summary> /// GotFocus イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnGotFocus(ref RoutedEventContext context) { }
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; } }
/// <summary> /// LogicalLostFocus イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnLostLogicalFocus(ref RoutedEventContext context) { }