Skip to content

Commit

Permalink
Add a progress dialog with cancellation to the XSLT transform panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
clovett committed Apr 16, 2024
1 parent 3ba8474 commit 6021f19
Show file tree
Hide file tree
Showing 19 changed files with 1,204 additions and 456 deletions.
Binary file modified docs/assets/images/options.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions docs/help/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,31 @@ Options that enable or disable the collection of anonymous app usage information
The options dialog allows you to select a color theme, light or dark, or configure the specific colors used in each type of node as well as the font used and the background color. A drop down arrow on each color lets you pick from different color palettes. You can also customize the font that is used in the XML Notepad tree view.

### Editor
The editor to use if the XML file is invalid
and cannot be opened by XML Notepad.
The editor to use if the XML file is invalid and cannot be opened by XML Notepad.

### Formatting
You can also configure the formatting options that are used when you save an XML file, or turn off formatting altogether. You can also configure the
TreeView indentation level in pixels.
You can also configure the formatting options that are used when you save an XML file, or turn off formatting altogether. Preserve Whitepsace also controls how the file is opened, when true you will
see all the whitespace nodes in the document, which are used also when the file is saved.
You can also configure the TreeView indentation level in pixels.

### Language
Specify which language annotations to pick from associated XSD schemas.

### Long Lines
How to deal with editing of long lines.

### Schema Options
Controls whether the tree view shows special information with the nodes in the tree.
It will promote the text of the specially named child nodes to the text of the parent
node in the tree.

### Settings Location
Where to store these settings.
See [Settings](settings.md) for more information.

### Updates

You can also configure the auto-update mechanism associated with
These settings configure the auto-update mechanism associated with
the ClickOnce installer. If the "Enable updates" field is true, then XML Notepad will ping the specified "Update Location" for an "Updates.xml" file to see if a new version of XML Notepad is available. See [Updates](updates.md) for more information on how this works.

