private void ListView_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return;
            }

            var address = (e.SelectedItem as Address);

            if (string.IsNullOrEmpty(address.PlaceId))
            {
                (sender as ListView).SelectedItem = null;
                return;
            }

            AddressSelected?.Invoke(this, address);
        }
Esempio n. 2
0
        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);
            };
        }
Esempio n. 3
0
 protected void OnAddressSelected(AddressSelectedEventArgs args) => AddressSelected?.Invoke(this, args);