Skip to content

Commit

Permalink
Merged PR 616: Create V3.2.11
Browse files Browse the repository at this point in the history
Create V3.2.11

- Performance: Send all molecules to Chemical Services Web Service in one call
- Internal: Update NuGet packages

Related work items: #1051
  • Loading branch information
MikeWilliams-UK committed May 31, 2023
1 parent dd4e8ee commit 2f46251
Show file tree
Hide file tree
Showing 39 changed files with 355 additions and 254 deletions.
4 changes: 2 additions & 2 deletions src/Chem4Word.V3-2.sln
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripts", "Scripts", "{53F5
Scripts\Install-Dev-Certificate.ps1 = Scripts\Install-Dev-Certificate.ps1
Scripts\Reset-User-Settings.ps1 = Scripts\Reset-User-Settings.ps1
Scripts\Set-Assembly-Version.ps1 = Scripts\Set-Assembly-Version.ps1
Scripts\SignAssembly.ps1 = Scripts\SignAssembly.ps1
Scripts\SignFiles.cmd = Scripts\SignFiles.cmd
Scripts\Sign-Assembly.ps1 = Scripts\Sign-Assembly.ps1
Scripts\Sign-Files.cmd = Scripts\Sign-Files.cmd
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chem4Word.Model2", "Chemistry\Chem4Word.Model2\Chem4Word.Model2.csproj", "{C69BAB8F-4881-4D5F-9929-FC8470DF1E48}"
Expand Down
158 changes: 84 additions & 74 deletions src/Chem4Word.V3/Chem4WordV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ public partial class Chem4WordV3
public XDocument ThisVersion;

public bool EventsEnabled = true;
public bool PlugInsHaveBeenLoaded;

public bool ChemistryAllowed = false;
public bool ChemistryAllowed;
public string ChemistryProhibitedReason = "";
private string _lastContentControlAdded = "";

private bool _chemistrySelected = false;
private bool _markAsChemistryHandled = false;
private bool _plugInsLoaded = false;
private bool _chemistrySelected;
private bool _markAsChemistryHandled;

public bool OptionsReloadRequired = false;
private int _rightClickEvents;
private ConfigWatcher _configWatcher;

public bool LibraryState = false;
public bool LibraryState;

private Thread _slowOperationsThread;
public List<string> StartUpTimings = new List<string>();
Expand Down Expand Up @@ -201,6 +201,7 @@ public static void SetGlobalRibbon(CustomRibbon ribbon)
private void C4WAddIn_Startup(object sender, EventArgs e)
{
var module = $"{MethodBase.GetCurrentMethod().Name}()";

try
{
// Deliberate crash to test Error Reporting
Expand Down Expand Up @@ -307,7 +308,7 @@ private void SlowOperations()
ServicePointManager.UseNagleAlgorithm = false;
ServicePointManager.Expect100Continue = false;

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

_configWatcher = new ConfigWatcher(AddInInfo.ProductAppDataPath);

Expand All @@ -330,6 +331,8 @@ private void PerformStartUpActions()

try
{
SetButtonStates(ButtonState.NoDocument);

LoadOptions();

AddInInfo = new C4wAddInInfo();
Expand Down Expand Up @@ -583,10 +586,13 @@ private void PerformShutDownActions()

try
{
_slowOperationsThread.Join();
if (_slowOperationsThread.IsAlive)
if (_slowOperationsThread != null)
{
_slowOperationsThread.Abort();
_slowOperationsThread.Join();
if (_slowOperationsThread.IsAlive)
{
_slowOperationsThread.Abort();
}
}

if (Editors != null)
Expand Down Expand Up @@ -638,7 +644,6 @@ private void LoadPlugins()

if (Ribbon != null)
{
_plugInsLoaded = true;
if (VersionsBehind >= Constants.MaximumVersionsBehind)
{
SetButtonStates(ButtonState.Disabled);
Expand Down Expand Up @@ -863,6 +868,8 @@ private void LoadPlugIns(bool mustBeSigned)
message = $"{module} examining {filesFound} files took {SafeDouble.AsString(sw.ElapsedMilliseconds)}ms";
Debug.WriteLine(message);
StartUpTimings.Add(message);

PlugInsHaveBeenLoaded = true;
}

public IChem4WordEditor GetEditorPlugIn(string name)
Expand Down Expand Up @@ -1065,20 +1072,75 @@ public void DisableContentControlEvents()

private void SetButtonStates(ButtonState state)
{
if (Ribbon != null && _plugInsLoaded)
if (Ribbon != null)
{
// Always enabled
// Help is always enabled
Ribbon.HelpMenu.Enabled = true;

var plugInsLoaded = Editors.Count + Renderers.Count + Searchers.Count > 0;
// Enabled once any PlugIns are loaded
Ribbon.ChangeOptions.Enabled = plugInsLoaded;
IsEnabled = true;
if (PlugInsHaveBeenLoaded)
{
var plugInsLoaded = Editors.Count + Renderers.Count + Searchers.Count > 0;
// Enabled once any PlugIns are loaded
Ribbon.ChangeOptions.Enabled = plugInsLoaded;
IsEnabled = true;

switch (state)
{
case ButtonState.Disabled:
case ButtonState.NoDocument:
Ribbon.EditStructure.Enabled = false;
Ribbon.EditStructure.Label = "Draw";
Ribbon.EditLabels.Enabled = false;
Ribbon.ViewCml.Enabled = false;
Ribbon.ImportFromFile.Enabled = false;
Ribbon.ExportToFile.Enabled = false;
Ribbon.ShowAsMenu.Enabled = false;
Ribbon.ShowNavigator.Enabled = false;
Ribbon.ShowLibrary.Enabled = false;
Ribbon.WebSearchMenu.Enabled = false;
Ribbon.SaveToLibrary.Enabled = false;
Ribbon.ArrangeMolecules.Enabled = false;
Ribbon.ButtonsDisabled.Enabled = true;
break;

switch (state)
{
case ButtonState.Disabled:
case ButtonState.NoDocument:
case ButtonState.CanEdit:
Ribbon.EditStructure.Enabled = plugInsLoaded && Editors.Count > 0;
Ribbon.EditStructure.Label = "Edit";
Ribbon.EditLabels.Enabled = true;
Ribbon.ViewCml.Enabled = true;
Ribbon.ImportFromFile.Enabled = false;
Ribbon.ExportToFile.Enabled = true;
Ribbon.ShowAsMenu.Enabled = true;
Ribbon.ShowNavigator.Enabled = true;
Ribbon.ShowLibrary.Enabled = true;
Ribbon.WebSearchMenu.Enabled = false;
Ribbon.SaveToLibrary.Enabled = true;
Ribbon.ArrangeMolecules.Enabled = true;
Ribbon.ButtonsDisabled.Enabled = false;
break;

case ButtonState.CanInsert:
Ribbon.EditStructure.Enabled = plugInsLoaded && Editors.Count > 0;
Ribbon.EditStructure.Label = "Draw";
Ribbon.EditLabels.Enabled = false;
Ribbon.ViewCml.Enabled = false;
Ribbon.ImportFromFile.Enabled = plugInsLoaded;
Ribbon.ExportToFile.Enabled = false;
Ribbon.ShowAsMenu.Enabled = false;
Ribbon.ShowNavigator.Enabled = true;
Ribbon.ShowLibrary.Enabled = true;
Ribbon.WebSearchMenu.Enabled = plugInsLoaded && Searchers.Count > 0;
Ribbon.SaveToLibrary.Enabled = false;
Ribbon.ArrangeMolecules.Enabled = false;
Ribbon.ButtonsDisabled.Enabled = false;
break;
}

var betaValue = Globals.Chem4WordV3.ThisVersion.Root?.Element("IsBeta")?.Value;
var isBeta = betaValue != null && bool.Parse(betaValue);

if (IsEndOfLife || isBeta && !VersionAvailableIsBeta)
{
Ribbon.EditStructure.Enabled = false;
Ribbon.EditStructure.Label = "Draw";
Ribbon.EditLabels.Enabled = false;
Expand All @@ -1092,61 +1154,9 @@ private void SetButtonStates(ButtonState state)
Ribbon.SaveToLibrary.Enabled = false;
Ribbon.ArrangeMolecules.Enabled = false;
Ribbon.ButtonsDisabled.Enabled = true;
break;

case ButtonState.CanEdit:
Ribbon.EditStructure.Enabled = plugInsLoaded && Editors.Count > 0;
Ribbon.EditStructure.Label = "Edit";
Ribbon.EditLabels.Enabled = true;
Ribbon.ViewCml.Enabled = true;
Ribbon.ImportFromFile.Enabled = false;
Ribbon.ExportToFile.Enabled = true;
Ribbon.ShowAsMenu.Enabled = true;
Ribbon.ShowNavigator.Enabled = true;
Ribbon.ShowLibrary.Enabled = true;
Ribbon.WebSearchMenu.Enabled = false;
Ribbon.SaveToLibrary.Enabled = true;
Ribbon.ArrangeMolecules.Enabled = true;
Ribbon.ButtonsDisabled.Enabled = false;
break;

case ButtonState.CanInsert:
Ribbon.EditStructure.Enabled = plugInsLoaded && Editors.Count > 0;
Ribbon.EditStructure.Label = "Draw";
Ribbon.EditLabels.Enabled = false;
Ribbon.ViewCml.Enabled = false;
Ribbon.ImportFromFile.Enabled = plugInsLoaded;
Ribbon.ExportToFile.Enabled = false;
Ribbon.ShowAsMenu.Enabled = false;
Ribbon.ShowNavigator.Enabled = true;
Ribbon.ShowLibrary.Enabled = true;
Ribbon.WebSearchMenu.Enabled = plugInsLoaded && Searchers.Count > 0;
Ribbon.SaveToLibrary.Enabled = false;
Ribbon.ArrangeMolecules.Enabled = false;
Ribbon.ButtonsDisabled.Enabled = false;
break;
}

var betaValue = Globals.Chem4WordV3.ThisVersion.Root?.Element("IsBeta")?.Value;
var isBeta = betaValue != null && bool.Parse(betaValue);

if (IsEndOfLife || isBeta && !VersionAvailableIsBeta)
{
Ribbon.EditStructure.Enabled = false;
Ribbon.EditStructure.Label = "Draw";
Ribbon.EditLabels.Enabled = false;
Ribbon.ViewCml.Enabled = false;
Ribbon.ImportFromFile.Enabled = false;
Ribbon.ExportToFile.Enabled = false;
Ribbon.ShowAsMenu.Enabled = false;
Ribbon.ShowNavigator.Enabled = false;
Ribbon.ShowLibrary.Enabled = false;
Ribbon.WebSearchMenu.Enabled = false;
Ribbon.SaveToLibrary.Enabled = false;
Ribbon.ArrangeMolecules.Enabled = false;
Ribbon.ButtonsDisabled.Enabled = true;

IsEnabled = false;
IsEnabled = false;
}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/Chem4Word.V3/Data/Chem4Word-Versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
<Version>
<Number>3.2.11 Release 7</Number>
<IsBeta>false</IsBeta>
<Released>01-Apr-2023</Released>
<Released>31-May-2023</Released>
<Changes>
<Change>...</Change>
<Change>...</Change>
<Change>Performance: Send all molecules to Chemical Services Web Service in one call</Change>
<Change>Internal: Update NuGet packages to latest</Change>
<Change>Please note any previous beta versions V3.2.4 and below will cease to allow insertion or editing of chemistry</Change>
Expand Down
2 changes: 1 addition & 1 deletion src/Chem4Word.V3/Data/This-Version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<Version>
<Number>3.2.11 Release 7</Number>
<IsBeta>false</IsBeta>
<Released>01-Apr-2023</Released>
<Released>31-May-2023</Released>
</Version>
6 changes: 3 additions & 3 deletions src/Chem4Word.V3/Helpers/UpdateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static int CheckForUpdates(int frequency)

if (doCheck)
{
Globals.Chem4WordV3.Telemetry.Write(module, "Information", $"Last check {delta.TotalDays:0} day(s) ago; Check frequency {frequency} days.");
Globals.Chem4WordV3.Telemetry.Write(module, "AutomaticUpdate", $"Last check {delta.TotalDays:0} day(s) ago; Check frequency {frequency} days.");
Debug.WriteLine("Saving date last checked in Registry as Today");
RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(Constants.Chem4WordRegistryKey);
registryKey?.SetValue(Constants.RegistryValueNameLastCheck, DateTime.Today.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
Expand Down Expand Up @@ -327,7 +327,7 @@ private static string GetVersionsXmlFile()
string contents = null;

var securityProtocol = ServicePointManager.SecurityProtocol;
ServicePointManager.SecurityProtocol = securityProtocol | SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol = securityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

bool foundOurXmlFile = false;
foreach (var domain in Constants.OurDomains)
Expand All @@ -338,7 +338,7 @@ private static string GetVersionsXmlFile()

try
{
Globals.Chem4WordV3.Telemetry.Write(module, "Information", $"Looking for Chem4Word-Versions.xml at {domain}");
Globals.Chem4WordV3.Telemetry.Write(module, "AutomaticUpdate", $"Looking for Chem4Word-Versions.xml at {domain}");

client.DefaultRequestHeaders.Add("user-agent", "Chem4Word VersionChecker");
client.BaseAddress = new Uri(domain);
Expand Down
4 changes: 2 additions & 2 deletions src/Chem4Word.V3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.11.8491")]
[assembly: AssemblyFileVersion("3.2.11.8491")]
[assembly: AssemblyVersion("3.2.11.8551")]
[assembly: AssemblyFileVersion("3.2.11.8551")]
Loading

0 comments on commit 2f46251

Please sign in to comment.