2020-07-16 01:23:59 +08:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using Common;
|
|
|
|
|
using Microsoft.PowerToys.Telemetry;
|
|
|
|
|
|
2020-09-17 02:15:34 +08:00
|
|
|
|
namespace Microsoft.PowerToys.PreviewHandler.Markdown
|
2020-07-16 01:23:59 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Implementation of preview handler for markdown files.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Guid("45769bcc-e8fd-42d0-947e-02beef77a1f5")]
|
|
|
|
|
[ClassInterface(ClassInterfaceType.None)]
|
|
|
|
|
[ComVisible(true)]
|
2020-09-17 02:15:34 +08:00
|
|
|
|
public class MarkdownPreviewHandler : FileBasedPreviewHandler, IDisposable
|
2020-07-16 01:23:59 +08:00
|
|
|
|
{
|
2020-09-17 02:15:34 +08:00
|
|
|
|
private MarkdownPreviewHandlerControl _markdownPreviewHandlerControl;
|
|
|
|
|
private bool disposedValue;
|
2020-07-16 01:23:59 +08:00
|
|
|
|
|
2020-09-24 01:22:17 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="MarkdownPreviewHandler"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public MarkdownPreviewHandler()
|
|
|
|
|
{
|
|
|
|
|
Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-16 01:23:59 +08:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public override void DoPreview()
|
|
|
|
|
{
|
2020-09-17 02:15:34 +08:00
|
|
|
|
_markdownPreviewHandlerControl.DoPreview(FilePath);
|
2020-07-16 01:23:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override IPreviewHandlerControl CreatePreviewHandlerControl()
|
|
|
|
|
{
|
|
|
|
|
PowerToysTelemetry.Log.WriteEvent(new Telemetry.Events.MarkdownFileHandlerLoaded());
|
2020-09-17 02:15:34 +08:00
|
|
|
|
_markdownPreviewHandlerControl = new MarkdownPreviewHandlerControl();
|
|
|
|
|
|
|
|
|
|
return _markdownPreviewHandlerControl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Disposes objects
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="disposing">Is Disposing</param>
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
if (!disposedValue)
|
|
|
|
|
{
|
|
|
|
|
if (disposing)
|
|
|
|
|
{
|
|
|
|
|
_markdownPreviewHandlerControl.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);
|
2020-07-16 01:23:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|