void OnRequestCreateUrl(UrlInfo urlInfo) { if (urlInfo == null) { return; } switch (urlInfo.Mode) { case UrlMode.CreateByReceive: if (!UrlInfos.Any(x => x.Address == urlInfo.Address)) { UrlInfos.Add(urlInfo); } break; case UrlMode.EditByReceive: var result = AccountsService.Default.SetAccountTag(urlInfo.Address, urlInfo.Tag); if (!result.IsFail) { this.SelectedItem.Tag = urlInfo.Tag; ReceiveAddressBookMonitor.Default.Start(500); } break; default: break; } }
protected override void OnLoaded() { base.OnLoaded(); BtnCommand = new RelayCommand <string>(OnCommand); MouseDubleClickCommand = new RelayCommand <UrlInfo>(OnMouseDubleClick); RegeistMessenger <UrlInfo>(OnRequestCreateUrl); RegeistMessenger <PayUrlPageType>(OnGetRequest); PayAddressBookMonitor.Default.MonitorCallBack += books => { Application.Current.Dispatcher.Invoke(() => { string account = null; if (SelectedItem != null) { account = SelectedItem.Address; } UrlInfos.Clear(); books.ForEach(x => { UrlInfos.Add(new UrlInfo(x)); }); if (account != null) { SelectedItem = UrlInfos.FirstOrDefault(x => x.Address == account); } StaticViewModel.GlobalViewModel.IsLoading = false; }); }; LoadUrls(); UrlInfos.CollectionChanged += (s, e) => { RaisePropertyChanged("UrlInfos"); }; }
protected override void OnLoaded() { base.OnLoaded(); BtnCommand = new RelayCommand <string>(OnCommand); MouseDubleClickCommand = new RelayCommand <UrlInfo>(OnMouseDubleClick); RegeistMessenger <UrlInfo>(OnRequestCreateUrl); ReceiveAddressBookMonitor.Default.MonitorCallBack += accounts => { Application.Current.Dispatcher.Invoke(() => { var selectedItem = this.SelectedItem; UrlInfos.Clear(); accounts.ForEach(x => UrlInfos.Add(new UrlInfo() { Address = x.Address, Tag = x.Tag })); if (selectedItem != null) { this.SelectedItem = UrlInfos.FirstOrDefault(x => x.Address == selectedItem.Address); } }); ReceiveAddressBookMonitor.Default.Start(6000); }; LoadUrls(); UrlInfos.CollectionChanged += (s, e) => { RaisePropertyChanged("UrlInfos"); }; }
void LoadUrls() { PayAddressBookMonitor.Default.MonitorCallBack += books => { Application.Current.Dispatcher.Invoke(() => { PayAddressBookMonitor.Default.Stop(); UrlInfos.Clear(); books.ForEach(x => { UrlInfos.Add(new UrlInfo(x)); }); }); }; }
void LoadUrls() { ReceiveAddressBookMonitor.Default.MonitorCallBack += accounts => { ReceiveAddressBookMonitor.Default.Stop(); Application.Current.Dispatcher.Invoke(() => { UrlInfos.Clear(); accounts.ForEach(x => UrlInfos.Add(new UrlInfo() { Address = x.Address, Tag = x.Tag })); }); }; }
protected override void OnLoaded() { base.OnLoaded(); BtnCommand = new RelayCommand <string>(OnCommand); MouseDubleClickCommand = new RelayCommand <UrlInfo>(OnMouseDubleClick); RegeistMessenger <UrlInfo>(OnRequestCreateUrl); RegeistMessenger <PayUrlPageType>(OnGetRequest); PayAddressBookMonitor.Default.MonitorCallBack += books => { Application.Current.Dispatcher.Invoke(() => { PayAddressBookMonitor.Default.Stop(); UrlInfos.Clear(); books.ForEach(x => { UrlInfos.Add(new UrlInfo(x)); }); }); }; LoadUrls(); UrlInfos.CollectionChanged += (s, e) => { RaisePropertyChanged("UrlInfos"); }; }
void OnRequestCreateUrl(UrlInfo urlInfo) { if (urlInfo == null) { return; } var netstr = OmniCoinSetting.NodeTypeStr; if (!AddressTools.AddressVerfy(netstr, urlInfo.Address)) { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Error_Address)); return; } switch (urlInfo.Mode) { case UrlMode.CreatePay: if (UrlInfos.Any(x => x.Address.Equals(urlInfo.Address))) { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Address_Existed)); return; } StaticViewModel.GlobalViewModel.IsLoading = true; var result = AddressBookService.Default.UpsertAddrBookItem(urlInfo.Address, urlInfo.Tag); if (!result.IsFail) { LoadUrls(); } else { ShowMessage(result.GetErrorMsg()); } break; case UrlMode.Edit: if (UrlInfos.Any(x => x.Address.Equals(urlInfo.Address) && x.Id != urlInfo.Id)) { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Address_Existed)); return; } var updateResult = AddressBookService.Default.UpsertAddrBookItem(urlInfo.Address, urlInfo.Tag, urlInfo.Id); if (!updateResult.IsFail) { var selectedUrlinfo = UrlInfos.FirstOrDefault(x => x.Id == urlInfo.Id); if (selectedUrlinfo == null) { UrlInfos.Add(urlInfo); } else { selectedUrlinfo.Tag = urlInfo.Tag; selectedUrlinfo.Address = urlInfo.Address; selectedUrlinfo.Mode = urlInfo.Mode; SelectedItem = selectedUrlinfo; } } else { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Edit_Fail)); } break; default: break; } }
void OnRequestCreateUrl(UrlInfo urlInfo) { if (urlInfo == null) { return; } var netstr = "mainnet"; switch (NodeSetting.CurrentNetworkType) { case Biz.NetworkType.MainnetPort: break; case Biz.NetworkType.TestNetPort: netstr = "testnet"; break; default: break; } if (!AddressTools.AddressVerfy(netstr, urlInfo.Address)) { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Error_Address)); return; } switch (urlInfo.Mode) { case UrlMode.CreatePay: if (UrlInfos.Any(x => x.Address.Equals(urlInfo.Address))) { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Address_Existed)); return; } var result = AddressBookService.Default.AddNewAddressBookItem(urlInfo.Address, urlInfo.Tag); if (!result.IsFail) { //UrlInfos.Add(urlInfo); LoadUrls(); } else { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Add_Fail)); } break; case UrlMode.Edit: if (UrlInfos.Any(x => x.Address.Equals(urlInfo.Address) && x.Id != urlInfo.Id)) { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Address_Existed)); return; } var updateResult = AddressBookService.Default.AddNewAddressBookItem(urlInfo.Address, urlInfo.Tag); if (!updateResult.IsFail) { var urlinfo = UrlInfos.FirstOrDefault(x => x.Id == urlInfo.Id); if (urlinfo == null) { UrlInfos.Add(urlInfo); } else { urlinfo.Tag = urlInfo.Tag; urlinfo.Address = urlInfo.Address; } } else { ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Edit_Fail)); } SelectedItem.Address = urlInfo.Address; SelectedItem.Tag = urlInfo.Tag; SelectedItem.Mode = urlInfo.Mode; break; default: break; } }