Пример #1
0
        private void treeView_DragOver(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

                foreach (string filename in files)
                {
                    try
                    {
                        IParserFactory lfp = PluginFactory.FindLogFileParser(filename);
                        if (lfp != null)
                        {
                            e.Effects = DragDropEffects.Copy;
                            e.Handled = true;
                            return;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            e.Effects = DragDropEffects.None;
            e.Handled = true;
        }
Пример #2
0
        public void FindLogFileParserTest()
        {
            PluginFactory.Reset();
            PluginFactory.LoadPlugins(pluginPath);

            IParserFactory lfp = PluginFactory.FindLogFileParser("dummy.csv");

            IsTypenameSame(lfp.GetType(), typeof(Sample_Crunch.StandardPanels.CsvParserFactory));
        }
Пример #3
0
        public void AddLogFile(string filename)
        {
            IParserFactory lfp = PluginFactory.FindLogFileParser(filename);

            if (lfp != null)
            {
                AddLogFile(filename, lfp);
            }
            else
            {
                throw new FileLoadException("No available log file parser can open the selected file.", filename);
            }
        }
Пример #4
0
        public FileViewModel(IProjectViewModel parentProject, IFileModel fileData)
        {
            this.project  = parentProject;
            this.fileData = fileData;

            try
            {
                // Try to use specified factory
                var parserFactory = PluginFactory.FindParser(fileData.DataParserType);

                // If not available use any other able to use open that format
                if (parserFactory == null)
                {
                    parserFactory = PluginFactory.FindLogFileParser(fileData.FileName);
                }

                if (parserFactory == null)
                {
                    throw new InvalidOperationException("No parser for " + fileData.FileName + " available.");
                }

                this.LogFile = parserFactory.Open(fileData.FileName, fileData.Settings);
            }
            catch (IOException ioe)
            {
                throw new IOException("Can no open file", ioe);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
                throw;
            }

            this.Icon        = ResourceHelper.SetIconFromBitmap(Properties.Resources.folder);
            signalViewModels = new ObservableCollection <ISignalViewModel>();

            foreach (Signal s in LogFile.Signals)
            {
                SignalViewModel subitem = new SignalViewModel(this, s);
                this.Signals.Add(subitem);
            }

            foreach (IMarkerModel m in fileData.Markers)
            {
                MarkerViewModel markerItem = new MarkerViewModel(m, false);
                this.Markers.Add(markerItem);
            }

            markerViewModels.CollectionChanged += MarkerViewModels_CollectionChanged;
        }