From f84f6606637d9340a98afb9500838e4f5e2ba81f Mon Sep 17 00:00:00 2001 From: Xjph Date: Sat, 22 Jun 2019 13:00:43 -0230 Subject: [PATCH] Fix copy exception, other tidying. --- EDDisco/EDDisco.cs | 7 ------- EDDisco/EDDisco.csproj | 1 + EDDisco/EDDiscoFrm.Designer.cs | 7 +++++++ EDDisco/EDDiscoFrm.cs | 31 +++++++++++++++++-------------- EDDisco/EDDiscoFrm.resx | 3 +++ EDDisco/TODO.txt | 8 ++++++++ 6 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 EDDisco/TODO.txt diff --git a/EDDisco/EDDisco.cs b/EDDisco/EDDisco.cs index 64087cb..9804b22 100644 --- a/EDDisco/EDDisco.cs +++ b/EDDisco/EDDisco.cs @@ -9,16 +9,9 @@ namespace EDDisco { static class EDDisco { - /// - /// The main entry point for the application. - /// [STAThread] static void Main() { - //JObject test = JObject.Parse("{ \"timestamp\":\"2019 - 06 - 05T01: 41:44Z\", \"event\":\"Scan\", \"ScanType\":\"Detailed\", \"BodyName\":\"Plaa Fleau QS-J c22-0 5 a\", \"BodyID\":8, \"Parents\":[ {\"Planet\":7}, {\"Star\":0} ], \"DistanceFromArrivalLS\":3068.617188, \"TidalLock\":false, \"TerraformState\":\"\", \"PlanetClass\":\"Icy body\", \"Atmosphere\":\"\", \"AtmosphereType\":\"None\", \"Volcanism\":\"\", \"MassEM\":0.039342, \"Radius\":2984278.000000, \"SurfaceGravity\":1.760719, \"SurfaceTemperature\":67.210930, \"SurfacePressure\":90.113243, \"Landable\":true, \"Materials\":[ { \"Name\":\"sulphur\", \"Percent\":27.437029 }, { \"Name\":\"carbon\", \"Percent\":23.071699 }, { \"Name\":\"phosphorus\", \"Percent\":14.770898 }, { \"Name\":\"iron\", \"Percent\":11.999499 }, { \"Name\":\"nickel\", \"Percent\":9.075918 }, { \"Name\":\"chromium\", \"Percent\":5.396573 }, { \"Name\":\"germanium\", \"Percent\":3.174578 }, { \"Name\":\"vanadium\", \"Percent\":2.946659 }, { \"Name\":\"cadmium\", \"Percent\":0.931815 }, { \"Name\":\"antimony\", \"Percent\":0.671342 }, { \"Name\":\"mercury\", \"Percent\":0.523998 } ], \"Composition\":{ \"Ice\":0.878241, \"Rock\":0.104724, \"Metal\":0.017035 }, \"SemiMajorAxis\":2443254784.000000, \"Eccentricity\":0.000000, \"OrbitalInclination\":-37.623867, \"Periapsis\":149.435867, \"OrbitalPeriod\":53715820.000000, \"RotationPeriod\":176866.078125, \"AxialTilt\":-0.354162, \"WasDiscovered\":false, \"WasMapped\":false }"); - //ScanEvent scanEvent; - //scanEvent = test.ToObject(); - //Properties.Settings.Default. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new EDDiscoFrm()); diff --git a/EDDisco/EDDisco.csproj b/EDDisco/EDDisco.csproj index 2d06825..94e6e2b 100644 --- a/EDDisco/EDDisco.csproj +++ b/EDDisco/EDDisco.csproj @@ -120,6 +120,7 @@ + diff --git a/EDDisco/EDDiscoFrm.Designer.cs b/EDDisco/EDDiscoFrm.Designer.cs index 1d1b4d8..87179c3 100644 --- a/EDDisco/EDDiscoFrm.Designer.cs +++ b/EDDisco/EDDiscoFrm.Designer.cs @@ -46,6 +46,7 @@ private void InitializeComponent() this.copyNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.copyAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.cbxTtsDetail = new System.Windows.Forms.CheckBox(); + this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.contextCopy.SuspendLayout(); this.SuspendLayout(); // @@ -190,6 +191,11 @@ private void InitializeComponent() this.cbxTtsDetail.UseVisualStyleBackColor = true; this.cbxTtsDetail.Visible = false; // + // notifyIcon + // + this.notifyIcon.Text = "EDDiscoMon"; + this.notifyIcon.Visible = true; + // // EDDiscoFrm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -228,6 +234,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem copyNameToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem copyAllToolStripMenuItem; private System.Windows.Forms.CheckBox cbxTtsDetail; + private System.Windows.Forms.NotifyIcon notifyIcon; } } diff --git a/EDDisco/EDDiscoFrm.cs b/EDDisco/EDDiscoFrm.cs index f84879b..809fa81 100644 --- a/EDDisco/EDDiscoFrm.cs +++ b/EDDisco/EDDiscoFrm.cs @@ -15,7 +15,6 @@ namespace EDDisco public partial class EDDiscoFrm : Form { private LogMonitor logMonitor; - private NotifyIcon notifyIcon; private SpeechSynthesizer speech; public EDDiscoFrm() @@ -24,11 +23,8 @@ public EDDiscoFrm() logMonitor = new LogMonitor(""); logMonitor.LogEntry += LogEvent; Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); - notifyIcon = new NotifyIcon() - { - Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath), - Visible = false - }; + notifyIcon.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); + notifyIcon.Visible = false; } private void BtnToggleMonitor_Click(object sender, EventArgs e) @@ -202,7 +198,6 @@ private void CbxTts_CheckedChanged(object sender, EventArgs e) private void EDDiscoFrm_FormClosing(object sender, FormClosingEventArgs e) { notifyIcon.Icon = null; - notifyIcon.Dispose(); speech?.Dispose(); } @@ -241,13 +236,21 @@ private void CopyAllSelected() StringBuilder copyText = new StringBuilder(); foreach (ListViewItem item in listEvent.SelectedItems) { - copyText.AppendLine( - item.SubItems[2].Text + " - " + - item.SubItems[0].Text + " - " + - (item.SubItems[4].Text.Length > 0 ? "Landable - " : string.Empty) + - item.SubItems[1].Text + - (item.SubItems[3].Text.Length > 0 ? " - " + item.SubItems[3].Text : string.Empty) - ); + if (item.SubItems.Count == 5) + { + copyText.AppendLine( + item.SubItems[2].Text + " - " + + item.SubItems[0].Text + " - " + + (item.SubItems[4].Text.Length > 0 ? "Landable - " : string.Empty) + + item.SubItems[1].Text + + (item.SubItems[3].Text.Length > 0 ? " - " + item.SubItems[3].Text : string.Empty) + ); + } + else + { + copyText.AppendLine(item.SubItems[0].Text + " - Uninteresting"); + } + } Clipboard.SetText(copyText.ToString()); diff --git a/EDDisco/EDDiscoFrm.resx b/EDDisco/EDDiscoFrm.resx index cae2ef0..0fcf2fa 100644 --- a/EDDisco/EDDiscoFrm.resx +++ b/EDDisco/EDDiscoFrm.resx @@ -120,6 +120,9 @@ 17, 17 + + 137, 17 + diff --git a/EDDisco/TODO.txt b/EDDisco/TODO.txt new file mode 100644 index 0000000..e89230a --- /dev/null +++ b/EDDisco/TODO.txt @@ -0,0 +1,8 @@ +TO DO: + +- User configurable notification criteria +- Settings window + - Configure format of "copy all" + - Enable/disable built in criteria + - Configure TTS voice +- Investigate possibility of notifying via in-game chat \ No newline at end of file