protected void list_ItemCreated(object sender, RepeaterItemEventArgs e) { APLocatorLogView log = e.Item.DataItem as APLocatorLogView; if (log != null) { Anchor apName = e.Item.FindControl("apName") as Anchor; apName.Text = string.Format("{0}[{1}]", log.APName, log.APMac); //apName.Href = PathUtil.ResolveUrl("Objects/Tag.aspx?id=" + log.TagId); Anchor apStatus = e.Item.FindControl("apStatus") as Anchor; if (log.APLocatorStatus == 1) { apStatus.Text = "重现"; } else if (log.APLocatorStatus == 0) { apStatus.Text = "消失"; } DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel; writeTime.DisplayValue = log.WriteTime; SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; facilityName.Text = log.FacilityName; SmartLabel coordinatesName = e.Item.FindControl("coordinatesName") as SmartLabel; coordinatesName.Text = log.CoordinatesName; } }
public HdPubKey GetNextReceiveKey(SmartLabel label, out bool minGapLimitIncreased) { if (label.IsEmpty) { throw new InvalidOperationException("Observers are required."); } minGapLimitIncreased = false; AssertCleanKeysIndexed(isInternal: false); // Find the next clean external key with empty label. var newKey = GetKeys(x => x.IsInternal == false && x.KeyState == KeyState.Clean && x.Label.IsEmpty).FirstOrDefault(); // If not found, generate a new. if (newKey is null) { SetMinGapLimit(MinGapLimit.Value + 1); newKey = AssertCleanKeysIndexed(isInternal: false).First(); // If the new is over the MinGapLimit, set minGapLimitIncreased to true. minGapLimitIncreased = true; } newKey.SetLabel(label, kmToFile: this); return(newKey); }
public HdPubKey(PubKey pubKey, KeyPath fullKeyPath, SmartLabel label, KeyState keyState) { PubKey = Guard.NotNull(nameof(pubKey), pubKey); FullKeyPath = Guard.NotNull(nameof(fullKeyPath), fullKeyPath); _cluster = new Cluster(this); Label = label; Cluster.UpdateLabels(); KeyState = keyState; P2pkScript = PubKey.ScriptPubKey; P2pkhScript = PubKey.Hash.ScriptPubKey; P2wpkhScript = PubKey.WitHash.ScriptPubKey; P2shOverP2wpkhScript = P2wpkhScript.Hash.ScriptPubKey; PubKeyHash = PubKey.Hash; HashCode = PubKeyHash.GetHashCode(); Index = (int)FullKeyPath.Indexes[4]; NonHardenedKeyPath = new KeyPath(FullKeyPath[3], FullKeyPath[4]); int change = (int)FullKeyPath.Indexes[3]; if (change == 0) { IsInternal = false; } else if (change == 1) { IsInternal = true; } else { throw new ArgumentException(nameof(FullKeyPath)); } }
public ReceiveTabViewModel(Wallet wallet) : base("Receive") { Global = Locator.Current.GetService <Global>(); Wallet = wallet; LabelSuggestion = new SuggestLabelViewModel(Wallet); _addresses = new ObservableCollection <AddressViewModel>(); LabelSuggestion.Label = ""; InitializeAddresses(); GenerateCommand = ReactiveCommand.Create(() => { var label = new SmartLabel(LabelSuggestion.Label); LabelSuggestion.Label = label; if (label.IsEmpty) { NotificationHelpers.Warning("Observers are required."); return; } AvaloniaThreadingExtensions.PostLogException(Dispatcher.UIThread, () => { var newKey = Wallet.KeyManager.GetNextReceiveKey(label, out bool minGapLimitIncreased); if (minGapLimitIncreased) { int minGapLimit = Wallet.KeyManager.MinGapLimit.Value; int prevMinGapLimit = minGapLimit - 1; NotificationHelpers.Warning($"{nameof(KeyManager.MinGapLimit)} increased from {prevMinGapLimit} to {minGapLimit}."); } var newAddress = new AddressViewModel(newKey, Wallet.KeyManager, this); Addresses.Insert(0, newAddress); SelectedAddress = newAddress; LabelSuggestion.Label = ""; }); }); this.WhenAnyValue(x => x.SelectedAddress) .Subscribe(async address => { if (Global.UiConfig.Autocopy is false || address is null) { return; } await address.TryCopyToClipboardAsync(); }); Observable .Merge(GenerateCommand.ThrownExceptions) .ObserveOn(RxApp.TaskpoolScheduler) .Subscribe(ex => { Logger.LogError(ex); NotificationHelpers.Error(ex.ToUserFriendlyString()); }); }
public static void AddPocket(this List <Pocket> pockets, decimal amount, out Pocket pocket, params string[] labels) { var label = new SmartLabel(labels); var coinsView = new CoinsView(new[] { BitcoinFactory.CreateSmartCoin(NewKey(label), amount) }); pocket = new Pocket((label, coinsView)); pockets.Add(pocket); }
protected void userRepeater_ItemCreated(object sender, RepeaterItemEventArgs e) { User user = e.Item.DataItem as User; if (user != null) { SmartLabel userName = (SmartLabel)e.Item.FindControl("userName"); userName.Text = user.UserName; userName.Attributes.Add("id", "user_" + user.Id); SmartLabel userRole = (SmartLabel)e.Item.FindControl("userRole"); switch ((UserRole)user.Role) { default: case UserRole.User: userRole.Text = "普通用户"; break; case UserRole.Admin: userRole.Text = "管理员"; break; } Anchor edit = (Anchor)e.Item.FindControl("edit"); Anchor delete = (Anchor)e.Item.FindControl("delete"); switch (meRole) { default: case UserRole.User: //编辑 edit.CssClass = "t3"; //删除 delete.CssClass = "t3"; break; case UserRole.Admin: //编辑 if (user.Id == me.Id) { edit.CssClass = "t3"; } else { edit.Href = "EditUser.aspx?id=" + user.Id; } //删除 if (user.Id == me.Id) { delete.CssClass = "t3"; } else { delete.Href = "javascript:deleteUser(" + user.Id + ");"; } break; } } }
protected void list_ItemCreated(object sender, RepeaterItemEventArgs e) { //AreaEventLogView log = e.Item.DataItem as AreaEventLogView; //---add by tan 2009-10-6---// DataRowView log = (DataRowView)e.Item.DataItem; if (log != null) { Anchor tagName = e.Item.FindControl("tagName") as Anchor; SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; SmartLabel areaName = e.Item.FindControl("areaName") as SmartLabel; SmartLabel areaEventType = e.Item.FindControl("areaEventType") as SmartLabel; DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel; tagName.Text = LocatingMonitorUtils.GetHostName(log["TagName"].ToString(), log["TagMac"].ToString(), log["HostName"].ToString()); HostTagGroupStatus hostTagGroupStatus = HostTagGroupStatus.SelectByHostId((int)log["HostId"]); if (hostTagGroupStatus != null) { int groupId = hostTagGroupStatus.HostGroupId; tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}", log["HostId"], groupId)); } else { } facilityName.Text = Convert.ToString(log["FacilityName"]); areaName.Text = Convert.ToString(log["AreaName"]); if (Convert.ToInt32(log["AreaEventType"]) == 0) { areaEventType.Text = "进入区域"; } else { areaEventType.Text = "离开区域"; } writeTime.DisplayValue = Convert.ToDateTime(log["WriteTime"]); } //----------------------------------// /* * Anchor tagName = e.Item.FindControl("tagName") as Anchor; * SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; * SmartLabel areaName = e.Item.FindControl("areaName") as SmartLabel; * SmartLabel areaEventType = e.Item.FindControl("areaEventType") as SmartLabel; * DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel; * * tagName.Text = log.TagName; * tagName.Href = PathUtil.ResolveUrl("Objects/Tag.aspx?id=" + log.TagId); * facilityName.Text = log.FacilityName; * areaName.Text = log.AreaName; * areaEventType.Text = (AreaEventType)log.AreaEventType == AreaEventType.StayInside ? "进入区域" : "离开区域"; * writeTime.DisplayValue = log.WriteTime; */ }
public void LabelParsingTests() { var label = new SmartLabel(); Assert.Equal("", label); label = new SmartLabel(""); Assert.Equal("", label); label = new SmartLabel(null !); Assert.Equal("", label); label = new SmartLabel(null !, null !); Assert.Equal("", label); label = new SmartLabel(" "); Assert.Equal("", label); label = new SmartLabel(","); Assert.Equal("", label); label = new SmartLabel(":"); Assert.Equal("", label); label = new SmartLabel("foo"); Assert.Equal("foo", label); label = new SmartLabel("foo", "bar"); Assert.Equal("bar, foo", label); label = new SmartLabel("foo bar"); Assert.Equal("foo bar", label); label = new SmartLabel("foo bar", "Buz quX@"); Assert.Equal("Buz quX@, foo bar", label); label = new SmartLabel(new List <string>() { "foo", "bar" }); Assert.Equal("bar, foo", label); label = new SmartLabel(" foo "); Assert.Equal("foo", label); label = new SmartLabel("foo ", " bar"); Assert.Equal("bar, foo", label); label = new SmartLabel(new List <string>() { " foo ", " bar " }); Assert.Equal("bar, foo", label); label = new SmartLabel(new List <string>() { "foo:", ":bar", null !, ":buz:", ",", ": , :", "qux:quux", "corge,grault", "", " ", " , garply, waldo,", " : , : , fred , : , : plugh, : , : ," });
protected void list_ItemCreated(object sender, RepeaterItemEventArgs e) { AreaInOutTime areaTime = (AreaInOutTime)e.Item.DataItem; if (areaTime != null) { Img icon = e.Item.FindControl("icon") as Img; Anchor tagName = e.Item.FindControl("tagName") as Anchor; DateTimeLabel inTime = e.Item.FindControl("inTime") as DateTimeLabel; DateTimeLabel outTime = e.Item.FindControl("outTime") as DateTimeLabel; SmartLabel duration = e.Item.FindControl("duration") as SmartLabel; tagName.Text = Convert.ToString(areaTime.hostName); if (areaTime.inTime != DateTime.MinValue) { inTime.DisplayValue = areaTime.inTime; } if (areaTime.outTime != DateTime.MinValue) { outTime.DisplayValue = areaTime.outTime; } duration.Text = ""; if (tagName.Text == "--- ---") { duration.Text = "("; } if (areaTime.stayTime.Ticks == 0) { duration.Text += "0"; } else { if (areaTime.stayTime.Days > 0) { duration.Text += areaTime.stayTime.Days.ToString() + "天"; } if (areaTime.stayTime.Hours > 0) { duration.Text += areaTime.stayTime.Hours.ToString() + "时"; } if (areaTime.stayTime.Minutes > 0) { duration.Text += areaTime.stayTime.Minutes.ToString() + "分"; } if (areaTime.stayTime.Seconds > 0) { duration.Text += areaTime.stayTime.Seconds.ToString() + "秒"; } } if (tagName.Text == "--- ---") { duration.Text += ")"; } } }
public Pocket[] AutoSelectPockets(SmartLabel recipient) { var knownPockets = NonPrivatePockets.Where(x => x.Labels != CoinPocketHelper.UnlabelledFundsText).ToArray(); var unknownPockets = NonPrivatePockets.Except(knownPockets).ToArray(); var privateAndUnknownPockets = _allPockets.Except(knownPockets).ToArray(); var privateAndKnownPockets = _allPockets.Except(unknownPockets).ToArray(); var knownByRecipientPockets = knownPockets.Where(pocket => pocket.Labels.Any(label => recipient.Contains(label, StringComparer.OrdinalIgnoreCase))).ToArray(); var onlyKnownByRecipientPockets = knownByRecipientPockets .Where(pocket => pocket.Labels.Count() == recipient.Count() && pocket.Labels.All(label => recipient.Contains(label, StringComparer.OrdinalIgnoreCase))) .ToArray(); if (onlyKnownByRecipientPockets.Sum(x => x.Amount) >= _targetAmount) { return(onlyKnownByRecipientPockets); } if (_privatePocket.Amount >= _targetAmount) { return(new[] { _privatePocket }); } if (TryGetBestKnownByRecipientPockets(knownByRecipientPockets, _targetAmount, recipient, out var pockets)) { return(pockets); } if (knownPockets.Sum(x => x.Amount) >= _targetAmount) { return(knownPockets); } if (unknownPockets.Sum(x => x.Amount) >= _targetAmount) { return(unknownPockets); } if (NonPrivatePockets.Sum(x => x.Amount) >= _targetAmount) { return(NonPrivatePockets); } if (privateAndKnownPockets.Sum(x => x.Amount) >= _targetAmount) { return(privateAndKnownPockets); } if (privateAndUnknownPockets.Sum(x => x.Amount) >= _targetAmount) { return(privateAndUnknownPockets); } return(_allPockets.ToArray()); }
public ConfirmHideAddressViewModel(SmartLabel label) { Label = label; _title = "Hide Address"; NextCommand = ReactiveCommand.Create(() => Close(result: true)); CancelCommand = ReactiveCommand.Create(() => Close(DialogResultKind.Cancel)); SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: true); }
public HdPubKey GenerateNewKey(SmartLabel label, KeyState keyState, bool isInternal, bool toFile = true) { // BIP44-ish derivation scheme // m / purpose' / coin_type' / account' / change / address_index var change = isInternal ? 1 : 0; lock (HdPubKeysLock) { HdPubKey[] relevantHdPubKeys = HdPubKeys.Where(x => x.IsInternal == isInternal).ToArray(); KeyPath path = new KeyPath($"{change}/0"); if (relevantHdPubKeys.Any()) { int largestIndex = relevantHdPubKeys.Max(x => x.Index); var smallestMissingIndex = largestIndex; var present = new bool[largestIndex + 1]; for (int i = 0; i < relevantHdPubKeys.Length; ++i) { present[relevantHdPubKeys[i].Index] = true; } for (int i = 1; i < present.Length; ++i) { if (!present[i]) { smallestMissingIndex = i - 1; break; } } path = relevantHdPubKeys[smallestMissingIndex].NonHardenedKeyPath.Increment(); } var fullPath = AccountKeyPath.Derive(path); var pubKey = ExtPubKey.Derive(path).PubKey; var hdPubKey = new HdPubKey(pubKey, fullPath, label, keyState); HdPubKeys.Add(hdPubKey); lock (HdPubKeyScriptBytesLock) { HdPubKeyScriptBytes.Add(hdPubKey.P2wpkhScript.ToCompressedBytes()); } lock (ScriptHdPubKeyMapLock) { ScriptHdPubKeyMap.Add(hdPubKey.P2wpkhScript, hdPubKey); } if (toFile) { ToFile(); } return(hdPubKey); } }
public HdPubKey GenerateNewKey(SmartLabel label, KeyState keyState, bool isInternal, bool toFile = true) { // BIP44-ish derivation scheme // m / purpose' / coin_type' / account' / change / address_index var change = isInternal ? 1 : 0; lock (HdPubKeysLock) { IEnumerable <HdPubKey> relevantHdPubKeys = isInternal ? HdPubKeys.Where(x => x.IsInternal) : HdPubKeys.Where(x => !x.IsInternal); KeyPath path; if (relevantHdPubKeys.Any()) { int largestIndex = relevantHdPubKeys.Max(x => x.Index); List <int> missingIndexes = Enumerable.Range(0, largestIndex).Except(relevantHdPubKeys.Select(x => x.Index)).ToList(); if (missingIndexes.Any()) { int smallestMissingIndex = missingIndexes.Min(); path = relevantHdPubKeys.First(x => x.Index == (smallestMissingIndex - 1)).NonHardenedKeyPath.Increment(); } else { path = relevantHdPubKeys.First(x => x.Index == largestIndex).NonHardenedKeyPath.Increment(); } } else { path = new KeyPath($"{change}/0"); } var fullPath = AccountKeyPath.Derive(path); var pubKey = ExtPubKey.Derive(path).PubKey; var hdPubKey = new HdPubKey(pubKey, fullPath, label, keyState); HdPubKeys.Add(hdPubKey); lock (HdPubKeyScriptBytesLock) { HdPubKeyScriptBytes.Add(hdPubKey.P2wpkhScript.ToCompressedBytes()); } lock (ScriptHdPubKeyMapLock) { ScriptHdPubKeyMap.Add(hdPubKey.P2wpkhScript, hdPubKey); } if (toFile) { ToFile(); } return(hdPubKey); } }
public void SetLabel(SmartLabel label, KeyManager kmToFile = null) { label ??= SmartLabel.Empty; if (Label == label) { return; } Label = label; kmToFile?.ToFile(); }
public AddressLabelEditViewModel(ReceiveAddressesViewModel owner, HdPubKey hdPubKey, KeyManager keyManager, HashSet <string> suggestions) { Suggestions = suggestions; _labels = new(hdPubKey.Label); SetupCancel(enableCancel: true, enableCancelOnEscape: true, enableCancelOnPressed: true); Labels .WhenAnyValue(x => x.Count) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => FinalLabel = new SmartLabel(Labels)); var canExecute = this.WhenAnyValue(x => x.FinalLabel).Select(x => x is { IsEmpty: false });
public static SmartTransaction FromLine(string line, Network expectedNetwork) { line = Guard.NotNullOrEmptyOrWhitespace(nameof(line), line, trim: true); expectedNetwork = Guard.NotNull(nameof(expectedNetwork), expectedNetwork); var parts = line.Split(':', StringSplitOptions.None).Select(x => x.Trim()).ToArray(); var transactionString = parts[1]; Transaction transaction = Transaction.Parse(transactionString, expectedNetwork); try { // First is redundant txhash serialization. var heightString = parts[2]; var blockHashString = parts[3]; var blockIndexString = parts[4]; var labelString = parts[5]; var firstSeenString = parts[6]; var isReplacementString = parts[7]; if (!Height.TryParse(heightString, out Height height)) { height = Height.Unknown; } if (!uint256.TryParse(blockHashString, out uint256 blockHash)) { blockHash = null; } if (!int.TryParse(blockIndexString, out int blockIndex)) { blockIndex = 0; } var label = new SmartLabel(labelString); DateTimeOffset firstSeen = default; if (long.TryParse(firstSeenString, out long unixSeconds)) { firstSeen = DateTimeOffset.FromUnixTimeSeconds(unixSeconds); } if (!bool.TryParse(isReplacementString, out bool isReplacement)) { isReplacement = false; } return(new SmartTransaction(transaction, height, blockHash, blockIndex, label, isReplacement, firstSeen)); } catch (Exception ex) { Logger.LogDebug(ex); return(new SmartTransaction(transaction, Height.Unknown)); } }
protected void messageRepeater_ItemCreated(object sender, RepeaterItemEventArgs e) { DBViewTagAlert ev = e.Item.DataItem as DBViewTagAlert; if (ev != null) { SmartLabel isResolved = (SmartLabel)e.Item.FindControl("isResolved"); if (ev.AlertStatus != (byte)AlertStatusType.New) { isResolved.Text = "√"; } else { isResolved.Text = "<input type='checkbox' name='selection' value='" + ev.AlertId + "' />"; } Img icon = e.Item.FindControl("icon") as Img; HostTagGroupStatus hostTagGroupStatus = HostTagGroupStatus.SelectByHostId((int)ev.HostId); int groupId = hostTagGroupStatus.HostGroupId; icon.Src = CommonExtension.IdentityIconByGroupId(groupId); Anchor tagName = (Anchor)e.Item.FindControl("tagName"); tagName.Text = ev.HostName; tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}", ev.HostId, groupId)); SmartLabel facilityName = (SmartLabel)e.Item.FindControl("facilityName"); facilityName.Text = ev.FacilityName; SmartLabel coordinatesName = (SmartLabel)e.Item.FindControl("coordinatesName"); coordinatesName.Text = ev.CoordinatesName; SmartLabel eventType = (SmartLabel)e.Item.FindControl("eventType"); eventType.Text = CommonExtension.GetEventDescription((SupportEvent)ev.AlertType, ev.HostId.Value); SmartLabel alertStatus = (SmartLabel)e.Item.FindControl("alertStatus"); alertStatus.Text = Misc.GetAlertStatus((AlertStatusType)ev.AlertStatus); DateTimeLabel lastHappenTime = (DateTimeLabel)e.Item.FindControl("lastHappenTime"); lastHappenTime.DisplayValue = ev.WriteTime; Anchor alertDetail = (Anchor)e.Item.FindControl("alertDetail"); alertDetail.Text = "详情"; alertDetail.Href = PathUtil.ResolveUrl("/Monitor/TagAlertProcess.aspx?id=" + ev.AlertId); if (ev.AlertStatus == (byte)ResolveFlag.Processed) { HtmlTableRow tr = (HtmlTableRow)e.Item.FindControl("tr"); tr.Attributes["class"] = "t3"; tagName.CssClass = "t3"; } } }
public ReceiveTabViewModel(WalletViewModel walletViewModel) : base("Receive", walletViewModel) { _labelSuggestion = new SuggestLabelViewModel(Global); _addresses = new ObservableCollection <AddressViewModel>(); _labelSuggestion.Label = ""; InitializeAddresses(); GenerateCommand = ReactiveCommand.Create(() => { var label = new SmartLabel(_labelSuggestion.Label); _labelSuggestion.Label = label; if (label.IsEmpty) { NotificationHelpers.Warning("Label is required."); return; } Dispatcher.UIThread.PostLogException(() => { HdPubKey newKey = Global.WalletService.GetReceiveKey(_labelSuggestion.Label, Addresses.Select(x => x.Model).Take(7)); // Never touch the first 7 keys. AddressViewModel found = Addresses.FirstOrDefault(x => x.Model == newKey); if (found != default) { Addresses.Remove(found); } var newAddress = new AddressViewModel(newKey, Global); Addresses.Insert(0, newAddress); SelectedAddress = newAddress; _labelSuggestion.Label = ""; }); }); this.WhenAnyValue(x => x.SelectedAddress).Subscribe(async address => { if (Global.UiConfig?.Autocopy is false || address is null) { return; } await address.TryCopyToClipboardAsync(); }); var isCoinListItemSelected = this.WhenAnyValue(x => x.SelectedAddress).Select(coin => coin is { });
private static SmartCoin Coin(string label, HdPubKey pubKey, decimal amount, bool confirmed = true, int anonymitySet = 1) { var randomIndex = new Func <int>(() => new Random().Next(0, 200)); var height = confirmed ? new Height(randomIndex()) : Height.Mempool; SmartLabel slabel = label; var spentOutput = new[] { new OutPoint(RandomUtils.GetUInt256(), (uint)randomIndex()) }; pubKey.SetLabel(slabel); pubKey.SetKeyState(KeyState.Used); return(new SmartCoin(RandomUtils.GetUInt256(), (uint)randomIndex(), pubKey.P2wpkhScript, Money.Coins(amount), spentOutput, height, false, anonymitySet, slabel, pubKey: pubKey)); }
public LabelViewModel[] GetAssociatedLabels(LabelViewModel labelViewModel) { if (labelViewModel.IsBlackListed) { var associatedPocketLabels = NonPrivatePockets.OrderBy(x => x.Labels.Count()).First(x => x.Labels.Contains(labelViewModel.Value)).Labels; return(LabelsBlackList.Where(x => associatedPocketLabels.Contains(x.Value)).ToArray()); } else { var associatedPockets = NonPrivatePockets.Where(x => x.Labels.Contains(labelViewModel.Value)); var notAssociatedPockets = NonPrivatePockets.Except(associatedPockets); var allNotAssociatedLabels = SmartLabel.Merge(notAssociatedPockets.Select(x => x.Labels)); return(LabelsWhiteList.Where(x => !allNotAssociatedLabels.Contains(x.Value)).ToArray()); } }
protected void list_ItemCreated(object sender, RepeaterItemEventArgs e) { DataRowView log = (DataRowView)e.Item.DataItem; if (log != null) { Anchor tagName = e.Item.FindControl("tagName") as Anchor; //tagName.Text = LocatingMonitorUtils.GetHostName(log["TagName"].ToString(), log["TagMac"].ToString(), log["HostName"].ToString()); tagName.Text = Convert.ToString(log["HostName"]); HostTagGroupStatus hostTagGroupStatus = HostTagGroupStatus.SelectByHostId((int)log["HostId"]); if (hostTagGroupStatus != null) { int groupId = hostTagGroupStatus.HostGroupId; tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}", log["HostId"], groupId)); } else { } DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel; writeTime.DisplayValue = Convert.ToDateTime(log["WriteTime"]); SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; SmartLabel coordinatesName = e.Item.FindControl("coordinatesName") as SmartLabel; facilityName.Text = Convert.ToString(log["FacilityName"]); coordinatesName.Text = Convert.ToString(log["CoordinatesName"]); } /////////////////////////////////////////////////////////////////////// /* * GenericEventLogView log = e.Item.DataItem as GenericEventLogView; * if (log != null) { * Anchor tagName = e.Item.FindControl("tagName") as Anchor; * tagName.Text = LocatingMonitorUtils.GetHostName(log.TagName, log.HostName); * tagName.Href = PathUtil.ResolveUrl("Objects/Tag.aspx?id=" + log.TagId); * * DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel; * writeTime.DisplayValue = log.WriteTime; * * SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; * facilityName.Text = log.FacilityName; * * SmartLabel coordinatesName = e.Item.FindControl("coordinatesName") as SmartLabel; * coordinatesName.Text = log.CoordinatesName; * } */ }
protected void areaList_ItemCreated(object sender, RepeaterItemEventArgs e) { MapArea area = e.Item.DataItem as MapArea; if (area != null) { Anchor areaName = (Anchor)e.Item.FindControl("areaName"); SmartLabel facilityName = (SmartLabel)e.Item.FindControl("facilityName"); //NumericLabel ruleCount = (NumericLabel)e.Item.FindControl("ruleCount"); Anchor setRule = (Anchor)e.Item.FindControl("setRule"); areaName.Text = area.AreaName; facilityName.Text = Facility.GetNameByMapId(area.MapId); areaName.Href = setRule.Href = "MapAreaRules.aspx?AreaId=" + area.Id; } }
public ReceiveTabViewModel(WalletViewModel walletViewModel) : base("Receive", walletViewModel) { _labelSuggestion = new SuggestLabelViewModel(Global); _addresses = new ObservableCollection <AddressViewModel>(); _labelSuggestion.Label = ""; InitializeAddresses(); GenerateCommand = ReactiveCommand.Create(() => { var label = new SmartLabel(_labelSuggestion.Label); _labelSuggestion.Label = label; if (label.IsEmpty) { NotificationHelpers.Warning("Label is required."); return; } AvaloniaThreadingExtensions.PostLogException(Dispatcher.UIThread, () => { var newKey = KeyManager.GetNextReceiveKey(label, out bool minGapLimitIncreased); if (minGapLimitIncreased) { int minGapLimit = KeyManager.MinGapLimit.Value; int prevMinGapLimit = minGapLimit - 1; NotificationHelpers.Warning($"{nameof(KeyManager.MinGapLimit)} increased from {prevMinGapLimit} to {minGapLimit}."); } var newAddress = new AddressViewModel(newKey, Global); Addresses.Insert(0, newAddress); SelectedAddress = newAddress; _labelSuggestion.Label = ""; }); }); this.WhenAnyValue(x => x.SelectedAddress).Subscribe(async address => { if (Global.UiConfig?.Autocopy is false || address is null) { return; } await address.TryCopyToClipboardAsync(); }); var isCoinListItemSelected = this.WhenAnyValue(x => x.SelectedAddress).Select(coin => coin is { });
public TransactionPreviewViewModel(Wallet wallet, TransactionInfo info, BuildTransactionResult transaction) { _wallet = wallet; _labels = SmartLabel.Empty; _info = info; SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: false); EnableBack = true; _confirmationTimeText = ""; var destinationAmount = transaction.CalculateDestinationAmount().ToDecimal(MoneyUnit.BTC); var btcAmountText = $"{destinationAmount} bitcoins "; var fiatAmountText = destinationAmount.GenerateFiatText(_wallet.Synchronizer.UsdExchangeRate, "USD"); AmountText = $"{btcAmountText}{fiatAmountText}"; AddressText = info.Address.ToString(); var fee = transaction.Fee; var btcFeeText = $"{fee.ToDecimal(MoneyUnit.Satoshi)} sats "; var fiatFeeText = fee.ToDecimal(MoneyUnit.BTC).GenerateFiatText(_wallet.Synchronizer.UsdExchangeRate, "USD"); FeeText = $"{btcFeeText}{fiatFeeText}"; PayJoinUrl = info.PayJoinClient?.PaymentUrl.AbsoluteUri; IsPayJoin = PayJoinUrl is not null; if (PreferPsbtWorkflow) { SkipCommand = ReactiveCommand.CreateFromTask(async() => await OnConfirmAsync(transaction)); NextCommand = ReactiveCommand.CreateFromTask(async() => { var saved = await TransactionHelpers.ExportTransactionToBinaryAsync(transaction); if (saved) { Navigate().To(new SuccessViewModel("The PSBT has been successfully created.")); } }); _nextButtonText = "Save PSBT file"; } else { NextCommand = ReactiveCommand.CreateFromTask(async() => await OnConfirmAsync(transaction)); _nextButtonText = "Confirm"; } }
public AddressViewModel(ReceiveAddressesViewModel parent, Wallet wallet, HdPubKey model, Network network) { _address = model.GetP2wpkhAddress(network).ToString(); _label = model.Label; CopyAddressCommand = ReactiveCommand.CreateFromTask(async() => await Application.Current.Clipboard.SetTextAsync(Address)); HideAddressCommand = ReactiveCommand.CreateFromTask(async() => await parent.HideAddressAsync(model, Address)); EditLabelCommand = ReactiveCommand.Create(() => parent.NavigateToAddressEdit(model, parent.Wallet.KeyManager)); NavigateCommand = ReactiveCommand.Create(() => { parent.Navigate().To(new ReceiveAddressViewModel(wallet, model)); }); }
protected void list_ItemCreated(object sender, RepeaterItemEventArgs e) { DataRowView log = (DataRowView)e.Item.DataItem; if (log != null) { Anchor tagName = e.Item.FindControl("tagName") as Anchor; tagName.Text = LocatingMonitorUtils.GetHostName(log["TagName"].ToString(), log["TagMac"].ToString(), log["HostName"].ToString()); tagName.Href = PathUtil.ResolveUrl("Objects/Tag.aspx?id=" + Convert.ToString(log["TagID"])); DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel; writeTime.DisplayValue = Convert.ToDateTime(log["WriteTime"]); SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; SmartLabel coordinatesName = e.Item.FindControl("coordinatesName") as SmartLabel; facilityName.Text = Convert.ToString(log["FacilityName"]); coordinatesName.Text = Convert.ToString(log["CoordinatesName"]); } }
private bool TryParseUrl(string text) { bool result = false; var wallet = _owner.Wallet; if (AddressStringParser.TryParse(text, wallet.Network, out BitcoinUrlBuilder? url)) { result = true; SmartLabel label = url.Label; if (!label.IsEmpty) { //LabelSuggestion.Label = label; } if (url.Address is { })
public void SetUsedLabel(IEnumerable <SmartCoin>?usedCoins, int privateThreshold) { if (usedCoins is null) { return; } var usedLabels = SmartLabel.Merge(usedCoins.Select(x => x.GetLabels(privateThreshold))); var usedLabelViewModels = AllLabelsViewModel.Where(x => usedLabels.Contains(x.Value)).ToArray(); var notUsedLabelViewModels = AllLabelsViewModel.Except(usedLabelViewModels); foreach (LabelViewModel label in notUsedLabelViewModels) { label.Swap(); } OnSelectionChanged(); }
protected void list_ItemCreated(object sender, RepeaterItemEventArgs e) { Facility f = (Facility)e.Item.DataItem; SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; SmartLabel headCount = e.Item.FindControl("headCount") as SmartLabel; facilityName.Text = f.FacilityName; IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; //GTang 20101122 修改为统计hostGroupid=1,2 //int[] _hostGroupArray = new int[1] { 1 }; int[] _hostGroupArray = new int[2] { 1, 2 }; int totalCount = 0; IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null && LocatingServiceUtil.IsAvailable()) { TagStatusView tagStatusView = new TagStatusView(); tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, f.MapId, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 0,//only get total count 0, out totalCount); headCount.Text = totalCount.ToString(); _totalCount += totalCount; } }
/// <summary> /// Update the transaction with the data acquired from another transaction. (For example merge their labels.) /// </summary> public bool TryUpdate(SmartTransaction tx) { var updated = false; // If this is not the same tx, then don't update. if (this != tx) { throw new InvalidOperationException($"{GetHash()} != {tx.GetHash()}"); } // Set the height related properties, only if confirmed. if (tx.Confirmed) { if (Height != tx.Height) { Height = tx.Height; updated = true; } if (tx.BlockHash != null && BlockHash != tx.BlockHash) { BlockHash = tx.BlockHash; BlockIndex = tx.BlockIndex; updated = true; } } // Always the earlier seen is the firstSeen. if (tx.FirstSeen < FirstSeen) { FirstSeen = tx.FirstSeen; updated = true; } // Merge labels. if (Label != tx.Label) { Label = SmartLabel.Merge(Label, tx.Label); updated = true; } return(updated); }
public SmartLabelSettingsWrapper(SmartLabel label) { Alignment = label.Alignment; AllowMarkerOverlap = label.AllowMarkerOverlap; AutoWrap = label.AutoWrap; Color = new ColorSettingsWrapper(label.Color); DistanceMaximum = label.DistanceMaximum; DynamicDisplay = label.DynamicDisplay; DynamicPosition = label.DynamicPosition; Font = new FontSettingsWrapper(label.Font); ForceVertical = label.ForceVertical; GlowColor = label.GlowColor; Hotspot = new HotspotSettingsWrapper(label.Hotspot); Line = new LineSettingsWrapper(label.Line); LineAlignment = label.LineAlignment; OutlineColor = label.OutlineColor; Padding = label.Padding; PieLabelMode = label.PieLabelMode; RadarLabelMode = label.RadarLabelMode; Shadow = new ShadowSettingsWrapper(label.Shadow); Text = label.Text; Truncation = new TruncationSettingsWrapper(label.Truncation); Type = label.Type; }
/// <summary> /// Восстановить сохранненые значения. /// </summary> public void RestoreSettings(SmartLabel label) { label.Alignment = Alignment; label.AllowMarkerOverlap = AllowMarkerOverlap; label.AutoWrap = AutoWrap; label.Color = Color.RestoreSettings(); label.DistanceMaximum = DistanceMaximum; label.DynamicDisplay = DynamicDisplay; label.DynamicPosition = DynamicPosition; label.Font = Font.RestoreSettings(); label.ForceVertical = ForceVertical; label.GlowColor = GlowColor; Hotspot.RestoreSettings(label.Hotspot); Line.RestoreSettings(label.Line); label.LineAlignment = LineAlignment; label.OutlineColor = OutlineColor; label.Padding = Padding; label.PieLabelMode = PieLabelMode; label.RadarLabelMode = RadarLabelMode; Shadow.RestoreSettings(label.Shadow); label.Text = Text; Truncation.RestoreSettings(label.Truncation); label.Type = Type; }