Exemplo n.º 1
0
        async protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            base.OnMouseDown(e);
            MainWindow w = Window.GetWindow(this) as MainWindow;

            if (w == null)
            {
                return;
            }

            if (e.ClickCount == 1)
            {
                Point p;
                if (e.ChangedButton == MouseButton.Left)
                {
                    p    = PointToScreen(e.GetPosition(this));
                    p.X += 1;
                    p.Y += 1;
                }
                else
                {
                    p    = PointToScreen(e.GetPosition(this));
                    p.X += 1;
                    p.Y += 1;
                }
                SystemCommands.ShowSystemMenu(w, p);
            }
            if (e.ClickCount == 2 && e.ChangedButton == MouseButton.Left)
            {
                await((MainWindowViewModel)DataContext).CloseCommand.Execute();
            }
        }
Exemplo n.º 2
0
 protected override void OnInitialized(EventArgs e)
 {
     CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand,
                                            (s, args) => SystemCommands.CloseWindow((Window)args.Parameter)));
     CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand,
                                            (s, args) => SystemCommands.MaximizeWindow((Window)args.Parameter)));
     CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand,
                                            (s, args) => SystemCommands.MinimizeWindow((Window)args.Parameter)));
     CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand,
                                            (s, args) => SystemCommands.RestoreWindow((Window)args.Parameter)));
     //Debug.Assert(this.Owner != null);
     base.OnInitialized(e);
 }