public static void ShowDialog(RestartWindowsViewModel vm) { ContainerWindow.ShowWindow(new ContainerWindowViewModel { Title = "重启电脑", Width = 400, Height = 200, IsMaskTheParent = true, CloseVisible = System.Windows.Visibility.Collapsed, IconName = "Icon_Restart" }, ucFactory: (window) => { RestartWindows uc = new RestartWindows(vm); window.AddCloseWindowOnecePath(uc.Vm.Id); return(uc); }, fixedSize: true); }
public RestartWindows(RestartWindowsViewModel vm) { this.DataContext = vm; InitializeComponent(); this.OnLoaded(window => { IMessagePathId messagePathId = null; messagePathId = window.AddViaTimesLimitPath <Per1SecondEvent>("重启倒计时", LogEnum.None, action: message => { if (_isCanceled) { return; } Vm.Seconds = Vm.Seconds - 1; if (messagePathId.ViaTimesLimit == 0) { Windows.Power.Restart(); } }, Vm.Seconds, location: this.GetType()); }); }