mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-11 12:14:53 +08:00
[FxCop] Svg preview handler (#6647)
* Adjusting namespace * Getting FxCop working e2e
This commit is contained in:
parent
b0f0940534
commit
13fd6bd6e1
@ -421,18 +421,18 @@
|
|||||||
<!-- Added a separate component for Per-User registry changes -->
|
<!-- Added a separate component for Per-User registry changes -->
|
||||||
<!-- Registry Key for Class Registration of Svg Preview Handler -->
|
<!-- Registry Key for Class Registration of Svg Preview Handler -->
|
||||||
<RegistryKey Root="HKCR" Key="CLSID\{ddee2b8a-6807-48a6-bb20-2338174ff779}">
|
<RegistryKey Root="HKCR" Key="CLSID\{ddee2b8a-6807-48a6-bb20-2338174ff779}">
|
||||||
<RegistryValue Type="string" Value="SvgPreviewHandler.SvgPreviewHandler" />
|
<RegistryValue Type="string" Value="Microsoft.PowerToys.PreviewHandler.Svg.SvgPreviewHandler" />
|
||||||
<RegistryValue Type="string" Name="DisplayName" Value="Svg Preview Handler" />
|
<RegistryValue Type="string" Name="DisplayName" Value="Svg Preview Handler" />
|
||||||
<RegistryValue Type="string" Name="AppID" Value="{CF142243-F059-45AF-8842-DBBE9783DB14}" />
|
<RegistryValue Type="string" Name="AppID" Value="{CF142243-F059-45AF-8842-DBBE9783DB14}" />
|
||||||
<RegistryValue Type="string" Key="Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value=""/>
|
<RegistryValue Type="string" Key="Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value=""/>
|
||||||
<RegistryValue Type="string" Key="InprocServer32" Value="mscoree.dll" />
|
<RegistryValue Type="string" Key="InprocServer32" Value="mscoree.dll" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32" Name="Assembly" Value="SvgPreviewHandler, Version=$(var.Version).0, Culture=neutral" />
|
<RegistryValue Type="string" Key="InprocServer32" Name="Assembly" Value="SvgPreviewHandler, Version=$(var.Version).0, Culture=neutral" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32" Name="Class" Value="SvgPreviewHandler.SvgPreviewHandler" />
|
<RegistryValue Type="string" Key="InprocServer32" Name="Class" Value="Microsoft.PowerToys.PreviewHandler.Svg.SvgPreviewHandler" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32" Name="RuntimeVersion" Value="v4.0.30319" />
|
<RegistryValue Type="string" Key="InprocServer32" Name="RuntimeVersion" Value="v4.0.30319" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32" Name="ThreadingModel" Value="Both" />
|
<RegistryValue Type="string" Key="InprocServer32" Name="ThreadingModel" Value="Both" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32" Name="CodeBase" Value="file:///[FileExplorerPreviewInstallFolder]SvgPreviewHandler.dll" />
|
<RegistryValue Type="string" Key="InprocServer32" Name="CodeBase" Value="file:///[FileExplorerPreviewInstallFolder]SvgPreviewHandler.dll" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32\$(var.Version).0" Name="Assembly" Value="SvgPreviewHandler, Version=$(var.Version).0, Culture=neutral" />
|
<RegistryValue Type="string" Key="InprocServer32\$(var.Version).0" Name="Assembly" Value="SvgPreviewHandler, Version=$(var.Version).0, Culture=neutral" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32\$(var.Version).0" Name="Class" Value="SvgPreviewHandler.SvgPreviewHandler" />
|
<RegistryValue Type="string" Key="InprocServer32\$(var.Version).0" Name="Class" Value="Microsoft.PowerToys.PreviewHandler.Svg.SvgPreviewHandler" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32\$(var.Version).0" Name="RuntimeVersion" Value="v4.0.30319" />
|
<RegistryValue Type="string" Key="InprocServer32\$(var.Version).0" Name="RuntimeVersion" Value="v4.0.30319" />
|
||||||
<RegistryValue Type="string" Key="InprocServer32\$(var.Version).0" Name="CodeBase" Value="file:///[FileExplorerPreviewInstallFolder]SvgPreviewHandler.dll" />
|
<RegistryValue Type="string" Key="InprocServer32\$(var.Version).0" Name="CodeBase" Value="file:///[FileExplorerPreviewInstallFolder]SvgPreviewHandler.dll" />
|
||||||
</RegistryKey>
|
</RegistryKey>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace SvgPreviewHandler {
|
namespace Microsoft.PowerToys.PreviewHandler.Svg {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace SvgPreviewHandler {
|
|||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SvgPreviewHandler.Resource", typeof(Resource).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.PowerToys.PreviewHandler.Svg.Resource", typeof(Resource).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
|
@ -3,22 +3,18 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices.ComTypes;
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
using System.Runtime.Versioning;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using Common;
|
using Common;
|
||||||
using Common.Utilities;
|
using Common.Utilities;
|
||||||
|
using Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events;
|
||||||
|
using Microsoft.PowerToys.PreviewHandler.Svg.Utilities;
|
||||||
using Microsoft.PowerToys.Telemetry;
|
using Microsoft.PowerToys.Telemetry;
|
||||||
using PreviewHandlerCommon;
|
using PreviewHandlerCommon;
|
||||||
using SvgPreviewHandler.Telemetry.Events;
|
|
||||||
|
|
||||||
namespace SvgPreviewHandler
|
namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implementation of Control for Svg Preview Handler.
|
/// Implementation of Control for Svg Preview Handler.
|
||||||
@ -28,17 +24,17 @@ namespace SvgPreviewHandler
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extended Browser Control to display Svg.
|
/// Extended Browser Control to display Svg.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private WebBrowserExt browser;
|
private WebBrowserExt _browser;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Text box to display the information about blocked elements from Svg.
|
/// Text box to display the information about blocked elements from Svg.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private RichTextBox textBox;
|
private RichTextBox _textBox;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represent if an text box info bar is added for showing message.
|
/// Represent if an text box info bar is added for showing message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool infoBarAdded = false;
|
private bool _infoBarAdded;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start the preview on the Control.
|
/// Start the preview on the Control.
|
||||||
@ -46,11 +42,11 @@ namespace SvgPreviewHandler
|
|||||||
/// <param name="dataSource">Stream reference to access source file.</param>
|
/// <param name="dataSource">Stream reference to access source file.</param>
|
||||||
public override void DoPreview<T>(T dataSource)
|
public override void DoPreview<T>(T dataSource)
|
||||||
{
|
{
|
||||||
this.InvokeOnControlThread(() =>
|
InvokeOnControlThread(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.infoBarAdded = false;
|
_infoBarAdded = false;
|
||||||
string svgData = null;
|
string svgData = null;
|
||||||
using (var stream = new StreamWrapper(dataSource as IStream))
|
using (var stream = new StreamWrapper(dataSource as IStream))
|
||||||
{
|
{
|
||||||
@ -63,21 +59,23 @@ namespace SvgPreviewHandler
|
|||||||
// Add a info bar on top of the Preview if any blocked element is present.
|
// Add a info bar on top of the Preview if any blocked element is present.
|
||||||
if (SvgPreviewHandlerHelper.CheckBlockedElements(svgData))
|
if (SvgPreviewHandlerHelper.CheckBlockedElements(svgData))
|
||||||
{
|
{
|
||||||
this.infoBarAdded = true;
|
_infoBarAdded = true;
|
||||||
this.AddTextBoxControl(Resource.BlockedElementInfoText);
|
AddTextBoxControl(Resource.BlockedElementInfoText);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.AddBrowserControl(svgData);
|
AddBrowserControl(svgData);
|
||||||
this.Resize += this.FormResized;
|
Resize += FormResized;
|
||||||
base.DoPreview(dataSource);
|
base.DoPreview(dataSource);
|
||||||
PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewed());
|
PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewed());
|
||||||
}
|
}
|
||||||
|
#pragma warning disable CA1031 // Do not catch general exception types
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
#pragma warning restore CA1031 // Do not catch general exception types
|
||||||
{
|
{
|
||||||
PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewError { Message = ex.Message });
|
PowerToysTelemetry.Log.WriteEvent(new SvgFilePreviewError { Message = ex.Message });
|
||||||
this.Controls.Clear();
|
Controls.Clear();
|
||||||
this.infoBarAdded = true;
|
_infoBarAdded = true;
|
||||||
this.AddTextBoxControl(Resource.SvgNotPreviewedError);
|
AddTextBoxControl(Resource.SvgNotPreviewedError);
|
||||||
base.DoPreview(dataSource);
|
base.DoPreview(dataSource);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -101,9 +99,9 @@ namespace SvgPreviewHandler
|
|||||||
/// <param name="e">Provides data for the resize event.</param>
|
/// <param name="e">Provides data for the resize event.</param>
|
||||||
private void FormResized(object sender, EventArgs e)
|
private void FormResized(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (this.infoBarAdded)
|
if (_infoBarAdded)
|
||||||
{
|
{
|
||||||
this.textBox.Width = this.Width;
|
_textBox.Width = Width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,14 +111,14 @@ namespace SvgPreviewHandler
|
|||||||
/// <param name="svgData">Svg to display on Browser Control.</param>
|
/// <param name="svgData">Svg to display on Browser Control.</param>
|
||||||
private void AddBrowserControl(string svgData)
|
private void AddBrowserControl(string svgData)
|
||||||
{
|
{
|
||||||
this.browser = new WebBrowserExt();
|
_browser = new WebBrowserExt();
|
||||||
this.browser.DocumentText = svgData;
|
_browser.DocumentText = svgData;
|
||||||
this.browser.Dock = DockStyle.Fill;
|
_browser.Dock = DockStyle.Fill;
|
||||||
this.browser.IsWebBrowserContextMenuEnabled = false;
|
_browser.IsWebBrowserContextMenuEnabled = false;
|
||||||
this.browser.ScriptErrorsSuppressed = true;
|
_browser.ScriptErrorsSuppressed = true;
|
||||||
this.browser.ScrollBarsEnabled = true;
|
_browser.ScrollBarsEnabled = true;
|
||||||
this.browser.AllowNavigation = false;
|
_browser.AllowNavigation = false;
|
||||||
this.Controls.Add(this.browser);
|
Controls.Add(_browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -129,16 +127,16 @@ namespace SvgPreviewHandler
|
|||||||
/// <param name="message">Message to be displayed in textbox.</param>
|
/// <param name="message">Message to be displayed in textbox.</param>
|
||||||
private void AddTextBoxControl(string message)
|
private void AddTextBoxControl(string message)
|
||||||
{
|
{
|
||||||
this.textBox = new RichTextBox();
|
_textBox = new RichTextBox();
|
||||||
this.textBox.Text = message;
|
_textBox.Text = message;
|
||||||
this.textBox.BackColor = Color.LightYellow;
|
_textBox.BackColor = Color.LightYellow;
|
||||||
this.textBox.Multiline = true;
|
_textBox.Multiline = true;
|
||||||
this.textBox.Dock = DockStyle.Top;
|
_textBox.Dock = DockStyle.Top;
|
||||||
this.textBox.ReadOnly = true;
|
_textBox.ReadOnly = true;
|
||||||
this.textBox.ContentsResized += this.RTBContentsResized;
|
_textBox.ContentsResized += RTBContentsResized;
|
||||||
this.textBox.ScrollBars = RichTextBoxScrollBars.None;
|
_textBox.ScrollBars = RichTextBoxScrollBars.None;
|
||||||
this.textBox.BorderStyle = BorderStyle.None;
|
_textBox.BorderStyle = BorderStyle.None;
|
||||||
this.Controls.Add(this.textBox);
|
Controls.Add(_textBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
|
|||||||
using Common;
|
using Common;
|
||||||
using Microsoft.PowerToys.Telemetry;
|
using Microsoft.PowerToys.Telemetry;
|
||||||
|
|
||||||
namespace SvgPreviewHandler
|
namespace Microsoft.PowerToys.PreviewHandler.Svg
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extends <see cref="StreamBasedPreviewHandler"/> for Svg Preview Handler.
|
/// Extends <see cref="StreamBasedPreviewHandler"/> for Svg Preview Handler.
|
||||||
@ -15,22 +15,51 @@ namespace SvgPreviewHandler
|
|||||||
[Guid("ddee2b8a-6807-48a6-bb20-2338174ff779")]
|
[Guid("ddee2b8a-6807-48a6-bb20-2338174ff779")]
|
||||||
[ClassInterface(ClassInterfaceType.None)]
|
[ClassInterface(ClassInterfaceType.None)]
|
||||||
[ComVisible(true)]
|
[ComVisible(true)]
|
||||||
public class SvgPreviewHandler : StreamBasedPreviewHandler
|
public class SvgPreviewHandler : StreamBasedPreviewHandler, IDisposable
|
||||||
{
|
{
|
||||||
private SvgPreviewControl svgPreviewControl;
|
private SvgPreviewControl _svgPreviewControl;
|
||||||
|
private bool disposedValue;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override void DoPreview()
|
public override void DoPreview()
|
||||||
{
|
{
|
||||||
this.svgPreviewControl.DoPreview(this.Stream);
|
_svgPreviewControl.DoPreview(Stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override IPreviewHandlerControl CreatePreviewHandlerControl()
|
protected override IPreviewHandlerControl CreatePreviewHandlerControl()
|
||||||
{
|
{
|
||||||
PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.SvgFileHandlerLoaded());
|
PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.SvgFileHandlerLoaded());
|
||||||
this.svgPreviewControl = new SvgPreviewControl();
|
_svgPreviewControl = new SvgPreviewControl();
|
||||||
return this.svgPreviewControl;
|
|
||||||
|
return _svgPreviewControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes objects
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">Is Disposing</param>
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_svgPreviewControl.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
|
||||||
|
// TODO: set large fields to null
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
Dispose(disposing: true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
<ProjectGuid>{DA425894-6E13-404F-8DCB-78584EC0557A}</ProjectGuid>
|
<ProjectGuid>{DA425894-6E13-404F-8DCB-78584EC0557A}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>SvgPreviewHandler</RootNamespace>
|
<RootNamespace>Microsoft.PowerToys.PreviewHandler.Svg</RootNamespace>
|
||||||
<AssemblyName>SvgPreviewHandler</AssemblyName>
|
<AssemblyName>SvgPreviewHandler</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
@ -115,6 +115,7 @@
|
|||||||
<Compile Include="Telemetry\Events\SvgFileHandlerLoaded.cs" />
|
<Compile Include="Telemetry\Events\SvgFileHandlerLoaded.cs" />
|
||||||
<Compile Include="Telemetry\Events\SvgFilePreviewed.cs" />
|
<Compile Include="Telemetry\Events\SvgFilePreviewed.cs" />
|
||||||
<Compile Include="Telemetry\Events\SvgFilePreviewError.cs" />
|
<Compile Include="Telemetry\Events\SvgFilePreviewError.cs" />
|
||||||
|
<Compile Include="Utilities\SvgPreviewHandlerHelper.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
|
<ProjectReference Include="..\..\..\common\ManagedTelemetry\Telemetry\Telemetry.csproj">
|
||||||
@ -132,6 +133,11 @@
|
|||||||
</AdditionalFiles>
|
</AdditionalFiles>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
|
||||||
|
<Version>3.3.0</Version>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="StyleCop.Analyzers">
|
<PackageReference Include="StyleCop.Analyzers">
|
||||||
<Version>1.1.118</Version>
|
<Version>1.1.118</Version>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
@ -6,7 +6,7 @@ using System.Diagnostics.Tracing;
|
|||||||
using Microsoft.PowerToys.Telemetry;
|
using Microsoft.PowerToys.Telemetry;
|
||||||
using Microsoft.PowerToys.Telemetry.Events;
|
using Microsoft.PowerToys.Telemetry.Events;
|
||||||
|
|
||||||
namespace SvgPreviewHandler.Telemetry.Events
|
namespace Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
|
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
|
||||||
|
@ -6,7 +6,7 @@ using System.Diagnostics.Tracing;
|
|||||||
using Microsoft.PowerToys.Telemetry;
|
using Microsoft.PowerToys.Telemetry;
|
||||||
using Microsoft.PowerToys.Telemetry.Events;
|
using Microsoft.PowerToys.Telemetry.Events;
|
||||||
|
|
||||||
namespace SvgPreviewHandler.Telemetry.Events
|
namespace Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A telemetry event to be raised when an error has occurred in the preview pane.
|
/// A telemetry event to be raised when an error has occurred in the preview pane.
|
||||||
|
@ -6,7 +6,7 @@ using System.Diagnostics.Tracing;
|
|||||||
using Microsoft.PowerToys.Telemetry;
|
using Microsoft.PowerToys.Telemetry;
|
||||||
using Microsoft.PowerToys.Telemetry.Events;
|
using Microsoft.PowerToys.Telemetry.Events;
|
||||||
|
|
||||||
namespace SvgPreviewHandler.Telemetry.Events
|
namespace Microsoft.PowerToys.PreviewHandler.Svg.Telemetry.Events
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
|
/// A telemetry event to be raised when a svg file has been viewed in the preview pane.
|
||||||
|
@ -4,15 +4,16 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Common.Utilities
|
namespace Microsoft.PowerToys.PreviewHandler.Svg.Utilities
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper utilities for Svg Preview Handler.
|
/// Helper utilities for Svg Preview Handler.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SvgPreviewHandlerHelper
|
public static class SvgPreviewHandlerHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dictionary of elements in lower case that are blocked from Svg for preview pane.
|
/// Dictionary of elements in lower case that are blocked from Svg for preview pane.
|
||||||
@ -46,7 +47,7 @@ namespace Common.Utilities
|
|||||||
var elements = doc.Descendants().ToList();
|
var elements = doc.Descendants().ToList();
|
||||||
foreach (XElement element in elements)
|
foreach (XElement element in elements)
|
||||||
{
|
{
|
||||||
var elementName = element?.Name?.LocalName?.ToLower();
|
var elementName = element?.Name?.LocalName?.ToLower(CultureInfo.CurrentCulture);
|
||||||
if (elementName != null && blockedElementsName.ContainsKey(elementName))
|
if (elementName != null && blockedElementsName.ContainsKey(elementName))
|
||||||
{
|
{
|
||||||
foundBlockedElement = true;
|
foundBlockedElement = true;
|
||||||
@ -56,7 +57,9 @@ namespace Common.Utilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma warning disable CA1031 // Do not catch general exception types
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
#pragma warning restore CA1031 // Do not catch general exception types
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -4,15 +4,14 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.InteropServices.ComTypes;
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Microsoft.PowerToys.PreviewHandler.Svg;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Moq;
|
using Moq;
|
||||||
using PreviewHandlerCommon;
|
using PreviewHandlerCommon;
|
||||||
using SvgPreviewHandler;
|
|
||||||
|
|
||||||
namespace SvgPreviewHandlerUnitTests
|
namespace SvgPreviewHandlerUnitTests
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Common.Utilities;
|
using Microsoft.PowerToys.PreviewHandler.Svg.Utilities;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
namespace SvgPreviewHandlerUnitTests
|
namespace SvgPreviewHandlerUnitTests
|
||||||
|
@ -130,7 +130,6 @@
|
|||||||
<Compile Include="handlers\StreamBasedPreviewHandler.cs" />
|
<Compile Include="handlers\StreamBasedPreviewHandler.cs" />
|
||||||
<Compile Include="examplehandler\TestCustomHandler.cs" />
|
<Compile Include="examplehandler\TestCustomHandler.cs" />
|
||||||
<Compile Include="Utilities\StreamWrapper.cs" />
|
<Compile Include="Utilities\StreamWrapper.cs" />
|
||||||
<Compile Include="Utilities\SvgPreviewHandlerHelper.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
|
<AdditionalFiles Include="..\..\..\codeAnalysis\StyleCop.json">
|
||||||
|
Loading…
Reference in New Issue
Block a user