public CSVFileListItem(CSVFileRecord csv)
 {
     CSV = csv;
     InitializeComponent();
     FileName.Text = CSV.path;
     foreach (Variable v in CSV.stream.CSVVariables)
     {
         ContentControl g = new ContentControl(); //have to wrap in a control to get DataTemplate XAML to work on Variable
         g.Content = v;
         VariableEntries.Children.Add(g);
     }
 }
Esempio n. 2
0
        private CSVFileRecord OpenCVSFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "Open a CSV file ...";
            ofd.AddExtension = true;
            ofd.DefaultExt = ".csv"; // Default file extension
            ofd.Filter = "CSV files (.csv)|*.csv|All files|*.*"; // Filter files by extension
            Nullable<bool> result = ofd.ShowDialog();
            if (result == false) return null;

            CSV.CSVInputStream csvStream;
            try
            {
                csvStream = new CSV.CSVInputStream(ofd.FileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to read CVS file " + ofd.FileName + "." + Environment.NewLine + "Exception: " + ex.Message,
                    "CVS error", MessageBoxButton.OK, MessageBoxImage.Error);
                return null;
            }
            CSVFileRecord csv = new CSVFileRecord();
            csv.stream = csvStream;
            csv.path = ofd.FileName;
            CSVFileListItem cfi = new CSVFileListItem(csv);
            csv.CSVFilePointSelector = cfi;
            cfi.ErrorCheckReq += new EventHandler(checkForError);
            checkForError(cfi, null);
            return csv;
        }