private void _erase_Click(object sender, EventArgs e) { if (DialogResult.OK != MessageBox.Show(Properties.Resources.MSG5, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { // 実行を中止しますよ return; } UseWaitCursor = true; NowProcessing = false; _progress.Value = 0; string portName = this.PortName; if (Properties.Resources.PORT_AUTOSEL == portName) { try { portName = SkytraqController.AutoSelectPort(); this.PortName = portName; } catch { _posrts.Items.Remove(portName); MessageBox.Show(Properties.Resources.MSG1, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } _eraseWorker.RunWorkerAsync(portName); _timer.Start(); }
private void _connect_Click(object sender, EventArgs e) { try { string portName = this.PortName; if (Properties.Resources.PORT_AUTOSEL == portName) { try { portName = SkytraqController.AutoSelectPort(); this.PortName = portName; } catch { _posrts.Items.Remove(portName); MessageBox.Show(Properties.Resources.MSG1, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } _port = new SkytraqController(portName); MyEnviroment.LatestPortName = portName; _port.OnRead += _port_OnRead; // Version情報 SoftwareVersion sv = _port.SoftwareVersion; _kernelVersion.Text = string.Format("{0:D2}.{1:D2}.{2:D2}", ((sv.KernelVersion >> 16) & 0x00ff), ((sv.KernelVersion >> 8) & 0x00ff), (sv.KernelVersion & 0x00ff)); _ODMVersion.Text = string.Format("{0:D2}.{1:D2}.{2:D2}", ((sv.ODMVersion >> 16) & 0x00ff), ((sv.ODMVersion >> 8) & 0x00ff), (sv.ODMVersion & 0x00ff)); _Revision.Text = string.Format("{0:D2}/{1:D2}/{2:D2}", ((sv.Revision >> 16) & 0x00ff), ((sv.Revision >> 8) & 0x00ff), (sv.Revision & 0x00ff)); // バッファーサイズ BufferStatus bs = _port.GetBufferStatus(); UInt16 usedSectors = bs.TotalSectors; usedSectors -= bs.FreeSectors; _bufferStatus.Maximum = bs.TotalSectors; _bufferStatus.Value = usedSectors; // ボタンを制御 _connect.Enabled = false; _download.Enabled = true; _posrts.Enabled = false; if (bs.TotalSectors == bs.FreeSectors) { _download.Enabled = false; MessageBox.Show(Properties.Resources.MSG3, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(string.Format(Properties.Resources.MSG4, ex.Message), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void _start_Click(object sender, EventArgs e) { string portName = this.PortName; if (Properties.Resources.PORT_AUTOSEL == portName) { try { portName = SkytraqController.AutoSelectPort(); this.PortName = portName; } catch { _posrts.Items.Remove(portName); MessageBox.Show(Properties.Resources.MSG1, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } try { _port = new SkytraqController(portName); MyEnviroment.LatestPortName = portName; } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } _port.OnSetEphemeris += _port_OnSetEphemeris; System.Net.WebClient wc = new System.Net.WebClient(); wc.Credentials = new System.Net.NetworkCredential(_username.Text, _password.Text); string URL = string.Format("ftp://{0}/ephemeris/Eph.dat", _host.Text); wc.DownloadProgressChanged += Wc_DownloadProgressChanged; wc.DownloadDataCompleted += Wc_DownloadDataCompleted; wc.DownloadDataAsync(new Uri(URL)); return; }
private void _connect_Click(object sender, EventArgs e) { try { string portName = this.PortName; if (Properties.Resources.PORT_AUTOSEL == portName) { try { portName = SkytraqController.AutoSelectPort(); this.PortName = portName; } catch { _posrts.Items.Remove(portName); MessageBox.Show(Properties.Resources.MSG1, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } _port = new SkytraqController(portName); MyEnviroment.LatestPortName = portName; // Version情報 SoftwareVersion sv = _port.SoftwareVersion; _kernelVersion.Text = string.Format("{0:D2}.{1:D2}.{2:D2}", ((sv.KernelVersion >> 16) & 0x00ff), ((sv.KernelVersion >> 8) & 0x00ff), (sv.KernelVersion & 0x00ff)); _ODMVersion.Text = string.Format("{0:D2}.{1:D2}.{2:D2}", ((sv.ODMVersion >> 16) & 0x00ff), ((sv.ODMVersion >> 8) & 0x00ff), (sv.ODMVersion & 0x00ff)); _Revision.Text = string.Format("{0:D2}/{1:D2}/{2:D2}", ((sv.Revision >> 16) & 0x00ff), ((sv.Revision >> 8) & 0x00ff), (sv.Revision & 0x00ff)); // バッファ情報 _bs = _port.GetBufferStatus(); if (0 != _bs.Time) { _thresholdType.SelectedIndex = 0; } else { if (0 != _bs.Distance) { _thresholdType.SelectedIndex = 1; } else { _bs.Time = 5; _thresholdType.SelectedIndex = 0; } } _speed.Value = _bs.Speed; _thresholdType.Enabled = true; _threshold.Enabled = true; _speed.Enabled = true; _update.Enabled = true; } catch (Exception ex) { _thresholdType.Enabled = false; _threshold.Enabled = false; _speed.Enabled = false; _update.Enabled = false; MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }