Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #24 from WereDev/develop
Browse files Browse the repository at this point in the history
More graceful launch errors
  • Loading branch information
WereDev committed Aug 5, 2020
2 parents dcf230c + fcd92e7 commit 6a1983d
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 258 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -23,6 +23,7 @@ bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Pp]ublish/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down
13 changes: 5 additions & 8 deletions AdvancedInstaller/wu10man.aip
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DOCUMENT Type="Advanced Installer" CreateVersion="15.0" version="17.0" Modules="simple" RootPath="." Language="en" Id="{F18B9A17-E631-498A-8CF8-210F80EA0231}">
<COMPONENT cid="caphyon.advinst.msicomp.ProjectOptionsComponent">
<ROW Name="HiddenItems" Value="AppXAppDetailsComponent;FixupComponent;AppXCapabilitiesComponent;AppXDependenciesComponent;AppXProductDetailsComponent;AppXVisualAssetsComponent;AppXAppDeclarationsComponent;AppXUriRulesComponent;MsiXDiffComponent;MsixManifestEditorComponent"/>
</COMPONENT>
<DOCUMENT Type="Advanced Installer" CreateVersion="15.0" version="17.3" Modules="simple" RootPath="." Language="en" Id="{F18B9A17-E631-498A-8CF8-210F80EA0231}">
<COMPONENT cid="caphyon.advinst.msicomp.MsiPropsComponent">
<ROW Property="AI_BITMAP_DISPLAY_MODE" Value="0"/>
<ROW Property="AI_RUN_AS_ADMIN" Value="0"/>
Expand All @@ -12,14 +9,14 @@
<ROW Property="ARPNOMODIFY" MultiBuildValue="DefaultBuild:1"/>
<ROW Property="ARPNOREPAIR" Value="1"/>
<ROW Property="ARPPRODUCTICON" Value="wu10man.exe" Type="8"/>
<ROW Property="ARPURLINFOABOUT" Value="https://github.com/WereDev/Wu10Man/issues"/>
<ROW Property="ARPURLUPDATEINFO" Value="https://github.com/WereDev/Wu10Man/releases"/>
<ROW Property="ARPURLINFOABOUT" Value="https://github.com/WereDev/Wu10Man/issues/"/>
<ROW Property="ARPURLUPDATEINFO" Value="https://weredev.com/developer/wu10man/releases/"/>
<ROW Property="CTRLS" Value="2"/>
<ROW Property="Manufacturer" Value="Weredev"/>
<ROW Property="Manufacturer" Value="WereDev"/>
<ROW Property="ProductCode" Value="1033:{00273625-7096-487C-A5AB-A5116B423932} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="Wu10Man"/>
<ROW Property="ProductVersion" Value="4.0.0.0" Type="32" TargetFile="Wu10Man.exe"/>
<ROW Property="ProductVersion" Value="4.1.0.0" Type="32" TargetFile="Wu10Man.exe"/>
<ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/>
<ROW Property="RUNAPPLICATION" Value="1" Type="4"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
Expand Down
434 changes: 228 additions & 206 deletions AdvancedInstaller/wu10man.back.aip

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Wu10Man/Properties/AssemblyInfo.cs
Expand Up @@ -48,6 +48,6 @@
// 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("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyVersion("4.1.0.0")]
[assembly: AssemblyFileVersion("4.1.0.0")]
[assembly: NeutralResourcesLanguage("en-US")]
33 changes: 24 additions & 9 deletions Wu10Man/UserControls/DeclutterControl.xaml.cs
Expand Up @@ -14,6 +14,7 @@ namespace WereDev.Utils.Wu10Man.UserControls
/// </summary>
public partial class DeclutterControl : UserControl, IDisposable
{
private const string TabTitle = "Declutter";
private readonly ILogWriter _logWriter;
private readonly IWindowsPackageManager _packageManager;
private readonly DeclutterModel _model;
Expand All @@ -30,11 +31,12 @@ public DeclutterControl()

if (!DesignerProperties.GetIsInDesignMode(this))
{
SetRuntimeOptions();
ShowMicrosoftApps(null, null);
if (SetRuntimeOptions())
{
ShowMicrosoftApps(null, null);
_logWriter.LogInfo("Declutter Control initialized.");
}
}

_logWriter.LogInfo("Declutter Control initialized.");
}

// Dispose() calls Dispose(true)
Expand All @@ -58,11 +60,24 @@ protected virtual void Dispose(bool disposing)
_isDisposed = true;
}

