private async Task DisplayNetworkReportAsync(WiFiNetworkReport report) { rootPage.NotifyUser(string.Format("Network Report Timestamp: {0}", report.Timestamp), NotifyType.StatusMessage); ResultCollection.Clear(); ConcurrentDictionary <string, WiFiNetworkDisplay> dictionary = new ConcurrentDictionary <string, WiFiNetworkDisplay>(); foreach (var network in report.AvailableNetworks) { if (!String.IsNullOrEmpty(network.Ssid)) { var item = new WiFiNetworkDisplay(network, firstAdapter); dictionary.TryAdd(network.Ssid, item); } } var values = dictionary.Values; foreach (var item in values) { /*await*/ item.UpdateAsync(); if (IsConnected(item.AvailableNetwork)) { ResultCollection.Insert(0, item); ResultsListView.SelectedItem = ResultsListView.Items[0]; ResultsListView.ScrollIntoView(ResultsListView.SelectedItem); SwitchToItemState(item.AvailableNetwork, WifiConnectedState, false); } else { ResultCollection.Add(item); } } ResultsListView.Focus(FocusState.Pointer); }
private async void AddToLibraryMenu_Click(object sender, RoutedEventArgs e) { MenuFlyoutItem item = sender as MenuFlyoutItem; if (item != null) { entryToEdit = item.DataContext as SearchResponseEntry; } var flyout = RootGrid.Resources["AddToLibraryFlyout"] as Flyout; var listViewItem = ResultsListView.ContainerFromItem(entryToEdit) as GridViewItem; if (flyout != null) { var editor = ((FrameworkElement)flyout.Content).FindDescendantByName("AddToMyPodcastsEditor") as AddToMyPodcasts; WaitRingManager.IsWaitRingVisible = true; var podcast = await Podcast.ParseAsync(entryToEdit.feedUrl, false); WaitRingManager.IsWaitRingVisible = false; if (podcast != null) { editor?.SetPodcast(podcast); flyout.ShowAt(listViewItem); } } }
private async Task DisplayNetworkReportAsync(WiFiNetworkReport report) { rootPage.NotifyUser(string.Format("Network Report Timestamp: {0}", report.Timestamp), NotifyType.StatusMessage); ResultCollection.Clear(); foreach (var network in report.AvailableNetworks) { var item = new WiFiNetworkDisplay(network, firstAdapter); /*await*/ item.UpdateAsync(); if (IsConnected(network)) { ResultCollection.Insert(0, item); ResultsListView.SelectedItem = ResultsListView.Items[0]; ResultsListView.ScrollIntoView(ResultsListView.SelectedItem); SwitchToItemState(network, WifiConnectedState, false); } else { ResultCollection.Add(item); } } ResultsListView.Focus(FocusState.Pointer); }
private void ResultsListView_MouseDoubleClick(object sender, MouseEventArgs e) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; try { ErrorsAndWarnings.Text = ""; using (new WaitCursor()) { var itemUnderCursor = ResultsListView.HitTest(e.Location).Item; if (itemUnderCursor != null) { UpdateDisplay(); if (_lastModel != null && _lastModel.AllErrors.Count + _lastModel.AllWarnings.Count == 0) { ResultsListView.SelectedItems.Clear(); itemUnderCursor.Selected = true; EnableImport(); ImportStructure(); if (!string.IsNullOrEmpty(Cml)) { DialogResult = DialogResult.OK; Close(); } } } } } catch (Exception ex) { new ReportError(Telemetry, TopLeft, module, ex).ShowDialog(); } }
private void ShowMolfile_Click(object sender, EventArgs e) { MolFileViewer tv = new MolFileViewer(new System.Windows.Point(TopLeft.X + Core.Helpers.Constants.TopLeftOffset, TopLeft.Y + Core.Helpers.Constants.TopLeftOffset), _lastMolfile); tv.ShowDialog(); ResultsListView.Focus(); }
private void ActionButton_Click(object sender, RoutedEventArgs e) { var curItem = ((ListBoxItem)ResultsListView.ContainerFromElement((Button)sender)); selectedActivity = curItem.Content as ActivityResult; cm = FindResource("ActionContextMenu") as ContextMenu; cm.PlacementTarget = sender as Button; cm.IsOpen = true; }
private void btnSearch_Click(object sender, EventArgs e) { ResultsListView.Clear(); try { //get selected surface material and assign to string string SearchSurfaceMaterial = comboBoxSurfaceMaterial.SelectedItem.ToString(); //check that the file is present and then read in data from csv if (!File.Exists(@"quotes.txt")) { MessageBox.Show("Can not find the quotes.txt file.", "Error reading file"); } else { //Add headers to list view ResultsListView.Columns.Add("#", 30, HorizontalAlignment.Center); ResultsListView.Columns.Add("Date", 120, HorizontalAlignment.Center); ResultsListView.Columns.Add("Name", 170, HorizontalAlignment.Center); ResultsListView.Columns.Add("Width", 70, HorizontalAlignment.Center); ResultsListView.Columns.Add("Depth", 70, HorizontalAlignment.Center); ResultsListView.Columns.Add("Drawers", 80, HorizontalAlignment.Center); ResultsListView.Columns.Add("Surface Material", 120, HorizontalAlignment.Center); ResultsListView.Columns.Add("Rush Order", 70, HorizontalAlignment.Center); ResultsListView.Columns.Add("Cost", 100, HorizontalAlignment.Center); //read in file using (var reader = new StreamReader(@"quotes.txt")) { int numQuotes = 0; while (!reader.EndOfStream) { string[] values = reader.ReadLine().Split(','); if (values[5].Trim() == SearchSurfaceMaterial) //Won't compare for some reason { numQuotes++; ResultsListView.Items.Add(new ListViewItem(new[] { numQuotes.ToString(), values[0], values[1], values[2], values[3], values[4], values[5], values[6], "$" + values[7] })); } } } } } catch (Exception ex) { MessageBox.Show("There was a problem with listing the quotes using StremReader." + "\n\n" + ex); } }
private ListViewItem SwitchToItemState(object dataContext, DataTemplate template, bool forceUpdate) { if (forceUpdate) { ResultsListView.UpdateLayout(); } var item = ResultsListView.ContainerFromItem(dataContext) as ListViewItem; if (item != null) { item.ContentTemplate = template; } return(item); }
private void ResizeSetFocus() { if (ResultsListView.Items.Count <= 0) { return; } Invoke((MethodInvoker) ( () => { ResultsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); ResultsListView.EndUpdate(); ResultsListView.FocusedItem = ResultsListView.Items[ResultsListView.Items.Count - 1]; ResultsListView.Items[ResultsListView.Items.Count - 1].Selected = true; ActiveControl = ResultsListView; } )); }
private async Task DisplayNetworkReportAsync(WiFiNetworkReport report) { ResultCollection.Clear(); foreach (var network in report.AvailableNetworks) { var item = new WiFiNetworkDisplay(network, firstAdapter); /*await*/ item.UpdateAsync(); if (IsConnected(network)) { ResultCollection.Insert(0, item); ResultsListView.SelectedItem = ResultsListView.Items[0]; ResultsListView.ScrollIntoView(ResultsListView.SelectedItem); SwitchToItemState(network, WifiConnectedState, false); } else { ResultCollection.Add(item); } } ResultsListView.Focus(FocusState.Pointer); }
private async void DoWifiConnect(object sender, RoutedEventArgs e, bool pushButtonConnect) { var selectedNetwork = ResultsListView.SelectedItem as WiFiNetworkDisplay; if (selectedNetwork == null || firstAdapter == null) { rootPage.NotifyUser("Network not selected", NotifyType.ErrorMessage); return; } WiFiReconnectionKind reconnectionKind = WiFiReconnectionKind.Manual; if (selectedNetwork.ConnectAutomatically) { reconnectionKind = WiFiReconnectionKind.Automatic; } Task <WiFiConnectionResult> didConnect = null; WiFiConnectionResult result = null; if (pushButtonConnect) { if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5, 0)) { didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind, null, String.Empty, WiFiConnectionMethod.WpsPushButton).AsTask <WiFiConnectionResult>(); } } else if (selectedNetwork.IsEapAvailable) { if (selectedNetwork.UsePassword) { var credential = new PasswordCredential(); if (!String.IsNullOrEmpty(selectedNetwork.Domain)) { credential.Resource = selectedNetwork.Domain; } credential.UserName = selectedNetwork.UserName ?? ""; credential.Password = selectedNetwork.Password ?? ""; didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind, credential).AsTask <WiFiConnectionResult>(); } else { didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind).AsTask <WiFiConnectionResult>(); } } else if (selectedNetwork.AvailableNetwork.SecuritySettings.NetworkAuthenticationType == Windows.Networking.Connectivity.NetworkAuthenticationType.Open80211 && selectedNetwork.AvailableNetwork.SecuritySettings.NetworkEncryptionType == NetworkEncryptionType.None) { didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind).AsTask <WiFiConnectionResult>(); } else { // Only the password potion of the credential need to be supplied if (String.IsNullOrEmpty(selectedNetwork.Password)) { didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind).AsTask <WiFiConnectionResult>(); } else { var credential = new PasswordCredential(); credential.Password = selectedNetwork.Password ?? ""; didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind, credential).AsTask <WiFiConnectionResult>(); } } SwitchToItemState(selectedNetwork, WifiConnectingState, false); if (didConnect != null) { result = await didConnect; } if (result != null && result.ConnectionStatus == WiFiConnectionStatus.Success) { rootPage.NotifyUser(string.Format("Successfully connected to {0}.", selectedNetwork.Ssid), NotifyType.StatusMessage); // refresh the webpage webViewGrid.Visibility = Visibility.Visible; toggleBrowserButton.Content = "Hide Browser Control"; refreshBrowserButton.Visibility = Visibility.Visible; ResultCollection.Remove(selectedNetwork); ResultCollection.Insert(0, selectedNetwork); ResultsListView.SelectedItem = ResultsListView.Items[0]; ResultsListView.ScrollIntoView(ResultsListView.SelectedItem); SwitchToItemState(selectedNetwork, WifiConnectedState, false); } else { rootPage.NotifyUser(string.Format("Could not connect to {0}. Error: {1}", selectedNetwork.Ssid, result.ConnectionStatus), NotifyType.ErrorMessage); SwitchToItemState(selectedNetwork, WifiConnectState, false); } // Since a connection attempt was made, update the connectivity level displayed for each foreach (var network in ResultCollection) { network.UpdateConnectivityLevel(); } }
private void ViewModel_OnSelect(object sender, EventArgs e) { ResultsListView.ScrollIntoView(ViewModel.SelectedWiFiNetwork); SetSelectedItemState(ViewModel.SelectedWiFiNetwork); ResultsListView.Focus(FocusState.Pointer); }
private async void DoWifiConnect(object sender, RoutedEventArgs e, bool pushButtonConnect) { var selectedNetwork = ResultsListView.SelectedItem as WiFiNetworkDisplay; if (selectedNetwork == null || firstAdapter == null) { rootPage.NotifyUser("Network not selected", NotifyType.ErrorMessage); return; } var ssid = selectedNetwork.AvailableNetwork.Ssid; if (string.IsNullOrEmpty(ssid)) { if (string.IsNullOrEmpty(selectedNetwork.HiddenSsid)) { rootPage.NotifyUser("Ssid required for connection to hidden network.", NotifyType.ErrorMessage); return; } else { ssid = selectedNetwork.HiddenSsid; } } WiFiReconnectionKind reconnectionKind = WiFiReconnectionKind.Manual; if (selectedNetwork.ConnectAutomatically) { reconnectionKind = WiFiReconnectionKind.Automatic; } Task <WiFiConnectionResult> didConnect = null; WiFiConnectionResult result = null; if (pushButtonConnect) { if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5, 0)) { didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind, null, string.Empty, WiFiConnectionMethod.WpsPushButton).AsTask(); } } else { PasswordCredential credential = new PasswordCredential(); if (selectedNetwork.IsEapAvailable && selectedNetwork.UsePassword) { if (!String.IsNullOrEmpty(selectedNetwork.Domain)) { credential.Resource = selectedNetwork.Domain; } credential.UserName = selectedNetwork.UserName ?? ""; credential.Password = selectedNetwork.Password ?? ""; } else if (!String.IsNullOrEmpty(selectedNetwork.Password)) { credential.Password = selectedNetwork.Password; } if (selectedNetwork.IsHiddenNetwork) { // Hidden networks require the SSID to be supplied didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind, credential, ssid).AsTask(); } else { didConnect = firstAdapter.ConnectAsync(selectedNetwork.AvailableNetwork, reconnectionKind, credential).AsTask(); } } SwitchToItemState(selectedNetwork, WifiConnectingState, false); if (didConnect != null) { result = await didConnect; } if (result != null && result.ConnectionStatus == WiFiConnectionStatus.Success) { rootPage.NotifyUser(string.Format("Successfully connected to {0}.", selectedNetwork.Ssid), NotifyType.StatusMessage); // refresh the webpage webViewGrid.Visibility = Visibility.Visible; toggleBrowserButton.Content = "Hide Browser Control"; refreshBrowserButton.Visibility = Visibility.Visible; ResultCollection.Remove(selectedNetwork); ResultCollection.Insert(0, selectedNetwork); ResultsListView.SelectedItem = ResultsListView.Items[0]; ResultsListView.ScrollIntoView(ResultsListView.SelectedItem); SwitchToItemState(selectedNetwork, WifiConnectedState, false); } else { // Entering the wrong password may cause connection attempts to timeout // Disconnecting the adapter will return it to a non-busy state if (result.ConnectionStatus == WiFiConnectionStatus.Timeout) { firstAdapter.Disconnect(); } rootPage.NotifyUser(string.Format("Could not connect to {0}. Error: {1}", selectedNetwork.Ssid, (result != null ? result.ConnectionStatus : WiFiConnectionStatus.UnspecifiedFailure)), NotifyType.ErrorMessage); SwitchToItemState(selectedNetwork, WifiConnectState, false); } // Since a connection attempt was made, update the connectivity level displayed for each foreach (var network in ResultCollection) { var task = network.UpdateConnectivityLevelAsync(); } }