/Samples/ExampleToolWPF/MainWindow.xaml.cs
C# | 67 lines | 45 code | 6 blank | 16 comment | 2 complexity | f604c573a66d3bc02986820eaa4d1a6a MD5 | raw file
Possible License(s): Apache-2.0
- using Delta.Platforms.Windows;
- using Delta.Engine;
- using Delta.Rendering.Basics.Materials;
- using Delta.Utilities.Datatypes;
- using Delta.InputSystem;
- using Delta.Rendering.Basics.Drawing;
- using Delta.Rendering.Basics.Fonts;
- using FormsColor = System.Drawing.Color;
- using FormsPanel = System.Windows.Forms.Panel;
-
- namespace Delta.Tools.ExampleToolWPF
- {
- /// <summary>
- /// Sample on how to integrate WPF editors and tools with the Delta Engine!
- /// </summary>
- public partial class MainWindow : System.Windows.Window
- {
- #region Constructor
- /// <summary>
- /// Create main window
- /// </summary>
- public MainWindow()
- {
- InitializeComponent();
-
- // Setup the WPF window and create a panel in the ViewportHoster for us
- WindowsApplication.SetEditorWPFWindow(this, ViewportHoster);
-
- // Do initialization code like setting the background color (optional)
- Application.BackgroundColor = Color.DarkBlue;//.Green;//LightBlue;
-
- float wheelValue = 0.0f;
- // And finally start the Delta Engine like you normally would
- Application.Start(delegate
- {
- // Line from top left up to bottom right in quadratic space
- Line.Draw(new Point(0, 0), new Point(1, 1), Color.Red);
- // Draw a rotating default material in the middle
- Material2D.Default.Draw(Rectangle.FromCenter(Point.Half, 0.25f),
- Time.Milliseconds / 25.0f);
-
- // Also draw some information about the mouse
- Font.Default.Draw("Mouse: " + Input.Mouse.Position,
- Rectangle.FromCenter(Point.Half, Size.Half));
- float wheelDelta = Input.Mouse.ScrollWheelDelta;
- if (wheelDelta != 0)
- {
- wheelValue += wheelDelta;
- } // if
- Font.Default.Draw("Mouse wheelValue= '" + wheelValue + "'",
- Rectangle.FromCenter(new Point(0.5f, 0.55f), Size.Half));
- });
- }
- #endregion
-
- #region OnExitClicked
- /// <summary>
- /// On exit clicked, not needed, just shown as an example how to quit the
- /// whole app (including the engine and the wpf tool window).
- /// </summary>
- private void OnExitClicked(object sender, System.Windows.RoutedEventArgs e)
- {
- Application.Quit();
- }
- #endregion
- }
- }