protected override void OnMouseEnter(ref RoutedEventContext context) { pressedByMouse = (Screen.MouseDevice.MouseState.LeftButton == ButtonState.Pressed); context.Handled = true; base.OnMouseEnter(ref context); }
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(); } }
protected override void OnMouseLeave(ref RoutedEventContext context) { pressedByMouse = false; context.Handled = true; base.OnMouseLeave(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; }
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(); } } }
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; } }
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); } } }
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); }
void OnStackedOverlayDialogDemoButtonClick(Control sender, ref RoutedEventContext context) { var dialog = new SecondOverlayDialog(Screen); dialog.Overlay.Opacity = 0.5f; dialog.Show(); }
void OnRightColorButtonKeyDown(Control sender, ref RoutedEventContext context) { if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right)) { ForwardPage(); context.Handled = true; } }
void OnCubeControlMouseEnter(Control sender, ref RoutedEventContext context) { var cubeControl = sender as CubeControl; cubeControl.Scale = 1.5f; rotateCubeAnimation.Enabled = true; }
void OnCubeControlMouseLeave(Control sender, ref RoutedEventContext context) { var cubeControl = sender as CubeControl; cubeControl.Scale = 1; rotateCubeAnimation.Enabled = false; }
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(); } }
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(); }
void OnUploadDemoBlocksButtonClick(Control sender, ref RoutedEventContext context) { var boxIntegration = (Screen.Game as BlockViewerGame).BoxIntegration; // 保存されている設定からの BoxSession の復元を試みます。 viewModel.RestoreSessionAsync(RestoreSessionCallback); ShowProgressDialog(Strings.CheckingBoxSettingsMessage); }
/// <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); }
void OnLanguageSettingButtonClick(Control sender, ref RoutedEventContext context) { if (selectLanguageDialog == null) { selectLanguageDialog = new SelectLanguageDialog(Screen); } selectLanguageDialog.Show(); }
void OnSortByNameClick(Control sender, ref RoutedEventContext context) { PredefinedColors.Sort((x, y) => x.Name.CompareTo(y.Name)); // ページをリセットしてからリロードします。 predefinedColorGrid.ResetCurrentPageIndex(); predefinedColorGrid.ReloadPage(); predefinedColorList.ResetCurrentPageIndex(); predefinedColorList.ReloadPage(); }
protected override void OnKeyDown(ref RoutedEventContext context) { if (Screen.KeyboardDevice.IsKeyPressed(Keys.Escape)) { Close(); context.Handled = true; } base.OnKeyDown(ref context); }
/// <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); }
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 OnLoadButtonClick(Control sender, ref RoutedEventContext context) { if (loadBlockMeshDialog == null) { loadBlockMeshDialog = new LoadBlockMeshDialog(Screen) { DataContext = ViewModel.LoadBlockMeshViewModel }; loadBlockMeshDialog.Closed += new EventHandler(OnLoadBlockMeshDialogClosed); } loadBlockMeshDialog.Show(); }
protected override void OnKeyDown(ref RoutedEventContext context) { base.OnKeyDown(ref context); if (Screen.KeyboardDevice.IsKeyPressed(Keys.Escape)) { Result = EscapeKeyDownResult; Close(); context.Handled = true; } }
/// <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(); }
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; } }
void OnLodButtonClick(Control sender, ref RoutedEventContext context) { tab.SelectedIndex = lodMenuIndex; if (lodWindow != null && lodWindow.Visible) { showLodButton.Focus(); } else { hideLodButton.Focus(); } }
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; } }
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]"; } }
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); }
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); }
/// <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(); }
/// <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(); }
/// <summary> /// Unselected イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnUnselected(ref RoutedEventContext context) { }
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); }
/// <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); }
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); }
/// <summary> /// 項目が発生させた Unselected イベントを受け取り、 /// SelectedIndex プロパティを更新します。 /// </summary> /// <param name="sender"></param> /// <param name="context"></param> protected virtual void OnItemUnselected(Control sender, ref RoutedEventContext context) { SelectedIndex = FindFirstSelectedIndex(); }
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); } } }
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; } }
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); }
/// <summary> /// Click イベントの到達で呼び出されます。 /// </summary> /// <param name="context">RoutedEventContext。</param> protected virtual void OnClick(ref RoutedEventContext context) { }
void OnCloseButtonClick(Control sender, ref RoutedEventContext context) { Close(); }
/// <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; }
/// <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; } }