Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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"); };
        }
Exemplo n.º 3
0
        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"); };
        }
Exemplo n.º 4
0
        void OnDelete()
        {
            var removeItem = SelectedItem;

            if (SelectedItem == null)
            {
                removeItem = UrlInfos.FirstOrDefault();
            }

            var result = AddressBookService.Default.GetAddressBookItemByAddress(removeItem.Address);

            if (result.IsFail)
            {
                ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Delete_Fail));
                return;
            }

            var deleteResult = AddressBookService.Default.DeleteAddressBookByIds(result.Value.Id);

            if (deleteResult.IsFail)
            {
                ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Delete_Fail));
                return;
            }

            UrlInfos.Remove(removeItem);
        }
Exemplo n.º 5
0
 void LoadUrls()
 {
     PayAddressBookMonitor.Default.MonitorCallBack += books => {
         Application.Current.Dispatcher.Invoke(() =>
         {
             PayAddressBookMonitor.Default.Stop();
             UrlInfos.Clear();
             books.ForEach(x =>
             {
                 UrlInfos.Add(new UrlInfo(x));
             });
         });
     };
 }
Exemplo n.º 6
0
 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
             }));
         });
     };
 }
Exemplo n.º 7
0
        void Export()
        {
            if (UrlInfos == null || !UrlInfos.Any())
            {
                return;
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "CSV£¨*.csv£©|*.csv";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = true;
            var result = saveFileDialog.ShowDialog(BootStrapService.Default.Shell.GetWindow());

            if (result.HasValue && result.Value)
            {
                try
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    var           header        = string.Format("{0},{1}", LanguageService.Default.GetLanguageValue("Tag"), LanguageService.Default.GetLanguageValue("Address"));
                    stringBuilder.AppendLine(header);
                    UrlInfos.ToList().ForEach(x =>
                    {
                        var newline = string.Format("{0},{1}", x.Tag, x.Address);
                        stringBuilder.AppendLine(newline);
                    });


                    var file = saveFileDialog.FileName;
                    using (Stream stream = File.Create(file))
                    {
                        using (var writer = new StreamWriter(stream, Encoding.Unicode))
                        {
                            var data = stringBuilder.ToString().Replace(",", "\t");
                            writer.Write(data);
                            writer.Close();
                        }
                        stream.Close();
                    }
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Export_Sucesses));
                }
                catch
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Export_Fail));
                }
            }
        }
Exemplo n.º 8
0
        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"); };
        }
Exemplo n.º 9
0
        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;
            }
        }
Exemplo n.º 10
0
        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;
            }
        }