Skip to content

Commit

Permalink
Provide convient download help for installing WebView2 component.
Browse files Browse the repository at this point in the history
Publish version 2.8.0.61.
  • Loading branch information
clovett committed Jul 1, 2022
1 parent 3ac74c1 commit 3c31d38
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 24 deletions.
34 changes: 32 additions & 2 deletions src/Application/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ protected virtual void SetDefaultSettings()
this._settings["BrowserVersion"] = "";
this._settings["EnableXsltScripts"] = true;
this._settings["WebView2Exception"] = "";
this._settings["WebView2PromptInstall"] = true;

// XmlDiff options
this._settings["XmlDiffIgnoreChildOrder"] = false;
Expand Down Expand Up @@ -838,6 +839,7 @@ protected virtual void TabControlViews_Selected(object sender, NoBorderTabContro
{
if (e.TabPage == this.tabPageHtmlView)
{
this.CheckWebViewVersion();
this.DisplayXsltResults();
}
else
Expand All @@ -846,6 +848,31 @@ protected virtual void TabControlViews_Selected(object sender, NoBorderTabContro
}
}

private void CheckWebViewVersion()
{
if (this._settings.GetBoolean("WebView2PromptInstall") &&
!string.IsNullOrEmpty(this._settings.GetString("WebView2Exception")))
{
// prompt user once and only once so as not to be too annoying.
this._settings["WebView2PromptInstall"] = false;
var rc = MessageBox.Show(this.Owner, SR.WebView2InstallPrompt, SR.WebView2InstallTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (rc == DialogResult.Yes)
{
WebView2PromptInstall();
}
}
}

private void WebView2PromptInstall()
{
// prompt and download the setup program so user can easily run it.
var rc = MessageBox.Show(this.Owner, SR.WebView2InstallReady, SR.WebView2InstallTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (rc == DialogResult.OK)
{
WebBrowser.OpenUrl(this.Handle, "https://go.microsoft.com/fwlink/p/?LinkId=2124703");
}
}

void EnableFileMenu()
{
bool hasFile = (_model.FileName != null);
Expand Down Expand Up @@ -1430,7 +1457,11 @@ private void OnWebBrowserException(object sender, Exception e)
{
if (this.showingOptions && e is WebView2Exception)
{
MessageBox.Show(this, string.Format(SR.WebView2Error, e.Message), "WebView2 Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
var rc = MessageBox.Show(this, string.Format(SR.WebView2Error, e.Message), SR.WebView2ErrorTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (rc == DialogResult.OK)
{
this.WebView2PromptInstall();
}
}
}

Expand Down Expand Up @@ -1623,7 +1654,6 @@ protected virtual void OnSettingsChanged(object sender, string name)
}
}


public void SaveErrors(string filename)
{
this._taskList.Save(filename);
Expand Down
7 changes: 0 additions & 7 deletions src/Model/Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
<AssemblyName>XmlNotepad.Model</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MyKeyFile)</AssemblyOriginatorKeyFile>
<Company>Microsoft Corporation</Company>
<Copyright>Copyright © 2021 Microsoft Corporation</Copyright>
<Version>$(ApplicationVersion)</Version>
<Authors>Chris Lovett</Authors>
<Product>XmlNotepad</Product>
<RepositoryUrl>https://github.com/microsoft/xmlnotepad</RepositoryUrl>
<PackageProjectUrl>https://microsoft.github.io/XmlNotepad/</PackageProjectUrl>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
3 changes: 3 additions & 0 deletions src/Updates/Updates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<history>https://github.com/microsoft/XmlNotepad/blob/master/src/Updates/Updates.xml</history>
<frequency>1.00:00:00</frequency>
</application>
<version number="2.8.0.61">
<feature>Provide convient download help for installing WebView2 component.</feature>
</version>
<version number="2.8.0.60">
<feature>TreeView indent level is now configurable in the Options dialog under Formatting section.</feature>
<bug>Fix bug 203: Find backwards was broken.</bug>
Expand Down
4 changes: 2 additions & 2 deletions src/Version/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.8.0.60")]
[assembly: AssemblyFileVersion("2.8.0.60")]
[assembly: AssemblyVersion("2.8.0.61")]
[assembly: AssemblyFileVersion("2.8.0.61")]
12 changes: 10 additions & 2 deletions src/Version/Version.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>60</ApplicationRevision>
<ApplicationVersion>2.8.0.60</ApplicationVersion>
<ApplicationRevision>61</ApplicationRevision>
<ApplicationVersion>2.8.0.61</ApplicationVersion>

<Version>$(ApplicationVersion)</Version>
<Authors>Chris Lovett</Authors>
<Product>XmlNotepad</Product>
<RepositoryUrl>https://github.com/microsoft/xmlnotepad</RepositoryUrl>
<PackageProjectUrl>https://microsoft.github.io/XmlNotepad/</PackageProjectUrl>
<Company>Microsoft Corporation</Company>
<Copyright>Copyright © 2021 Microsoft Corporation</Copyright>
</PropertyGroup>
</Project>
40 changes: 38 additions & 2 deletions src/XmlNotepad/StringResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions src/XmlNotepad/StringResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -905,9 +905,9 @@ Do you want to enable execution of this script code?</value>
<value>Please go to Windows Settings for 'Default Apps' and select 'Choose default apps by file type' add XML Notepad for each file type you want associated with it.</value>
</data>
<data name="WebView2Error" xml:space="preserve">
<value>Error initializing WebView2 component. Please install WebView2 from https://developer.microsoft.com/en-us/microsoft-edge/webview2/ and check if you need to do a full reboot.
<value>Error initializing WebView2 component. Do you want to try and re-install the WebView2 component?

{0}</value>
Error: {0}</value>
</data>
<data name="InvalidFileName" xml:space="preserve">
<value>Invalid file name '{0}'</value>
Expand All @@ -919,4 +919,19 @@ Do you want to enable execution of this script code?</value>
<value>You have selected the 'Match whole word' check box but your find string contains spaces. This doesn't make sense as the 'Match whole word' option can only find individual matching words.</value>
<comment>Message box prompt</comment>
</data>
<data name="WebView2InstallPrompt" xml:space="preserve">
<value>The XSLT output is using an older web browser, if you want faster and more up to date HTML rendering support do you want to install WebView2 ?</value>
<comment>Message box prompt</comment>
</data>
<data name="WebView2InstallTitle" xml:space="preserve">
<value>WebView Upgrade</value>
</data>
<data name="WebView2ErrorTitle" xml:space="preserve">
<value>WebView2 Initialization Error</value>
<comment>Message box title</comment>
</data>
<data name="WebView2InstallReady" xml:space="preserve">
<value>We will download the WebView2 setup program named "MicrosoftEdgeWebview2Setup", and you will find it in your downloads folder. When the download is finished please run it then restart XML Notepad.</value>
<comment>Message box prompt</comment>
</data>
</root>
8 changes: 8 additions & 0 deletions src/XmlNotepad/XsltControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private async void InitializeBrowser(string version)
WebBrowserFallback();
}

this._settings["WebView2Exception"] = "";
Reload();
}
catch (Exception ex)
Expand Down Expand Up @@ -159,6 +160,7 @@ private void OnCoreWebView2InitializationCompleted(object sender, CoreWebView2In
{
this.webBrowser2.CoreWebView2.DOMContentLoaded += CoreWebView2_DOMContentLoaded;
this.webBrowser2.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted;
this.webBrowser2.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
this.webBrowser2.Visible = true;
this.webBrowser1.Visible = false;
this._webView2Supported = true;
Expand All @@ -170,6 +172,12 @@ private void OnCoreWebView2InitializationCompleted(object sender, CoreWebView2In
_webInitialized = true;
}

private void CoreWebView2_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e)
{
WebBrowser.OpenUrl(this.Handle, e.Uri);
e.Handled = true;
}

private void CoreWebView2_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
{
if (!e.IsSuccess && !DisableOutputFile)
Expand Down
8 changes: 4 additions & 4 deletions src/XmlNotepadPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap rescap">
<Identity Name="5632ff08-aa93-439a-b09f-677eb3664250" Publisher="CN=Chris Lovett, O=Chris Lovett, S=Washington, C=US" Version="2.8.0.60" />
<Identity Name="43906ChrisLovett.XmlNotepad" Publisher="CN=BC801FCC-0BF8-49D7-9F51-1B625C3BE476" Version="2.8.0.61" />
<Properties>
<DisplayName>XML Notepad</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<DisplayName>XmlNotepad</DisplayName>
<PublisherDisplayName>Chris Lovett</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
Expand All @@ -15,7 +15,7 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements DisplayName="XML Notepad" Description="XML Notepad is a lightweight and fast tool for editing XML documents. XML has proliferated across the planet and XML Notepad has been downloaded over 3 million times!" BackgroundColor="transparent" Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png">
<uap:VisualElements DisplayName="XmlNotepad" Description="XML Notepad is a lightweight and fast tool for editing XML documents. XML has proliferated across the planet and XML Notepad has been downloaded over 3 million times!" BackgroundColor="transparent" Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" Square71x71Logo="Images\SmallTile.png" Square310x310Logo="Images\LargeTile.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
Expand Down
2 changes: 1 addition & 1 deletion src/XmlNotepadSetup/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="XmlNotepad" Language="1033" Version="2.8.0.60" Manufacturer="Lovett Software" UpgradeCode="14C1B5E8-3198-4AF2-B4BC-351017A109D3">
<Product Id="*" Name="XmlNotepad" Language="1033" Version="2.8.0.61" Manufacturer="Lovett Software" UpgradeCode="14C1B5E8-3198-4AF2-B4BC-351017A109D3">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade Schedule="afterInstallFinalize" DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="yes" />
<MediaTemplate />
Expand Down
4 changes: 2 additions & 2 deletions src/xmlnotepadsetup.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
# Visual Studio Version 17
VisualStudioVersion = 17.2.32505.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{484CF3FF-5CEA-4C82-A937-949100142455}"
ProjectSection(SolutionItems) = preProject
Expand Down

0 comments on commit 3c31d38

Please sign in to comment.