public WolSettingsView() { InitializeComponent(); tbTryCount.Validation = EntryViewValidation.UShortValidation(min: 1); tbPort.Validation = EntryViewValidation.UShortValidation(); tbMac.Validation = (v) => { try { LanUtils.MacAddressParse(v.EntryView.Text); } catch { v.ErrorMessage = "МAC-адрес должен состоять из шести\r\nшестнадцатеричных чисел (от 00 до FF), разделенных двоеточием"; } }; tbMac.ErrorStateChanged += (o, args) => { var isError = args.Value.InputWrong; if (isError) { tbError.Text = args.Value.ErrorMessage; } else { tbError.Text = null; } ErrorStateChanged?.Invoke(isError); }; }
public WakeOnLanActionView() { InitializeComponent(); searchView.AddressSelected += (address) => paramsView.SetMac(LanUtils.MacAddressParse(address.MacAddress.GetAddressBytes())); paramsView.ErrorStateChanged += (err) => btApply.IsEnabled = !err; btApply.Click += (o, e) => { paramsView.SetSettingsTo(_action); Apply?.Invoke(); }; btCancel.Click += (o, e) => Cancel?.Invoke(); }
public AddressSearchView() { InitializeComponent(); btSelect.IsEnabled = false; btSearch.Click += (o, e) => { captionView.StartAnimateProgress(); _tokenSource?.Cancel(); lvAddresses.Children.Clear(); CancellationTokenSource oldTokenSource = null; oldTokenSource = _tokenSource = LanUtils.ListAllHosts( ipBaseView.IpBase, (address) => { if (oldTokenSource == _tokenSource) //if new search is not starts { lvAddresses.Dispatcher.BeginInvoke((Action)(() => { var itemView = new ItemView(); itemView.Content = address.IPAddress + " (mac: " + LanUtils.MacAddressParse(address.MacAddress.GetAddressBytes()) + ")"; itemView.Tag = address; itemView.Margin = new Thickness(2); lvAddresses.Children.Add(itemView); })); } }, () => { captionView.StopAnimateProgress(); }); }; lvAddresses.SelectionChanged += (o, e) => { btSelect.IsEnabled = lvAddresses.GetSelectedItems().Any(); }; btSelect.Click += (o, e) => { AddressSelected?.Invoke((Address)((ItemView)lvAddresses.SelectedItem).Tag); }; }