Example #1
0
        private void UploadFileButton_OnClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Multiselect      = true,
                Filter           = "Rec files (*.rec)|*.rec|Text files (*.txt)|*.txt",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer)
            };

            if (openFileDialog.ShowDialog() == true)
            {
                FileReader fr = new FileReader();
                foreach (var file in openFileDialog.FileNames)
                {
                    Recording r    = fr.StoreRecording(file);
                    var       name = "PortTab" + r.Port;

                    for (var i = TabControl.Items.Count; i > 0; i--)
                    {
                        TabItem item = (TabItem)TabControl.Items[i - 1];
                        if (!item.Name.Equals(name))
                        {
                            continue;
                        }
                        App.RecordingData.Remove(r.Port);
                        TabControl.Items.Remove(item);
                    }
                    App.RecordingData.Add(r.Port, r);
                    DetailsTab tab = new DetailsTab(r.Port)
                    {
                        Header = "Port " + r.Port,
                        Name   = name
                    };
                    TabControl.AddToSource(tab);
                }
            }
        }