Exemplo n.º 1
0
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string dirPath = value as string;

            SharksFinder.TryGetByPath(dirPath, out WiresharkDirectory wd);
            return(wd);
        }
Exemplo n.º 2
0
        public void TryGetByPath__DirExists__ReturnsDir()
        {
            // Arrange

            // Act
            SharksFinder.TryGetByPath(valid_dir, out WiresharkDirectory wd);

            // Assert
            Assert.IsNotNull(wd);
        }
        private void ChooseCustomDirectoryButtonClick(object sender, System.Windows.RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog
            {
                Filter = "Wireshark.exe|Wireshark.exe"
            };
            DialogResult res = ofd.ShowDialog();

            if (res == System.Windows.Forms.DialogResult.OK)
            {
                if (ofd.CheckFileExists)
                {
                    string dirPath = Path.GetDirectoryName(ofd.FileName);
                    if (SharksFinder.TryGetByPath(dirPath, out WiresharkDirectory wd))
                    {
                        WiresharkFinderViewModel wfvm = this.DataContext as WiresharkFinderViewModel;
                        wfvm.AddCustomDirectory(wd);
                    }
                }
            }
        }