示例#1
0
 public FileListStruct(string fn, string ffn, FormatProcessor p, bool ps)
 {
     filename = fn;
     formatName = ffn;
     processor = p;
     persistent = ps;
 }
示例#2
0
        protected override void ProcessRecord()
        {
            Collection <FormatData> data;

            if (InputObject.BaseObject is FormatData)
            {
                data = new Collection <FormatData>();
                data.Add((FormatData)InputObject.BaseObject);
            }
            else
            {
                if (_formatManager == null)
                {
                    _formatManager = new FormatManager(FormatShape.Undefined, ExecutionContext);
                }
                data = _formatManager.Process(InputObject);
            }
            // although we might have multiple FormatData objects, they are all derived from a single data object
            // so all should be formatted in the same shape
            var processor = FormatProcessor.Get(OutputWriter, data[0].Shape);

            foreach (var curData in data)
            {
                processor.ProcessPayload(curData);
            }
        }
示例#3
0
 public FileListStruct(string fn, string ffn, FormatProcessor p, bool ps)
 {
     filename   = fn;
     formatName = ffn;
     processor  = p;
     persistent = ps;
 }
示例#4
0
        protected override void EndProcessing()
        {
            if (_formatManager == null)
            {
                return;
            }
            var data = _formatManager.End();

            if (data.Count < 1)
            {
                return;
            }
            var processor = FormatProcessor.Get(OutputWriter, data[0].Shape);

            foreach (var formatPayload in data)
            {
                processor.ProcessPayload(formatPayload);
            }
        }
示例#5
0
        private void detectFormatButton_Click(object sender, System.EventArgs e)
        {
            string filename = fileTextBox.Text;
            string goodFormat = "";

            int numFormats = 0;
            switch(FileImportForm.m_mode)
            {
                case MODE_GPS:
                    numFormats = AllFormats.gpsFormatObjects.Length;
                    elementName = "waypoints";
                    break;
                case MODE_EQ:
                    numFormats = AllFormats.eqFormatObjects.Length;
                    elementName = "earthquakes";
                    break;
            }

            fileStatusLabel.Text = "selected format: " + m_selectedFormat + "\nTrying available formats:\n";
            for(int i=0; i < numFormats ;i++)
            {
                string formatName = "";
                BaseFormat format = null;
                FormatProcessor fileProcessor = null;

                switch(FileImportForm.m_mode)
                {
                    case MODE_GPS:
                    {
                        formatName = AllFormats.gpsFormatNames[i];
                        format = AllFormats.gpsFormatObjects[i];
                        format.InsertWaypoint = m_countWaypoint;
                        fileProcessor = new FormatProcessor(format.process);
                    }
                        break;
                    case MODE_EQ:
                    {
                        formatName = AllFormats.eqFormatNames[i];
                        format = AllFormats.eqFormatObjects[i];
                        format.InsertEarthquake = m_countEarthquake;
                        fileProcessor = new FormatProcessor(format.process);
                    }
                        break;
                }
                elementCount = 0;
                fileProcessor("", filename, filename);

                string diag = "  ...trying: " + formatName;

                if(elementCount > 0)
                {
                    diag += " - OK: detected " + elementCount + " " + elementName + ".\n";
                    goodFormat = formatName;
                }
                else
                {
                    diag += " - no match\n";
                }

                fileStatusLabel.Text += diag;
            }

            if(goodFormat.Length > 0)
            {
                if(goodFormat.Equals(m_selectedFormat))
                {
                    fileStatusLabel.Text += "Click \"Next>>\" to continue";
                    fileStatusLabel.ForeColor = Color.Black;
                }
                else
                {
                    fileStatusLabel.Text += "\nClick \"<<Back\" and select " + goodFormat + " format";
                    fileStatusLabel.ForeColor = Color.Red;
                }
            }
            else
            {
                fileStatusLabel.Text += "Sorry, the file cannot be imported";
                fileStatusLabel.ForeColor = Color.Red;
            }
        }
示例#6
0
            private void setFormatFields(RadioButton radioButton, string[] formatNames, string[] formatHelps,
											string[] formatExt, string[] formatExts, BaseFormat[] formatObjects, int mode)
            {
                if(radioButton.Checked)
                {
                    FileImportForm.m_mode = mode;
                    m_fileImportForm.detailComboBox.Items.Clear();
                    m_fileImportForm.detailComboBox.Items.AddRange(formatNames);
                    // try to keep previously selected format:
                    int index = 0;
                    int i=0;
                    for (; i < formatNames.Length ;i++)
                    {
                        if(formatNames[i].Equals(FileImportForm.m_selectedFormat))
                        {
                            index = i;
                            break;
                        }
                    }
                    m_fileImportForm.detailComboBox.SelectedIndex = index;
                    m_fileImportForm.detailLabel.Text = formatHelps[index];
                    m_fileImportForm.m_defaultExt = formatExt[index];
                    m_fileImportForm.m_defaultExts = formatExts[index];
                    m_fileProcessor = new FormatProcessor(formatObjects[index].process);
                    m_fileImportForm.nextButton.Enabled = true;
                }
            }
示例#7
0
 private void setFormat()
 {
     int index = m_fileImportForm.detailComboBox.SelectedIndex;
     switch(FileImportForm.m_mode)
     {
         case MODE_GPS:
         {
             m_fileImportForm.detailLabel.Text = AllFormats.gpsFormatHelps[index];
             m_fileImportForm.m_defaultExt = AllFormats.gpsDefaultExtension[index];
             m_fileImportForm.m_defaultExts = AllFormats.gpsDefaultExtensions[index];
             FileImportForm.m_selectedFormat = AllFormats.gpsFormatNames[index];
             BaseFormat format = AllFormats.gpsFormatObjects[index];
             format.InsertWaypoint = m_countWaypoint;
             m_fileProcessor = new FormatProcessor(format.process);
             elementName = "waypoints";
         }
             break;
         case MODE_EQ:
         {
             m_fileImportForm.detailLabel.Text = AllFormats.eqFormatHelps[index];
             m_fileImportForm.m_defaultExt = AllFormats.eqDefaultExtension[index];
             m_fileImportForm.m_defaultExts = AllFormats.eqDefaultExtensions[index];
             FileImportForm.m_selectedFormat = AllFormats.eqFormatNames[index];
             BaseFormat format = AllFormats.eqFormatObjects[index];
             format.InsertEarthquake = m_countEarthquake;
             m_fileProcessor = new FormatProcessor(format.process);
             elementName = "earthquakes";
         }
             break;
     }
 }
 public void SetUp()
 {
     _database  = new Mock <IDatabase>();
     _processor = new FormatProcessor();
 }
示例#9
0
 public UrlListStruct(string u, string s, FormatProcessor p)
 {
     url = u;
     source = s;
     processor = p;
 }
示例#10
0
        private void importFavoritesMenuItem_Click(object sender, System.EventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new OpenFileDialog();

            // use .gpx and .loc format:
            openFileDialog.InitialDirectory = Project.fileInitialDirectory;
            openFileDialog.FileName = "";
            openFileDialog.DefaultExt = ".gpx";
            openFileDialog.AddExtension = true;
            // "Text files (*.txt)|*.txt|All files (*.*)|*.*"
            openFileDialog.Filter = "GPX files (*.gpx)|*.gpx";
            DialogResult result = openFileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                fvCount = 0;
                string fileName = openFileDialog.FileName;
                BaseFormat format = AllFormats.gpsFormatObjects[0];
                FileImportForm.m_selectedFormat = AllFormats.gpsFormatNames[0];
                format.InsertWaypoint = new InsertWaypoint(insertFavorite);
                FormatProcessor fileProcessor = new FormatProcessor(format.process);
                fileProcessor("", fileName, fileName);
                if(fvCount > 0)
                {
                    rebuildFavoritesMenu();
                    Project.SaveFavorites();		// save favorites
                    Project.MessageBox(this, "" + fvCount + " items were imported successfully and will appear in Favorites menu");
                }
                else
                {
                    Project.ErrorBox(this, "No items were imported from\r\n\r\n" + fileName + "\r\n\r\n - could not find any named waypoints there.");
                }
            }
        }