Esempio n. 1
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public WindowViewModel(Window window)
        {
            mWindow = window;

            // Listen out for the window resizing
            mWindow.StateChanged += (sender, e) =>
            {
                // Fire off events for all properties that are affected by a resize
                WindowResized();
            };

            // Create commands
            MinimizeCommand = new RelayCommand(() => mWindow.WindowState = WindowState.Minimized);
            MaximizeCommand = new RelayCommand(() => mWindow.WindowState ^= WindowState.Maximized);
            CloseCommand    = new RelayCommand(() => mWindow.Close());
            MenuCommand     = new RelayCommand(() => SystemCommands.ShowSystemMenu(mWindow, GetMousePosition()));

            // Fix window resize issue
            var resizer = new WindowResizer(mWindow);

            // Listen out for dock changes
            resizer.WindowDockChanged += (dock) =>
            {
                // Store last position
                mDockPosition = dock;

                // Fire off resize events
                WindowResized();
            };
        }
Esempio n. 2
0
        public WindowViewModel(Window window)
        {
            this.window = window;

            this.window.StateChanged += (sender, e) =>
            {
                this.OnPropertyChanged(nameof(this.ResizeBorderThickness));
                this.OnPropertyChanged(nameof(this.OuterMarginSize));
                this.OnPropertyChanged(nameof(this.OuterMarginSizeThickness));
                this.OnPropertyChanged(nameof(this.WindowRadius));
                this.OnPropertyChanged(nameof(this.WindowCornerRadius));
            };

            this.MinimizeCommand = new RelayCommand(() => this.window.WindowState = WindowState.Minimized);
            this.MaximizeCommand = new RelayCommand(() => this.window.WindowState ^= WindowState.Maximized);
            this.CloseCommand    = new RelayCommand(() => this.window.Close());
            this.MenuCommand     = new RelayCommand(() => SystemCommands.ShowSystemMenu(this.window, this.GetMousePosition()));

            var resizer = new WindowResizer(this.window);
        }
Esempio n. 3
0
        /// <summary>
        ///  default contructor
        /// </summary>
        /// <param name="window"></param>
        public WindowsViewModel(Window window)
        {
            mWindow = window;
            //Listen out for the window resizing
            mWindow.StateChanged += (sender, e) =>
            {
                //Fire off all events for all properties that are affected by a resize
                //OnPropertyChanged(nameof(ResizeBorder));
                OnPropertyChanged(nameof(ResizeBorderThickness));
                OnPropertyChanged(nameof(OuterMarginSize));
                OnPropertyChanged(nameof(OuterMarginSizeThickness));
                OnPropertyChanged(nameof(WindowRadius));
                OnPropertyChanged(nameof(WindowCornerRadius));
            };

            // create commands
            MinimizeCommand = new RelayCommand(() => mWindow.WindowState = WindowState.Minimized);
            MaximizeCommand = new RelayCommand(() => mWindow.WindowState ^= WindowState.Maximized);
            CloseCommand    = new RelayCommand(() => mWindow.Close());
            MenuCommand     = new RelayCommand(() => SystemCommands.ShowSystemMenu(mWindow, GetMousePosition()));

            // fix windows resize issue
            var resizer = new WindowResizer(mWindow);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowViewModel"/> class.
        /// </summary>
        /// <param name="windowHandle">The windowHandle.</param>
        public WindowViewModel(Window windowHandle)
        {
            mWindowHandle = windowHandle;

            // Listen for Window Resize event
            mWindowHandle.StateChanged += (sender, e) =>
            {
                // Fire of events on resizing of windowHandle
                OnPropertyChanged(nameof(ResizeBorderThickness));
                OnPropertyChanged(nameof(OuterMarginSize));
                OnPropertyChanged(nameof(OuterMarginSizeThickness));
                OnPropertyChanged(nameof(WindowRadius));
                OnPropertyChanged(nameof(WindowCornerRadius));
            };

            // Create commands
            MinimizeCommand   = new RelayCommand(() => mWindowHandle.WindowState = WindowState.Minimized);
            MaximizeCommand   = new RelayCommand(() => mWindowHandle.WindowState ^= WindowState.Maximized);
            CloseCommand      = new RelayCommand(() => mWindowHandle.Close());
            SystemMenuCommand = new RelayCommand(() => SystemCommands.ShowSystemMenu(mWindowHandle, GetMousePosition(mWindowHandle)));

            // Fix windowHandle resize issue when windowHandle.style is none
            var resizer = new WindowResizer(mWindowHandle);
        }