private void SetViewTypeAndUpdateMenuCheck(CommonClass.TransmissionType viewType) { this.hexToolStripMenuItem.Checked = false; this.aSCIIToolStripMenuItem.Checked = false; this.sSBToolStripMenuItem.Checked = false; this.gP2ToolStripMenuItem.Checked = false; this.cSVToolStripMenuItem.Checked = false; this._viewType = CommonClass.TransmissionType.GP2; switch (viewType) { case CommonClass.TransmissionType.Text: this.aSCIIToolStripMenuItem.Checked = true; this._viewType = CommonClass.TransmissionType.Text; this.comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.Text; return; case CommonClass.TransmissionType.Hex: this.hexToolStripMenuItem.Checked = true; this._viewType = CommonClass.TransmissionType.Hex; this.comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.Hex; return; case CommonClass.TransmissionType.SSB: this.sSBToolStripMenuItem.Checked = true; this._viewType = CommonClass.TransmissionType.SSB; this.comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.SSB; return; case CommonClass.TransmissionType.GP2: this.gP2ToolStripMenuItem.Checked = true; this._viewType = CommonClass.TransmissionType.GP2; this.comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.GP2; return; case CommonClass.TransmissionType.GPS: this.cSVToolStripMenuItem.Checked = true; this._viewType = CommonClass.TransmissionType.GPS; this.comm.RxCurrentTransmissionType = CommunicationManager.TransmissionType.GPS; return; } }
private void frmFileReplayOpenToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Specify log file name:"; dialog.InitialDirectory = @"..\..\logs\"; dialog.Filter = "GP2 (*.gp2)|*.gp2|GPS (*.gps)|*.gps|All files (*.*)|*.*"; dialog.FilterIndex = 1; dialog.CheckPathExists = false; dialog.CheckFileExists = false; if (dialog.ShowDialog() != DialogResult.OK) { return; } this._logFileName = dialog.FileName; this.Text = "Open: " + this._logFileName; this._fileHdlr = new LargeFileHandler(this._logFileName); this._totalFileSize = this._fileHdlr.Length; this.frmFileReplayTrackBar.Value = 0; this.frmFileReplayTrackBar.Maximum = 100; this.frmFileReplayTrackBar.Minimum = 0; this._playState = _playStates.IDLE; this._lastPlayState = this._playState; this.comm.MessageProtocol = this.cboProtocols.SelectedItem.ToString(); string[] strArray = this._logFileName.Split(new char[] { '.' }); if (strArray.Length != 2) { return; } string str = strArray[1].ToUpper(); if (str != null) { if (!(str == "GP2") && !(str == "GPX")) { if (str == "GPS") { this._viewType = CommonClass.TransmissionType.GPS; this._fileType = CommonClass.TransmissionType.GPS; goto Label_01A1; } if (str == "TXT") { this._viewType = CommonClass.TransmissionType.Text; this._fileType = CommonClass.TransmissionType.Text; goto Label_01A1; } if (str == "BIN") { this._viewType = CommonClass.TransmissionType.Hex; this._fileType = CommonClass.TransmissionType.Hex; goto Label_01A1; } } else { this._viewType = CommonClass.TransmissionType.GP2; this._fileType = CommonClass.TransmissionType.GP2; goto Label_01A1; } } this._viewType = CommonClass.TransmissionType.Hex; this._fileType = CommonClass.TransmissionType.Hex; Label_01A1: this._processFileLog = strArray[0] + ".par"; this.frmFileReplayOpenToolStripMenuItem.Enabled = false; }
private DialogResult fileReplayOpenHandler() { bool flag = false; foreach (string str in PortManagerHash.Keys) { if (!(str == clsGlobal.FilePlayBackPortName)) { PortManager manager = (PortManager) PortManagerHash[str]; if ((manager != null) && manager.comm.IsSourceDeviceOpen()) { flag = true; break; } } } if (flag && (MessageBox.Show("Proceeding will close all open ports. Continue?", "File Playback Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)) { return DialogResult.Cancel; } foreach (string str2 in PortManagerHash.Keys) { if (str2 != clsGlobal.FilePlayBackPortName) { PortManager tmpP = (PortManager) PortManagerHash[str2]; if (tmpP != null) { if (tmpP.comm.IsSourceDeviceOpen()) { tmpP.comm.ClosePort(); } tmpP.CloseAll(); updateGUIOnConnectNDisconnect(tmpP); } } } updateAllMainBtn(); menuBtnInit(); OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Specify log file name:"; dialog.InitialDirectory = @"..\..\logs\"; dialog.Filter = "GP2 (*.gp2)|*.gp2|GPS (*.gps)|*.gps|Text files (*.txt)|*.txt|All files (*.*)|*.*"; dialog.FilterIndex = 4; dialog.CheckPathExists = false; dialog.CheckFileExists = false; if (dialog.ShowDialog() != DialogResult.OK) { goto Label_04AE; } _logFileName = dialog.FileName; if ((_logFileName == string.Empty) || !File.Exists(_logFileName)) { MessageBox.Show(string.Format("Error Open file\n {0}", _logFileName), "File Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); _playState = _playStates.IDLE; return DialogResult.Cancel; } Text = string.Format("{0}: File Playback", clsGlobal.SiRFLiveVersion); _fileHdlr = new LargeFileHandler(_logFileName); _totalFileSize = _fileHdlr.Length; filePlayBackTrackBar.Value = 0; filePlayBackTrackBar.Maximum = 100; filePlayBackTrackBar.Minimum = 0; filePlayBackTrackBar.Enabled = true; filePlayBackTrackBar.Visible = true; _playState = _playStates.IDLE; _lastPlayState = _playState; FileInfo info = new FileInfo(_logFileName); if (info.Length == 0L) { MessageBox.Show(string.Format("0 length file dectected!\n{0}", _logFileName), "File Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); return DialogResult.Cancel; } string str3 = info.Extension.ToUpper(); if (str3 != null) { if (!(str3 == ".GP2") && !(str3 == ".GPX")) { if (str3 == ".GPS") { _viewType = CommonClass.TransmissionType.GPS; _fileType = CommonClass.TransmissionType.GPS; goto Label_033C; } if (str3 == ".TXT") { _viewType = CommonClass.TransmissionType.Text; _fileType = CommonClass.TransmissionType.Text; goto Label_033C; } if (str3 == ".BIN") { _viewType = CommonClass.TransmissionType.Hex; _fileType = CommonClass.TransmissionType.Hex; goto Label_033C; } } else { _viewType = CommonClass.TransmissionType.GPS; _fileType = CommonClass.TransmissionType.GP2; goto Label_033C; } } _viewType = CommonClass.TransmissionType.Hex; _fileType = CommonClass.TransmissionType.Hex; Label_033C: _processFileLog = info.DirectoryName + info.Name + ".par"; PortManager manager3 = setupFileReplayPort(); if (manager3 != null) { manager3.UpdateMainWindow += new PortManager.updateParentEventHandler(updateMainWindowTitle); if (!toolStripPortComboBox.Items.Contains(clsGlobal.FilePlayBackPortName)) { toolStripPortComboBox.Items.Add(clsGlobal.FilePlayBackPortName); } toolStripPortComboBox.Text = clsGlobal.FilePlayBackPortName; if (_lastPlayState == _playStates.IDLE) { manager3.comm.WriteApp("User marker: Open file: " + _logFileName); } manager3.PerPortToolStrip = AddPortToolbar((toolStripMain.Location.Y + (0x19 * PortManagerHash.Count)) + 0x23, manager3.comm.PortName); manager3.ClearSubWindowsData(true); } else { MessageBox.Show("Error Setup Port for File Playback", "File Playback Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); _playState = _playStates.IDLE; return DialogResult.Cancel; } fileOpenToolStripMenuItem.Enabled = false; toolStripOpenFileBtn.Enabled = false; logManagerStatusLabel.Text = _logFileName; _isFileOpen = true; _parseThread = new Thread(new ThreadStart(parseFile)); _parseThread.IsBackground = true; _parseThread.Start(); EnableDisableMenuAndButtonForFilePlayback(true); updateFilePlaybackBtn(true); Label_04AE: return base.DialogResult; }