Example #1
0
            /// <summary>
            /// Main constructor for XUi_Window
            /// </summary>
            ///
            /// <param name="window"><see cref="Window"/> to set up the view model</param>
            public XUiWindowToolViewModel(Window window)
            {
                _window = window;
                // Set window resizer behaviour
                WindowResizer = new WindowResizer(_window);

                CloseCommand = new RelayCommand(() => WindowResizer.SendMessage(WindowHandle, NativeMethods.WM_SYSCOMMAND, new IntPtr(NativeMethods.SC_CLOSE), IntPtr.Zero));
                MenuCommand  = new RelayCommand(() =>
                {
                    // Get the mouse position
                    Point mousePosition = Mouse.GetPosition(_window);
                    Point screenPosition;
                    // Create the screen position
                    if (_window.WindowState != WindowState.Maximized)
                    {
                        screenPosition = new Point(_window.Left, 30 + _window.Top);
                    }
                    else
                    {
                        screenPosition = new Point(0, 30);
                    }

                    // Display the system menu
                    SystemCommands.ShowSystemMenu(_window, screenPosition);
                });
            }