private void cmsGrid_Sent_Click(object sender, EventArgs e) { if (dgvSearch.SelectedRows == null) { return; } if (dgvSearch.SelectedRows.Count == 0) { return; } cQSO qso = dgvSearch.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { return; } if (qso.Card_Send) { qso.Card_Send = false; } else { qso.Card_Send = true; } }
private void cmsGrid_Received_Click(object sender, EventArgs e) { if (dgvSearch.SelectedRows == null) { return; } if (dgvSearch.SelectedRows.Count == 0) { return; } cQSO qso = dgvSearch.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { return; } if (qso.Card_Resv) { qso.Card_Resv = false; } else { qso.Card_Resv = true; } qso.LastUpdate = DateTime.UtcNow.Ticks; }
private void cmdCancel_Click(object sender, EventArgs e) { _QSO = new cQSO(_QSO); _blPastQSO.Clear(); lblLastQSO.Text = "LastQSO: N/A"; RefleshForm(); }
private void cmsGrid_Sent_Click(object sender, EventArgs e) { if (dgvMain.SelectedRows == null) { return; } if (dgvMain.SelectedRows.Count == 0) { return; } cQSO qso = dgvMain.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { return; } if (qso.Card_Send) { qso.Card_Send = false; } else { qso.Card_Send = true; } qso.LastUpdate = DateTime.UtcNow.Ticks; SaveToDb(); CountCard(); }
private void ShowTooltip() { try { if (dgvPastQSO.SelectedRows == null) { return; } if (dgvPastQSO.SelectedRows.Count == 0) { return; } cQSO qso = dgvPastQSO.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { return; } ToolTip tlp = new ToolTip(); tlp.InitialDelay = 0; tlp.AutoPopDelay = 10000; string sQTH = string.Format("His:{0}\nMy :{1}", qso.QTH, qso.QTH_My); tlp.SetToolTip(dgvPastQSO, sQTH); } catch (Exception ex) { ErrMsg("Tooltip(Past QSO)\n" + ex.Message); } }
/// <summary> /// 最新QSOの周波数・形式・出力・自局情報を継承する /// </summary> /// <param name="LastQSO"></param> public cQSO(cQSO LastQSO) { _id = -1; _dFreq = LastQSO.Freq; _dPwr_My = LastQSO.Pwr_My; _sMode = LastQSO.Mode; _bCard_Send = false; _bCard_Resv = false; _bExcept = false; _iRS_His = 59; _iRS_My = 59; _iTimeZone = (DateTime.Now - DateTime.UtcNow).Hours; _eQSLMethod = enQSLMethod.B; _lDate_S = DateTime.UtcNow.Ticks; _lDate_E = -1; _lLastUpdate = DateTime.UtcNow.Ticks;; _sPrefix1 = ""; _sCall = ""; _sPrefix2 = ""; _sQRA = ""; _sDXCC = ""; _sCityCode = ""; _sGL = ""; _sQTH = ""; _sQTH_h = ""; _sQSLManager = ""; _sRig_His = ""; _sAnt_His = ""; _sRig_My = LastQSO.Rig_My; _sAnt_My = LastQSO.Ant_My; _sQTH_My = LastQSO.QTH_My; _sPrefix_My = LastQSO.Prefix_My; _sCityCode_My = LastQSO.CityCode_My; _sGL_My = LastQSO.GL_My; _sCardMsg = ""; _sRemark = ""; }
private void cmsGrid_EditQSO_Click(object sender, EventArgs e) { try { if (dgvSearch.SelectedRows == null) { return; } cQSO qso = dgvSearch.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { return; } frmQSO fq = new frmQSO(qso, _fMain); fq.Show(); } catch (Exception ex) { ErrMsg(ex.Message); } }
private void cmsGrid_QSL_1way_Click(object sender, EventArgs e) { try { if (dgvSearch.SelectedRows == null) { return; } cQSO qso = dgvSearch.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { return; } qso.QSLMethod = (int)cQSO.enQSLMethod.R; dgvSearch.Refresh(); } catch (Exception ex) { ErrMsg(ex.Message); } }
//QSOをダブルクリック private void dgvMain_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvMain.SelectedRows == null) { return; } cQSO qso = dgvMain.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { if (_blQSOs.Count == 0) { qso = new cQSO(); } else { qso = new cQSO(_blQSOs[_blQSOs.Count - 1]); } } int[] iColW = new int[dgvMain.ColumnCount]; string[] sColN = new string[dgvMain.ColumnCount]; for (int i = 0; i < iColW.Length; i++) { if (dgvMain.Columns[i].Visible) { iColW[i] = dgvMain.Columns[i].Width; sColN[i] = dgvMain.Columns[i].HeaderText; } else { iColW[i] = -1; sColN[i] = "N/A"; } } frmQSO fq = new frmQSO(qso, _blQSOs, _dcDXCC, _dcCityCode, _dcBand, _dcMode, _dcDefault, iColW, sColN, _cfg); fq.Show(); } catch (Exception ex) { ErrMsg(ex.Message); } }
private void cmsGrid_Remove_Click(object sender, EventArgs e) { if (dgvMain.SelectedRows == null) { return; } if (dgvMain.SelectedRows.Count == 0) { return; } cQSO qso = dgvMain.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { return; } int iD = qso.ID; _blQSOs.Remove(qso); if (0 <= iD) { string sQSODb = Path.Combine(_cfg.DBpath, string.Format("{0}.db", _cfg.MyCall.ToUpper())); try { System.Reflection.PropertyInfo[] piQSO = typeof(cQSO).GetProperties(); using (SQLiteConnection con = new SQLiteConnection(string.Format("Data Source={0};Version=3;", sQSODb))) { con.Open(); using (SQLiteTransaction st = con.BeginTransaction()) using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = string.Format("delete from [T_QSO] where [ID] = {0}", iD); cmd.ExecuteNonQuery(); st.Commit(); } } } catch (Exception ex) { ErrMsg("Error: Saving QSO to DB.\n" + ex.Message); } } }
private void mnuAddNewQSO_Click(object sender, EventArgs e) { List <cQSO> lsAllQSO = new List <cQSO>(); foreach (cQSO q in _blQSOs) { lsAllQSO.Add(q); } cQSO NewQSO; if (0 < _blQSOs.Count) { NewQSO = new cQSO(_blQSOs[_blQSOs.Count - 1]); } else { NewQSO = new cQSO(); } int[] iColW = new int[dgvMain.ColumnCount]; string[] sColN = new string[dgvMain.ColumnCount]; for (int i = 0; i < iColW.Length; i++) { if (dgvMain.Columns[i].Visible) { iColW[i] = dgvMain.Columns[i].Width; sColN[i] = dgvMain.Columns[i].HeaderText; } else { iColW[i] = -1; sColN[i] = "N/A"; } } frmQSO f = new frmQSO(NewQSO, _blQSOs, _dcDXCC, _dcCityCode, _dcBand, _dcMode, _dcDefault, iColW, sColN, _cfg); f.Show(); }
private void cmsGrid_Print_Click(object sender, EventArgs e) { if (dgvMain.SelectedRows == null) { return; } if (dgvMain.SelectedRows.Count == 0) { return; } cQSO qso = dgvMain.SelectedRows[0].DataBoundItem as cQSO; if (qso == null) { return; } frmPrintCards fp = new frmPrintCards(new List <cQSO>() { qso }, _dcMode); fp.ShowDialog(); }
//WSJT-XのLogプレビュー作成 private void PreviewWSJT() { List <string> lsErr = new List <string>(); int iDc = 0; //Dupeの件数 int iL = 0; using (StreamReader sr = new StreamReader(txtSetInCSV.Text, Encoding.ASCII)) { while (-1 < sr.Peek()) { iL++; cQSO q = new cQSO(); //自局情報 if (txtPrefix_My.Text != "") { q.Prefix_My = txtPrefix_My.Text; } if (txtQTH_My.Text != "") { q.QTH_My = txtQTH_My.Text; } if (txtDcode.Text != "") { q.CityCode_My = txtDcode.Text; } if (txtGL.Text != "") { q.GL_My = txtGL.Text; } if (0 <= cboQSL.SelectedIndex) { cQSL qs = (cQSL)cboQSL.SelectedItem; q.QSLMethod = qs.QSLMethod; } //QSO情報 string[] sL = sr.ReadLine().Split(','); DateTime dtS, dtE; int iV; double dV; if (!DateTime.TryParse(sL[0].Replace("-", "/") + " " + sL[1], out dtS)) { lsErr.Add(string.Format("Line:{0} 開始時刻の書式が不正", iL)); } if (!DateTime.TryParse(sL[2].Replace("-", "/") + " " + sL[3], out dtE)) { lsErr.Add(string.Format("Line:{0} 終了時刻の書式が不正", iL)); } q.Date_S = dtS.Ticks; q.Date_E = dtE.Ticks; q.TimeZone = 0; q.Call = sL[4]; q.GL = sL[5]; if (double.TryParse(sL[6], out dV)) { q.SetFreq(dV, _dcBand); } else { lsErr.Add(string.Format("Line:{0} 周波数の書式が不正", iL)); } q.Mode = sL[7]; string[] sCalls = q.Call.Split('/'); #region "移動運用対策" if (sCalls.Length == 3) { q.Prefix1 = sCalls[0]; q.Call = sCalls[1]; q.Prefix2 = sCalls[2]; } else if (sCalls.Length == 2) { if (sCalls[0].Length < sCalls[1].Length) { q.Prefix1 = sCalls[0]; q.Call = sCalls[1]; } else { q.Call = sCalls[0]; q.Prefix2 = sCalls[1]; } } #endregion //デフォルト設定のリグ if (chkUseDefault.Checked && _dcDefault.ContainsKey(q.Band)) { if (q.Prefix_My == "") { q.Rig_My = _dcDefault[q.Band].RigHome; q.Ant_My = _dcDefault[q.Band].AntHome; } else { q.Rig_My = _dcDefault[q.Band].RigMobile; q.Ant_My = _dcDefault[q.Band].AntMobile; } } if (int.TryParse(sL[8], out iV)) { q.RS_His = iV; } else { lsErr.Add(string.Format("Line:{0} 相手RSの書式が不正", iL)); } if (int.TryParse(sL[9], out iV)) { q.RS_My = iV; } else { lsErr.Add(string.Format("Line:{0} 自局RSの書式が不正", iL)); } if (double.TryParse(sL[10], out dV)) { q.Pwr_My = dV; } else { if (sL[10] != "") { lsErr.Add(string.Format("Line:{0} 出力の書式が不正", iL)); } } q.Remarks = sL[11]; q.QRA = sL[12]; //重複判別 bool bDupe = false; foreach (cQSO pq in _blDest) { if (pq.Date_S == q.Date_S && pq.Call == pq.Call) { bDupe = true; iDc++; } } if (bDupe && chkExceptDupe.Checked) { continue; } #region "DXCC" { string sPrefix = q.Call; if (1 < q.Prefix1.Length) { sPrefix = q.Prefix1; } if (1 < q.Prefix2.Length) { sPrefix = q.Prefix2; } Dictionary <string, string> dcDx = GetDXCC(sPrefix); if (dcDx.Count == 1) { var kv = dcDx.FirstOrDefault(); q.DXCC = kv.Key; } } #endregion _blPreview.Add(q); } } if (lsErr.Count != 0) { string sErr = string.Join("\n", lsErr); MessageBox.Show("エラーがありました。\n\n" + sErr, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (iDc != 0) { MessageBox.Show("重複件数: " + iDc.ToString(), "重複がありました", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void frmMain_Load(object sender, EventArgs e) { if (_cfg.MyCall == "") { ErrMsg("コールサインが未設定です。\n一旦アプリを終了します。アプリを再起動して、コールサインを入力してください。"); } #region "DXCC・JCC/JCG・バンド・モード取得" try { string sPropDb = Path.Combine(_cfg.DBpath, "PropatyList.db"); if (!Directory.Exists(_cfg.DBpath)) { ErrMsg(string.Format("Error: Not exist Directory \"{0}\"", _cfg.DBpath)); return; } if (!File.Exists(sPropDb)) { ErrMsg("Error: Not exist \"PropatyList.db\""); return; } #region "DXCC, JCC/JCG, Band, Mode, DefaultRig(Key・空の値のみ)" using (SQLiteConnection con = new SQLiteConnection(string.Format("Data Source={0};Version=3;", sPropDb))) { con.Open(); //DXCC using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = "select [DXCC],[Name],[Pattern],[EntityCode] from [T_DXCC]"; SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string sDxcc = dr["DXCC"].ToString(); string sPats = dr["Pattern"].ToString(); string sName = dr["Name"].ToString(); int iECode; if (!int.TryParse(dr["EntityCode"].ToString(), out iECode)) { ErrMsg("Error: DXCC Entityのフォーマットが不正です。"); return; } _dcDXCC.Add(sDxcc, new cDxcc(sDxcc, sName, sPats, iECode)); } } //JCC・JCG using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = "select [CityCode],[JCCG],[Area],[Name],[Search] from [T_City]"; SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string sDc = dr["CityCode"].ToString(); string sC2 = dr["JCCG"].ToString(); string sA = dr["Area"].ToString(); string sN = dr["Name"].ToString(); string sS = dr["Search"].ToString(); _dcCityCode.Add(sDc, new cCity(sDc, sC2, sA, sN, sS)); } } //Band using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = "select [BandF],[BandL],[Lower],[Upper] from [T_Band] order by [Lower]"; SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string sBF = dr["BandF"].ToString(); string sBL = dr["BandL"].ToString(); double dL = double.Parse(dr["Lower"].ToString()); double dU = double.Parse(dr["Upper"].ToString()); _dcBand.Add(sBF, new cBand(sBF, sBL, dL, dU)); //初期設定のRig・Ant→Keyのみ登録 _dcDefault.Add(sBF, new cDefaultRig(sBF)); } } //Mode using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = "select [Mode],[Category],[Type] from [T_Mode]"; SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string sMd = dr["Mode"].ToString(); string sCt = dr["Category"].ToString(); string sTp = dr["Type"].ToString(); _dcMode.Add(sMd, new cMode(sMd, sCt, sTp)); } } } #endregion } catch (Exception ex) { ErrMsg("Reading propaty.\n" + ex.Message); return; } #endregion string sQOsDb = Path.Combine(_cfg.DBpath, string.Format("{0}.db", _cfg.MyCall.ToUpper())); dgvMain.SuspendLayout(); #region "QSO DB①" //DBなし→空のDBを作成 if (!File.Exists(sQOsDb)) { try { CreateQsoDb(); } catch (Exception ex) { ErrMsg("Error: While creating QSO db.\n" + ex.Message); } } else { try { //DBあり→QSOデータを読み取る List <string> lsFld = new List <string>(); //Select文→[]付き Dictionary <string, Type> dcFld = new Dictionary <string, Type>(); #region "cQSOのPropertyInfo取得" { System.Reflection.PropertyInfo[] pi = typeof(cQSO).GetProperties(); for (int i = 0; i < pi.Length; i++) { if (!pi[i].CanWrite) { continue; } //書込不可プロパティは飛ばす(他プロパティから表示用を生成) lsFld.Add(string.Format("[{0}]", pi[i].Name)); dcFld.Add(pi[i].Name, pi[i].PropertyType); } } #endregion #region "DB→cQSO" using (SQLiteConnection con = new SQLiteConnection(string.Format("Data Source={0};Version=3;", sQOsDb))) { con.Open(); using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = string.Format("select {0} from [T_QSO];", string.Join(", ", lsFld)); SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { cQSO q = new cQSO(); #region "db→cQSO" foreach (string sP in dcFld.Keys) { var pp = typeof(cQSO).GetProperty(sP); string sVal = dr[sP].ToString(); if (pp.PropertyType == typeof(int)) { pp.SetValue(q, int.Parse(sVal)); } else if (pp.PropertyType == typeof(long)) { pp.SetValue(q, long.Parse(sVal)); } else if (pp.PropertyType == typeof(double)) { pp.SetValue(q, double.Parse(sVal)); } else if (pp.PropertyType == typeof(string)) { pp.SetValue(q, sVal); } else if (pp.PropertyType == typeof(bool)) { pp.SetValue(q, Convert.ToBoolean(int.Parse(sVal))); } } #endregion _blQSOs.Add(q); } } con.Close(); } //ファイルを開放させるおまじない //https://www.it-swarm.dev/ja/sqlite/systemdatasqlite-close%EF%BC%88%EF%BC%89%E3%81%8C%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E8%A7%A3%E6%94%BE%E3%81%97%E3%81%AA%E3%81%84/941181713/ GC.Collect(); GC.WaitForPendingFinalizers(); #endregion } catch (Exception ex) { ErrMsg("Error: While reading QSO db.\n" + ex.Message); } } #endregion #region "QSO DB②→初期設定のRig・Ant" try { List <string> lsFlds = new List <string>(); #region "cDefaultRigのPropertyInfo取得" { System.Reflection.PropertyInfo[] pi = typeof(cDefaultRig).GetProperties(); for (int i = 0; i < pi.Length; i++) { if (pi[i].Name != "BandF") { lsFlds.Add(string.Format("[{0}]", pi[i].Name)); } } } #endregion string sQSODb = Path.Combine(_cfg.DBpath, string.Format("{0}.db", _cfg.MyCall.ToUpper())); using (SQLiteConnection con = new SQLiteConnection(string.Format("Data Source={0};Version=3;", sQSODb))) { con.Open(); using (SQLiteTransaction st = con.BeginTransaction()) using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = string.Format("CREATE TABLE IF NOT EXISTS[T_DefaultRig]([BandF] text PRIMARY KEY, {0} text);", string.Join(" text, ", lsFlds)); cmd.ExecuteNonQuery(); st.Commit(); System.Reflection.PropertyInfo[] pi = typeof(cDefaultRig).GetProperties(); lsFlds.Add("[BandF]"); foreach (string sB in _dcDefault.Keys) { cmd.CommandText = string.Format("select {0} from [T_DefaultRig] where [BandF] = '{1}';", string.Join(",", lsFlds), sB); using (SQLiteDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { string sT = dr.GetTableName(0); for (int i = 0; i < pi.Length; i++) { string sFn = pi[i].Name; string sVal = dr[sFn].ToString(); if (!pi[i].CanWrite) { continue; } //書込不可プロパティは飛ばす(他プロパティから表示用を生成) var pp = typeof(cDefaultRig).GetProperty(sFn); pp.SetValue(_dcDefault[sB], sVal); } } } } } } //ファイルを開放させるおまじない //https://www.it-swarm.dev/ja/sqlite/systemdatasqlite-close%EF%BC%88%EF%BC%89%E3%81%8C%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E8%A7%A3%E6%94%BE%E3%81%97%E3%81%AA%E3%81%84/941181713/ GC.Collect(); GC.WaitForPendingFinalizers(); } catch (Exception ex) { ErrMsg("Error: While Read/Create DefaultRig on QSO db.\n" + ex.Message); } #endregion try { _BS.DataSource = _blQSOs; dgvMain.DataSource = _BS; #region "DataGridView制御" dgvMain.RowHeadersVisible = false; dgvMain.Columns["ID"].Width = (int)(_cfg.DPIscaleFactor * 55); dgvMain.Columns["ScreenQSLMethod"].Width = (int)(_cfg.DPIscaleFactor * 20); dgvMain.Columns["ScreenCardSend"].Width = (int)(_cfg.DPIscaleFactor * 20); dgvMain.Columns["ScreenCardReceive"].Width = (int)(_cfg.DPIscaleFactor * 20); dgvMain.Columns["ScreenDate"].Width = (int)(_cfg.DPIscaleFactor * 95); dgvMain.Columns["ScreenTime"].Width = (int)(_cfg.DPIscaleFactor * 75); dgvMain.Columns["ScreenTimeZone"].Width = (int)(_cfg.DPIscaleFactor * 35); dgvMain.Columns["ScreenCall"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["RS_His"].Width = (int)(_cfg.DPIscaleFactor * 40); dgvMain.Columns["RS_My"].Width = (int)(_cfg.DPIscaleFactor * 40); dgvMain.Columns["Freq"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["Mode"].Width = (int)(_cfg.DPIscaleFactor * 50); dgvMain.Columns["ScreenPwr_My"].Width = (int)(_cfg.DPIscaleFactor * 30); dgvMain.Columns["QRA"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["QTH"].Width = (int)(_cfg.DPIscaleFactor * 200); dgvMain.Columns["DXCC"].Width = (int)(_cfg.DPIscaleFactor * 60); dgvMain.Columns["CityCode"].Width = (int)(_cfg.DPIscaleFactor * 80); dgvMain.Columns["GL"].Width = (int)(_cfg.DPIscaleFactor * 60); dgvMain.Columns["QTH_h"].Width = (int)(_cfg.DPIscaleFactor * 200); dgvMain.Columns["QSLManager"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["Rig_His"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["Ant_His"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["ScreenPwr_His"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["Rig_My"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["Ant_My"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["QTH_My"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["Prefix_My"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["CityCode_My"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["GL_My"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["CardMsg"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["Remarks"].Width = (int)(_cfg.DPIscaleFactor * 100); dgvMain.Columns["ScreenQSLMethod"].HeaderText = "Q"; dgvMain.Columns["ScreenCardSend"].HeaderText = "S"; dgvMain.Columns["ScreenCardReceive"].HeaderText = "R"; dgvMain.Columns["ScreenDate"].HeaderText = "Date"; dgvMain.Columns["ScreenTime"].HeaderText = "Time"; dgvMain.Columns["ScreenTimeZone"].HeaderText = " "; dgvMain.Columns["ScreenCall"].HeaderText = "Callsign"; dgvMain.Columns["RS_His"].HeaderText = "His"; dgvMain.Columns["RS_My"].HeaderText = "My"; dgvMain.Columns["Freq"].HeaderText = "Freq[MHz]"; dgvMain.Columns["Mode"].HeaderText = "Mode"; dgvMain.Columns["ScreenPwr_My"].HeaderText = "Power"; dgvMain.Columns["QRA"].HeaderText = "Name"; dgvMain.Columns["QTH"].HeaderText = "QTH"; dgvMain.Columns["DXCC"].HeaderText = "DXCC"; dgvMain.Columns["CityCode"].HeaderText = "JCC/JCG"; dgvMain.Columns["GL"].HeaderText = "GL"; dgvMain.Columns["QTH_h"].HeaderText = "Home"; dgvMain.Columns["QSLManager"].HeaderText = "Manager"; dgvMain.Columns["Rig_His"].HeaderText = "His Rig"; dgvMain.Columns["Ant_His"].HeaderText = "His Ang"; dgvMain.Columns["ScreenPwr_His"].HeaderText = "His Power"; dgvMain.Columns["Rig_My"].HeaderText = "My Rig"; dgvMain.Columns["Ant_My"].HeaderText = "My Ant"; dgvMain.Columns["QTH_My"].HeaderText = "My QTH"; dgvMain.Columns["Prefix_My"].HeaderText = "My Area"; dgvMain.Columns["CityCode_My"].HeaderText = "My JCC/JCG"; dgvMain.Columns["GL_My"].HeaderText = "My GL"; dgvMain.Columns["CardMsg"].HeaderText = "Message"; dgvMain.Columns["Remarks"].HeaderText = "Remarks"; dgvMain.Columns["Prefix1"].HeaderText = "P1"; dgvMain.Columns["Prefix1"].Visible = false; dgvMain.Columns["Prefix2"].Visible = false; dgvMain.Columns["Call"].Visible = false; dgvMain.Columns["Date_S"].Visible = false; dgvMain.Columns["Date_E"].Visible = false; dgvMain.Columns["TimeZone"].Visible = false; dgvMain.Columns["Band"].Visible = false; dgvMain.Columns["Pwr_My"].Visible = false; dgvMain.Columns["Pwr_His"].Visible = false; dgvMain.Columns["QSLMethod"].Visible = false; dgvMain.Columns["Card_Send"].Visible = false; dgvMain.Columns["Card_Resv"].Visible = false; dgvMain.Columns["Except"].Visible = false; dgvMain.Columns["LastUpdate"].Visible = false; dgvMain.Columns["CallQSL"].Visible = false; dgvMain.Columns["Time_HHmm"].Visible = false; if (0 < dgvMain.Rows.Count) { dgvMain.FirstDisplayedCell = dgvMain[0, dgvMain.Rows.Count - 1]; } #endregion CountCard(); //カード未発行枚数 } catch (Exception ex) { ErrMsg("DataGridView.\n" + ex.Message); return; } dgvMain.ContextMenuStrip = cmsGrid; dgvMain.ResumeLayout(); }
private void RegistQSO() { int iTmp; double dTmp; #region "交信開始時刻" { int iTz; if (txtTimeZone.Text.ToUpper() == "JST") { iTz = 9; } else if (txtTimeZone.Text.ToUpper() == "UTC") { iTz = 0; } else if (!int.TryParse(txtTimeZone.Text, out iTz)) { //DateTime dtU = DateTime.UtcNow; //TimeSpan ts = DateTime.Now - dtU; ErrMsg("Invalid timezone formatting.\nタイムゾーンの書式が不正です(JST:+9、UTC:0)。"); } DateTime dtS; if (!DateTime.TryParse(txtDate_S.Text + " " + txtTime_S.Text, out dtS)) { ErrMsg("Invalid date formatting.\n日付の書式が不正です。"); return; } dtS = dtS.AddHours(-iTz); _QSO.Date_S = dtS.Ticks; } #endregion _QSO.Prefix1 = txtPrefix1.Text; _QSO.Prefix2 = txtPrefix2.Text; if (txtCall.Text == "") { ErrMsg("Error:The callsign is blank.\nコールサインが空白です。"); return; } else { _QSO.Call = txtCall.Text; } _QSO.QRA = txtQRA.Text; _QSO.DXCC = txtDXCC.Text; _QSO.CityCode = txtCityCode.Text; _QSO.GL = txtGL.Text; _QSO.QTH = txtQTH.Text; _QSO.QTH_h = txtQTH_h.Text; if (int.TryParse(txtRS_His.Text, out iTmp)) { _QSO.RS_His = iTmp; } else { ErrMsg("Error: RS_His"); return; } if (int.TryParse(txtRS_My.Text, out iTmp)) { _QSO.RS_My = iTmp; } else { ErrMsg("Error: RS_My"); return; } if (double.TryParse(txtFreq.Text, out dTmp)) { _QSO.SetFreq(dTmp, _dcBand); } else { ErrMsg("Error: Freq"); return; } _QSO.Mode = txtMode.Text; if (double.TryParse(txtPwr_My.Text, out dTmp)) { _QSO.Pwr_My = dTmp; } else { ErrMsg("Error: Pwr_My"); return; } #region "交信終了時刻" { if (txtTime_E.Text == "") { _QSO.Date_E = -1; } else { DateTime dtTmp; if (DateTime.TryParse(txtDate_S.Text + " " + txtTime_E.Text, out dtTmp)) { _QSO.Date_E = dtTmp.AddHours(-_QSO.TimeZone).Ticks; if (_QSO.Date_E < _QSO.Date_S) { _QSO.Date_E = dtTmp.AddHours(24 - _QSO.TimeZone).Ticks; } //零時またぎのQSO } else { ErrMsg("Error: Date_E or Time_E"); return; } } } #endregion _QSO.QSLManager = txtQSLManager.Text; _QSO.Rig_His = txtRig_His.Text; _QSO.Ant_His = txtAnt_His.Text; #region "相手局出力" if (txtPwr_His.Text == "") { _QSO.Pwr_His = -1d; } else { if (double.TryParse(txtPwr_His.Text, out dTmp)) { _QSO.Pwr_His = dTmp; } else { ErrMsg("Error: Pwr_His"); return; } } #endregion _QSO.Rig_My = txtRig_My.Text; _QSO.Ant_My = txtAnt_My.Text; _QSO.QTH_My = txtQTH_My.Text; _QSO.Prefix_My = txtPrefix_My.Text; _QSO.CityCode_My = txtCityCode_My.Text; _QSO.GL_My = txtGL_My.Text; _QSO.CardMsg = txtCardMsg.Text; _QSO.Remarks = txtRemark.Text; _QSO.Card_Send = chkCard_Send.Checked; _QSO.Card_Resv = chkCard_Resv.Checked; _QSO.Except = chkExcept.Checked; _QSO.LastUpdate = DateTime.UtcNow.Ticks; #region "QSLカード交換方法" if (rdoBureau.Checked) { _QSO.QSLMethod = (int)cQSO.enQSLMethod.B; } else if (rdoDirect.Checked) { _QSO.QSLMethod = (int)cQSO.enQSLMethod.D; } else if (rdoManager.Checked) { _QSO.QSLMethod = (int)cQSO.enQSLMethod.M; } else if (rdoNone.Checked) { _QSO.QSLMethod = (int)cQSO.enQSLMethod.N; } else if (rdo1way.Checked) { _QSO.QSLMethod = (int)cQSO.enQSLMethod.R; } else { _QSO.QSLMethod = (int)cQSO.enQSLMethod.X; } #endregion //新規QSO→更新履歴に追加する if (!_blAllQSO.Contains(_QSO) && _QSO.Call != "") { _blAllQSO.Add(_QSO); } //QSOを新規に _QSO = new cQSO(_QSO); RefleshForm(); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="QSO">編集・新規QSOオブジェクト</param> /// <param name="AllQSO">全更新履歴</param> /// <param name="DXCC">DXCCリスト</param> /// <param name="CityCode">JCC/JCG+町村リスト</param> /// <param name="Bands">バンド一覧</param> /// <param name="Modes">モード一覧</param> /// <param name="Config">設定</param> public frmQSO(cQSO QSO, BindingList <cQSO> AllQSO, Dictionary <string, cDxcc> DXCC, Dictionary <string, cCity> CityCode, Dictionary <string, cBand> Bands, Dictionary <string, cMode> Modes, Dictionary <string, cDefaultRig> Default, int[] ColWidths, string[] ColNames, Config Config) { _QSO = QSO; _blAllQSO = AllQSO; _dcDXCC = DXCC; _dcCityCode = CityCode; _dcBand = Bands; _dcMode = Modes; _dcDefault = Default; _cfg = Config; _iColWidth = ColWidths; _sColName = ColNames; InitializeComponent(); }
private void cmdSetInCSV_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (Directory.Exists(txtSetInCSV.Text)) { ofd.InitialDirectory = txtSetInCSV.Text; } ofd.Filter = "Logcs CSV file(*.csv)|*.csv|All files(*.*)|*.*"; if (ofd.ShowDialog() != DialogResult.OK) { return; } txtSetInCSV.Text = ofd.FileName; List <string> lsErr = new List <string>(); dgvInport.SuspendLayout(); using (StreamReader sr = new StreamReader(txtSetInCSV.Text, Encoding.GetEncoding(932))) { int iL = 0; while (-1 < sr.Peek()) { iL++; string[] sL = sr.ReadLine().Split(','); List <string> lsL = new List <string>(); #region "カンマ区切り対策" lsL.AddRange(sL); // 項目分繰り返す for (int i = 0; i < lsL.Count; ++i) { //先頭のスペースを除去して、ダブルクォーテーションが入っていないか判定する if (lsL[i] != string.Empty && lsL[i].TrimStart()[0] == '"') { // もう一回ダブルクォーテーションが出てくるまで要素を結合 while (lsL[i].TrimEnd()[lsL[i].TrimEnd().Length - 1] != '"') { lsL[i] = lsL[i] + "," + lsL[i + 1]; //結合したら要素を削除する lsL.RemoveAt(i + 1); } } } for (int i = 0; i < lsL.Count; i++) { lsL[i] = lsL[i].Trim().Replace("\"", ""); } #endregion cQSO q = new cQSO(); int iV; double dV; q.Prefix1 = lsL[0]; q.Call = lsL[1]; q.Prefix2 = lsL[2]; q.CityCode = lsL[3]; q.QTH = lsL[4]; q.QTH_h = lsL[6]; q.QRA = lsL[7]; if (int.TryParse(lsL[8], out iV)) { q.RS_His = iV; } else { lsErr.Add(string.Format("{0} RS_His={1}", iL, lsL[8])); } if (int.TryParse(lsL[9], out iV)) { q.RS_My = iV; } else { lsErr.Add(string.Format("{0} RS_My={1}", iL, lsL[9])); } if (double.TryParse(lsL[10], out dV)) { q.SetFreq(dV, _dcBand); } q.Mode = lsL[11]; if (double.TryParse(lsL[12], out dV)) { q.Pwr_My = dV; } else { q.Pwr_My = -1d; } DateTime dtS; if (lsL[16] == "J") { q.TimeZone = 9; } else if (lsL[16] == "U") { q.TimeZone = 0; } else { lsErr.Add(string.Format("{0} TimeZone={1}", iL, lsL[16])); } if (!DateTime.TryParse(string.Format("{0} {1}", lsL[13].Replace("-", "/"), lsL[14]), out dtS)) { lsErr.Add(string.Format("{0} Day={1} Time={2}", iL, lsL[13], lsL[14])); } else { q.Date_S = dtS.AddHours(-q.TimeZone).Ticks; } q.QTH_My = lsL[21]; q.Prefix_My = lsL[22]; if (Regex.IsMatch(lsL[23], @"^\d{4}")) { q.DXCC = "JA"; q.CityCode_My = lsL[23]; } else { q.DXCC = lsL[23]; } q.GL_My = lsL[24]; q.Rig_My = lsL[25]; q.Ant_My = lsL[26]; #region "カード交換方式" q.QSLMethod = (int)cQSO.enQSLMethod.N; if (lsL[29] == "J") { q.QSLMethod = (int)cQSO.enQSLMethod.B; } else if (lsL[29] == "D") { q.QSLMethod = (int)cQSO.enQSLMethod.D; } else if (lsL[29] == "M") { q.QSLMethod = (int)cQSO.enQSLMethod.M; } #endregion if (lsL[30] == "*") { q.Card_Send = true; } else { q.Card_Send = false; } if (lsL[31] == "*") { q.Card_Resv = true; } else { q.Card_Resv = false; } _blPreview.Add(q); } dgvInport.ResumeLayout(); } MessageBox.Show("プレビューされた交信リストを確認のうえ、問題が無ければ登録を押してください。", "確認", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void txtCall_Leave(object sender, EventArgs e) { txtCall.Text = txtCall.Text.ToUpper(); if (txtCall.Text == "") { return; } //コールサインの書式 if (!Regex.IsMatch(txtCall.Text, @"[A-Z0-1]*")) { WarnMsg("Check the call sign format.\nコールサインの書式を確認してください。\n" + txtCall.Text); return; } #region "DXCC" { string sPrefix = txtCall.Text; if (1 < txtPrefix1.Text.Length) { sPrefix = txtPrefix1.Text; } if (1 < txtPrefix2.Text.Length) { sPrefix = txtPrefix2.Text; } Dictionary <string, string> dcDx = GetDXCC(sPrefix); if (dcDx.Count == 1) { var kv = dcDx.FirstOrDefault(); txtDXCC.Text = kv.Key; if (txtQTH.Text == "" && kv.Key != "JA") { txtQTH.Text = kv.Value; } } } #endregion if (txtDXCC.Text != "JA" && txtDXCC.Text != "" && txtTimeZone.Text == "JST") { string sDT = txtDate_S.Text + " " + txtTime_S.Text; DateTime dt; if (DateTime.TryParse(sDT, out dt)) { dt = dt.AddHours(-9d); txtTimeZone.Text = "UTC"; txtDate_S.Text = string.Format("{0:yyyy/MM/dd}", dt); txtTime_S.Text = string.Format("{0:HH:mm}", dt); } } string sQRA = ""; //名前(Hitした中で一番長い名前を取得する→コンテスト等を考慮) #region "過去のQSO検索" dgvPastQSO.SuspendLayout(); //描画を止める if (0 < _blPastQSO.Count) { _blPastQSO.Clear(); } List <cQSO> lsPast = new List <cQSO>(); //過去QSO一時置き場(ソート可能に) foreach (cQSO q in _blAllQSO) { if (txtCall.Text == q.Call) { if (sQRA.Length < q.QRA.Length) { sQRA = q.QRA; } lsPast.Add(q); } } txtQRA.Text = sQRA; //ソート lsPast.Sort((a, b) => a.Date_S.CompareTo(b.Date_S)); foreach (cQSO q in lsPast) { _blPastQSO.Add(q); } if (0 < _blPastQSO.Count) { dgvPastQSO.FirstDisplayedCell = dgvPastQSO[0, _blPastQSO.Count - 1]; cQSO ql = _blPastQSO[_blPastQSO.Count - 1]; lblLastQSO.Text = string.Format("Last QSO: {0:yyyy/MM/dd} {1}({2})", DateTime.FromBinary(ql.Date_S).AddHours(ql.TimeZone), ql.Band, ql.Mode); } else { lblLastQSO.Text = "Last QSO: N/A (1st QSO)"; } dgvPastQSO.ResumeLayout(); #endregion }
/// <summary> /// コンストラクタ /// </summary> /// <param name="QSO">編集・新規QSOオブジェクト</param> public frmQSO(cQSO QSO, frmMain MainForm) { _QSO = QSO; _blAllQSO = MainForm.AllQSO; _dcDXCC = MainForm.DXCCList; _dcCityCode = MainForm.CityList; _dcBand = MainForm.BandList; _dcMode = MainForm.ModeList; _dcDefault = MainForm.DefaultRigList; _cfg = MainForm.Config; _iColWidth = MainForm.GridColWidth; _sColName = MainForm.GridColNames; InitializeComponent(); }
public void PrintQSLCard(object sender, PrintPageEventArgs e) { PrintErrors.Clear(); Graphics g = e.Graphics; //ミリメートル単位に g.PageUnit = GraphicsUnit.Millimeter; //構文パターン & データパターン(フィールド取得) Regex rgCom = new Regex(sComPat); Regex rgDat = new Regex(sDatPat); System.Reflection.PropertyInfo[] piQSO = typeof(cQSO).GetProperties(); Dictionary <string, string>[] dcDats = new Dictionary <string, string> [iQSOsParPage]; int iStep = 0; //当該ページに載るQSOの数 #region "QSOデータ取得" //まずは空の値を取得 for (int i = 0; i < iQSOsParPage; i++) { dcDats[i] = new Dictionary <string, string>(); for (int j = 0; j < piQSO.Length; j++) { string sPn = piQSO[j].Name; dcDats[i].Add(sPn, ""); } } for (int i = 0; i < iQSOsParPage; i++) { if (_lsQSO.Count <= iCurIndex + i) { break; } //印刷QSOの範囲を超えているとき→データは無い if (_lsQSO[iCurIndex].Call != _lsQSO[iCurIndex + i].Call) { break; } iStep = i + 1; for (int j = 0; j < piQSO.Length; j++) { string sPn = piQSO[j].Name; System.Reflection.PropertyInfo pi = typeof(cQSO).GetProperty(sPn); //名前でアクセス cQSO q = _lsQSO[iCurIndex + i]; string ss = pi.GetValue(q).ToString(); dcDats[i][sPn] = pi.GetValue(q).ToString(); } } #endregion for (int iC = 0; iC < _lsCom.Count; iC++) { string sCom = _lsCom[iC].Command; string[] sPrm = _lsCom[iC].Params; string sDat = _lsCom[iC].RawDate; try { #region "データ取得" { int iDp = 0; //データページ var mts = rgDat.Matches(sDat); for (int j = 0; j < mts.Count; j++) { if (mts[j].Groups.Count < 2) { continue; } string sFn = Regex.Replace(mts[j].Groups[1].Value, @"%([^\%]+)%", "$1"); if (3 <= (mts[j].Groups.Count)) { if (int.TryParse(Regex.Replace(mts[j].Groups[2].Value, @"^\[(\d+)]", "$1"), out iDp)) { iDp--; } } if (dcDats.Length <= iDp) { continue; } if (!dcDats[iDp].ContainsKey(sFn)) { continue; } sDat = sDat.Replace(mts[j].Groups[0].Value, dcDats[iDp][sFn]); } } #endregion #region "コマンド実行" //パラメータのうち、第1・第2引数は位置(x,y) float fX, fY; if (!float.TryParse(sPrm[0], out fX)) { throw new Exception(string.Format("印刷コマンドの第1パラメータ(印刷位置X)は数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } if (!float.TryParse(sPrm[1], out fY)) { throw new Exception(string.Format("印刷コマンドの第2パラメータ(印刷位置Y)は数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } fX += fDx; fY += fDy; //印刷コマンド if (sCom == "line") //線分 #line(x1, y1, x2, y2, Red, Green, Blue, Width) { float fX2, fY2; if (!float.TryParse(sPrm[2], out fX2)) { throw new Exception(string.Format("印刷位置X2は数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } if (!float.TryParse(sPrm[3], out fY2)) { throw new Exception(string.Format("印刷位置Y2は数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } fX2 += fDx; fY2 += fDy; int iR, iG, iB; float fW; int.TryParse(sPrm[4], out iR); int.TryParse(sPrm[5], out iG); int.TryParse(sPrm[6], out iB); float.TryParse(sPrm[7], out fW); Pen pn = new Pen(Color.FromArgb(iR, iG, iB), fW); g.DrawLine(pn, fX, fY, fX2, fY2); } else if (sCom == "line_ifblank") //線分 #line(x1, y1, x2, y2, Red, Green, Blue, Width,対象とするQSO番号) { int iNo = 0; if (9 <= sPrm.Length) { if (int.TryParse(sPrm[8], out iNo)) { iNo--; } } bool bFlg = false; if (_lsQSO.Count <= iCurIndex + iNo) { bFlg = true; } else { if (_lsQSO[iCurIndex].Call != _lsQSO[iCurIndex + iNo].Call) { bFlg = true; } } if (!bFlg) { continue; } float fX2, fY2; if (!float.TryParse(sPrm[2], out fX2)) { throw new Exception(string.Format("印刷位置X2は数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } if (!float.TryParse(sPrm[3], out fY2)) { throw new Exception(string.Format("印刷位置Y2は数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } fX2 += fDx; fY2 += fDy; int iR, iG, iB; float fW; int.TryParse(sPrm[4], out iR); int.TryParse(sPrm[5], out iG); int.TryParse(sPrm[6], out iB); float.TryParse(sPrm[7], out fW); Pen pn = new Pen(Color.FromArgb(iR, iG, iB), fW); g.DrawLine(pn, fX, fY, fX2, fY2); } else if (sCom == "rect") //長方形 #rect(x1, y1, w, h, Red, Green, Blue, Width) { float fW, fH; if (!float.TryParse(sPrm[2], out fW)) { throw new Exception(string.Format("幅Wは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } if (!float.TryParse(sPrm[3], out fH)) { throw new Exception(string.Format("高さHは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } int iR, iG, iB; float fT; int.TryParse(sPrm[4], out iR); int.TryParse(sPrm[5], out iG); int.TryParse(sPrm[6], out iB); float.TryParse(sPrm[7], out fT); Pen pn = new Pen(Color.FromArgb(iR, iG, iB), fT); g.DrawRectangle(pn, fX, fY, fW, fH); } else if (sCom == "text") //横書きテキスト #text(x, y, フォント名, サイズ, Align) Data { float fS; if (!float.TryParse(sPrm[3], out fS)) { throw new Exception(string.Format("フォントサイズは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } Font ft = new Font(sPrm[2], fS); Brush bh = Brushes.Black; string sAlgn = ""; if (4 < sPrm.Length) { sAlgn = sPrm[4]; GetTextOrg(sDat, sAlgn, ft, g, ref fX, ref fY); } g.DrawString(sDat, ft, bh, fX, fY); } else if (sCom == "text_p") //1文字テキスト #text_p(x, y, フォント名, サイズ, 開始位置:1~) Data { float fS; if (!float.TryParse(sPrm[3], out fS)) { throw new Exception(string.Format("フォントサイズは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } Font ft = new Font(sPrm[2], fS); Brush bh = Brushes.Black; string sAlgn = ""; if (5 < sPrm.Length) { sAlgn = sPrm[5]; GetTextOrg(sDat, sAlgn, ft, g, ref fX, ref fY); } int iStart = int.Parse(sPrm[4]) - 1; if (sDat.Length < iStart + 1) { sDat = ""; } else { sDat = sDat.Substring(iStart, 1); } g.DrawString(sDat, ft, bh, fX, fY); } else if (sCom == "text_rcvd") //QSL受領時テキスト #text_rcvd(x, y, フォント名, サイズ, Align, QSO番号) Data { int iNo = 0; if (6 <= sPrm.Length) { if (int.TryParse(sPrm[5], out iNo)) { iNo--; } } if (_lsQSO.Count <= iCurIndex + iNo) { continue; } if (_lsQSO[iCurIndex].Call != _lsQSO[iCurIndex + iNo].Call) { continue; } if (!_lsQSO[iCurIndex + iNo].Card_Resv) { continue; } float fS; if (!float.TryParse(sPrm[3], out fS)) { throw new Exception(string.Format("フォントサイズは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } Font ft = new Font(sPrm[2], fS); Brush bh = Brushes.Black; string sAlgn = ""; if (4 < sPrm.Length) { sAlgn = sPrm[4]; GetTextOrg(sDat, sAlgn, ft, g, ref fX, ref fY); } g.DrawString(sDat, ft, bh, fX, fY); } else if (sCom == "text_unrcvd") //QSL未受領時テキスト #text_unrcvd(x, y, フォント名, サイズ, Align, QSO番号) Data { int iNo = 0; if (6 <= sPrm.Length) { if (int.TryParse(sPrm[5], out iNo)) { iNo--; } } if (_lsQSO.Count <= iCurIndex + iNo) { continue; } if (_lsQSO[iCurIndex].Call != _lsQSO[iCurIndex + iNo].Call) { continue; } if (_lsQSO[iCurIndex + iNo].Card_Resv) { continue; } float fS; if (!float.TryParse(sPrm[3], out fS)) { throw new Exception(string.Format("フォントサイズは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } Font ft = new Font(sPrm[2], fS); Brush bh = Brushes.Black; string sAlgn = ""; if (4 < sPrm.Length) { sAlgn = sPrm[4]; GetTextOrg(sDat, sAlgn, ft, g, ref fX, ref fY); } g.DrawString(sDat, ft, bh, fX, fY); } else if (sCom == "text_myport") //自局移動運用時Prefix(/エリア) #text_unrcvd(x, y, フォント名, サイズ, Align, QSO番号) Data { int iNo = 0; if (6 <= sPrm.Length) { if (int.TryParse(sPrm[5], out iNo)) { iNo--; } } if (_lsQSO.Count <= iCurIndex + iNo) { continue; } if (_lsQSO[iCurIndex].Call != _lsQSO[iCurIndex + iNo].Call) { continue; } if (_lsQSO[iCurIndex + iNo].Prefix_My == "") { continue; } sDat = "/" + _lsQSO[iCurIndex + iNo].Prefix_My; float fS; if (!float.TryParse(sPrm[3], out fS)) { throw new Exception(string.Format("フォントサイズは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } Font ft = new Font(sPrm[2], fS); Brush bh = Brushes.Black; string sAlgn = ""; if (4 < sPrm.Length) { sAlgn = sPrm[4]; GetTextOrg(sDat, sAlgn, ft, g, ref fX, ref fY); } g.DrawString(sDat, ft, bh, fX, fY); } else if (sCom == "text_date") //年月日(x, y, フォント名, サイズ, Align, Format, QSO番号) { int iNo = 0; if (7 <= sPrm.Length) { if (int.TryParse(sPrm[6], out iNo)) { iNo--; } } if (_lsQSO.Count <= iCurIndex + iNo) { continue; } if (_lsQSO[iCurIndex].Call != _lsQSO[iCurIndex + iNo].Call) { continue; } DateTime dtS = DateTime.FromBinary(_lsQSO[iCurIndex + iNo].Date_S).AddHours(_lsQSO[iCurIndex + iNo].TimeZone); string sFmt = ""; if (5 < sPrm.Length) { sFmt = sPrm[5]; } string sDat2 = string.Format("{0:dd} {1}.", dtS, dtS.ToString("MMM", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))); if (sFmt == "yyyy" || sFmt == "MM" || sFmt == "M" || sFmt == "dd" || sFmt == "d") { sDat2 = dtS.ToString(sFmt); } if (sFmt == "MMM") { sDat2 = dtS.ToString(sFmt, System.Globalization.CultureInfo.CreateSpecificCulture("en-US")); } float fS; if (!float.TryParse(sPrm[3], out fS)) { throw new Exception(string.Format("フォントサイズは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } Font ft = new Font(sPrm[2], fS); Brush bh = Brushes.Black; string sAlgn = ""; if (4 < sPrm.Length) { sAlgn = sPrm[4]; GetTextOrg(sDat2, sAlgn, ft, g, ref fX, ref fY); } g.DrawString(sDat2, ft, bh, fX, fY); } else if (sCom == "text_ifdata") //横書きテキスト #text_ifdata(x, y, フォント名, サイズ, Align, QSO番号, データの時のText, データ以外の時のText) { int iNo = 0; if (6 <= sPrm.Length) { if (int.TryParse(sPrm[5], out iNo)) { iNo--; } } float fS; if (!float.TryParse(sPrm[3], out fS)) { throw new Exception(string.Format("フォントサイズは数値である必要があります。\n{0}行目、{1}", _lsCom[iC].LineNo, _lsCom[iC].Line)); } Font ft = new Font(sPrm[2], fS); Brush bh = Brushes.Black; string sAlgn = ""; sDat = sPrm[6]; string sMd = ""; if (dcDats[iNo].ContainsKey("Mode")) { sMd = dcDats[iNo]["Mode"]; } if (_dcMode.ContainsKey(sMd)) { string sCat = _dcMode[sMd].Type; if (sCat.ToUpper() == "DATA") { sDat = sPrm[5]; } } if (4 < sPrm.Length) { sAlgn = sPrm[4]; GetTextOrg(sDat, sAlgn, ft, g, ref fX, ref fY); } g.DrawString(sDat, ft, bh, fX, fY); } #endregion } catch (Exception ex) { //throw ex; PrintErrors.Add(ex.Message); } } iCurIndex += iStep; if (iCurIndex < _lsQSO.Count) { e.HasMorePages = true; } else { e.HasMorePages = false; iCurIndex = 0; } }
private void mnuMain_ToolsSortDT_Click(object sender, EventArgs e) { string sQSODb = Path.Combine(_cfg.DBpath, string.Format("{0}.db", _cfg.MyCall.ToUpper())); string sOldDB = Path.Combine(_cfg.DBpath, string.Format("{0}_old.db", _cfg.MyCall.ToUpper())); List <cQSO> lsQSO = new List <cQSO>(); #region "ソート準備" try { GC.Collect(); GC.WaitForPendingFinalizers(); if (File.Exists(sOldDB)) { File.Delete(sOldDB); } File.Move(sQSODb, sOldDB); bool bBandErr = false; //バンド名称エラー #region "ソート用リスト作成&バンドチェック" foreach (cQSO q in _blQSOs) { if (!_dcBand.ContainsKey(q.Band)) { bBandErr = true; } lsQSO.Add(q); } if (bBandErr) { if (MessageBox.Show("周波数帯を修正しますか?", "確認", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { foreach (cQSO q in lsQSO) { foreach (string sB in _dcBand.Keys) { if (_dcBand[sB].Lower <= q.Freq && q.Freq <= _dcBand[sB].Upper) { q.Band = sB; break; } } } } } #endregion lsQSO.Sort((a, b) => (int)((a.Date_S - b.Date_S) / 10000000)); CreateQsoDb(); GC.Collect(); GC.WaitForPendingFinalizers(); } catch (Exception ex) { ErrMsg("ソート中のエラー\n" + ex.Message); } #endregion #region "ソート結果をBindingList & DBに登録" try { dgvMain.SuspendLayout(); _blQSOs.Clear(); for (int i = 0; i < lsQSO.Count; i++) { cQSO q = lsQSO[i]; q.ID = -1; //i + 1; _blQSOs.Add(q); } SaveToDb(); } catch (Exception ex) { ErrMsg("ソート反映中のエラー" + ex.Message); } #endregion #region "DefaultRigをDBに登録" try { using (SQLiteConnection con = new SQLiteConnection(string.Format("Data Source={0};Version=3;", sQSODb))) { con.Open(); using (SQLiteTransaction st = con.BeginTransaction()) using (SQLiteCommand cmd = con.CreateCommand()) { cmd.CommandText = "delete from [T_DefaultRig]"; cmd.ExecuteNonQuery(); foreach (cDefaultRig df in _dcDefault.Values) { cmd.CommandText = string.Format("INSERT INTO [T_DefaultRig]([BandF], [RigHome], [AntHome], [RigMobile], [AntMobile]) VALUES('{0}','{1}','{2}','{3}','{4}');", df.BandF, df.RigHome, df.AntHome, df.RigMobile, df.AntMobile); int iRes = cmd.ExecuteNonQuery(); } st.Commit(); } con.Close(); } //DBを開放させるおまじない GC.Collect(); GC.WaitForPendingFinalizers(); } catch (Exception ex) { ErrMsg(ex.Message); } #endregion //用済みになったバックアップを削除 if (MessageBox.Show("ソート前のバックアップを削除します。\nファイル名:" + sOldDB, "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { File.Delete(sOldDB); } }