Beispiel #1
0
        public Main()
        {
            InitializeComponent();

            // Initialize UI.
            EnableWatermark();
            StartTimeInput.Value = DateTime.UtcNow.AddMinutes(-5);
            EndTimeInput.Value = DateTime.UtcNow;

            // Add version number to title
            this.Text = string.Format(this.Text, AssemblyInfo.EntryAssembly.Version.ToString(3));

            foreach (string port in SerialPort.GetPortNames())
            {
                SerialPortInput.Items.Add(port);
            }

            if (SerialPortInput.Items.Count > 0)
            {
                SerialPortInput.SelectedIndex = 0;
                SerialBaudRateInput.SelectedIndex = 4;
                SerialParityInput.SelectedIndex = 0;
                SerialStopBitsInput.SelectedIndex = 1;
            }
            else
            {
                // No serial ports where found on this machineso the option for serial output will be removed
                OutputChannelTabs.TabPages.Remove(SerialSettingsTab);
            }

            Application.DoEvents();

            // Initialize member variables.
            m_activeThreads = new List<Thread>();
            m_archiveReader = new ArchiveReader();
            m_archiveReader.RolloverStart += m_archiveReader_RolloverStart;
            m_archiveReader.RolloverComplete += m_archiveReader_RolloverComplete;
            m_archiveReader.HistoricFileListBuildStart += m_archiveReader_HistoricFileListBuildStart;
            m_archiveReader.HistoricFileListBuildComplete += m_archiveReader_HistoricFileListBuildComplete;
            m_archiveReader.HistoricFileListBuildException += m_archiveReader_HistoricFileListBuildException;
            m_archiveReader.DataReadException += m_archiveReader_DataReadException;
            m_lastSelectedArchiveLocation = ConfigurationFile.Current.Settings.General["ArchiveLocation", true].ValueAs("");

            // If last selected archive is not defined, try to a few default selections
            if (string.IsNullOrWhiteSpace(m_lastSelectedArchiveLocation) || !Directory.Exists(m_lastSelectedArchiveLocation))
            {
                // See if a local archive folder exists with a valid archive
                m_lastSelectedArchiveLocation = FilePath.GetAbsolutePath("Archive");

                if (!Directory.Exists(m_lastSelectedArchiveLocation) || Directory.GetFiles(m_lastSelectedArchiveLocation, "*_archive.d").Length == 0)
                {
                    // See if a local statistics folder exists with a valid archive
                    m_lastSelectedArchiveLocation = FilePath.GetAbsolutePath("Statistics");

                    // If neither of these folders exist, just leave setting blank
                    if (!Directory.Exists(m_lastSelectedArchiveLocation) || Directory.GetFiles(m_lastSelectedArchiveLocation, "*_archive.d").Length == 0)
                        m_lastSelectedArchiveLocation = "";
                }
            }

            // Update archive location text box to contain the archive location from the configuration file.
            ArchiveLocationInput.Text = m_lastSelectedArchiveLocation;
        }
Beispiel #2
0
        // Opens an archive reader and returns the ArchiveReader object.
        private ArchiveReader OpenArchiveReader(string fileName)
        {
            ArchiveReader file = new ArchiveReader();

            file.Open(fileName);

            return file;
        }