private void DriveLetter_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e != null && e.RemovedItems.Count > 0) { char c = (char)(e.RemovedItems[0]); ((App)App.Current).Unmount(c, true); } var sI = (sender as ComboBox).SelectedItem; if (sI == null) { return; } var selectedLetter = (char)sI; if (!DriveToMount.ContainsKey(selectedLetter)) { var curItem = ((ListViewItem)DriveList.ContainerFromElement((sender as ComboBox))); var myContentPresenter = FindVisualChild <ContentPresenter>(curItem); var myDataTemplate = myContentPresenter.ContentTemplate; ((Button)myDataTemplate.FindName("UnmountBtn", myContentPresenter)).Visibility = Visibility.Visible; ((App)App.Current).Mount(selectedLetter, (sender as ComboBox).DataContext as Atonline.Rest.Drive, true); } }
private void CheckBox_Checked(object sender, RoutedEventArgs e) { var curItem = ((ListViewItem)DriveList.ContainerFromElement((CheckBox)sender)); var myContentPresenter = FindVisualChild <ContentPresenter>(curItem); var myDataTemplate = myContentPresenter.ContentTemplate; var cb = (ComboBox)myDataTemplate.FindName("DriveLetter", myContentPresenter); cb.Visibility = Visibility.Visible; cb.ItemsSource = getAvailableDriveLetters(); cb.SelectedIndex = cb.Items.Count - 1; }
private void UnmountBtn_Click(object sender, RoutedEventArgs e) { var btn = sender as Button; btn.Visibility = Visibility.Hidden; var curItem = ((ListViewItem)DriveList.ContainerFromElement(btn)); var myContentPresenter = FindVisualChild <ContentPresenter>(curItem); var myDataTemplate = myContentPresenter.ContentTemplate; var cb = (ComboBox)myDataTemplate.FindName("DriveLetter", myContentPresenter); cb.SelectedIndex = -1; }
private void CheckBox_Unchecked(object sender, RoutedEventArgs e) { var curItem = ((ListViewItem)DriveList.ContainerFromElement((CheckBox)sender)); var myContentPresenter = FindVisualChild <ContentPresenter>(curItem); var myDataTemplate = myContentPresenter.ContentTemplate; var cb = (ComboBox)myDataTemplate.FindName("DriveLetter", myContentPresenter); cb.Visibility = Visibility.Hidden; var selectedItem = cb.SelectedItem as ComboBoxItem; cb.SelectedIndex = -1; if (selectedItem == null) { return; } DriveToMount.Remove((char)selectedItem.Content); }