### Validation
Expand All @@ -51,3 +56,4 @@ on documents that have no `<?xml-stylesheet` processing instruction.
Toggle the Web Browser Version to WebView2 if you have the new
[WebView2](https://developer.microsoft.com/en-us/microsoft-edge/webview2/)
component installed on your machine.
Note: the Preserve Whitespace option can also affect XSLT output.
73 changes: 48 additions & 25 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
<ApplicationIcon>Resources\XmlNote.ico</ApplicationIcon>
<StartupObject>XmlNotepad.Program</StartupObject>
<AssemblyOriginatorKeyFile>$(MyKeyFile)</AssemblyOriginatorKeyFile>
<FileUpgradeFlags></FileUpgradeFlags>
<UpgradeBackupLocation></UpgradeBackupLocation>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp></NuGetPackageImportStamp>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>..\..\publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -37,6 +40,8 @@
<PublisherName>Chris Lovett</PublisherName>
<WebPage>readme.htm</WebPage>
<DisallowUrlActivation>true</DisallowUrlActivation>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>2.9.0.8</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down Expand Up @@ -68,7 +73,8 @@
<ManifestCertificateThumbprint>50D58171E20BB6188B199ACA7C20A26DA0DFBF35</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestTimestampUrl></ManifestTimestampUrl>
<ManifestTimestampUrl>
</ManifestTimestampUrl>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
Expand Down Expand Up @@ -104,10 +110,10 @@
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Security.AccessControl, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.AccessControl.5.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.AccessControl, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.AccessControl.5.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -172,7 +178,8 @@
<Compile Include="FormSearch.Designer.cs">
<DependentUpon>FormSearch.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs"></Compile>
<Compile Include="Program.cs">
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XmlDiffWrapper.cs" />
<EmbeddedResource Include="FormGotoLine.resx">
Expand Down Expand Up @@ -301,64 +308,80 @@
<ItemGroup>
<PublishFile Include="Samples\basket.xml">
<Visible>False</Visible>
<Group></Group>
<TargetPath></TargetPath>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
<PublishFile Include="Samples\basket.xsd">
<Visible>False</Visible>
<Group></Group>
<TargetPath></TargetPath>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
<PublishFile Include="Samples\Employee.xml">
<Visible>False</Visible>
<Group></Group>
<TargetPath></TargetPath>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
<PublishFile Include="Samples\Employee.xsd">
<Visible>False</Visible>
<Group></Group>
<TargetPath></TargetPath>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
<PublishFile Include="Samples\Hamlet.xml">
<Visible>False</Visible>
<Group></Group>
<TargetPath></TargetPath>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
<PublishFile Include="Samples\rss.xml">
<Visible>False</Visible>
<Group></Group>
<TargetPath></TargetPath>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
<PublishFile Include="Samples\rsspretty.xsl">
<Visible>False</Visible>
<Group></Group>
<TargetPath></TargetPath>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
<PublishFile Include="Samples\willy.xsl">
<Visible>False</Visible>
<Group></Group>
<TargetPath></TargetPath>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Include</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
Expand Down
20 changes: 18 additions & 2 deletions src/Application/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace XmlNotepad
/// <summary>
/// Summary description for Form1.
/// </summary>
public partial class FormMain : Form, ISite
public partial class FormMain : Form, ISite, ITrustService
{
private readonly UndoManager _undoManager;
private Settings _settings = new Settings();
Expand Down Expand Up @@ -179,7 +179,7 @@ public FormMain(SettingsLocation location)

private void DispatchAction(Action action)
{
if (!this.Disposing)
if (!this.Disposing && !this.closing)
{
ISynchronizeInvoke si = (ISynchronizeInvoke)this;
if (si.InvokeRequired)
Expand Down Expand Up @@ -505,6 +505,7 @@ protected override void OnClosing(CancelEventArgs e)
return;
}
}
this.closing = true;
this._delayedActions.Close();
SaveConfig();
base.OnClosing(e);
Expand Down Expand Up @@ -567,6 +568,7 @@ protected override void OnLayout(LayoutEventArgs levent)
/// </summary>
protected override void Dispose(bool disposing)
{
this.closing = true;
if (disposing)
{
if (components != null)
Expand Down Expand Up @@ -2927,6 +2929,7 @@ private void goToLineToolStripMenuItem_Click(object sender, EventArgs e)
TextBox xPos;
TextBox yPos;
TextBox status;
private bool closing;

internal void ShowMousePosition()
{
Expand Down Expand Up @@ -2977,6 +2980,19 @@ private void Panel_MouseMove(object sender, MouseEventArgs e)
xPos.Text = e.X.ToString();
yPos.Text = e.Y.ToString();
}

public async System.Threading.Tasks.Task<bool> CanTrustUrl(Uri location)
{
bool result = false;
this.Invoke(new Action(() =>
{
result = MessageBox.Show(this, SR.XslScriptCodePrompt, SR.XslScriptCodeCaption,
MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes;
}
));
await System.Threading.Tasks.Task.CompletedTask;
return result;
}
#endregion

}
Expand Down
18 changes: 18 additions & 0 deletions src/Application/FormOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public class UserSettings
private int _indentLevel;
private IndentChar _indentChar;
private string _newLineChars;
private bool _preserveWhitespace;
private string _language;
private int _maximumLineLength;
private int _maximumValueLength;
Expand Down Expand Up @@ -252,6 +253,7 @@ public UserSettings(Settings s)
_indentLevel = this._settings.GetInteger("IndentLevel");
_indentChar = (IndentChar)this._settings["IndentChar"];
_newLineChars = this._settings.GetString("NewLineChars");
_preserveWhitespace = this._settings.GetBoolean("PreserveWhitespace");
_language = this._settings.GetString("Language");
_settingsLocation = this._settings.GetLocation();
_schemaAwareText = this._settings.GetBoolean("SchemaAwareText");
Expand Down Expand Up @@ -348,6 +350,7 @@ public void Apply()
this._settings["IndentLevel"] = _indentLevel;
this._settings["IndentChar"] = _indentChar;
this._settings["NewLineChars"] = _newLineChars;
this._settings["PreserveWhitespace"] = _preserveWhitespace;
this._settings["NoByteOrderMark"] = _noByteOrderMark;
this._settings.SetLocation(_settingsLocation);

Expand Down Expand Up @@ -765,6 +768,21 @@ public string NewLineChars
}
}

[SRCategory("FormatCategory")]
[LocDisplayName("PreserveWhitespace")]
[SRDescription("PreserveWhitespaceDescription")]
public bool PreserveWhitespace
{
get
{
return this._preserveWhitespace;
}
set
{
this._preserveWhitespace = value;
}
}

[SRCategory("FormatCategory")]
[LocDisplayName("NoByteOrderMark")]
[SRDescription("NoByteOrderMarkDescription")]
Expand Down
1 change: 0 additions & 1 deletion src/Model/DelayedAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ internal void OnDelayTimerTick(object state)
{
try
{
Debug.WriteLine("invoking delayed action: " + this.name);
a();
}
catch (Exception ex)
Expand Down
3 changes: 2 additions & 1 deletion src/Model/DomLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public XmlDocument Load(XmlReader r)
this._lineInfos = new List<LineInfo>();
this._firstRealLine = null;
this._doc = new XmlDocument();
this._doc.PreserveWhitespace = Settings.Instance.GetBoolean("PreserveWhitespace");
this._doc.XmlResolver = Settings.Instance.Resolver;
this._doc.Schemas.XmlResolver = Settings.Instance.Resolver;
SetLoading(this._doc, true);
Expand Down Expand Up @@ -206,7 +207,7 @@ void SetLoading(XmlDocument doc, bool flag)

private void LoadDocument()
{
bool preserveWhitespace = false;
bool preserveWhitespace = this._doc.PreserveWhitespace;
XmlReader r = this._reader;
XmlNode parent = this._doc;
XmlElement element;
Expand Down
1 change: 1 addition & 0 deletions src/Model/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ public void SetDefaults()
this["IndentLevel"] = 2;
this["IndentChar"] = IndentChar.Space;
this["NewLineChars"] = Settings.EscapeNewLines("\r\n");
this["PreserveWhitespace"] = false;
this["Language"] = "";
this["NoByteOrderMark"] = false;

Expand Down

0 comments on commit 6021f19

Please sign in to comment.