Add Repeater selection and tuning

This commit is contained in:
mlhnet 2015-08-27 10:20:32 -04:00
parent 2f75571d03
commit 5aacd492f9
15 changed files with 992 additions and 144 deletions

View file

@ -41,6 +41,7 @@ using System.Threading.Tasks;
using System.IO;
using System.Net.Http.Headers;
using System.Reflection;
using System.Xml;
namespace CODEC2_GUI
{
@ -51,6 +52,21 @@ namespace CODEC2_GUI
}
private static HttpClient _client;
private static HttpClient client
{
get
{
if (_client == null)
_client = new HttpClient() { BaseAddress = new Uri("http://apps.dstarinfo.com") };
return _client;
}
}
private static string eventvalidation;
private static string viewstate;
private static string viewstategenerator;
private List<ReflectorOrRepeater> Repeaters_;
public List<ReflectorOrRepeater> Repeaters
{
@ -59,14 +75,9 @@ namespace CODEC2_GUI
if (Repeaters_ == null)
{
LoadRepeaters();
if (Repeaters_ == null || Repeaters_.Count == 0)
{
try
{
FetchAndSaveRepeaterList();
}
catch { }
}
if (Repeaters_ == null)
Repeaters_ = new List<ReflectorOrRepeater>();
}
return Repeaters_;
}
@ -93,9 +104,26 @@ namespace CODEC2_GUI
}
}
public bool FetchAndSaveRepeaterList()
public bool FetchAndSaveRepeaterList(string area)
{
return false;
bool result = false;
try
{
List<ReflectorOrRepeater> rptrs = GetDStarRepeaterByArea(area);
if (rptrs != null && rptrs.Count > 0)
{
SaveRepeaters(rptrs);
Repeaters_ = rptrs;
result = true;
}
}
catch (Exception ex)
{
string msg = "Fetch and save Repeater list failed!";
System.Diagnostics.Debug.WriteLine(string.Format("{0} {1}", msg, ex.Message));
throw new ApplicationException(msg, ex);
}
return result;
}
public bool FetchAndSaveReflectorList()
@ -120,17 +148,214 @@ namespace CODEC2_GUI
return result;
}
public List<string> GetDStarRepeaterAreas()
{
List<string> rptareas = new List<string>();
string htmlAreas = string.Empty;
try
{
if (client != null)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "D-STAR_Repeater_List.aspx");
Task<HttpResponseMessage> resp = client.SendAsync(request);
resp.Wait();
resp.Result.EnsureSuccessStatusCode();
Task<Stream> strm = resp.Result.Content.ReadAsStreamAsync();
strm.Wait();
using (StreamReader sr = new StreamReader(strm.Result, System.Text.Encoding.UTF8))
{
htmlAreas = sr.ReadToEnd();
}
}
viewstate = getHiddenValues(htmlAreas, "id=\"__VIEWSTATE\" value=\"");
viewstategenerator = getHiddenValues(htmlAreas, "id=\"__VIEWSTATEGENERATOR\" value=\"");
eventvalidation = getHiddenValues(htmlAreas, "id=\"__EVENTVALIDATION\" value=\"");
// parsing HTML select of areas
// start by finding "<select name=\"Countries1\""
int ofs = htmlAreas.IndexOf("<select name=\"Countries1\"");
if (ofs > 0)
{
// find end of select
int ofs2 = htmlAreas.IndexOf("</select>", ofs + 23);
if (ofs2 > 0)
{
string selVals = htmlAreas.Substring(ofs, ofs2 - ofs);
int ofs3 = 0;
int ofs4 = 0;
while (ofs4 < selVals.Length)
{
ofs4 = selVals.IndexOf("<option ", ofs3);
if (ofs4 > 0)
{
ofs4 += 8;
ofs3 = selVals.IndexOf("value=\"", ofs4);
if (ofs3 > 0)
{
ofs3 += 7;
ofs4 = selVals.IndexOf("\"", ofs3);
string val = selVals.Substring(ofs3, ofs4 - ofs3);
val = System.Net.WebUtility.HtmlDecode(val);
ofs3 = ofs4;
rptareas.Add(val);
}
}
else
break;
}
}
}
}
catch (Exception ex)
{
string msg = "Fetch Repeater Areas list failed!";
System.Diagnostics.Debug.WriteLine(string.Format("{0} {1}", msg, ex.Message));
throw new ApplicationException(msg, ex);
}
return rptareas;
}
private string getHiddenValues(string str, string prefix)
{
int ofs = str.IndexOf(prefix);
if (ofs > 0)
{
ofs += prefix.Length;
int ofs2 = str.IndexOf("\"", ofs);
if (ofs2 > ofs)
{
return str.Substring(ofs, ofs2 - ofs);
}
}
return null;
}
public List<ReflectorOrRepeater> GetDStarRepeaterByArea(string area)
{
string htmlRptrs = string.Empty;
if (client != null)
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "D-STAR_Repeater_List.aspx");
request.Content = new FormUrlEncodedContent(new [] {
new KeyValuePair<string, string>("__EVENTARGUMENT", string.Empty),
new KeyValuePair<string, string>("__EVENTTARGET", "Countries1"),
new KeyValuePair<string, string>("__EVENTVALIDATION", eventvalidation ?? string.Empty),
new KeyValuePair<string, string>("__LASTFOCUS", string.Empty),
new KeyValuePair<string, string>("__VIEWSTATE", viewstate ?? string.Empty),
new KeyValuePair<string, string>("__VIEWSTATEENCRYPTED", string.Empty),
new KeyValuePair<string, string>("__VIEWSTATEGENERATOR", viewstategenerator ?? string.Empty),
new KeyValuePair<string, string>("Countries1", System.Net.WebUtility.HtmlEncode(area)),
});
Task<HttpResponseMessage> resp = client.SendAsync(request);
resp.Wait();
resp.Result.EnsureSuccessStatusCode();
Task<Stream> strm = resp.Result.Content.ReadAsStreamAsync();
strm.Wait();
using (StreamReader sr = new StreamReader(strm.Result, System.Text.Encoding.UTF8))
{
htmlRptrs = sr.ReadToEnd();
}
}
List<ReflectorOrRepeater> rptr = new List<ReflectorOrRepeater>();
// parsing HTML table of repeaters
// find the start of table of repeaters
int ofs = htmlRptrs.IndexOf("<table id=\"ListView1_itemPlaceholderContainer\"");
if (ofs > 0)
{
// find end of table
int ofs2 = htmlRptrs.IndexOf("</table>", ofs + 46);
if (ofs2 > 0)
{
string selVals = htmlRptrs.Substring(ofs, ofs2 - ofs + 8);
// fix improper ampersand html encoding
string[] doms = System.Text.RegularExpressions.Regex.Split(selVals, @"&(?!\w{1,3};)");
selVals = string.Join("&amp;", doms);
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + selVals);
XmlNodeList xnl = xdoc.SelectNodes("//tr");
foreach (XmlNode xn in xnl)
{
ReflectorOrRepeater rr = new ReflectorOrRepeater();
string city = null;
string cty_state = null;
string modC = null;
string modB = null;
string modA = null;
XmlNodeList dnl = xn.SelectNodes("descendant::span");
foreach (XmlNode dn in dnl)
{
foreach (XmlAttribute xa in dn.Attributes)
{
if (xa.Name == "id")
{
if (xa.Value.StartsWith("ListView1_CityLabel"))
city = dn.InnerText;
else if (xa.Value.StartsWith("ListView1_CountryStateLabel"))
cty_state = dn.InnerText;
else if (xa.Value.StartsWith("ListView1_C_ModLabel"))
modC = dn.InnerText;
else if (xa.Value.StartsWith("ListView1_B_ModLabel"))
modB = dn.InnerText;
else if (xa.Value.StartsWith("ListView1_A_ModLabel"))
modA = dn.InnerText;
}
}
}
XmlNode fn = xn.FirstChild; // td
if (fn != null)
fn = fn.FirstChild; // a
if (fn != null && fn.Attributes != null)
{
XmlAttribute xlnk = fn.Attributes["href"];
if (xlnk != null)
{
string lnk = xlnk.Value;
if (!string.IsNullOrEmpty(lnk))
{
int idx = lnk.IndexOf("?Repeater=");
if (idx > 0)
{
string cs = System.Net.WebUtility.UrlDecode(lnk.Substring(idx + 10));
rr.Name = cs;
rr.Desc = string.Format("{0}|{1}|C:{2}|B:{3}|A:{4}", city ?? string.Empty, cty_state ?? string.Empty, modC ?? string.Empty, modB ?? string.Empty, modA ?? string.Empty);
rptr.Add(rr);
}
}
}
}
}
}
}
return rptr;
}
private List<ReflectorOrRepeater> GetDStarInfoReflectors()
{
string htmlReflector = string.Empty;
using (HttpClient client = new HttpClient())
if (client != null)
{
client.BaseAddress = new Uri("http://apps.dstarinfo.com");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "reflectors.aspx");
Task<HttpResponseMessage> resp = client.SendAsync(request);
resp.Wait();
resp.Result.EnsureSuccessStatusCode();
Task<Stream> strm = resp.Result.Content.ReadAsStreamAsync();
strm.Wait();
using (StreamReader sr = new StreamReader(strm.Result, System.Text.Encoding.UTF8))
@ -141,47 +366,54 @@ namespace CODEC2_GUI
List<ReflectorOrRepeater> refs = new List<ReflectorOrRepeater>();
// parsing HTML table of reflector information
// start by finding start of reflector name by prefix
// find next span tag which is description
// eliminate any link tag inside description span tag
// find the start of reflector NAME
int ofs = htmlReflector.IndexOf(">REF");
while (ofs > 0)
int ofs = htmlReflector.IndexOf("<table>");
if (ofs > 0)
ofs = htmlReflector.IndexOf("<table", ofs + 7);
if (ofs > 0)
{
// find end of name span
int ofs2 = htmlReflector.IndexOf("</span>", ofs + 1);
int ofs2 = htmlReflector.IndexOf("</table>", ofs + 7);
if (ofs2 > 0)
{
ReflectorOrRepeater rf = new ReflectorOrRepeater();
string sref = htmlReflector.Substring(ofs + 1, ofs2 - ofs - 1);
rf.Name = sref;
// find desc span
int ofs3 = htmlReflector.IndexOf("<span", ofs2);
if (ofs > 0)
string dom = htmlReflector.Substring(ofs, ofs2 - ofs + 8)
.Replace("target=_blank", string.Empty); // format issue for xml parse
// fix improper ampersand html encoding
string[] doms = System.Text.RegularExpressions.Regex.Split(dom, @"&(?!\w{1,3};)");
dom = string.Join("&amp;", doms);
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + dom);
XmlNodeList xnl = xdoc.SelectNodes("//tr");
foreach (XmlNode xn in xnl)
{
// find end of desc open span tag
ofs3 = htmlReflector.IndexOf(">", ofs3 + 1);
// find desc close span tag
int ofs4 = htmlReflector.IndexOf("</span>", ofs3 + 1);
// find possible surrounding link tag
int ofs5 = htmlReflector.IndexOf("<a href", ofs3 + 1);
// there is an link tag
if (ofs5 >= 0 && ofs5 < ofs4)
ReflectorOrRepeater rr = new ReflectorOrRepeater();
string refl = null;
string loc = null;
XmlNodeList dnl = xn.SelectNodes("descendant::span");
foreach (XmlNode dn in dnl)
{
ofs3 = htmlReflector.IndexOf(">", ofs5 + 1);
ofs4 = htmlReflector.IndexOf("</a>", ofs3 + 1);
foreach (XmlAttribute xa in dn.Attributes)
{
if (xa.Name == "id")
{
if (xa.Value.StartsWith("ListView1_ReflectorLabel"))
refl = dn.InnerText;
else if (xa.Value.StartsWith("ListView1_LocationLabel"))
loc = dn.InnerText;
}
}
}
if (!string.IsNullOrEmpty(refl))
{
rr.Name = refl;
rr.Desc = loc ?? string.Empty;
refs.Add(rr);
}
string desc = htmlReflector.Substring(ofs3 + 1, ofs4 - ofs3 - 1);
rf.Desc = desc;
refs.Add(rf);
// find next
ofs = htmlReflector.IndexOf(">REF", ofs3);
continue;
}
}
break;
}
return refs;
@ -229,9 +461,9 @@ namespace CODEC2_GUI
{
string line = sr.ReadLine();
string[] vals = line.Split('|');
if (vals.Length == 2)
if (vals.Length >= 2)
{
refs.Add(new ReflectorOrRepeater() { Name = vals[0], Desc = vals[1] });
refs.Add(new ReflectorOrRepeater() { Name = vals[0], Desc = string.Join("|", vals, 1, vals.Length - 1) });
}
}
sr.Close();
@ -288,10 +520,5 @@ namespace CODEC2_GUI
}
public class ReflectorOrRepeater
{
public string Name { get; set; }
public string Desc { get; set; }
}
}