private void SetRuntimeOptions()
private bool SetRuntimeOptions()
{
GetPackageStatus();
DataContext = _model;
InitializeComponent();
try
{
GetPackageStatus();
DataContext = _model;
return true;
}
catch (Exception ex)
{
_logWriter.LogError(ex);
System.Windows.MessageBox.Show($"Error initializing {TabTitle} tab.", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return false;
}
finally
{
InitializeComponent();
}
}

private void GetPackageStatus()
Expand Down Expand Up @@ -137,7 +152,7 @@ private void SetItemSource()

private void ShowMessage(string message)
{
MessageBox.Show(message, "Declutter", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
MessageBox.Show(message, TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
}

private void InitializeProgressBar(int minValue, int maxValue)
Expand Down
41 changes: 34 additions & 7 deletions Wu10Man/UserControls/GroupPolicyControl.xaml.cs
@@ -1,6 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Windows.Controls;
using WereDev.Utils.Wu10Man.Core;
using WereDev.Utils.Wu10Man.Core.Interfaces;
Expand Down Expand Up @@ -30,6 +33,8 @@ public partial class GroupPolicyControl : UserControl
private const string RegistryAuOptions = "AuOptions";
private const string RegistryNoUpdate = "NoAutoUpdate";

private const string TabTitle = "Group Policies";

private readonly ILogWriter _logWriter;
private readonly IRegistryEditor _registryEditor;

Expand All @@ -39,16 +44,38 @@ public GroupPolicyControl()
_registryEditor = DependencyManager.Resolve<IRegistryEditor>();

_logWriter.LogInfo("Group Policy Control initializing.");
PolicyOptions = CreatePolicyOptions();
GetCurrentStatus();
InitializeComponent();
_logWriter.LogInfo("Group Policy Control initialized.");

if (!DesignerProperties.GetIsInDesignMode(this))
{
if (SetRuntimeOptions())
_logWriter.LogInfo("Group Policy Control initialized.");
}
}

public ObservableCollection<KeyValuePair<string, string>> PolicyOptions { get; }
public ObservableCollection<KeyValuePair<string, string>> PolicyOptions { get; private set; }

public KeyValuePair<string, string> SelectedPolicyOption { get; set; }

private bool SetRuntimeOptions()
{
try
{
PolicyOptions = CreatePolicyOptions();
GetCurrentStatus();
return true;
}
catch (Exception ex)
{
_logWriter.LogError(ex);
System.Windows.MessageBox.Show($"Error initializing {TabTitle} tab.", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return false;
}
finally
{
InitializeComponent();
}
}

private ObservableCollection<KeyValuePair<string, string>> CreatePolicyOptions()
{
var options = new ObservableCollection<KeyValuePair<string, string>>()
Expand Down Expand Up @@ -133,7 +160,7 @@ private void SetGroupPolicy(object sender, System.Windows.RoutedEventArgs e)
}

_logWriter.LogInfo(string.Format("Group Policy set: {0}", SelectedPolicyOption.Value));
System.Windows.MessageBox.Show("Registry settings updated.", "Group Policies", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
System.Windows.MessageBox.Show("Registry settings updated.", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
}
}
}
35 changes: 26 additions & 9 deletions Wu10Man/UserControls/HostsFileControl.xaml.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows.Controls;
using WereDev.Utils.Wu10Man.Core;
Expand All @@ -13,6 +14,7 @@ namespace WereDev.Utils.Wu10Man.UserControls
/// </summary>
public partial class HostsFileControl : UserControl
{
private const string TabTitle = "Hosts File";
private readonly HostsFileModel _model;
private readonly IHostsFileEditor _hostsFileEditor;
private readonly ILogWriter _logWriter;
Expand All @@ -25,15 +27,30 @@ public HostsFileControl()
_logWriter.LogInfo("Hosts File initializing.");
_model = new HostsFileModel();
if (!DesignerProperties.GetIsInDesignMode(this))
SetRuntimeOptions();
_logWriter.LogInfo("Hosts File initialized.");
{
if (SetRuntimeOptions())
_logWriter.LogInfo("Hosts File initialized.");
}
}

private void SetRuntimeOptions()
private bool SetRuntimeOptions()
{
GetHostSettings();
DataContext = _model;
InitializeComponent();
try
{
GetHostSettings();
DataContext = _model;
return true;
}
catch (Exception ex)
{
_logWriter.LogError(ex);
System.Windows.MessageBox.Show($"Error initializing {TabTitle} tab.", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return false;
}
finally
{
InitializeComponent();
}
}

private void GetHostSettings()
Expand Down Expand Up @@ -94,7 +111,7 @@ private void BlockAllHosts_Click(object sender, System.Windows.RoutedEventArgs e

private void ShowUpdateNotice()
{
System.Windows.MessageBox.Show("Hosts file updated.", "Hosts File", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
System.Windows.MessageBox.Show("Hosts file updated.", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
}

private bool IsHostsFileLocked()
Expand All @@ -105,7 +122,7 @@ private bool IsHostsFileLocked()
var processNames = string.Join("\r\n", lockingProcesses);
var message = "The Hosts file is being locked by the following processes and cannot be updated:\r\n" + processNames;
_logWriter.LogInfo(message);
System.Windows.MessageBox.Show(message, "Hosts File Locked", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
System.Windows.MessageBox.Show(message, TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return true;
}

Expand Down
31 changes: 23 additions & 8 deletions Wu10Man/UserControls/PauseUpdatesControl.xaml.cs
Expand Up @@ -24,6 +24,7 @@ public partial class PauseUpdatesControl : UserControl
private const string PauseQualityUpdatesEndTime = "PauseQualityUpdatesEndTime";
private const string PauseUpdatesExpiryTime = "PauseUpdatesExpiryTime";
// private const string PendingRebootStartTime = "PendingRebootStartTime";
private const string TabTitle = "Pause and Defer";

private readonly Regex _numberOnlyRegex = new Regex("[^0-9]+");
private readonly PauseUpdatesModel _model = new PauseUpdatesModel();
Expand All @@ -38,21 +39,35 @@ public PauseUpdatesControl()
_logWriter.LogInfo("Pause and Defer initializing.");
DataContext = _model;
InitializeComponent();
ReadCurrentSettings();
_logWriter.LogInfo("Pause and Defer initialized.");
if (SetRuntimeOptions())
_logWriter.LogInfo("Pause and Defer initialized.");
}

private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = _numberOnlyRegex.IsMatch(e.Text);
}

private void ReadCurrentSettings()
private bool SetRuntimeOptions()
{
_model.FeatureUpdateDelayDays = GetIntFromRegistryValue(DeferFeatureUpdatesPeriodInDays);
_model.FeatureUpdatePauseDate = GetDateFromRegistryValue(PauseFeatureUpdatesEndTime);
_model.QualityUpdateDelayDays = GetIntFromRegistryValue(DeferQualityUpdatesPeriodInDays);
_model.QualityUpdatePauseDate = GetDateFromRegistryValue(PauseQualityUpdatesEndTime);
try
{
_model.FeatureUpdateDelayDays = GetIntFromRegistryValue(DeferFeatureUpdatesPeriodInDays);
_model.FeatureUpdatePauseDate = GetDateFromRegistryValue(PauseFeatureUpdatesEndTime);
_model.QualityUpdateDelayDays = GetIntFromRegistryValue(DeferQualityUpdatesPeriodInDays);
_model.QualityUpdatePauseDate = GetDateFromRegistryValue(PauseQualityUpdatesEndTime);
return true;
}
catch (Exception ex)
{
_logWriter.LogError(ex);
System.Windows.MessageBox.Show($"Error initializing {TabTitle} tab.", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return false;
}
finally
{
InitializeComponent();
}
}

private DateTime? GetDateFromRegistryValue(string registryName)
Expand Down Expand Up @@ -154,7 +169,7 @@ private void WriteChanges()
_logWriter.LogInfo($"Removing Pause Date Expiry");
}

MessageBox.Show($"Windows Update pause dates and deferal period have been saved.", "Pause and Defer", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
MessageBox.Show($"Windows Update pause dates and deferal period have been saved.", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
}

private string GetDateString(DateTime datetime)
Expand Down
34 changes: 26 additions & 8 deletions Wu10Man/UserControls/WindowsServicesControl.xaml.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows.Controls;
using WereDev.Utils.Wu10Man.Core;
Expand All @@ -14,6 +15,8 @@ namespace WereDev.Utils.Wu10Man.UserControls
/// </summary>
public partial class WindowsServicesControl : UserControl
{
private const string TabTitle = "Windows Services";

private readonly WindowsServicesModel _model = new WindowsServicesModel();
private readonly ILogWriter _logWriter;
private readonly IWindowsServiceManager _windowsServiceManager;
Expand All @@ -27,14 +30,29 @@ public WindowsServicesControl()
DataContext = _model;

if (!DesignerProperties.GetIsInDesignMode(this))
SetRuntimeOptions();
_logWriter.LogInfo("Windows Services initialized.");
{
if (SetRuntimeOptions())
_logWriter.LogInfo("Windows Services initialized.");
}
}

private void SetRuntimeOptions()
private bool SetRuntimeOptions()
{
BuildServiceStatus();
InitializeComponent();
try
{
BuildServiceStatus();
return true;
}
catch (Exception ex)
{
_logWriter.LogError(ex);
System.Windows.MessageBox.Show($"Error initializing {TabTitle} tab.", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return false;
}
finally
{
InitializeComponent();
}
}

private void BuildServiceStatus()
Expand Down Expand Up @@ -81,14 +99,14 @@ private void EnableService(string serviceName, string displayName)
if (!enabledRealtime)
message += "\r\rYou will need to reboot for the setting to take effect.";

System.Windows.MessageBox.Show(message, "Windows Service", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
System.Windows.MessageBox.Show(message, TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
}

private void DisableService(string serviceName, string displayName)
{
_windowsServiceManager.DisableService(serviceName);
SetServiceStatus(serviceName);
System.Windows.MessageBox.Show($"{displayName} has been DISABLED", "Windows Service", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
System.Windows.MessageBox.Show($"{displayName} has been DISABLED", TabTitle, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
}
}
}
3 changes: 2 additions & 1 deletion Wu10Man/Wu10Man.csproj
Expand Up @@ -30,7 +30,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>4.0.0.0</ApplicationVersion>
<ApplicationVersion>4.1.0.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down Expand Up @@ -106,6 +106,7 @@
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WPFSpark.1.4.0\lib\net461\System.Windows.Interactivity.dll</HintPath>
</Reference>
Expand Down

0 comments on commit 6a1983d

Please sign in to comment.