private void ShowWindow <TUc>(Action <ContainerWindow, TUc> beforeShow = null) where TUc : UserControl { beforeShow?.Invoke(this, (TUc)_uc); if (Vm.IsMaskTheParent && this.Owner == null) { var owner = WpfUtil.GetTopWindow(); if (owner != null && this != owner) { this.Owner = owner; } } if (Vm.IsMaskTheParent || this.Owner != null) { this.ShowInTaskbar = false; this.BtnMin.Visibility = Visibility.Collapsed; } if (Vm.IsMaskTheParent) { this.WindowStartupLocation = WindowStartupLocation.CenterOwner; this.ShowSoftDialog(); } else { this.ShowActivated = true; this.Show(); if (this.WindowState == WindowState.Minimized) { this.WindowState = WindowState.Normal; } this.Activate(); } }
public NTMinerFileEdit(string iconName, NTMinerFileViewModel vm) { this.DataContext = vm; InitializeComponent(); this.PathIcon.Data = (Geometry)Application.Current.Resources[iconName]; this.Owner = WpfUtil.GetTopWindow(); }
public static void Login(Action onLoginSuccess) { if (!IsLogined()) { UIThread.Execute(() => { var topWindow = WpfUtil.GetTopWindow(); LoginWindow window = new LoginWindow(onLoginSuccess); if (topWindow != null && topWindow.GetType() != typeof(NotiCenterWindow)) { window.Owner = topWindow; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; } window.Closing += (sender, e) => { if (IsLogined()) { onLoginSuccess?.Invoke(); } }; window.ShowSoftDialog(); window.PasswordFocus(); }); } else { onLoginSuccess?.Invoke(); } }
public void ShowWindow(Action <UserControl> beforeShow = null) { beforeShow?.Invoke(_uc); if (Vm.IsDialogWindow || Vm.HasOwner) { var owner = WpfUtil.GetTopWindow(); if (this != owner) { this.Owner = owner; } } if (Vm.IsDialogWindow || Vm.HasOwner || Vm.HeaderVisible == Visibility.Collapsed) { this.ShowInTaskbar = false; } if (Vm.IsDialogWindow) { this.WindowStartupLocation = WindowStartupLocation.CenterOwner; this.ShowDialogEx(); } else { this.Topmost = Vm.IsTopMost; this.ShowActivated = true; this.Show(); if (this.WindowState == WindowState.Minimized) { this.WindowState = WindowState.Normal; } this.Activate(); } }
public NTMinerFileEdit(string iconName, NTMinerFileViewModel vm) { this.DataContext = vm; InitializeComponent(); this.PathIcon.Data = AppUtil.GetResource <Geometry>(iconName); this.Owner = WpfUtil.GetTopWindow(); }
public MinerClientSetting(MinerClientSettingViewModel vm) { this.DataContext = vm; InitializeComponent(); var owner = WpfUtil.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 = WpfUtil.GetTopWindow() }; var result = window.ShowDialogEx(); return(result.HasValue && result.Value); } return(true); }
public static void ShowWindow() { ContainerWindow.ShowWindow(new ContainerWindowViewModel { Title = "内核频道设置:基于关键字从内核输出中订阅消息", IconName = "Icon_Message", Width = 600, Height = 400, CloseVisible = System.Windows.Visibility.Visible, FooterVisible = System.Windows.Visibility.Collapsed }, ucFactory: (window) => { window.Owner = WpfUtil.GetTopWindow(); return(new KernelOutputKeywords()); }, fixedSize: true); }
public InputWindow( string title, string text, string tail, Func <string, string> check, Action <string> onOk, bool isPassword) { _isPassword = isPassword; this.Title = title; InitializeComponent(); this.TbUcName.Text = nameof(InputWindow); TbTitle.Text = title; if (isPassword) { TbText.Visibility = Visibility.Collapsed; PbPassword.Visibility = Visibility.Visible; PbPassword.Password = text; } else { TbText.Text = text; } TbTail.Text = tail; var owner = WpfUtil.GetTopWindow(); if (this != owner) { this.Owner = owner; } _check = check; _onOk = onOk ?? throw new ArgumentNullException(nameof(onOk)); TimeSpan.FromMilliseconds(100).Delay().ContinueWith(t => { UIThread.Execute(() => () => { if (isPassword) { PbPassword.Focus(); } else { if (!string.IsNullOrEmpty(TbText.Text)) { TbText.SelectionStart = TbText.Text.Length; } TbText.Focus(); } }); }); }
public NTMinerFileViewModel() { _id = Guid.NewGuid(); _publishOn = DateTime.Now; this.Save = new DelegateCommand(() => { LoginWindow.Login(() => { RpcRoot.OfficialServer.FileUrlService.AddOrUpdateNTMinerFileAsync(new NTMinerFileData().Update(this), (response, e) => { if (response.IsSuccess()) { MainWindowViewModel.Instance.Refresh(); UIThread.Execute(() => () => { WpfUtil.GetTopWindow()?.Close(); }); } else { Logger.ErrorDebugLine($"AddOrUpdateNTMinerFileAsync失败"); } }); }); }); this.Edit = new DelegateCommand(() => { NTMinerFileEdit window = new NTMinerFileEdit("Icon_Edit", new NTMinerFileViewModel(this)); window.ShowSoftDialog(); }); this.Remove = new DelegateCommand(() => { LoginWindow.Login(() => { this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => { RpcRoot.OfficialServer.FileUrlService.RemoveNTMinerFileAsync(this.Id, (response, e) => { if (response.IsSuccess()) { MainWindowViewModel.Instance.Refresh(); 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); } } else { VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4); } }); })); }); }); }
private DialogWindow(DialogWindowViewModel vm) { this.DataContext = vm; InitializeComponent(); if (!string.IsNullOrEmpty(vm.Icon) && Application.Current.Resources.Contains(vm.Icon)) { this.Resources["Icon"] = Application.Current.Resources[vm.Icon]; } var owner = WpfUtil.GetTopWindow(); if (this != owner) { this.Owner = owner; } }
public static void ShowWindow(MinerClientsWindowViewModel minerClientsWindowVm) { if (minerClientsWindowVm.SelectedMinerClients == null && minerClientsWindowVm.SelectedMinerClients.Length != 1) { return; } var minerClientVm = minerClientsWindowVm.SelectedMinerClients[0]; ContainerWindow.ShowWindow(new ContainerWindowViewModel { Title = $"超频 - 基于矿机{minerClientVm.MinerName}({minerClientVm.MinerIp})", IconName = "Icon_OverClock", Width = 800, Height = 700, CloseVisible = Visibility.Visible, FooterVisible = Visibility.Collapsed }, ucFactory: (window) => { window.Owner = WpfUtil.GetTopWindow(); var vm = new GpuProfilesPageViewModel(minerClientsWindowVm) { CloseWindow = window.Close }; var uc = new GpuProfilesPage(vm); var client = minerClientsWindowVm.SelectedMinerClients[0]; void handler(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(minerClientsWindowVm.SelectedMinerClients)) { if (minerClientsWindowVm.SelectedMinerClients.Contains(minerClientVm)) { vm.IsMinerClientVmVisible = Visibility.Collapsed; } else { vm.IsMinerClientVmVisible = Visibility.Visible; } } } minerClientsWindowVm.PropertyChanged += handler; uc.Unloaded += (object sender, RoutedEventArgs e) => { minerClientsWindowVm.PropertyChanged -= handler; }; return(uc); }, fixedSize: false); }
public InputWindow( string title, string text, Func <string, string> check, Action <string> onOk) { InitializeComponent(); TbTitle.Text = title; TbText.Text = text; var owner = WpfUtil.GetTopWindow(); if (this != owner) { this.Owner = owner; } _check = check; _onOk = onOk ?? throw new ArgumentNullException(nameof(onOk)); }
public static void Login(Action onLoginSuccess, string serverHost = null, Action btnCloseClick = null) { if (!RpcRoot.IsLogined) { var parent = WpfUtil.GetTopWindow(); LoginWindow window = new LoginWindow(onLoginSuccess, serverHost, btnCloseClick); if (parent != null && parent.GetType() != typeof(NotiCenterWindow)) { window.Owner = parent; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; window.ShowInTaskbar = false; } window.ShowSoftDialog(); window.PasswordFocus(); } else { onLoginSuccess?.Invoke(); } }
private DialogWindow(DialogWindowViewModel vm) { this.DataContext = vm; this.Title = vm.Title; InitializeComponent(); this.TbUcName.Text = nameof(DialogWindow); if (!string.IsNullOrEmpty(vm.Icon)) { object obj = AppUtil.GetResource(vm.Icon); if (obj != null) { this.Resources["Icon"] = obj; } } var owner = WpfUtil.GetTopWindow(); if (this != owner) { this.Owner = owner; } }
public static void Login(Action onLoginSuccess, string serverHost = null, Action btnCloseClick = null) { if (!RpcRoot.IsLogined) { var parent = WpfUtil.GetTopWindow(); LoginWindow window = new LoginWindow(onLoginSuccess, serverHost, btnCloseClick); if (parent != null && parent.GetType() != typeof(NotiCenterWindow)) { window.Owner = parent; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; window.ShowInTaskbar = false; } window.BuildEventPath <SignUpedEvent>("注册了新外网群控用户后自动填入外网群控用户名", LogEnum.None, path: message => { window.Vm.LoginName = message.LoginName; }, typeof(LoginWindow)); window.ShowSoftDialog(); window.PasswordFocus(); } else { onLoginSuccess?.Invoke(); } }