void UpdateData(WalletForms wf) { var w = wf.Wallet; int i = 0; foreach (var alert in w.Alerts) { string comment = alert.Comment; if (!AllAlerts.ContainsKey(comment)) { AllAlerts.Add(comment, 1); WalletEvents.Add(new WalletEvent() { Timestamp = alert.UntilTimestamp, Comment = comment }); } } foreach (var tx in w.Transactions) { if (!AllTxes.ContainsKey(tx)) { AllTxes.Add(tx, null); var addr = tx.Address; try { decimal amount = tx.Amount; string s; if (amount > 0) { s = $"{amount} {w.CurrencySymbol} received to our "; } else { s = $"{-amount} {w.CurrencySymbol} sent to"; } s += $" address {addr.Value} {addr.Comment} {tx.Comment}"; WalletEvents.Add(new WalletEvent() { Timestamp = tx.Timestamp, Comment = s }); if (++i > 10) { break; } } finally { // Marshal.FinalReleaseComObject(addr); } } } if (wf.FormTransactions != null) { wf.FormTransactions.CtlTxes.UpdateTransactions(); } }
WalletForms SelectedWalletNotNull() { WalletForms r = (WalletForms)LvWallet.SelectedItem; if (r == null) { throw new ApplicationException("No Currency selected in the List"); } return(r); }
private void OnAddressBook(object sender, RoutedEventArgs e) { WalletForms wf = SelectedWallet(); if (wf.FormAddressBook == null) { wf.FormAddressBook = new FormAddressBook(wf); } wf.FormAddressBook.Show(); wf.FormAddressBook.Activate(); }
void AddWalletToList(WalletForms wf) { wf.Wallet.Enabled = true; if (App.CancelPendingTxes) { wf.Wallet.CancelPendingTxes(); } // wf.Wallet.MiningEnabled = wf.MiningEnabled; UpdateData(wf); ActiveWalletForms.Add(wf); // LvWallet.ItemsSource = ActiveWalletForms; }
void ShowTransactions() { WalletForms wf = SelectedWallet(); if (wf.FormTransactions == null) { wf.FormTransactions = new FormTransactions(); wf.FormTransactions.CtlTxes.WalletForms = wf; wf.FormTransactions.CtlTxes.InitLoaded(); } wf.FormTransactions.Show(); wf.FormTransactions.Activate(); }
void ShowTransactions() { WalletForms wf = SelectedWallet(); if (!(wf.FormTransactions is FormTransactions form)) { wf.FormTransactions = form = new FormTransactions(); form.Title = wf.CurrencySymbol + " " + wf.FormTransactions.Title; form.CtlTxes.WalletForms = wf; form.CtlTxes.InitLoaded(); } form.Show(); form.Activate(); }
private void MenuDBMode_Click(object sender, RoutedEventArgs e) { MenuItem mi = (MenuItem)sender; if (!mi.IsChecked) { mi.IsChecked = true; } else { WalletForms wf = SelectedWallet(); wf.Wallet.Mode = (EEngMode)mi.Tag; UserAppRegistryKey.CreateSubKey(wf.Wallet.CurrencySymbol).SetValue("DBMode", ((EEngMode)mi.Tag).ToString()); SetMenuDBMode(); } }
public FormAddressBook(WalletForms wf) { WalletForms = wf; InitializeComponent(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { LvWallet.ItemsSource = ActiveWalletForms; LvEvent.ItemsSource = WalletEvents; var port = UserAppRegistryKey.GetValue("LocalPort"); if (port != null) { try { Eng.LocalPort = Convert.ToUInt16(port); } catch (Exception) { } } Wallet[] wallets = null; try { wallets = Eng.Wallets; } catch (Exception x) { MessageBox.Show(x.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); return; } foreach (var wallet in wallets) { string currencyName = wallet.CurrencyName; var wf = new WalletForms(); wf.Wallet = wallet; MenuItem mi = new MenuItem(); wf.MenuItem = mi; mi.Header = string.Format("{0} ({1})", currencyName, wallet.CurrencySymbol); // mi.Icon = new Image() { Source = new BitmapImage(new Uri(String.Format("images/{0}.ico", currencyName), UriKind.Relative)) }; menuCurrency.Items.Add(mi); mi.IsCheckable = true; mi.Tag = wf; mi.Checked += Currency_CheckChanged; mi.Unchecked += Currency_CheckChanged; m_wallet2forms[wallet] = wf; } timer1.Tick += (s, e1) => { bool b = false; foreach (var wf in ActiveWalletForms) b |= wf.CheckForChanges(); if (b) UpdateView(); }; timer1.Start(); List<WalletForms> ar = new List<WalletForms>(); var obj = UserAppRegistryKey.GetValue("ActiveCurrencies", null); if (obj == null) { ar = (from de in m_wallet2forms select de.Value).Take(2).ToList(); //!!!R foreach (var de in m_wallet2forms) //!!!R ar.Add(de.Value); } else { foreach (var s in (string[])obj) { string[] ss = s.Split(); string name = ss[0]; try { WalletForms wf = null; foreach (var pp in m_wallet2forms) if (pp.Key.CurrencyName == name) { wf = pp.Value; break; } if (wf != null) { wf.MiningEnabled = false; foreach (var subs in ss) { //!!! wf.MiningEnabled |= subs == "Mining"; // CRASH danger when Mining on Start } ar.Add(wf); } } catch (Exception) { } } } foreach (var wf in ar) { try { wf.MenuItem.IsChecked = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Coin", MessageBoxButton.OK, MessageBoxImage.Error); } } m_Loaded = true; UpdateView(); CheckForCommands(); RegisterUriHandler(); // OnFileImport(null, null);//!!!D }
void UpdateData(WalletForms wf) { var w = wf.Wallet; int i = 0; foreach (var alert in w.Alerts) { string comment = alert.Comment; if (!AllAlerts.ContainsKey(comment)) { AllAlerts.Add(comment, 1); WalletEvents.Add(new WalletEvent() { Timestamp = alert.UntilTimestamp, Comment = comment }); } } foreach (var tx in w.Transactions) { if (!AllTxes.ContainsKey(tx)) { AllTxes.Add(tx, null); var addr = tx.Address; try { decimal amount = tx.Amount; string s; if (amount > 0) s = string.Format("{0} {1} received to our ", amount, w.CurrencySymbol); else s = string.Format("{0} {1} sent to", -amount, w.CurrencySymbol); s += string.Format(" address {0} {1} {2}", addr.Value, addr.Comment, tx.Comment); WalletEvents.Add(new WalletEvent() { Timestamp = tx.Timestamp, Comment = s }); if (++i > 10) break; } finally { Marshal.FinalReleaseComObject(addr); } } } if (wf.FormTransactions != null) wf.FormTransactions.UpdateTransactions(); }
void AddWalletToList(WalletForms wf) { wf.Wallet.Enabled = true; if (App.CancelPendingTxes) wf.Wallet.CancelPendingTxes(); wf.Wallet.MiningEnabled = wf.MiningEnabled; UpdateData(wf); ActiveWalletForms.Add(wf); // LvWallet.ItemsSource = ActiveWalletForms; }
private void Window_Loaded(object sender, RoutedEventArgs e) { MenuModeFull.Tag = EEngMode.Bootstrap; MenuModeLite.Tag = EEngMode.Lite; LvWallet.ItemsSource = ActiveWalletForms; LvEvent.ItemsSource = WalletEvents; var port = UserAppRegistryKey.GetValue("LocalPort"); if (port != null) { try { Eng.LocalPort = Convert.ToUInt16(port); } catch (Exception) { } } var proxyType = UserAppRegistryKey.GetValue("ProxyType"); if (proxyType != null) { try { Eng.ProxyString = ToProxyString(Convert.ToString(proxyType), Convert.ToString(UserAppRegistryKey.GetValue("ProxyEndPoint"))); } catch (Exception) { } } if (App.Testnet) { Eng.Testnet = App.Testnet; } Wallet[] wallets = null; try { wallets = Eng.Wallets; } catch (Exception x) { MessageBox.Show(x.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); return; } foreach (var wallet in wallets) { string currencyName = wallet.CurrencyName; var wf = new WalletForms(); wf.Wallet = wallet; MenuItem mi = new MenuItem(); wf.MenuItem = mi; mi.Header = $"{wallet.CurrencySymbol} {currencyName}"; mi.Icon = new Image() { Source = new BitmapImage(new Uri($"images/{Regex.Replace(currencyName, @"-testnet\d?", "")}.ico", UriKind.Relative)) }; menuCurrency.Items.Add(mi); mi.Template = menuTemplate; mi.IsCheckable = true; mi.Tag = wf; mi.Checked += Currency_CheckChanged; mi.Unchecked += Currency_CheckChanged; m_wallet2forms[wallet] = wf; EEngMode mode = EEngMode.Bootstrap; bool bMiningEnabled = false; var sk = UserAppRegistryKey.OpenSubKey(wf.Wallet.CurrencySymbol); if (sk != null) { switch ((string)sk.GetValue("DBMode")) { case "Bootstrap": mode = EEngMode.Bootstrap; break; case "Lite": mode = EEngMode.Lite; break; } try { // bMiningEnabled = (int)sk.GetValue("Mining", 0) != 0; } catch (Exception) { } } wallet.Mode = mode; if (wallet.MiningAllowed) { wallet.MiningEnabled = bMiningEnabled; } } timer1.Tick += (s, e1) => { bool b = false; foreach (var wf in ActiveWalletForms) { b |= wf.CheckForChanges(); } if (b) { UpdateView(); } }; timer1.Start(); List <WalletForms> ar = new List <WalletForms>(); var obj = UserAppRegistryKey.GetValue("ActiveCurrencies", null); if (obj == null) { ar = (from de in m_wallet2forms select de.Value).Take(2).ToList(); //!!!R foreach (var de in m_wallet2forms) //!!!R ar.Add(de.Value); } else { foreach (var name in (string[])obj) { try { WalletForms wf = null; foreach (var pp in m_wallet2forms) { if (pp.Key.CurrencyName == name) { wf = pp.Value; break; } } if (wf != null) { ar.Add(wf); } } catch (Exception) { } } } foreach (var wf in ar) { try { wf.MenuItem.IsChecked = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Coin", MessageBoxButton.OK, MessageBoxImage.Error); } } m_Loaded = true; UpdateView(); CheckForCommands(); if (LvWallet.SelectedItem == null && LvWallet.Items.Count == 1) { LvWallet.SelectedIndex = 0; } // RegisterUriHandler(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { MenuModeNormal.Tag = EEngMode.Normal; MenuModeBootstrap.Tag = EEngMode.Bootstrap; MenuModeLite.Tag = EEngMode.Lite; LvWallet.ItemsSource = ActiveWalletForms; LvEvent.ItemsSource = WalletEvents; var port = UserAppRegistryKey.GetValue("LocalPort"); if (port != null) { try { Eng.LocalPort = Convert.ToUInt16(port); } catch (Exception) { } } var proxyType = UserAppRegistryKey.GetValue("ProxyType"); if (proxyType != null) { try { Eng.ProxyString = ToProxyString(Convert.ToString(proxyType), Convert.ToString(UserAppRegistryKey.GetValue("ProxyEndPoint"))); } catch (Exception) { } } Wallet[] wallets = null; try { wallets = Eng.Wallets; } catch (Exception x) { MessageBox.Show(x.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); return; } foreach (var wallet in wallets) { string currencyName = wallet.CurrencyName; var wf = new WalletForms(); wf.Wallet = wallet; MenuItem mi = new MenuItem(); wf.MenuItem = mi; mi.Header = string.Format("{0} {1}", wallet.CurrencySymbol, currencyName); mi.Icon = new Image() { Source = new BitmapImage(new Uri(String.Format("images/{0}.ico", currencyName), UriKind.Relative)) }; menuCurrency.Items.Add(mi); mi.Template = menuTemplate; mi.IsCheckable = true; mi.Tag = wf; mi.Checked += Currency_CheckChanged; mi.Unchecked += Currency_CheckChanged; m_wallet2forms[wallet] = wf; EEngMode mode = wallet.CurrencySymbol == "BTC" ? EEngMode.Bootstrap : EEngMode.Normal; bool bMiningEnabled = false; var sk = UserAppRegistryKey.OpenSubKey(wf.Wallet.CurrencySymbol); if (sk != null) { switch ((string)sk.GetValue("DBMode")) { case "Normal": mode = EEngMode.Normal; break; case "Bootstrap": mode = EEngMode.Bootstrap; break; case "Lite": mode = EEngMode.Lite; break; } try { // bMiningEnabled = (int)sk.GetValue("Mining", 0) != 0; } catch (Exception) { } } wallet.Mode = mode; if (wallet.MiningAllowed) wallet.MiningEnabled = bMiningEnabled; } timer1.Tick += (s, e1) => { bool b = false; foreach (var wf in ActiveWalletForms) b |= wf.CheckForChanges(); if (b) UpdateView(); }; timer1.Start(); List<WalletForms> ar = new List<WalletForms>(); var obj = UserAppRegistryKey.GetValue("ActiveCurrencies", null); if (obj == null) { ar = (from de in m_wallet2forms select de.Value).Take(2).ToList(); //!!!R foreach (var de in m_wallet2forms) //!!!R ar.Add(de.Value); } else { foreach (var s in (string[])obj) { string[] ss = s.Split(); string name = ss[0]; try { WalletForms wf = null; foreach (var pp in m_wallet2forms) if (pp.Key.CurrencyName == name) { wf = pp.Value; break; } if (wf != null) { ar.Add(wf); } } catch (Exception) { } } } foreach (var wf in ar) { try { wf.MenuItem.IsChecked = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Coin", MessageBoxButton.OK, MessageBoxImage.Error); } } m_Loaded = true; UpdateView(); CheckForCommands(); // RegisterUriHandler(); }