public VActivity() { LoadedCommand = new RelayCommand(() => { loadActivity(); }); SearchCommand = new RelayCommand <string>(key => { loadActivity(key); }); LogoutCommand = new RelayCommand(() => { App.CurrentUser.PassWord = string.Empty; AdminDataService.Instance.InsertOrUpdate(GlobalKeys.LoginAccount, App.CurrentUser); LocalSysCmds.RestartApp(); }); AddCommand = new RelayCommand(() => { new AddActivityDialog().Show(); }); }
public XWindow(bool dragable, string style, bool hook = true) { _dragable = dragable; _defaultStyle = style; InitializeTheme(); InitializeStyle(); this.BindCommand(LocalSysCmds.CloseWindowCommand, (s, e) => { LocalSysCmds.CloseWindow(this); }); this.BindCommand(ApplicationCommands.Close, (s, e) => { LocalSysCmds.CloseWindow(this); }); this.BindCommand(LocalSysCmds.MinimizeWindowCommand, (s, e) => { WindowState = WindowState.Minimized; e.Handled = true; }); var mg = Margin; var corner = AttachProperty.GetCornerRadius(this); this.BindCommand(LocalSysCmds.MaximizeWindowCommand, (s, e) => { if (WindowState == WindowState.Maximized) { LocalSysCmds.RestoreWindow(this); Margin = mg; AttachProperty.SetCornerRadius(this, corner); WindowState = WindowState.Normal; } else { LocalSysCmds.MaximizeWindow(this); Margin = new Thickness(0); AttachProperty.SetCornerRadius(this, new CornerRadius(0)); WindowState = WindowState.Maximized; } e.Handled = true; }); //窗体加载完成事件 Loaded += (sender, args) => { }; //exc退出全屏 KeyUp += (s, e) => { if (WindowState == WindowState.Maximized && e.Key == Key.F11) { LocalSysCmds.RestoreWindow(this); Margin = mg; AttachProperty.SetCornerRadius(this, corner); WindowState = WindowState.Normal; } else if (WindowState == WindowState.Normal && e.Key == Key.F11) { LocalSysCmds.MaximizeWindow(this); Margin = new Thickness(0); AttachProperty.SetCornerRadius(this, new CornerRadius(0)); WindowState = WindowState.Maximized; } }; Unloaded += (sender, args) => { (DataContext as VBase)?.Cleanup(); }; //资源初始化事件 SourceInitialized += (sender, args) => { if (!hook) { return; } //重绘窗体大小 var handle = new WindowInteropHelper(this).Handle; var source = HwndSource.FromHwnd(handle); source?.AddHook(WindowProc); }; }