View file

@ -34,16 +34,17 @@
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reloadDStarRepeaterListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.selectAreaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reloadDStarInfoRelectorListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.saveLogToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clearURListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.logList = new System.Windows.Forms.ListBox();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.saveLogToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
@ -58,7 +59,7 @@
//
this.lblNoDstar.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblNoDstar.AutoSize = true;
this.lblNoDstar.Location = new System.Drawing.Point(196, 24);
this.lblNoDstar.Location = new System.Drawing.Point(236, 24);
this.lblNoDstar.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblNoDstar.Name = "lblNoDstar";
this.lblNoDstar.Size = new System.Drawing.Size(241, 21);
@ -72,7 +73,7 @@
this.sliceFlow.Dock = System.Windows.Forms.DockStyle.Fill;
this.sliceFlow.Location = new System.Drawing.Point(0, 0);
this.sliceFlow.Name = "sliceFlow";
this.sliceFlow.Size = new System.Drawing.Size(682, 200);
this.sliceFlow.Size = new System.Drawing.Size(762, 200);
this.sliceFlow.TabIndex = 1;
this.sliceFlow.TabStop = true;
//
@ -85,7 +86,7 @@
this.editToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(682, 28);
this.menuStrip1.Size = new System.Drawing.Size(762, 28);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
@ -104,10 +105,19 @@
//
// reloadDStarRepeaterListToolStripMenuItem
//
this.reloadDStarRepeaterListToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.selectAreaToolStripMenuItem});
this.reloadDStarRepeaterListToolStripMenuItem.Name = "reloadDStarRepeaterListToolStripMenuItem";
this.reloadDStarRepeaterListToolStripMenuItem.Size = new System.Drawing.Size(262, 26);
this.reloadDStarRepeaterListToolStripMenuItem.Text = "Reload DStar Repeater List";
this.reloadDStarRepeaterListToolStripMenuItem.Click += new System.EventHandler(this.reloadDStarRepeaterListToolStripMenuItem_Click);
this.reloadDStarRepeaterListToolStripMenuItem.DropDownOpening += new System.EventHandler(this.reloadDStarRepeaterListToolStripMenuItem_DropDownOpening);
//
// selectAreaToolStripMenuItem
//
this.selectAreaToolStripMenuItem.Enabled = false;
this.selectAreaToolStripMenuItem.Name = "selectAreaToolStripMenuItem";
this.selectAreaToolStripMenuItem.Size = new System.Drawing.Size(159, 26);
this.selectAreaToolStripMenuItem.Text = "Select Area";
//
// reloadDStarInfoRelectorListToolStripMenuItem
//
@ -116,6 +126,23 @@
this.reloadDStarInfoRelectorListToolStripMenuItem.Text = "Reload DStar Relector List";
this.reloadDStarInfoRelectorListToolStripMenuItem.Click += new System.EventHandler(this.reloadDStarInfoRelectorListToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(259, 6);
//
// saveLogToFileToolStripMenuItem
//
this.saveLogToFileToolStripMenuItem.Name = "saveLogToFileToolStripMenuItem";
this.saveLogToFileToolStripMenuItem.Size = new System.Drawing.Size(262, 26);
this.saveLogToFileToolStripMenuItem.Text = "&Save Log to File...";
this.saveLogToFileToolStripMenuItem.Click += new System.EventHandler(this.saveLogToFileToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(259, 6);
//
// closeToolStripMenuItem
//
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
@ -147,7 +174,7 @@
this.logList.Location = new System.Drawing.Point(0, 0);
this.logList.Name = "logList";
this.logList.ScrollAlwaysVisible = true;
this.logList.Size = new System.Drawing.Size(682, 121);
this.logList.Size = new System.Drawing.Size(762, 121);
this.logList.TabIndex = 2;
//
// splitContainer1
@ -168,7 +195,7 @@
//
this.splitContainer1.Panel2.Controls.Add(this.logList);
this.splitContainer1.Panel2MinSize = 50;
this.splitContainer1.Size = new System.Drawing.Size(682, 325);
this.splitContainer1.Size = new System.Drawing.Size(762, 325);
this.splitContainer1.SplitterDistance = 200;
this.splitContainer1.TabIndex = 0;
//
@ -178,11 +205,11 @@
// toolStripContainer1.ContentPanel
//
this.toolStripContainer1.ContentPanel.Controls.Add(this.splitContainer1);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(682, 325);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(762, 325);
this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer1.Location = new System.Drawing.Point(0, 0);
this.toolStripContainer1.Name = "toolStripContainer1";
this.toolStripContainer1.Size = new System.Drawing.Size(682, 353);
this.toolStripContainer1.Size = new System.Drawing.Size(762, 353);
this.toolStripContainer1.TabIndex = 1;
this.toolStripContainer1.Text = "toolStripContainer1";
//
@ -190,27 +217,10 @@
//
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(259, 6);
//
// saveLogToFileToolStripMenuItem
//
this.saveLogToFileToolStripMenuItem.Name = "saveLogToFileToolStripMenuItem";
this.saveLogToFileToolStripMenuItem.Size = new System.Drawing.Size(262, 26);
this.saveLogToFileToolStripMenuItem.Text = "&Save Log to File...";
this.saveLogToFileToolStripMenuItem.Click += new System.EventHandler(this.saveLogToFileToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(259, 6);
//
// MainForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(682, 353);
this.ClientSize = new System.Drawing.Size(762, 353);
this.Controls.Add(this.toolStripContainer1);
this.Font = new System.Drawing.Font("Courier New", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -254,6 +264,7 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem saveLogToFileToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem selectAreaToolStripMenuItem;
}
}

View file

@ -34,8 +34,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -73,14 +71,6 @@ namespace CODEC2_GUI
private void Form1_Load(object sender, EventArgs e)
{
// not complete code
reloadDStarRepeaterListToolStripMenuItem.Visible = false;
// end not complete code
if (!string.IsNullOrEmpty(Properties.Settings.Default.MainPosition))
{
string[] cords = Properties.Settings.Default.MainPosition.Split(',');
@ -129,7 +119,6 @@ namespace CODEC2_GUI
void API_RadioRemoved(Radio radio)
{
//sliceFlow.Controls.Clear();
}
//*************************************
@ -254,14 +243,15 @@ namespace CODEC2_GUI
}
}
private void reloadDStarRepeaterListToolStripMenuItem_Click(object sender, EventArgs e)
private void reloadDStarRepeaterListToolStripMenuItemList(string area)
{
try
{
DstarInfo di = new DstarInfo();
di.FetchAndSaveRepeaterList();
di.FetchAndSaveRepeaterList(area);
SelectForm sf = new SelectForm();
sf.showOnly = true;
sf.repeaterOnly = true;
sf.Mode = SelectForm.RMode.Repeater;
sf.Owner = this;
sf.Show();
@ -304,6 +294,45 @@ namespace CODEC2_GUI
}
}
}
private void reloadDStarRepeaterListToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
for (int idx = reloadDStarRepeaterListToolStripMenuItem.DropDownItems.Count - 1; idx > 0; idx--)
{
reloadDStarRepeaterListToolStripMenuItem.DropDownItems.RemoveAt(idx);
}
try
{
DstarInfo di = new DstarInfo();
List<string> areas = di.GetDStarRepeaterAreas();
if (areas != null && areas.Count > 0)
{
foreach (string area in areas)
{
ToolStripMenuItem ti = new ToolStripMenuItem(area);
ti.Click += RepeaterAreaSelection_Click;
reloadDStarRepeaterListToolStripMenuItem.DropDownItems.Add(ti);
}
}
}
catch (Exception ex)
{
StringBuilder sb = new StringBuilder();
Exception ex1 = ex;
while (ex1 != null)
{
sb.AppendLine(ex1.Message);
ex1 = ex1.InnerException;
}
MessageBox.Show(sb.ToString(), "Load DSTARINFO Repeater Area Info Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
private void RepeaterAreaSelection_Click(object sender, EventArgs e)
{
ToolStripMenuItem ti = sender as ToolStripMenuItem;
reloadDStarRepeaterListToolStripMenuItemList(ti.Text);
}
}

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyVersion("1.4.0.1")]
[assembly: AssemblyFileVersion("1.4.0.1")]

View file

@ -0,0 +1,51 @@
/*******************************************************************************
* ReflectorOrRepeater.cs
*
* DStar Repeater / Reflector Model
*
* Created on: 2015-08-27
* Author: Mark Hanson / AA3RK / MKCM Software, LLC.
*
*
*******************************************************************************
*
* Copyright (C) 2015 FlexRadio Systems.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact: gpl<AT>flexradio<DOT>com or
*
* GPL C/O FlexRadio Systems
* 4616 W. Howard Lane
* Suite 1-150
* Austin, TX USA 78728
*
******************************************************************************/
namespace CODEC2_GUI
{
public class ReflectorOrRepeater
{
public string Name { get; set; }
public string Desc { get; set; }
public double Frequency { get; set; }
public double Offset { get; set; }
public string RepeaterName
{
get
{
if (Frequency == 0)
return Name;
return string.Format("{0}~{1}~{2}", Name ?? string.Empty, Frequency, Offset);
}
}
}
}

View file

@ -0,0 +1,107 @@
namespace CODEC2_GUI
{
partial class RepeaterModule
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(30, 29);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(224, 40);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(30, 87);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(224, 40);
this.button2.TabIndex = 0;
this.button2.Text = "button1";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(30, 145);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(224, 40);
this.button3.TabIndex = 0;
this.button3.Text = "button1";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(30, 203);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(224, 40);
this.btnCancel.TabIndex = 0;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// RepeaterModule
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(282, 281);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "RepeaterModule";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "Repeater Module";
this.Load += new System.EventHandler(this.RepeaterModule_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button btnCancel;
}
}

View file

@ -0,0 +1,143 @@
/*******************************************************************************
* RepeaterModule.cs
*
* DStar Repeater Selection Dialog
*
* Created on: 2015-08-27
* Author: Mark Hanson / AA3RK / MKCM Software, LLC.
*
*
*******************************************************************************
*
* Copyright (C) 2015 FlexRadio Systems.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact: gpl<AT>flexradio<DOT>com or
*
* GPL C/O FlexRadio Systems
* 4616 W. Howard Lane
* Suite 1-150
* Austin, TX USA 78728
*
******************************************************************************/
using System;
using System.Windows.Forms;
namespace CODEC2_GUI
{
public partial class RepeaterModule : Form
{
public string RptName
{
get; set;
}
public string RptDesc
{
get; set;
}
public ReflectorOrRepeater SelectedRpt
{
get; set;
}
private double[] Frequency = new double[3];
private double[] Offset = new double[3];
public RepeaterModule()
{
InitializeComponent();
}
private void RepeaterModule_Load(object sender, EventArgs e)
{
button1.Visible = false;
button2.Visible = false;
button3.Visible = false;
string[] vals = RptDesc.Split('|');
for (int idx = 3; idx < vals.Length; idx++)
{
string[] mod = vals[idx].Split(':');
if (mod.Length != 2)
continue;
string[] fr = mod[1].Split(' ');
if (fr.Length == 0 || string.IsNullOrEmpty(fr[0]))
continue;
if (mod[0] == "A")
{
button1.Visible = true;
Frequency[0] = fr.Length > 0 ? Convert.ToDouble(fr[0]) : 0;
Offset[0] = fr.Length > 1 ? Convert.ToDouble(fr[1]) : 0;
button1.Text = string.Format("Mod A {0:#.000} MHz; {1:#.0} MHz", Frequency[0], Offset[0]);
}
else if (mod[0] == "B")
{
button2.Visible = true;
Frequency[1] = fr.Length > 0 ? Convert.ToDouble(fr[0]) : 0;
Offset[1] = fr.Length > 1 ? Convert.ToDouble(fr[1]) : 0;
button2.Text = string.Format("Mod B {0:#.000} MHz; {1:#.0} MHz", Frequency[1], Offset[1]);
}
else if (mod[0] == "C")
{
button3.Visible = true;
Frequency[2] = fr.Length > 0 ? Convert.ToDouble(fr[0]) : 0;
Offset[2] = fr.Length > 1 ? Convert.ToDouble(fr[1]) : 0;
button3.Text = string.Format("Mod C {0:#.000} MHz; {1:#.0} MHz", Frequency[2], Offset[2]);
}
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void button1_Click(object sender, EventArgs e)
{
SelectedRpt = new ReflectorOrRepeater();
SelectedRpt.Name = string.Format("{0,-7}A", RptName.Trim());
SelectedRpt.Desc = RptDesc;
SelectedRpt.Frequency = Frequency[0];
SelectedRpt.Offset = Offset[0];
DialogResult = DialogResult.OK;
Close();
}
private void button2_Click(object sender, EventArgs e)
{
SelectedRpt = new ReflectorOrRepeater();
SelectedRpt.Name = string.Format("{0,-7}B", RptName.Trim());
SelectedRpt.Desc = RptDesc;
SelectedRpt.Frequency = Frequency[1];
SelectedRpt.Offset = Offset[1];
DialogResult = DialogResult.OK;
Close();
}
private void button3_Click(object sender, EventArgs e)
{
SelectedRpt = new ReflectorOrRepeater();
SelectedRpt.Name = string.Format("{0,-7}C", RptName.Trim());
SelectedRpt.Desc = RptDesc;
SelectedRpt.Frequency = Frequency[2];
SelectedRpt.Offset = Offset[2];
DialogResult = DialogResult.OK;
Close();
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -33,12 +33,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CODEC2_GUI
@ -48,9 +43,10 @@ namespace CODEC2_GUI
public enum RMode { Repeater, Reflector, ReflectorCmd };
public RMode Mode { get; set; }
public bool showOnly { get; set; }
public bool repeaterOnly { get; set; }
public bool repeaterOnly { get; set; }
public string SelectedName { get; set; }
public string SelectedDesc { get; set; }
private IEnumerable<ReflectorOrRepeater> ReflectorList { get; set; }
private IEnumerable<ReflectorOrRepeater> RepeaterList { get; set; }
@ -77,23 +73,36 @@ namespace CODEC2_GUI
DstarInfo di = new DstarInfo();
ReflectorList = di.Refelectors;
RepeaterList = di.Repeaters;
if (repeaterOnly)
{
Mode = RMode.Repeater;
rb1.Checked = true;
rb2.Visible = false;
rb3.Visible = false;
if (di.Repeaters == null || di.Repeaters.Count == 0)
{
MessageBox.Show(this, "Load / Reload Repeater List from File Menu!", "Select Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
DialogResult = DialogResult.Cancel;
Close();
return;
}
RepeaterList = di.Repeaters;
}
else
{
if (RepeaterList == null || RepeaterList.Count() == 0)
if (di.Refelectors == null || di.Refelectors.Count == 0)
{
Mode = RMode.Reflector;
rb1.Visible = false;
MessageBox.Show(this, "Load / Reload Reflectors List from File Menu!", "Select Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
DialogResult = DialogResult.Cancel;
Close();
return;
}
ReflectorList = di.Refelectors;
rb1.Visible = false;
if (Mode == RMode.Repeater)
Mode = RMode.Reflector;
switch (Mode)
{
@ -146,9 +155,12 @@ namespace CODEC2_GUI
if (listView1.SelectedItems.Count > 0)
{
SelectedName = listView1.SelectedItems[0].Text;
if (Mode == RMode.Reflector)
SelectedName = string.Format("{0,-7}L", SelectedName);
StringBuilder sb = new StringBuilder();
foreach(ListViewItem.ListViewSubItem lvi in listView1.SelectedItems[0].SubItems)
{
sb.AppendFormat("{0}{1}", sb.Length > 0 ? "|" : string.Empty, lvi.Text);
}
SelectedDesc = sb.ToString();
DialogResult = DialogResult.OK;
Close();
}

View file

@ -97,6 +97,13 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReflectorOrRepeater.cs" />
<Compile Include="RepeaterModule.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RepeaterModule.Designer.cs">
<DependentUpon>RepeaterModule.cs</DependentUpon>
</Compile>
<Compile Include="SelectForm.cs">
<SubType>Form</SubType>
</Compile>
@ -122,6 +129,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="RepeaterModule.resx">
<DependentUpon>RepeaterModule.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SelectForm.resx">
<DependentUpon>SelectForm.cs</DependentUpon>
</EmbeddedResource>

View file

@ -123,6 +123,7 @@
this.urtxt.Name = "urtxt";
this.urtxt.Size = new System.Drawing.Size(152, 28);
this.urtxt.TabIndex = 7;
this.urtxt.SelectedIndexChanged += new System.EventHandler(this.urtxt_SelectedIndexChanged);
this.urtxt.TextChanged += new System.EventHandler(this.urtxt_TextChanged);
//
// rpt1txt
@ -131,8 +132,9 @@
this.rpt1txt.Margin = new System.Windows.Forms.Padding(4);
this.rpt1txt.MaxLength = 8;
this.rpt1txt.Name = "rpt1txt";
this.rpt1txt.Size = new System.Drawing.Size(159, 28);
this.rpt1txt.Size = new System.Drawing.Size(231, 28);
this.rpt1txt.TabIndex = 10;
this.rpt1txt.SelectedIndexChanged += new System.EventHandler(this.rpt1txt_SelectedIndexChanged);
this.rpt1txt.TextChanged += new System.EventHandler(this.rpt1txt_TextChanged);
//
// rpt2txt
@ -141,8 +143,9 @@
this.rpt2txt.Margin = new System.Windows.Forms.Padding(4);
this.rpt2txt.MaxLength = 8;
this.rpt2txt.Name = "rpt2txt";
this.rpt2txt.Size = new System.Drawing.Size(159, 28);
this.rpt2txt.Size = new System.Drawing.Size(231, 28);
this.rpt2txt.TabIndex = 13;
this.rpt2txt.SelectedIndexChanged += new System.EventHandler(this.rpt2txt_SelectedIndexChanged);
this.rpt2txt.TextChanged += new System.EventHandler(this.rpt2txt_TextChanged);
//
// rbDV
@ -199,13 +202,13 @@
this.btnRef.Name = "btnRef";
this.btnRef.Size = new System.Drawing.Size(61, 31);
this.btnRef.TabIndex = 8;
this.btnRef.Text = "R/R";
this.btnRef.Text = "Ref";
this.btnRef.UseVisualStyleBackColor = true;
this.btnRef.Click += new System.EventHandler(this.btnRef_Click);
//
// btnRpt
//
this.btnRpt.Location = new System.Drawing.Point(566, 58);
this.btnRpt.Location = new System.Drawing.Point(638, 58);
this.btnRpt.Name = "btnRpt";
this.btnRpt.Size = new System.Drawing.Size(61, 33);
this.btnRpt.TabIndex = 11;
@ -234,7 +237,7 @@
this.Font = new System.Drawing.Font("Courier New", 11F);
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "dstarctl";
this.Size = new System.Drawing.Size(641, 148);
this.Size = new System.Drawing.Size(730, 148);
this.Load += new System.EventHandler(this.dstarctl_Load);
this.ResumeLayout(false);
this.PerformLayout();

View file

@ -34,8 +34,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -64,6 +62,8 @@ namespace CODEC2_GUI
private string RPT1Orig = string.Empty;
private string RPT2Orig = string.Empty;
private bool inreset;
public bool DRMode
{
get
@ -80,7 +80,7 @@ namespace CODEC2_GUI
rpt1txt.Enabled =
rpt1.Enabled =
rpt2.Enabled =
//btnRpt.Visible =
btnRpt.Visible =
rpt2txt.Enabled =
value;
OnPropertyChanged("DRMode");
@ -158,9 +158,19 @@ namespace CODEC2_GUI
{
if (value == null)
value = string.Empty;
if (string.Compare(value, rpt1txt.Text, true) != 0)
if (rpt1txt.Text.StartsWith(value) == false)
{
rpt1txt.Text = value.ToUpper();
inreset = true;
value = value.ToUpper();
int idx = rpt1txt.FindString(value);
if (idx >= 0)
{
rpt1txt.SelectedIndex = idx;
value = rpt1txt.Text;
}
else
rpt1txt.Text = value;
inreset = false;
Modified = Modified & ~ModifyFlags.RPT1FLAG;
OnPropertyChanged("RPT1");
}
@ -256,6 +266,9 @@ namespace CODEC2_GUI
private void OnPropertyChanged(string prop)
{
if (inreset)
return;
if (prop == "Modified")
{
btnReset.Visible = Modified != ModifyFlags.NOFLAGS;
@ -276,7 +289,7 @@ namespace CODEC2_GUI
rpt1.Enabled = false;
rpt2.Enabled = false;
rpt2txt.Enabled = false;
//btnRpt.Visible = false;
btnRpt.Visible = false;
OnPropertyChanged("DRMode");
OnPropertyChanged("Modified");
@ -291,7 +304,7 @@ namespace CODEC2_GUI
rpt1.Enabled = true;
rpt2.Enabled = true;
rpt2txt.Enabled = true;
//btnRpt.Visible = true;
btnRpt.Visible = true;
OnPropertyChanged("DRMode");
OnPropertyChanged("Modified");
}
@ -307,17 +320,13 @@ namespace CODEC2_GUI
mynotetip.SetToolTip(mynotetxt, "Note (4 chars max)");
dvtip.SetToolTip(rbDV, "DStar Simplex Mode");
drtip.SetToolTip(rbDR, "DStar Repeater Mode");
// not complete code
btnRpt.Visible = false;
// end not complete code
}
private void mytxt_TextChanged(object sender, EventArgs e)
{
if (inreset)
return;
Modified = Modified | ModifyFlags.MYFLAG;
OnPropertyChanged("MY");
OnPropertyChanged("Modified");
@ -325,6 +334,8 @@ namespace CODEC2_GUI
private void mynotetxt_TextChanged(object sender, EventArgs e)
{
if (inreset)
return;
Modified = Modified | ModifyFlags.NOTEFLAG;
OnPropertyChanged("NOTE");
OnPropertyChanged("Modified");
@ -332,6 +343,8 @@ namespace CODEC2_GUI
private void urtxt_TextChanged(object sender, EventArgs e)
{
if (inreset)
return;
Modified = Modified | ModifyFlags.URFLAG;
OnPropertyChanged("UR");
OnPropertyChanged("Modified");
@ -339,6 +352,8 @@ namespace CODEC2_GUI
private void rpt1txt_TextChanged(object sender, EventArgs e)
{
if (inreset)
return;
Modified = Modified | ModifyFlags.RPT1FLAG;
OnPropertyChanged("RPT1");
OnPropertyChanged("Modified");
@ -346,10 +361,39 @@ namespace CODEC2_GUI
private void rpt2txt_TextChanged(object sender, EventArgs e)
{
if (inreset)
return;
Modified = Modified | ModifyFlags.RPT2FLAG;
OnPropertyChanged("RPT2");
OnPropertyChanged("Modified");
}
private void rpt1txt_SelectedIndexChanged(object sender, EventArgs e)
{
if (inreset)
return;
Modified = Modified | ModifyFlags.RPT1FLAG;
OnPropertyChanged("RPT1");
OnPropertyChanged("Modified");
}
private void rpt2txt_SelectedIndexChanged(object sender, EventArgs e)
{
if (inreset)
return;
Modified = Modified | ModifyFlags.RPT2FLAG;
OnPropertyChanged("RPT2");
OnPropertyChanged("Modified");
}
private void urtxt_SelectedIndexChanged(object sender, EventArgs e)
{
if (inreset)
return;
Modified = Modified | ModifyFlags.URFLAG;
OnPropertyChanged("UR");
OnPropertyChanged("Modified");
}
private void updateReset()
{
@ -366,6 +410,8 @@ namespace CODEC2_GUI
private void btnReset_Click(object sender, EventArgs e)
{
inreset = true;
rbDV.Checked = !DRModeOrig;
rbDR.Checked = DRModeOrig;
mytxt.Text = MYOrig;
@ -376,12 +422,13 @@ namespace CODEC2_GUI
rpt1txt.Enabled =
rpt1.Enabled =
rpt2.Enabled =
//btnRpt.Visible =
btnRpt.Visible =
rpt2txt.Enabled =
DRModeOrig;
Modified = ModifyFlags.NOFLAGS;
btnReset.Visible = false;
inreset = false;
Modified = ModifyFlags.NOFLAGS;
OnPropertyChanged("MY");
OnPropertyChanged("NOTE");
@ -397,9 +444,18 @@ namespace CODEC2_GUI
{
SelectForm sf = new SelectForm();
sf.Owner = this.TopLevelControl as Form;
sf.repeaterOnly = false;
if (sf.ShowDialog() == DialogResult.OK)
{
urtxt.Text = sf.SelectedName;
//if (sf.Mode == SelectForm.RMode.Repeater)
// urtxt.Text = "/" + sf.SelectedName.Split(' ')[0];
//else
if (sf.Mode == SelectForm.RMode.Reflector)
urtxt.Text = string.Format("{0,-7}L", sf.SelectedName);
else
urtxt.Text = sf.SelectedName;
Modified = Modified | ModifyFlags.URFLAG;
OnPropertyChanged("UR");
OnPropertyChanged("Modified");
@ -427,10 +483,17 @@ namespace CODEC2_GUI
sf.Owner = this.TopLevelControl as Form;
if (sf.ShowDialog() == DialogResult.OK)
{
rpt1txt.Text = sf.SelectedName;
Modified = Modified | ModifyFlags.RPT1FLAG;
OnPropertyChanged("RPT1");
OnPropertyChanged("Modified");
RepeaterModule rpm = new RepeaterModule();
rpm.Owner = this.TopLevelControl as Form;
rpm.RptName = sf.SelectedName;
rpm.RptDesc = sf.SelectedDesc;
if (rpm.ShowDialog() == DialogResult.OK)
{
rpt1txt.Text = rpm.SelectedRpt.RepeaterName;
Modified = Modified | ModifyFlags.RPT1FLAG;
OnPropertyChanged("RPT1");
OnPropertyChanged("Modified");
}
}
}
catch (Exception ex)
@ -445,5 +508,6 @@ namespace CODEC2_GUI
MessageBox.Show(sb.ToString(), "Select DSTARINFO Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
}

View file

@ -37,7 +37,7 @@
//
// btnCommit
//
this.btnCommit.Location = new System.Drawing.Point(528, 5);
this.btnCommit.Location = new System.Drawing.Point(565, 5);
this.btnCommit.Margin = new System.Windows.Forms.Padding(4);
this.btnCommit.Name = "btnCommit";
this.btnCommit.Size = new System.Drawing.Size(103, 29);
@ -80,10 +80,13 @@
this.dstarctl1.Name = "dstarctl1";
this.dstarctl1.NOTE = "";
this.dstarctl1.RPT1 = "";
this.dstarctl1.RPT1List = ((System.Collections.Generic.List<string>)(resources.GetObject("dstarctl1.RPT1List")));
this.dstarctl1.RPT2 = "";
this.dstarctl1.Size = new System.Drawing.Size(632, 146);
this.dstarctl1.RPT2List = ((System.Collections.Generic.List<string>)(resources.GetObject("dstarctl1.RPT2List")));
this.dstarctl1.Size = new System.Drawing.Size(731, 146);
this.dstarctl1.TabIndex = 0;
this.dstarctl1.UR = "";
this.dstarctl1.URList = ((System.Collections.Generic.List<string>)(resources.GetObject("dstarctl1.URList")));
//
// dstarlistitem
//
@ -96,7 +99,7 @@
this.Font = new System.Drawing.Font("Courier New", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "dstarlistitem";
this.Size = new System.Drawing.Size(652, 149);
this.Size = new System.Drawing.Size(734, 149);
this.Load += new System.EventHandler(this.dstarlistitem_Load);
this.ResumeLayout(false);
this.PerformLayout();

View file

@ -33,8 +33,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -210,7 +208,7 @@ namespace CODEC2_GUI
if (!string.IsNullOrEmpty(logMY) && !string.IsNullOrEmpty(logUR))
{
if (LogEvent != null)
LogEvent(this, new LogEventArgs(string.Format("{0} UR: {1,-8} MY: {2,-13}{3}",
LogEvent(this, new LogEventArgs(string.Format("{0} CALLED: {1,-8} CALLER: {2,-13}{3}",
DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
logUR,
logMY + (string.IsNullOrEmpty(logNote) ? string.Empty : "/" + logNote),
@ -261,12 +259,12 @@ namespace CODEC2_GUI
return;
}
string cmd;
string rpt1 = string.IsNullOrEmpty(dstarctl1.RPT1) ? "DIRECT" : dstarctl1.RPT1;
string rpt2 = string.IsNullOrEmpty(dstarctl1.RPT2) ? "DIRECT" : dstarctl1.RPT2;
cmd = "set destination_rptr=" + rpt2.Replace(" ", "\u007f");
_slice.SendWaveformCommand(cmd);
string rpt1 = string.IsNullOrEmpty(dstarctl1.RPT1) ? "DIRECT" : dstarctl1.RPT1;
cmd = "set departure_rptr=" + rpt1.Replace(" ", "\u007f");
_slice.SendWaveformCommand(cmd);
string ur = dstarctl1.UR;
cmd = "set companion_call=" + ur.Replace(" ", "\u007f");
_slice.SendWaveformCommand(cmd);
@ -277,6 +275,50 @@ namespace CODEC2_GUI
cmd = "set own_call2=" + note.Replace(" ", "\u007f");
_slice.SendWaveformCommand(cmd);
if (string.IsNullOrEmpty(dstarctl1.RPT1))
{
_slice.SendWaveformCommand("set departure_rptr=DIRECT");
}
else
{
string[] srpt1 = dstarctl1.RPT1.Split('~');
if (srpt1.Length > 0)
{
cmd = "set departure_rptr=" + srpt1[0].Replace(" ", "\u007f");
_slice.SendWaveformCommand(cmd);
if (srpt1.Length > 1)
{
try
{
_slice.Freq = Convert.ToDouble(srpt1[1]);
if (srpt1.Length > 2)
{
double ofs = Convert.ToDouble(srpt1[2]);
_slice.FMRepeaterOffsetFreq = Math.Abs(ofs);
_slice.RepeaterOffsetDirection = ofs == 0 ? FMTXOffsetDirection.Simplex :
(ofs < 0 ? FMTXOffsetDirection.Down : FMTXOffsetDirection.Up);
}
else
{
_slice.FMRepeaterOffsetFreq = 0;
_slice.RepeaterOffsetDirection = FMTXOffsetDirection.Simplex;
}
}
catch(Exception ex)
{
StringBuilder sb = new StringBuilder();
Exception ex1 = ex;
while (ex1 != null)
{
sb.AppendLine(ex1.Message);
ex1 = ex1.InnerException;
}
MessageBox.Show(sb.ToString(), "Set Slice Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
}
dstarctl1.Modified = dstarctl.ModifyFlags.NOFLAGS;
btnCommit.Enabled = false;
@ -288,7 +330,6 @@ namespace CODEC2_GUI
dstarctl1.RPT2 = rpt2 == "DIRECT" ? string.Empty : rpt2;
dstarctl1.DRMode = !string.IsNullOrEmpty(dstarctl1.RPT1);
// add new UR entry to dropdown list
List<string> lst = new List<string>(dstarctl1.URList);
ur = ur.ToUpper();

View file

@ -117,4 +117,31 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="dstarctl1.RPT1List" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB
AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0
ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs=
</value>
</data>
<data name="dstarctl1.RPT2List" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB
AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0
ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs=
</value>
</data>
<data name="dstarctl1.URList" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB
AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0
ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAgAAABEDAAAABAAAAA0ECw==
</value>
</data>
</root>