Skip to content

Commit 18ce2b1

Browse files
Merged PR 401: V3.1.14 Release 4
Related work items: #762, #763, #764, #765, #766, #767
1 parent fbf7d7f commit 18ce2b1

File tree

68 files changed

+880
-510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+880
-510
lines changed
33.8 KB
Binary file not shown.

src/Chem4Word.V3-1.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Notes", "Notes", "{1B81DF60
7171
ProjectSection(SolutionItems) = preProject
7272
Notes\Build Event Macro Locations.xlsx = Notes\Build Event Macro Locations.xlsx
7373
Notes\Git Tips.txt = Notes\Git Tips.txt
74-
Notes\MDL CTFile Formats.pdf = Notes\MDL CTFile Formats.pdf
7574
Notes\Metro Icon Colours.txt = Notes\Metro Icon Colours.txt
7675
Notes\MolFileFormat.txt = Notes\MolFileFormat.txt
7776
Notes\Releases.txt = Notes\Releases.txt

src/Chem4Word.V3/Chem4WordV3.cs

Lines changed: 97 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System;
99
using System.Collections.Generic;
1010
using System.Diagnostics;
11-
using System.Globalization;
1211
using System.IO;
1312
using System.Linq;
1413
using System.Net;
@@ -194,7 +193,7 @@ public static void SetGlobalRibbon(CustomRibbon ribbon)
194193

195194
private void C4WAddIn_Startup(object sender, EventArgs e)
196195
{
197-
string module = $"{MethodBase.GetCurrentMethod().Name}()";
196+
string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";
198197
try
199198
{
200199
// Deliberate crash to test Error Reporting
@@ -215,10 +214,18 @@ private void C4WAddIn_Startup(object sender, EventArgs e)
215214
PerformStartUpActions();
216215

217216
sw.Stop();
218-
message = $"{module} took {sw.ElapsedMilliseconds.ToString("#,000", CultureInfo.InvariantCulture)}ms";
217+
message = $"{module} took {SafeDouble.AsString(sw.ElapsedMilliseconds)}ms";
219218
StartUpTimings.Add(message);
220219
Debug.WriteLine(message);
221220
}
221+
else
222+
{
223+
if (Ribbon == null)
224+
{
225+
RegistryHelper.StoreMessage(module, "Ribbon is null");
226+
}
227+
RegistryHelper.StoreMessage(module, $"Command line {cmd}");
228+
}
222229
}
223230
catch (Exception exception)
224231
{
@@ -275,13 +282,13 @@ private void SlowOperations()
275282
Telemetry = new TelemetryWriter(true, Helper);
276283

277284
sw.Stop();
278-
message = $"{module} took {sw.ElapsedMilliseconds.ToString("#,000", CultureInfo.InvariantCulture)}ms";
285+
message = $"{module} took {SafeDouble.AsString(sw.ElapsedMilliseconds)}ms";
279286
Debug.WriteLine(message);
280287
StartUpTimings.Add(message);
281288
}
282-
catch (ThreadAbortException)
289+
catch (ThreadAbortException threadAbortException)
283290
{
284-
// Do Nothing
291+
RegistryHelper.StoreException(module, threadAbortException);
285292
}
286293
catch (Exception exception)
287294
{
@@ -297,15 +304,15 @@ private void PerformStartUpActions()
297304
{
298305
AddInInfo = new C4wAddInInfo();
299306

307+
UpdateHelper.ReadSavedValues();
308+
UpdateHelper.ReadThisVersion(Assembly.GetExecutingAssembly());
309+
ShowOrHideUpdateShield();
310+
300311
// Handle slower startup stuff on thread
301312
Thread thread = new Thread(SlowOperations);
302313
thread.SetApartmentState(ApartmentState.STA);
303314
thread.Start();
304315

305-
UpdateHelper.ReadSavedValues();
306-
UpdateHelper.ReadThisVersion(Assembly.GetExecutingAssembly());
307-
ShowOrHideUpdateShield();
308-
309316
if (VersionsBehind < Constants.MaximumVersionsBehind)
310317
{
311318
Word.Application app = Application;
@@ -349,18 +356,20 @@ private void PerformStartUpActions()
349356
}
350357
else
351358
{
359+
SetButtonStates(ButtonState.Disabled);
352360
StartUpTimings.Add(
353361
$"{module} chemistry operations disabled because Chem4Word is {VersionsBehind} versions behind!");
362+
RegistryHelper.StoreMessage(module, $"Chem4Word is disabled because it is {VersionsBehind} versions behind!");
354363
}
355364

356365
// Deliberate crash to test Error Reporting
357366
//int ii = 2;
358367
//int dd = 0;
359368
//int bang = ii / dd;
360369
}
361-
catch (ThreadAbortException)
370+
catch (ThreadAbortException threadAbortException)
362371
{
363-
// Do Nothing
372+
RegistryHelper.StoreException(module, threadAbortException);
364373
}
365374
catch (Exception exception)
366375
{
@@ -407,99 +416,98 @@ public void LoadOptions()
407416
// Initialise Telemetry with send permission
408417
Telemetry = new TelemetryWriter(true, Helper);
409418

410-
// Read in options file
411-
if (string.IsNullOrEmpty(AddInInfo.ProductAppDataPath))
412-
{
413-
Debugger.Break();
414-
}
415-
SystemOptions = new Chem4WordOptions(AddInInfo.ProductAppDataPath);
416-
if (SystemOptions.Errors.Any())
417-
{
418-
Telemetry.Write(module, "Exception", string.Join(Environment.NewLine, SystemOptions.Errors));
419-
SystemOptions.Errors = new List<string>();
420-
}
421-
422-
bool isBeta = true;
423-
try
419+
if (AddInInfo != null)
424420
{
425-
if (ThisVersion != null)
421+
// Read in options file
422+
SystemOptions = new Chem4WordOptions(AddInInfo.ProductAppDataPath);
423+
if (SystemOptions.Errors.Any())
426424
{
427-
string betaValue = ThisVersion.Root?.Element("IsBeta")?.Value;
428-
isBeta = betaValue != null && bool.Parse(betaValue);
425+
Telemetry.Write(module, "Exception", string.Join(Environment.NewLine, SystemOptions.Errors));
426+
SystemOptions.Errors = new List<string>();
429427
}
430-
}
431-
catch
432-
{
433-
// Assume isBeta
434-
}
435428

436-
// Belt and braces ...
437-
if (SystemOptions == null)
438-
{
439-
SystemOptions = new Chem4WordOptions
429+
bool isBeta = true;
430+
try
440431
{
441-
SettingsPath = AddInInfo.ProductAppDataPath
442-
};
443-
}
444-
445-
// ... as we are seeing some errors here ?
446-
// Re-Initialise Telemetry with granted permissions
447-
Telemetry = new TelemetryWriter(isBeta || SystemOptions.TelemetryEnabled, Helper);
448-
449-
try
450-
{
451-
bool settingsChanged = false;
432+
if (ThisVersion != null)
433+
{
434+
string betaValue = ThisVersion.Root?.Element("IsBeta")?.Value;
435+
isBeta = betaValue != null && bool.Parse(betaValue);
436+
}
437+
}
438+
catch
439+
{
440+
// Assume isBeta
441+
}
452442

453-
if (string.IsNullOrEmpty(SystemOptions.SelectedEditorPlugIn))
443+
// Belt and braces ...
444+
if (SystemOptions == null)
454445
{
455-
SystemOptions.SelectedEditorPlugIn = Constants.DefaultEditorPlugIn;
446+
SystemOptions = new Chem4WordOptions
447+
{
448+
SettingsPath = AddInInfo.ProductAppDataPath
449+
};
456450
}
457-
else
451+
452+
// ... as we are seeing some errors here ?
453+
// Re-Initialise Telemetry with granted permissions
454+
Telemetry = new TelemetryWriter(isBeta || SystemOptions.TelemetryEnabled, Helper);
455+
456+
try
458457
{
459-
if (Editors.Count > 0)
458+
bool settingsChanged = false;
459+
460+
if (string.IsNullOrEmpty(SystemOptions.SelectedEditorPlugIn))
461+
{
462+
SystemOptions.SelectedEditorPlugIn = Constants.DefaultEditorPlugIn;
463+
}
464+
else
460465
{
461-
var editor = GetEditorPlugIn(SystemOptions.SelectedEditorPlugIn);
462-
if (editor == null)
466+
if (Editors.Count > 0)
463467
{
464-
SystemOptions.SelectedEditorPlugIn = Constants.DefaultEditorPlugIn;
465-
Telemetry.Write(module, "Information", $"Setting editor to {SystemOptions.SelectedEditorPlugIn}");
466-
settingsChanged = true;
468+
var editor = GetEditorPlugIn(SystemOptions.SelectedEditorPlugIn);
469+
if (editor == null)
470+
{
471+
SystemOptions.SelectedEditorPlugIn = Constants.DefaultEditorPlugIn;
472+
Telemetry.Write(module, "Information", $"Setting editor to {SystemOptions.SelectedEditorPlugIn}");
473+
settingsChanged = true;
474+
}
467475
}
468476
}
469-
}
470477

471-
if (string.IsNullOrEmpty(SystemOptions.SelectedRendererPlugIn))
472-
{
473-
SystemOptions.SelectedRendererPlugIn = Constants.DefaultRendererPlugIn;
474-
}
475-
else
476-
{
477-
if (Renderers.Count > 0)
478+
if (string.IsNullOrEmpty(SystemOptions.SelectedRendererPlugIn))
479+
{
480+
SystemOptions.SelectedRendererPlugIn = Constants.DefaultRendererPlugIn;
481+
}
482+
else
478483
{
479-
var renderer = GetRendererPlugIn(SystemOptions.SelectedRendererPlugIn);
480-
if (renderer == null)
484+
if (Renderers.Count > 0)
481485
{
482-
SystemOptions.SelectedRendererPlugIn = Constants.DefaultRendererPlugIn;
483-
Telemetry.Write(module, "Information", $"Setting renderer to {SystemOptions.SelectedRendererPlugIn}");
484-
settingsChanged = true;
486+
var renderer = GetRendererPlugIn(SystemOptions.SelectedRendererPlugIn);
487+
if (renderer == null)
488+
{
489+
SystemOptions.SelectedRendererPlugIn = Constants.DefaultRendererPlugIn;
490+
Telemetry.Write(module, "Information", $"Setting renderer to {SystemOptions.SelectedRendererPlugIn}");
491+
settingsChanged = true;
492+
}
485493
}
486494
}
487-
}
488495

489-
if (settingsChanged)
490-
{
491-
Telemetry.Write(module, "Information", "Saving revised settings");
492-
SystemOptions.Save();
493-
if (SystemOptions.Errors.Any())
496+
if (settingsChanged)
494497
{
495-
Telemetry.Write(module, "Exception", string.Join(Environment.NewLine, SystemOptions.Errors));
496-
SystemOptions.Errors = new List<string>();
498+
Telemetry.Write(module, "Information", "Saving revised settings");
499+
SystemOptions.Save();
500+
if (SystemOptions.Errors.Any())
501+
{
502+
Telemetry.Write(module, "Exception", string.Join(Environment.NewLine, SystemOptions.Errors));
503+
SystemOptions.Errors = new List<string>();
504+
}
497505
}
498506
}
499-
}
500-
catch
501-
{
502-
//
507+
catch
508+
{
509+
//
510+
}
503511
}
504512
}
505513
catch (Exception exception)
@@ -800,7 +808,7 @@ private void LoadPlugIns(bool mustBeSigned)
800808

801809
sw.Stop();
802810

803-
message = $"{module} examining {filesFound} files took {sw.ElapsedMilliseconds.ToString("#,000", CultureInfo.InvariantCulture)}ms";
811+
message = $"{module} examining {filesFound} files took {SafeDouble.AsString(sw.ElapsedMilliseconds)}ms";
804812
Debug.WriteLine(message);
805813
StartUpTimings.Add(message);
806814
}
@@ -1133,13 +1141,16 @@ public void ShowOrHideUpdateShield()
11331141
Ribbon.Update.Image = Properties.Resources.Shield_Danger;
11341142
Ribbon.Update.Label = "Update to use Chem4Word again";
11351143
Ribbon.Update.ScreenTip = "You must update to continue using Chem4Word";
1136-
Ribbon.Update.SuperTip = $"You are {VersionsBehind} versions behind and Chem4Word has been disabled because it is too many versions old.";
1144+
Ribbon.Update.SuperTip = $"You are {VersionsBehind} versions behind therefore Chem4Word has been disabled as it is too many versions old.";
11371145
SetButtonStates(ButtonState.Disabled);
11381146
ChemistryProhibitedReason = Constants.Chem4WordTooOld;
11391147
break;
11401148
}
11411149

