public void ShowWindow(Action <UserControl> beforeShow = null) { beforeShow?.Invoke(_uc); if (Vm.IsDialogWindow) { this.ShowInTaskbar = false; this.WindowStartupLocation = WindowStartupLocation.CenterOwner; var owner = TopWindow.GetTopWindow(); if (this != owner) { this.Owner = owner; } double ownerOpacity = this.Owner.Opacity; this.Owner.Opacity = 0.6; this.ShowDialog(); this.Owner.Opacity = ownerOpacity; } else { this.ShowActivated = true; this.Show(); if (this.WindowState == WindowState.Minimized) { this.WindowState = WindowState.Normal; } this.Activate(); } }
private DialogWindow( string icon, string title, string message, Action onYes, Action onNo) { InitializeComponent(); ResourceDictionarySet.Instance.FillResourceDic(this, this.Resources); this.Resources["Title"] = title; this.Resources["Message"] = message; if (!string.IsNullOrEmpty(icon) && Application.Current.Resources.Contains(icon)) { this.Resources["Icon"] = Application.Current.Resources[icon]; } var owner = TopWindow.GetTopWindow(); if (this != owner) { this.Owner = owner; } _onYes = onYes; _onNo = onNo; if (onYes != null || onNo != null) { this.BtnOk.Visibility = Visibility.Collapsed; } if (onYes == null && onNo == null) { this.BtnYes.Visibility = Visibility.Collapsed; this.BtnNo.Visibility = Visibility.Collapsed; } }
public NTMinerFileEdit(string iconName, NTMinerFileViewModel vm) { this.DataContext = vm; InitializeComponent(); this.PathIcon.Data = (Geometry)Application.Current.Resources[iconName]; this.Owner = TopWindow.GetTopWindow(); }
public static void ShowWindow() { ContainerWindow.ShowWindow(new ContainerWindowViewModel { Title = "收益计算器设置", IconName = "Icon_Calc", Width = 500, Height = 450, CloseVisible = System.Windows.Visibility.Visible, SaveVisible = System.Windows.Visibility.Visible, OnOk = (uc) => { CalcConfigViewModels vm = (CalcConfigViewModels)uc.DataContext; NTMinerRoot.Current.CalcConfigSet.SaveCalcConfigs(vm.CalcConfigVms.Select(a => new CalcConfigData(a)).ToList()); TopWindow.GetTopWindow()?.Close(); return(true); } }, ucFactory: (window) => { var uc = new CalcConfig(); uc.ItemsControl.MouseDown += (object sender, System.Windows.Input.MouseButtonEventArgs e) => { if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) { window.DragMove(); } }; return(uc); }, fixedSize: false); }
public MinerClientAdd(MinerClientAddViewModel vm) { this.DataContext = vm; InitializeComponent(); var owner = TopWindow.GetTopWindow(); if (this != owner) { this.Owner = owner; } }
private bool Login() { if (string.IsNullOrEmpty(SingleUser.LoginName) || string.IsNullOrEmpty(SingleUser.PasswordSha1)) { LoginWindow window = new LoginWindow() { WindowStartupLocation = WindowStartupLocation.CenterOwner, Owner = TopWindow.GetTopWindow() }; var result = window.ShowDialogEx(); return(result.HasValue && result.Value); } return(true); }
public LangViewItemViewModel(Guid id) { _id = id; this.Edit = new DelegateCommand(() => { LangViewItemEdit.ShowWindow(new LangViewItemViewModel(this)); }); this.Save = new DelegateCommand(() => { if (LangViewItemViewModels.Current.Contains(this.Id)) { VirtualRoot.Execute(new UpdateLangViewItemCommand(this)); } else { VirtualRoot.Execute(new AddLangViewItemCommand(this)); } TopWindow.GetTopWindow()?.Close(); }); }
public NTMinerFileViewModel() { _id = Guid.NewGuid(); _publishOn = DateTime.Now; this.Save = new DelegateCommand(() => { if (Login()) { OfficialServer.FileUrlService.AddOrUpdateNTMinerFileAsync(new NTMinerFileData().Update(this), (response, e) => { if (response.IsSuccess()) { MainWindowViewModel.Instance.Refresh(); UIThread.Execute(() => { TopWindow.GetTopWindow()?.Close(); }); } else { Logger.ErrorDebugLine($"AddOrUpdateNTMinerFileAsync失败"); } }); } }); this.Edit = new DelegateCommand(() => { NTMinerFileEdit window = new NTMinerFileEdit("Icon_Edit", new NTMinerFileViewModel(this)); window.ShowDialogEx(); }); this.Remove = new DelegateCommand(() => { if (Login()) { this.ShowDialog(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => { OfficialServer.FileUrlService.RemoveNTMinerFileAsync(this.Id, (response, e) => { MainWindowViewModel.Instance.SelectedNTMinerFile = MainWindowViewModel.Instance.NTMinerFiles.FirstOrDefault(); if (this == MainWindowViewModel.Instance.ServerLatestVm) { MainWindowViewModel.Instance.ServerLatestVm = MainWindowViewModel.Instance.NTMinerFiles .FirstOrDefault(a => a != this && a.VersionData > MainWindowViewModel.Instance.LocalNTMinerVersion); } MainWindowViewModel.Instance.Refresh(); }); }, icon: IconConst.IconConfirm); } }); }
public InputWindow( string title, string text, Func <string, string> check, Action <string> onOk) { InitializeComponent(); TbTitle.Text = title; TbText.Text = text; var owner = TopWindow.GetTopWindow(); if (this != owner) { this.Owner = owner; } _check = check; _onOk = onOk ?? throw new ArgumentNullException(nameof(onOk)); }
public void ShowWindow(Action <UserControl> beforeShow = null) { beforeShow?.Invoke(_uc); if (Vm.IsDialogWindow || Vm.HasOwner) { var owner = TopWindow.GetTopWindow(); if (this != owner && owner != null) { this.Owner = owner; } } if (Vm.IsDialogWindow || Vm.HasOwner || Vm.HeaderVisible == Visibility.Collapsed) { this.ShowInTaskbar = false; } if (Vm.IsDialogWindow) { this.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (this.Owner != null) { double ownerOpacity = this.Owner.Opacity; this.Owner.Opacity = 0.6; this.ShowDialog(); this.Owner.Opacity = ownerOpacity; } else { this.ShowDialog(); } } else { this.Topmost = Vm.IsTopMost; this.ShowActivated = true; this.Show(); if (this.WindowState == WindowState.Minimized) { this.WindowState = WindowState.Normal; } this.Activate(); } }
public NTMinerFileViewModel() { _id = Guid.NewGuid(); _publishOn = DateTime.Now; this.Save = new DelegateCommand(() => { if (Login()) { Server.FileUrlService.AddOrUpdateNTMinerFile(new NTMinerFileData().Update(this), response => { if (response != null && response.IsSuccess()) { MainWindowViewModel.Current.Refresh(); Execute.OnUIThread(() => { TopWindow.GetTopWindow()?.Close(); }); } }); } }); this.Edit = new DelegateCommand(() => { NTMinerFileEdit window = new NTMinerFileEdit("编辑", "Icon_Edit", new NTMinerFileViewModel(this)); window.ShowDialogEx(); }); this.Remove = new DelegateCommand(() => { if (Login()) { DialogWindow.ShowDialog(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => { Server.FileUrlService.RemoveNTMinerFile(this.Id, isSuccess => { MainWindowViewModel.Current.SelectedNTMinerFile = MainWindowViewModel.Current.NTMinerFiles.FirstOrDefault(); if (this == MainWindowViewModel.Current.ServerLatestVm) { MainWindowViewModel.Current.ServerLatestVm = MainWindowViewModel.Current.NTMinerFiles .FirstOrDefault(a => a != this && a.VersionData > MainWindowViewModel.Current.LocalNTMinerVersion); } MainWindowViewModel.Current.Refresh(); }); }, icon: "Icon_Confirm"); } }); }
private DialogWindow( string icon, string title, string message, string helpUrl, Action onYes, Action onNo) { _helpUrl = helpUrl; InitializeComponent(); if (!string.IsNullOrEmpty(helpUrl)) { this.BtnHelp.Visibility = Visibility.Visible; } this.TextBlockTitle.Text = title; this.TextBlockMessage.Text = message; if (!string.IsNullOrEmpty(icon) && Application.Current.Resources.Contains(icon)) { this.Resources["Icon"] = Application.Current.Resources[icon]; } var owner = TopWindow.GetTopWindow(); if (this != owner) { this.Owner = owner; } _onYes = onYes; _onNo = onNo; if (onYes != null || onNo != null) { this.BtnOk.Visibility = Visibility.Collapsed; } if (onYes == null && onNo == null) { this.BtnYes.Visibility = Visibility.Collapsed; this.BtnNo.Visibility = Visibility.Collapsed; } }
public static void ShowDialog(string icon = null, string title = null, string message = null, Action onYes = null, Action onNo = null) { Window window = new DialogWindow(icon, title, message, onYes, onNo); var owner = TopWindow.GetTopWindow(); if (owner != window) { window.Owner = owner; double ownerOpacity = window.Owner.Opacity; window.Owner.Opacity = 0.6; window.ShowDialog(); window.Owner.Opacity = ownerOpacity; } else { window.ShowDialog(); } }
private DialogWindow( string icon, string title, string message, Action onYes, Action onNo) { InitializeComponent(); var owner = TopWindow.GetTopWindow(); if (this != owner) { this.Owner = owner; } if (!string.IsNullOrEmpty(icon)) { PathIcon.Data = (Geometry)Application.Current.Resources[icon]; } if (!string.IsNullOrEmpty(title)) { TxtTitle.Text = title; } if (!string.IsNullOrEmpty(message)) { TxtMessage.Text = message; } _onYes = onYes; _onNo = onNo; if (onYes != null || onNo != null) { this.BtnOk.Visibility = Visibility.Collapsed; } if (onYes == null && onNo == null) { this.BtnYes.Visibility = Visibility.Collapsed; this.BtnNo.Visibility = Visibility.Collapsed; } }