diff --git a/Source/Contrib/TrackViewer/Drawing/Labels/DrawLabels.cs b/Source/Contrib/TrackViewer/Drawing/Labels/DrawLabels.cs index 8adc478a8d..50908421bc 100644 --- a/Source/Contrib/TrackViewer/Drawing/Labels/DrawLabels.cs +++ b/Source/Contrib/TrackViewer/Drawing/Labels/DrawLabels.cs @@ -156,7 +156,7 @@ private void CreateContextMenu() SetLocationMenuItem = new MenuItem() { Header = "View scene here" }; SetLocationMenuItem.Click += new RoutedEventHandler((sender, e) => TrackViewer.menuControl.MenuSceneWindow_Click(sender, e)); - SetLocationMenuItem.Click += new RoutedEventHandler(async (sender, e) => await TrackViewer.SceneViewer?.SetCameraLocation( + SetLocationMenuItem.Click += new RoutedEventHandler(async (sender, e) => await TrackViewer.SceneView?.SetCameraLocation( SetLocationMenuItem.CommandParameter as WorldLocation? ?? new WorldLocation())); ContextMenu.Items.Add(SetLocationMenuItem); } diff --git a/Source/Contrib/TrackViewer/TrackViewer.cs b/Source/Contrib/TrackViewer/TrackViewer.cs index de4a15ba4e..9a7357af1c 100644 --- a/Source/Contrib/TrackViewer/TrackViewer.cs +++ b/Source/Contrib/TrackViewer/TrackViewer.cs @@ -53,7 +53,6 @@ namespace ORTS.TrackViewer public class TrackViewer : Orts.Viewer3D.Processes.Game { #region Public members - public SceneViewer SceneViewer { get; private set; } private static RenderTarget2D DummyRenderTarget; public bool IsTrackViewerWindowActive { get; private set; } @@ -132,6 +131,9 @@ public class TrackViewer : Orts.Viewer3D.Processes.Game /// The fontmanager that we use to draw strings public FontManager fontManager; + + public SceneView SceneView; + /// The command-line arguments private string[] commandLineArgs; #endregion @@ -173,8 +175,8 @@ public TrackViewer(string[] args) : base(new ORTS.Settings.UserSettings(new[] { LanguageManager = new LanguageManager(); LanguageManager.LoadLanguage(); // need this before all menus and stuff are initialized. - this.Activated += ActivateTrackViewer; - this.Deactivated += DeactivateTrackViewer; + Activated += ActivateTrackViewer; + Deactivated += DeactivateTrackViewer; PushState(new GameStateStandBy()); } @@ -236,9 +238,48 @@ protected override void Initialize() base.Initialize(); } - public void InitializeSceneViewer(string[] args) + public void InitializeSceneView(string[] args) { - SceneViewer = SceneViewer ?? new SceneViewer(this, args); + // Inject the secondary window into RunActivity + SwapChainWindow = GameWindow.Create(this, + GraphicsDevice.PresentationParameters.BackBufferWidth, + GraphicsDevice.PresentationParameters.BackBufferHeight); + + RenderFrame.FinalRenderTarget = new SwapChainRenderTarget(GraphicsDevice, + SwapChainWindow.Handle, + GraphicsDevice.PresentationParameters.BackBufferWidth, + GraphicsDevice.PresentationParameters.BackBufferHeight, + false, + GraphicsDevice.PresentationParameters.BackBufferFormat, + GraphicsDevice.PresentationParameters.DepthStencilFormat, + 1, + RenderTargetUsage.PlatformContents, + PresentInterval.Two); + + SceneView = new SceneView(SwapChainWindow.Handle); + + // The primary window activation events should not affect RunActivity + Activated -= ActivateRunActivity; + Deactivated -= DeactivateRunActivity; + + /// A workaround for a MonoGame bug where the + /// doesn't return the valid keyboard state. Needs to be enabled via reflection in a private method. + var keyboardSetActive = typeof(Microsoft.Xna.Framework.Input.Keyboard) + .GetMethod("SetActive", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); + + // The secondary window activation events should affect RunActivity + SceneView.Activated += ActivateRunActivity; + SceneView.Activated += new System.EventHandler((sender, e) => keyboardSetActive.Invoke(null, new object[] { true })); + SceneView.Deactivated += DeactivateRunActivity; + SceneView.Deactivated += new System.EventHandler((sender, e) => keyboardSetActive.Invoke(null, new object[] { false })); + + ReplaceState(new GameStateRunActivity(new[] { "-start", "-viewer", CurrentRoute.Path + "\\dummy\\.pat", "", "10:00", "1", "0" })); + } + + public void ShowSceneView() + { + SceneView.Show(); + SceneView.Activate(); } /// @@ -324,7 +365,11 @@ private void DrawLoadingMessage(string message) /// Provides a snapshot of timing values. protected override void Update(GameTime gameTime) { - SceneViewer?.Update(gameTime); + if (RenderProcess?.Viewer != null && SceneView != null) + { + SceneView.Viewer = SceneView.Viewer ?? RenderProcess.Viewer; + SceneView.Update(gameTime); + } if (!this.IsTrackViewerWindowActive) { diff --git a/Source/Contrib/TrackViewer/UserInterface/MenuControl.xaml.cs b/Source/Contrib/TrackViewer/UserInterface/MenuControl.xaml.cs index 5c176c4c16..2f99fa9e1a 100644 --- a/Source/Contrib/TrackViewer/UserInterface/MenuControl.xaml.cs +++ b/Source/Contrib/TrackViewer/UserInterface/MenuControl.xaml.cs @@ -1232,8 +1232,8 @@ public void MenuSceneWindow_Click(object sender, RoutedEventArgs e) { if (trackViewer.CurrentRoute == null) return; - trackViewer.InitializeSceneViewer(null); - trackViewer.SceneViewer.Show(); + trackViewer.InitializeSceneView(null); + trackViewer.ShowSceneView(); } } diff --git a/Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml b/Source/Contrib/TrackViewer/UserInterface/SceneView.xaml similarity index 86% rename from Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml rename to Source/Contrib/TrackViewer/UserInterface/SceneView.xaml index 364bb3e655..f32801cffc 100644 --- a/Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml +++ b/Source/Contrib/TrackViewer/UserInterface/SceneView.xaml @@ -1,13 +1,25 @@ - + + + + + + + + + + + + + + @@ -17,9 +29,9 @@ - - - + + + @@ -112,21 +124,21 @@ - + - + - + @@ -179,8 +191,4 @@ - - - diff --git a/Source/Contrib/TrackViewer/SceneViewer.cs b/Source/Contrib/TrackViewer/UserInterface/SceneView.xaml.cs similarity index 69% rename from Source/Contrib/TrackViewer/SceneViewer.cs rename to Source/Contrib/TrackViewer/UserInterface/SceneView.xaml.cs index 0f24865973..69a89d4f9d 100644 --- a/Source/Contrib/TrackViewer/SceneViewer.cs +++ b/Source/Contrib/TrackViewer/UserInterface/SceneView.xaml.cs @@ -1,55 +1,33 @@ -// COPYRIGHT 2023 by the Open Rails project. -// -// This file is part of Open Rails. -// -// Open Rails is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Open Rails is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Open Rails. If not, see . -// - -using System; +using System; using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; using System.Linq; -using System.Text; -using System.Windows.Interop; using System.Runtime.InteropServices; +using System.Text; using System.Threading.Tasks; -using System.Globalization; -using Windows.Win32; - -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - -using GNU.Gettext; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Interop; using ORTS.Common; -using Orts.Common; -using ORTS.TrackViewer.UserInterface; using Orts.Viewer3D; -using Orts.Viewer3D.Processes; using ORTS.Common.Input; -using System.Windows.Media.Imaging; +using Windows.Win32; +using Microsoft.Xna.Framework; -namespace ORTS.TrackViewer +namespace ORTS.TrackViewer.UserInterface { - public class SceneViewer + /// + /// Interaction logic for SceneWindow.xaml + /// + public partial class SceneView : Window { - public static GettextResourceManager Catalog; - - readonly string[] CommandLineArgs; - readonly TrackViewer Game; - readonly SceneWindow SceneWindow; readonly Stack UndoStack = new Stack(); readonly Stack RedoStack = new Stack(); - Viewer Viewer; + public Viewer Viewer; OrbitingCamera Camera; EditorState EditorState; @@ -66,63 +44,27 @@ public class SceneViewer WorldLocation CursorLocation; readonly List<(int TileX, int TileZ)> FlaggedTiles = new List<(int, int)>(); - public SceneViewer(TrackViewer trackViewer, string[] args) + public SceneView(IntPtr hostWindow) { - CommandLineArgs = args; - - Game = trackViewer; - - // Inject the secondary window into RunActivity - Game.SwapChainWindow = GameWindow.Create(Game, - Game.GraphicsDevice.PresentationParameters.BackBufferWidth, - Game.GraphicsDevice.PresentationParameters.BackBufferHeight); - - RenderFrame.FinalRenderTarget = new SwapChainRenderTarget(Game.GraphicsDevice, - Game.SwapChainWindow.Handle, - Game.GraphicsDevice.PresentationParameters.BackBufferWidth, - Game.GraphicsDevice.PresentationParameters.BackBufferHeight, - false, - Game.GraphicsDevice.PresentationParameters.BackBufferFormat, - Game.GraphicsDevice.PresentationParameters.DepthStencilFormat, - 1, - RenderTargetUsage.PlatformContents, - PresentInterval.Two); - - SceneWindow = new SceneWindow(new SceneViewerHwndHost(Game.SwapChainWindow.Handle)) - { - DataContext = this, - }; - - // The primary window activation events should not affect RunActivity - Game.Activated -= Game.ActivateRunActivity; - Game.Deactivated -= Game.DeactivateRunActivity; + InitializeComponent(); - // The secondary window activation events should affect RunActivity - SceneWindow.Activated += Game.ActivateRunActivity; - SceneWindow.Activated += new System.EventHandler((sender, e) => SetKeyboardInput(true)); - SceneWindow.Deactivated += Game.DeactivateRunActivity; - SceneWindow.Deactivated += new System.EventHandler((sender, e) => SetKeyboardInput(false)); - - Game.ReplaceState(new GameStateRunActivity(new[] { "-start", "-viewer", Game.CurrentRoute.Path + "\\dummy\\.pat", "", "10:00", "1", "0" })); - } - - public void Show() - { - SceneWindow.Show(); - SceneWindow.Activate(); + var hostWindowElement = new SceneViewerHwndHost(hostWindow); + GraphicsHostElement.Children.Add(hostWindowElement); } public void Update(GameTime gameTime) { - Viewer = Viewer ?? Game.RenderProcess?.Viewer; - if (Viewer == null) - return; Camera = Camera ?? Viewer.OrbitingCamera; Viewer.EditorShapes.MouseCrosshairEnabled = true; UpdateViewUndoState(); + if (UserInput.IsPressed(UserCommand.EditorCancel)) + { + ApplicationCommands.Stop.Execute(null, null); + } + if (EditorState == EditorState.Default || EditorState == EditorState.ObjectSelected) { if (UserInput.IsMouseLeftButtonPressed && UserInput.ModifiersMaskShiftCtrlAlt(false, false, false)) @@ -134,51 +76,9 @@ public void Update(GameTime gameTime) EditorState = EditorState.ObjectSelected; } } - if (UserInput.IsPressed(UserCommand.EditorCancel)) - { - SetDefaultMode(); - } - if (UserInput.IsPressed(UserCommand.EditorUndo)) - { - UndoCommand(); - } - if (UserInput.IsPressed(UserCommand.EditorRedo)) - { - RedoCommand(); - } - } - if (EditorState == EditorState.ObjectSelected) - { - if (UserInput.IsPressed(UserCommand.EditorMove)) - { - EditorMoveState = EditorMoveState.Move; - StartObjectMove(); - } - if (UserInput.IsPressed(UserCommand.EditorRotate)) - { - EditorMoveState = EditorMoveState.Rotate; - StartObjectMove(); - } - if (UserInput.IsPressed(UserCommand.EditorMoveHandle)) - { - EditorMoveState = EditorMoveState.Move; - StartHandleMove(); - } } if (EditorState == EditorState.HandleMoving) { - if (UserInput.IsPressed(UserCommand.EditorMove)) - { - EditorMoveState = EditorMoveState.Move; - } - if (UserInput.IsPressed(UserCommand.EditorRotate)) - { - EditorMoveState = EditorMoveState.Rotate; - } - if (UserInput.IsPressed(UserCommand.EditorCancel)) - { - CancelHandleMove(); - } if (UserInput.IsMouseLeftButtonPressed) { ApplyHandleMove(); @@ -186,18 +86,6 @@ public void Update(GameTime gameTime) } if (EditorState == EditorState.ObjectMoving) { - if (UserInput.IsPressed(UserCommand.EditorMove)) - { - EditorMoveState = EditorMoveState.Move; - } - if (UserInput.IsPressed(UserCommand.EditorRotate)) - { - EditorMoveState = EditorMoveState.Rotate; - } - if (UserInput.IsPressed(UserCommand.EditorCancel)) - { - CancelObjectMove(); - } if (UserInput.IsMouseLeftButtonPressed) { ApplyObjectMove(); @@ -233,35 +121,24 @@ public void Update(GameTime gameTime) FillDeltaStatus(); } - /// - /// A workaround for a MonoGame bug where the - /// doesn't return the valid keyboard state. Needs to be enabled via reflection in a private method. - /// - public void SetKeyboardInput(bool enable) - { - var keyboardType = typeof(Microsoft.Xna.Framework.Input.Keyboard); - var methodInfo = keyboardType.GetMethod("SetActive", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); - methodInfo.Invoke(null, new object[] { enable }); - } - /// /// Put the mouse location in the statusbar /// /// void SetCameraLocationStatus(WorldLocation location) { - SceneWindow.tileXZ.Text = string.Format(CultureInfo.InvariantCulture, "{0,-7} {1,-7}", location.TileX, location.TileZ); - SceneWindow.LocationX.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.X); - SceneWindow.LocationY.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.Y); - SceneWindow.LocationZ.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.Z); + tileXZ.Text = string.Format(CultureInfo.InvariantCulture, "{0,-7} {1,-7}", location.TileX, location.TileZ); + LocationX.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.X); + LocationY.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.Y); + LocationZ.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.Z); } void FillCursorPositionStatus(WorldLocation location) { - SceneWindow.tileXZcursor.Text = string.Format(CultureInfo.InvariantCulture, "{0,-7} {1,-7}", location.TileX, location.TileZ); - SceneWindow.LocationXcursor.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.X); - SceneWindow.LocationYcursor.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.Y); - SceneWindow.LocationZcursor.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.Z); + tileXZcursor.Text = string.Format(CultureInfo.InvariantCulture, "{0,-7} {1,-7}", location.TileX, location.TileZ); + LocationXcursor.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.X); + LocationYcursor.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.Y); + LocationZcursor.Text = string.Format(CultureInfo.InvariantCulture, "{0,3:F3} ", location.Location.Z); } void FillDeltaStatus() @@ -270,9 +147,9 @@ void FillDeltaStatus() { if (EditorState == EditorState.ObjectMoving) { - SceneWindow.DeltaX.Text = DeltaX.ToString("N3", CultureInfo.InvariantCulture); - SceneWindow.DeltaY.Text = DeltaY.ToString("N3", CultureInfo.InvariantCulture); - SceneWindow.DeltaZ.Text = DeltaZ.ToString("N3", CultureInfo.InvariantCulture); + DeltaXBlock.Text = DeltaX.ToString("N3", CultureInfo.InvariantCulture); + DeltaYBlock.Text = DeltaY.ToString("N3", CultureInfo.InvariantCulture); + DeltaZBlock.Text = DeltaZ.ToString("N3", CultureInfo.InvariantCulture); } } } @@ -401,7 +278,7 @@ void UpdateViewUndoState() { if (UndoStack.Count == 0) return; - + var lastView = UndoStack.First(s => s.UndoEvent == UndoEvent.ViewChanged); if (Camera.GetRotationX() == lastView.NewCameraRotationXRadians && Camera.GetRotationY() == lastView.NewCameraRotationYRadians && Camera.CameraWorldLocation == lastView.NewCameraLocation) @@ -443,7 +320,7 @@ public void SetDefaultMode() EditorState = EditorState.Default; } - public void UndoCommand() + private void UndoCommand(object sender, ExecutedRoutedEventArgs e) { SetDefaultMode(); if (UndoStack.Count > 1) @@ -454,7 +331,7 @@ public void UndoCommand() } } - public void RedoCommand() + public void RedoCommand(object sender, ExecutedRoutedEventArgs e) { SetDefaultMode(); if (RedoStack.Count > 0) @@ -554,13 +431,13 @@ void SelectedObjectChanged() SelectedWorldObject = SelectedWorldFile?.MstsWFile?.Tr_Worldfile?.SingleOrDefault(o => o.UID == SelectedObject?.Uid); // XAML binding doesn't work for fields (as opposed to properties), so doing it programmatically - SceneWindow.Filename.Text = SelectedObject != null ? System.IO.Path.GetFileName(SelectedObject.SharedShape.FilePath) : ""; - SceneWindow.TileX.Text = SelectedObject?.Location.TileX.ToString(CultureInfo.InvariantCulture).Replace(",", ""); - SceneWindow.TileZ.Text = SelectedObject?.Location.TileZ.ToString(CultureInfo.InvariantCulture).Replace(",", ""); - SceneWindow.PosX.Text = SelectedObject?.Location.Location.X.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); - SceneWindow.PosY.Text = SelectedObject?.Location.Location.Y.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); - SceneWindow.PosZ.Text = SelectedObject?.Location.Location.Z.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); - SceneWindow.Uid.Text = SelectedObject?.Uid.ToString(CultureInfo.InvariantCulture).Replace(",", ""); + Filename.Text = SelectedObject != null ? System.IO.Path.GetFileName(SelectedObject.SharedShape.FilePath) : ""; + TileX.Text = SelectedObject?.Location.TileX.ToString(CultureInfo.InvariantCulture).Replace(",", ""); + TileZ.Text = SelectedObject?.Location.TileZ.ToString(CultureInfo.InvariantCulture).Replace(",", ""); + PosX.Text = SelectedObject?.Location.Location.X.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); + PosY.Text = SelectedObject?.Location.Location.Y.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); + PosZ.Text = SelectedObject?.Location.Location.Z.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); + Uid.Text = SelectedObject?.Uid.ToString(CultureInfo.InvariantCulture).Replace(",", ""); double yaw = 0, pitch = 0, roll = 0; if (SelectedWorldObject?.Matrix3x3 != null) @@ -581,9 +458,9 @@ void SelectedObjectChanged() pitch = Math.Asin(2.0f * (x * w - y * z)) / Math.PI * 180; roll = Math.Atan2(2.0f * (x * y + z * w), 1.0f - 2.0f * (x * x + z * z)) / Math.PI * 180; } - SceneWindow.RotX.Text = SelectedWorldObject == null ? "" : pitch.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); - SceneWindow.RotY.Text = SelectedWorldObject == null ? "" : yaw.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); - SceneWindow.RotZ.Text = SelectedWorldObject == null ? "" : roll.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); + RotX.Text = SelectedWorldObject == null ? "" : pitch.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); + RotY.Text = SelectedWorldObject == null ? "" : yaw.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); + RotZ.Text = SelectedWorldObject == null ? "" : roll.ToString("N3", CultureInfo.InvariantCulture).Replace(",", ""); //if (SelectedObject is StaticShape ppp) //{ @@ -593,6 +470,66 @@ void SelectedObjectChanged() // var ccc = sb.ToString(); //} } + + protected override void OnClosing(CancelEventArgs e) + { + e.Cancel = true; + Hide(); + } + + private void IntValidationTextBox(object sender, TextCompositionEventArgs e) + { + e.Handled = int.TryParse(e.Text, out var _); + } + + private void UndoRedoCanExecute(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = EditorState == EditorState.Default || EditorState == EditorState.ObjectSelected; + } + + private void CancelCommand(object sender, ExecutedRoutedEventArgs e) + { + if (EditorState == EditorState.Default || EditorState == EditorState.ObjectSelected) + SetDefaultMode(); + else if (EditorState == EditorState.HandleMoving) + CancelHandleMove(); + else if (EditorState == EditorState.ObjectMoving) + CancelObjectMove(); + } + + private void RotateCommand(object sender, ExecutedRoutedEventArgs e) + { + EditorMoveState = EditorMoveState.Rotate; + + if (EditorState == EditorState.ObjectSelected) + StartObjectMove(); + } + + private void MoveCommand(object sender, ExecutedRoutedEventArgs e) + { + EditorMoveState = EditorMoveState.Move; + + if (EditorState == EditorState.ObjectSelected) + StartObjectMove(); + } + + private void MoveHandleCommand(object sender, ExecutedRoutedEventArgs e) + { + EditorMoveState = EditorMoveState.Move; + + if (EditorState == EditorState.ObjectSelected) + StartHandleMove(); + } + + private void UintValidationTextBox(object sender, TextCompositionEventArgs e) + { + e.Handled = uint.TryParse(e.Text, out var _); + } + + private void FloatValidationTextBox(object sender, TextCompositionEventArgs e) + { + e.Handled = float.TryParse(e.Text, out var _); + } } public class UndoDataSet @@ -637,7 +574,7 @@ public enum EditorMoveState Rotate, } - public class SceneViewerHwndHost : HwndHost + class SceneViewerHwndHost : HwndHost { readonly IntPtr HwndChildHandle; @@ -659,7 +596,7 @@ protected override HandleRef BuildWindowCore(HandleRef hwndParent) PInvoke.SetWindowLong(child, Windows.Win32.UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX.GWL_STYLE, style); PInvoke.SetParent(child, parent); - + return new HandleRef(this, HwndChildHandle); } diff --git a/Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml.cs b/Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml.cs deleted file mode 100644 index ef88ce577d..0000000000 --- a/Source/Contrib/TrackViewer/UserInterface/SceneWindow.xaml.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace ORTS.TrackViewer.UserInterface -{ - /// - /// Interaction logic for SceneWindow.xaml - /// - public partial class SceneWindow : Window - { - UIElement HostWindow; - - public SceneWindow(UIElement hostWindow) - { - InitializeComponent(); - - HostWindow = hostWindow; - //HostVisualElement.Children.Add((SceneViewerVisualHost)HostWindow); - GraphicsHostElement.Children.Add((SceneViewerHwndHost)hostWindow); - } - - protected override void OnClosing(CancelEventArgs e) - { - e.Cancel = true; - Hide(); - } - - private void IntValidationTextBox(object sender, TextCompositionEventArgs e) - { - e.Handled = int.TryParse(e.Text, out var _); - } - - private void UintValidationTextBox(object sender, TextCompositionEventArgs e) - { - e.Handled = uint.TryParse(e.Text, out var _); - } - - private void FloatValidationTextBox(object sender, TextCompositionEventArgs e) - { - e.Handled = float.TryParse(e.Text, out var _); - } - - private void UndoCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) - { - (DataContext as SceneViewer).UndoCommand(); - } - - private void RedoCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) - { - (DataContext as SceneViewer).RedoCommand(); - } - } -}