1142-
if (VersionsBehind > 0 && !VersionAvailableIsBeta)
1150+
string betaValue = Globals.Chem4WordV3.ThisVersion.Root?.Element("IsBeta")?.Value;
1151+
bool isBeta = betaValue != null && bool.Parse(betaValue);
1152+
1153+
if (isBeta && VersionsBehind > 0 && !VersionAvailableIsBeta)
11431154
{
11441155
Ribbon.Update.Visible = true;
11451156
Ribbon.Update.Enabled = true;

src/Chem4Word.V3/Data/Chem4Word-Versions.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
<!-- This file must be uploaded to https://www.chem4word.co.uk/files3-1/ folder as Chem4Word-Versions.xml -->
33
<ChangeLog>
44
<Id>f3c4f4db-2fff-46db-b14a-feb8e09f7742</Id>
5+
<Version>
6+
<Number>3.1.14 Release 4</Number>
7+
<IsBeta>false</IsBeta>
8+
<Released>30-Sep-2020</Released>
9+
<Changes>
10+
<Change>ACME: Fix Undo of SetBondLength not restoring drop down</Change>
11+
<Change>ACME: Fix Undo crash when atoms being reverted are selected</Change>
12+
<Change>ChEBI Search: Fix bug in import</Change>
13+
<Change>ACME: Fix crash on improperly fusing fixed or variable rings</Change>
14+
<Change>Please download Chem4Word-Setup.exe via https://www.chem4word.co.uk/download/ if you encounter any difficulties updating.</Change>
15+
</Changes>
16+
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.14.Release.4.msi</Url>
17+
</Version>
518
<Version>
619
<Number>3.1.13 Release 3</Number>
720
<IsBeta>false</IsBeta>
@@ -11,7 +24,6 @@
1124
<Change>Fix incorrect position of implicit Hydrogen for a lone atom (as seen in Microsoft Word)</Change>
1225
<Change>Please download Chem4Word-Setup.exe via https://www.chem4word.co.uk/download/ if you encounter any difficulties updating.</Change>
1326
</Changes>
14-
<Url>https://www.chem4word.co.uk/files3-1/Chem4Word-Setup.3.1.13.Release.3.msi</Url>
1527
</Version>
1628
<Version>
1729
<Number>3.1.12 Release 2</Number>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Version>
3-
<Number>3.1.13 Release 3</Number>
3+
<Number>3.1.14 Release 4</Number>
44
<IsBeta>false</IsBeta>
5-
<Released>17-Sep-2020</Released>
5+
<Released>30-Sep-2020</Released>
66
</Version>

src/Chem4Word.V3/Data/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ <h1>Chemistry for Word Add-In 2020</h1>
1515
<td>Setup Bootstrapper</td>
1616
<td><a href="/files3-1/Chem4Word-Setup.exe">Chem4Word-Setup</a></td>
1717
</tr>
18+
<tr>
19+
<td>Version 3.1.14 - Release 4</td>
20+
<td><a href="/files3-1/Chem4Word-Setup.3.1.14.Release.4.msi">Chem4Word-Setup 3.1.14 Release 4</a></td>
21+
</tr>
1822
<tr>
1923
<td>Version 3.1.13 - Release 3</td>
20-
<td><a href="/files3-1/Chem4Word-Setup.3.1.13.Release.3.msi">Chem4Word-Setup 3.1.13 Release 3</a></td>
24+
<td>Chem4Word-Setup 3.1.13 Release 3</td>
2125
</tr>
2226
<tr>
2327
<td>Version 3.1.12 - Release 2</td>

src/Chem4Word.V3/Database/Library.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using System.Data;
1111
using System.Data.SQLite;
1212
using System.Diagnostics;
13-
using System.Globalization;
1413
using System.IO;
1514
using System.Linq;
1615
using System.Reflection;
@@ -103,7 +102,7 @@ public Dictionary<string, int> GetLibraryNames()
103102
}
104103

105104
sw.Stop();
106-
Globals.Chem4WordV3.Telemetry.Write(module, "Timing", $"Reading {allNames.Count} Chemical names took {sw.ElapsedMilliseconds.ToString("#,##0", CultureInfo.InvariantCulture)}ms");
105+
Globals.Chem4WordV3.Telemetry.Write(module, "Timing", $"Reading {allNames.Count} Chemical names took {SafeDouble.AsString(sw.ElapsedMilliseconds)}ms");
107106
return allNames;
108107
}
109108

@@ -538,7 +537,7 @@ public List<ChemistryDTO> GetAllChemistry(string filter)
538537
}
539538

540539
sw.Stop();
541-
Globals.Chem4WordV3.Telemetry.Write(module, "Timing", $"Reading {results.Count} structures took {sw.ElapsedMilliseconds.ToString("#,##0", CultureInfo.InvariantCulture)}ms");
540+
Globals.Chem4WordV3.Telemetry.Write(module, "Timing", $"Reading {results.Count} structures took {SafeDouble.AsString(sw.ElapsedMilliseconds)}ms");
542541

543542
return results;
544543
}

0 commit comments

Comments
 (0)