2022-01-25 21:02:10 +01: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.
|
|
|
|
|
|
2022-08-16 19:32:49 +02:00
|
|
|
using System.Globalization;
|
2022-01-25 21:02:10 +01:00
|
|
|
using System.Runtime.CompilerServices;
|
2023-11-14 18:27:45 +03:00
|
|
|
using System.Text;
|
2022-01-25 21:02:10 +01:00
|
|
|
using Common;
|
2023-03-21 10:27:29 +01:00
|
|
|
using ManagedCommon;
|
2022-01-25 21:02:10 +01:00
|
|
|
using Microsoft.PowerToys.PreviewHandler.Monaco.Properties;
|
|
|
|
|
using Microsoft.Web.WebView2.Core;
|
|
|
|
|
using Microsoft.Web.WebView2.WinForms;
|
2023-11-14 18:27:45 +03:00
|
|
|
using UtfUnknown;
|
2022-01-25 21:02:10 +01:00
|
|
|
using Windows.System;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.PreviewHandler.Monaco
|
|
|
|
|
{
|
|
|
|
|
public class MonacoPreviewHandlerControl : FormHandlerControl
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Settings class
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly Settings _settings = new Settings();
|
|
|
|
|
|
2022-10-26 14:02:31 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Text box to display the information about blocked elements from Svg.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private RichTextBox _textBox;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represent if an text box info bar is added for showing message.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool _infoBarAdded;
|
|
|
|
|
|
2022-01-25 21:02:10 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Saves if the user already navigated to the index page
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool _hasNavigated;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// WebView2 element
|
|
|
|
|
/// </summary>
|
|
|
|
|
private WebView2 _webView;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// WebView2 Environment
|
|
|
|
|
/// </summary>
|
|
|
|
|
private CoreWebView2Environment _webView2Environment;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Loading label
|
|
|
|
|
/// </summary>
|
|
|
|
|
private Label _loading;
|
|
|
|
|
|
2022-08-16 19:32:49 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Loading progress bar
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ProgressBar _loadingBar;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Grey background
|
|
|
|
|
/// </summary>
|
|
|
|
|
private Label _loadingBackground;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// HTML code passed to the file
|
|
|
|
|
/// </summary>
|
|
|
|
|
#nullable enable
|
|
|
|
|
private string? _html;
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Id for monaco language
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _vsCodeLangSet;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The content of the previewing file in base64
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _base64FileCode;
|
|
|
|
|
|
2023-06-30 18:44:12 +02:00
|
|
|
public MonacoPreviewHandlerControl()
|
|
|
|
|
{
|
|
|
|
|
this.SetBackground();
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-25 21:02:10 +01:00
|
|
|
[STAThread]
|
|
|
|
|
public override void DoPreview<T>(T dataSource)
|
|
|
|
|
{
|
2022-08-16 19:32:49 +02:00
|
|
|
Logger.LogTrace();
|
|
|
|
|
|
2022-10-26 14:02:31 +01:00
|
|
|
if (global::PowerToys.GPOWrapper.GPOWrapper.GetConfiguredMonacoPreviewEnabledValue() == global::PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
|
|
|
|
{
|
|
|
|
|
// GPO is disabling this utility. Show an error message instead.
|
2022-12-14 13:37:23 +01:00
|
|
|
_infoBarAdded = true;
|
|
|
|
|
AddTextBoxControl(Properties.Resources.GpoDisabledErrorText);
|
|
|
|
|
Resize += FormResized;
|
|
|
|
|
base.DoPreview(dataSource);
|
2022-10-26 14:02:31 +01:00
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-25 21:02:10 +01:00
|
|
|
base.DoPreview(dataSource);
|
|
|
|
|
|
|
|
|
|
// Starts loading screen
|
2022-08-19 19:37:05 +02:00
|
|
|
InitializeLoadingScreen();
|
2022-01-25 21:02:10 +01:00
|
|
|
|
|
|
|
|
// New webview2 element
|
|
|
|
|
_webView = new WebView2();
|
2023-06-30 18:44:12 +02:00
|
|
|
_webView.DefaultBackgroundColor = Color.Transparent;
|
2022-01-25 21:02:10 +01:00
|
|
|
|
2024-03-11 17:24:42 +00:00
|
|
|
try
|
2022-01-25 21:02:10 +01:00
|
|
|
{
|
2024-03-11 17:24:42 +00:00
|
|
|
// Checks if dataSource is a string
|
|
|
|
|
if (!(dataSource is string filePath))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException($"{nameof(dataSource)} for {nameof(MonacoPreviewHandlerControl)} must be a string but was a '{typeof(T)}'");
|
|
|
|
|
}
|
2022-01-25 21:02:10 +01:00
|
|
|
|
2024-03-11 17:24:42 +00:00
|
|
|
// Check if the file is too big.
|
|
|
|
|
long fileSize = new FileInfo(filePath).Length;
|
2022-01-25 21:02:10 +01:00
|
|
|
|
2024-03-11 17:24:42 +00:00
|
|
|
if (fileSize < _settings.MaxFileSize)
|
2022-01-25 21:02:10 +01:00
|
|
|
{
|
2023-02-22 12:59:30 +01:00
|
|
|
InitializeIndexFileAndSelectedFile(filePath);
|
|
|
|
|
|
2022-12-14 13:37:23 +01:00
|
|
|
Logger.LogInfo("Create WebView2 environment");
|
|
|
|
|
ConfiguredTaskAwaitable<CoreWebView2Environment>.ConfiguredTaskAwaiter
|
|
|
|
|
webView2EnvironmentAwaiter = CoreWebView2Environment
|
2024-02-28 15:24:40 +01:00
|
|
|
.CreateAsync(userDataFolder: System.Environment.GetEnvironmentVariable("USERPROFILE") +
|
|
|
|
|
"\\AppData\\LocalLow\\Microsoft\\PowerToys\\MonacoPreview-Temp")
|
2022-12-14 13:37:23 +01:00
|
|
|
.ConfigureAwait(true).GetAwaiter();
|
|
|
|
|
webView2EnvironmentAwaiter.OnCompleted(async () =>
|
2022-01-25 21:02:10 +01:00
|
|
|
{
|
2022-12-14 13:37:23 +01:00
|
|
|
_loadingBar.Value = 60;
|
|
|
|
|
this.Update();
|
|
|
|
|
try
|
2022-01-25 21:02:10 +01:00
|
|
|
{
|
2022-12-14 13:37:23 +01:00
|
|
|
if (CoreWebView2Environment.GetAvailableBrowserVersionString() == null)
|
|
|
|
|
{
|
|
|
|
|
throw new WebView2RuntimeNotFoundException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_webView2Environment = webView2EnvironmentAwaiter.GetResult();
|
|
|
|
|
|
|
|
|
|
_loadingBar.Value = 70;
|
2022-08-16 19:32:49 +02:00
|
|
|
this.Update();
|
2022-12-14 13:37:23 +01:00
|
|
|
|
|
|
|
|
// Initialize WebView
|
|
|
|
|
try
|
2022-01-25 21:02:10 +01:00
|
|
|
{
|
2022-12-14 13:37:23 +01:00
|
|
|
await _webView.EnsureCoreWebView2Async(_webView2Environment).ConfigureAwait(true);
|
|
|
|
|
|
2023-07-20 00:12:46 +01:00
|
|
|
_webView.CoreWebView2.SetVirtualHostNameToFolderMapping(FilePreviewCommon.MonacoHelper.VirtualHostName, FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow);
|
2022-12-14 13:37:23 +01:00
|
|
|
|
|
|
|
|
Logger.LogInfo("Navigates to string of HTML file");
|
|
|
|
|
|
|
|
|
|
_webView.NavigateToString(_html);
|
|
|
|
|
_webView.NavigationCompleted += WebView2Init;
|
|
|
|
|
_webView.Height = this.Height;
|
|
|
|
|
_webView.Width = this.Width;
|
2023-08-21 15:51:29 +02:00
|
|
|
_webView.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
|
2022-12-14 13:37:23 +01:00
|
|
|
Controls.Add(_webView);
|
|
|
|
|
_webView.SendToBack();
|
|
|
|
|
_loadingBar.Value = 100;
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|
catch (NullReferenceException e)
|
|
|
|
|
{
|
2023-10-04 11:09:23 +01:00
|
|
|
Logger.LogError("NullReferenceException caught. Skipping exception.", e);
|
2022-12-14 13:37:23 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (WebView2RuntimeNotFoundException e)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogWarning("WebView2 was not found:");
|
|
|
|
|
Logger.LogWarning(e.Message);
|
|
|
|
|
Controls.Remove(_loading);
|
|
|
|
|
Controls.Remove(_loadingBar);
|
|
|
|
|
Controls.Remove(_loadingBackground);
|
|
|
|
|
|
|
|
|
|
// WebView2 not installed message
|
|
|
|
|
Label errorMessage = new Label();
|
|
|
|
|
errorMessage.Text = Resources.WebView2_Not_Installed_Message;
|
|
|
|
|
errorMessage.Width = TextRenderer.MeasureText(Resources.WebView2_Not_Installed_Message, errorMessage.Font).Width + 10;
|
|
|
|
|
errorMessage.Height = TextRenderer.MeasureText(Resources.WebView2_Not_Installed_Message, errorMessage.Font).Height;
|
|
|
|
|
Controls.Add(errorMessage);
|
|
|
|
|
|
|
|
|
|
// Download Link
|
|
|
|
|
Label downloadLink = new LinkLabel();
|
|
|
|
|
downloadLink.Text = Resources.Download_WebView2;
|
|
|
|
|
downloadLink.Click += DownloadLink_Click;
|
|
|
|
|
downloadLink.Top = TextRenderer.MeasureText(Resources.WebView2_Not_Installed_Message, errorMessage.Font).Height + 10;
|
|
|
|
|
downloadLink.Width = TextRenderer.MeasureText(Resources.Download_WebView2, errorMessage.Font).Width + 10;
|
|
|
|
|
downloadLink.Height = TextRenderer.MeasureText(Resources.Download_WebView2, errorMessage.Font).Height;
|
2023-02-13 19:57:33 +01:00
|
|
|
downloadLink.ForeColor = Settings.TextColor;
|
2022-12-14 13:37:23 +01:00
|
|
|
Controls.Add(downloadLink);
|
|
|
|
|
}
|
2022-01-25 21:02:10 +01:00
|
|
|
});
|
|
|
|
|
}
|
2024-03-11 17:24:42 +00:00
|
|
|
else
|
2022-01-25 21:02:10 +01:00
|
|
|
{
|
2024-03-11 17:24:42 +00:00
|
|
|
Logger.LogInfo("File is too big to display. Showing error message");
|
|
|
|
|
AddTextBoxControl(Resources.Max_File_Size_Error.Replace("%1", (_settings.MaxFileSize / 1000).ToString(CultureInfo.CurrentCulture), StringComparison.InvariantCulture));
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-03-11 17:24:42 +00:00
|
|
|
catch (UnauthorizedAccessException e)
|
2022-01-25 21:02:10 +01:00
|
|
|
{
|
2024-03-11 17:24:42 +00:00
|
|
|
Logger.LogError(e.Message);
|
|
|
|
|
AddTextBoxControl(Resources.Access_Denied_Exception_Message);
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
2024-03-11 17:24:42 +00:00
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogError(e.Message);
|
|
|
|
|
string errorMessage = Resources.Exception_Occurred;
|
|
|
|
|
errorMessage += e.Message;
|
|
|
|
|
errorMessage += "\n" + e.Source;
|
|
|
|
|
errorMessage += "\n" + e.StackTrace;
|
|
|
|
|
AddTextBoxControl(errorMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Resize += FormResize;
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
|
|
|
|
|
2023-08-21 15:51:29 +02:00
|
|
|
private async void CoreWebView2_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Monaco opens URI in a new window. We open the URI in the default web browser.
|
|
|
|
|
if (e.Uri != null && e.IsUserInitiated)
|
|
|
|
|
{
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
await Launcher.LaunchUriAsync(new Uri(e.Uri));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-25 21:02:10 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// This event sets the height and width of the webview to the size of the form
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void FormResize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_webView.Height = this.Height;
|
|
|
|
|
_webView.Width = this.Width;
|
2022-08-16 19:32:49 +02:00
|
|
|
this.Update();
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This event initializes the webview and sets various settings
|
|
|
|
|
/// </summary>
|
|
|
|
|
[STAThread]
|
|
|
|
|
private void WebView2Init(object sender, CoreWebView2NavigationCompletedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Checks if already navigated
|
|
|
|
|
if (!_hasNavigated)
|
|
|
|
|
{
|
2022-08-16 19:32:49 +02:00
|
|
|
Logger.LogInfo("Setting WebView2 settings");
|
2022-01-25 21:02:10 +01:00
|
|
|
CoreWebView2Settings settings = (sender as WebView2).CoreWebView2.Settings;
|
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
// Enable developer tools and context menu for debugging
|
|
|
|
|
settings.AreDefaultContextMenusEnabled = true;
|
|
|
|
|
settings.AreDevToolsEnabled = true;
|
|
|
|
|
#else
|
|
|
|
|
// Disable context menu
|
|
|
|
|
settings.AreDefaultContextMenusEnabled = false;
|
|
|
|
|
|
|
|
|
|
// Disable developer tools
|
|
|
|
|
settings.AreDevToolsEnabled = false;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Disable script dialogs (like alert())
|
|
|
|
|
settings.AreDefaultScriptDialogsEnabled = false;
|
|
|
|
|
|
|
|
|
|
// Enables JavaScript
|
|
|
|
|
settings.IsScriptEnabled = true;
|
|
|
|
|
|
|
|
|
|
// Disable zoom with ctrl and scroll
|
|
|
|
|
settings.IsZoomControlEnabled = false;
|
|
|
|
|
|
|
|
|
|
// Disable developer menu
|
|
|
|
|
settings.IsBuiltInErrorPageEnabled = false;
|
|
|
|
|
|
|
|
|
|
// Disable status bar
|
|
|
|
|
settings.IsStatusBarEnabled = false;
|
|
|
|
|
|
2022-08-16 19:32:49 +02:00
|
|
|
Logger.LogInfo("Remove loading elements");
|
2022-01-25 21:02:10 +01:00
|
|
|
Controls.Remove(_loading);
|
2022-08-16 19:32:49 +02:00
|
|
|
Controls.Remove(_loadingBar);
|
|
|
|
|
Controls.Remove(_loadingBackground);
|
2022-01-25 21:02:10 +01:00
|
|
|
#if DEBUG
|
|
|
|
|
_webView.CoreWebView2.OpenDevToolsWindow();
|
2022-08-16 19:32:49 +02:00
|
|
|
Logger.LogInfo("Opened Dev Tools window, because solution was built in debug mode");
|
2022-01-25 21:02:10 +01:00
|
|
|
#endif
|
2022-08-16 19:32:49 +02:00
|
|
|
|
|
|
|
|
_loadingBar.Value = 80;
|
|
|
|
|
this.Update();
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This event cancels every navigation inside the webview
|
|
|
|
|
/// </summary>
|
|
|
|
|
[STAThread]
|
|
|
|
|
private void NavigationStarted(object sender, CoreWebView2NavigationStartingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Prevents navigation if already one done to index.html
|
|
|
|
|
if (_hasNavigated)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = false;
|
2022-08-16 19:32:49 +02:00
|
|
|
Logger.LogInfo("Stopped navigation from user");
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If it has navigated to index.html it stops further navigations
|
|
|
|
|
if (e.Uri == "about:blank")
|
|
|
|
|
{
|
|
|
|
|
_hasNavigated = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-16 19:32:49 +02:00
|
|
|
private void SetBackground()
|
|
|
|
|
{
|
|
|
|
|
Logger.LogTrace();
|
2022-12-14 13:37:23 +01:00
|
|
|
this.BackColor = Settings.BackgroundColor;
|
2022-08-16 19:32:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-01-25 21:02:10 +01:00
|
|
|
private void InitializeLoadingScreen()
|
|
|
|
|
{
|
2022-08-16 19:32:49 +02:00
|
|
|
Logger.LogTrace();
|
2022-12-14 13:37:23 +01:00
|
|
|
_loadingBackground = new Label();
|
|
|
|
|
_loadingBackground.BackColor = Settings.BackgroundColor;
|
|
|
|
|
_loadingBackground.Width = this.Width;
|
|
|
|
|
_loadingBackground.Height = this.Height;
|
|
|
|
|
Controls.Add(_loadingBackground);
|
|
|
|
|
_loadingBackground.BringToFront();
|
|
|
|
|
|
|
|
|
|
_loadingBar = new ProgressBar();
|
|
|
|
|
_loadingBar.Width = this.Width - 10;
|
|
|
|
|
_loadingBar.Location = new Point(5, this.Height / 2);
|
|
|
|
|
_loadingBar.Maximum = 100;
|
|
|
|
|
_loadingBar.Value = 10;
|
|
|
|
|
Controls.Add(_loadingBar);
|
|
|
|
|
|
|
|
|
|
_loading = new Label();
|
|
|
|
|
_loading.Text = Resources.Loading_Screen_Message;
|
|
|
|
|
_loading.Width = this.Width;
|
|
|
|
|
_loading.Height = 45;
|
|
|
|
|
_loading.Location = new Point(0, _loadingBar.Location.Y - _loading.Height);
|
|
|
|
|
_loading.TextAlign = ContentAlignment.TopCenter;
|
|
|
|
|
_loading.Font = new Font("MS Sans Serif", 16, FontStyle.Bold);
|
|
|
|
|
_loading.ForeColor = Settings.TextColor;
|
|
|
|
|
Controls.Add(_loading);
|
|
|
|
|
|
|
|
|
|
_loading.BringToFront();
|
|
|
|
|
_loadingBar.BringToFront();
|
|
|
|
|
|
|
|
|
|
this.Update();
|
2022-08-16 19:32:49 +02:00
|
|
|
|
|
|
|
|
Logger.LogInfo("Loading screen initialized");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeIndexFileAndSelectedFile(string filePath)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInfo("Starting getting monaco language id out of filetype");
|
|
|
|
|
_vsCodeLangSet = FileHandler.GetLanguage(Path.GetExtension(filePath));
|
|
|
|
|
|
2023-11-14 18:27:45 +03:00
|
|
|
DetectionResult result = CharsetDetector.DetectFromFile(filePath);
|
|
|
|
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
|
|
|
|
|
|
|
|
// Check if the detected encoding is not null, otherwise default to UTF-8
|
|
|
|
|
Encoding encodingToUse = result.Detected?.Encoding ?? Encoding.UTF8;
|
|
|
|
|
|
|
|
|
|
using (StreamReader fileReader = new StreamReader(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), encodingToUse))
|
2022-08-16 19:32:49 +02:00
|
|
|
{
|
|
|
|
|
Logger.LogInfo("Starting reading requested file");
|
|
|
|
|
var fileContent = fileReader.ReadToEnd();
|
2022-08-24 13:08:10 +02:00
|
|
|
|
|
|
|
|
if (_settings.TryFormat)
|
|
|
|
|
{
|
[Peek] Powertoys Peek MVP (#25922)
* Peek (#22498)
* Add peek dll project
* add spacebar preview and launch on hotkey press
* add todo
* add process handle to handle continuous press of hotkey
* add tool to stop all powertoys processes
* Add a blank Peek page and update nav menu
* Add some initial content to Peek page including a toggle
* refactor settings parsing
* rename spacebar peek to peek viewer
* rename script to stop powertoys processes
* remove tool
* Adding FileUtils for retrieving selected file in File Explorer
* Remove unnecessary SndPeekSettings
* Add shortcut setting
* Set the shortcut to ctrl+space
* Launching viewer with selected FE file
* Add PeekUI WinUI3 project with interop events
* Moving FileTypeUtils into PeekFileUtils project
* execute winui3 app on hotkey
* Fix paths with spaces
* remove winui3 project
* Resolve comment
* add wpf app with toggle visibility on hotkey
* fix visibility on startup
* remove window properties and add todos
* Fixed hidden extension and system file handling
* wip
* Add working WPF app with FileExplorer querying
* remove c++ projects
* Move native awaiter
* Working Image control with image files
* Resize and move window based on explorer monitor
* Image render, window positioning and sizing clean up
* add window management logic and selection logic
* add extension methods to add circular iterating capability to linkedlistnode
* Add OnArrowKeyPresshandler
* Added titlebar with file name and scaling with titlebar height
* fix flashing window on startup and process kept alive when powertoys exits
* remove wait for debugger loop in ui
* Add KeyIsDown method
* Fix KeyDown issue with Key handled and check for repeat
* Add thumbnail logic
* Add all folder items if only one item is selected
* File type helper
* Using hresult
* Add cancellation and rotation handling
* Use extension instead of path
* fIX CONFLICTS
* Fixing some file type checks
* Add new icon for Peek
* Update page with the new Peek icon
* Initialize IsEnabled and hook ActivationShortcut to dllmain
* add icon to taskbar and titlebar
* Add theme sensitive backgrounds
* rename event handlers
* add settings image
* Move window data into obserable object
* Refactor viewmodel, interop and helpers
* Clean up
* Add loading spinner
* Add todos
* Fix conflicts
* Move native code into its own folder
* Add peek to installer
* Fix building peek and peekui projects
* Replace UWP namespaces to WinAppSDK
* Working WASDK placeholder project
* Add exit when powertoys runner exit
* Working winui3 with image display
* Add WIC project with <TreatWarningAsErros> false for now
* Fit content to window
* Use Size from Windows.Foundation
* Change order
* Add some todos
* Refactored native/interop code and added helpers to imagepreviewer
* Rename projects
* Move some code
* Remove using
Co-authored-by: Michael Salmon <miksalmon@users.noreply.github.com>
Co-authored-by: Michael Salmon 🐟 <michaelpsalmon@outlook.com>
Co-authored-by: Alireza Ebadi Ghajari <alirezae@microsoft.com>
Co-authored-by: Jessie Su <Jessie.Su@microsoft.com>
Co-authored-by: sujessie <102062556+sujessie@users.noreply.github.com>
* Bump Microsoft.Windows.SDK.BuildTools version
* [Peek] Plugin pattern to enable any file type previewing (#22475)
* [Peek] Fetching image size through PropertyStore (#22530)
* Fetching metadata from PropertySTore
* Releasing objects to fix crash
* Creating new PropertyHelper
Co-authored-by: Daniel Chau <dancha@microsoft.com>
* Juliata/filetypes (#22538)
* Using the same list of file extensions as Lightbox's AppxManifest, and ensuring we convert file extension to lowercase
* Add IsFileTypeSupported to IPreviewer
* respond to PR comments
* Add scale awareness to window centering (#22541)
* [Peek] Fix installer builds, project configs and update assets (#22540)
* Update installer
* Fix installer errors
* Fix peek vcxproj
* Add package signing
* Add peek to arm64
* Add back ARM64 toMeasureToolUI
* Add versions to project
* Update assets and icons
* Add correct icon
* [Peek] Enable PropertyStore for offline files (#22567)
* Enabling PropertyStore for offline files
Co-authored-by: Daniel Chau <dancha@microsoft.com>
* [Peek] Adding unsupported file previewer (#22598)
* Unsupported file previewer
* Fix file display info
* Fix property store calls
* Update TODO
* [Peek] Add WebView2 integration (#22506)
* First commit with WIP logic to support WV2 in Peek module
* Minor code cleanup and try/catch block
* Added control to wrap WebView2 logic
* Cleanup
* Added logic to handle HTML previewing
Properly update FilePreview according to file type
* Code cleanup
Updated comments
* Updated comment
* Removed comment
* Code cleanup
* Improved opening of web browser preview to avoid "blank" or "seeing previous page" issue
Removed unused method
Added xaml fallback to guarantee default/starting state
* Removed folder
* Updated factory logic to match master
* address code review
* addressed PR review
* address PR review
* Address PR review
* address PR review
* Address PR review
* [Peek] Add basic file querying and navigation (#22589)
* Refactor to facilitate file data initialization
* Extract file-related code to new FileManager class
* Add temp basic version
* Clean + add todo for cancellations
* Fix various nav-related issues
* Temp - start moving iteration-related code to bg thread
* Minor tweaks
* Add FEHelper todo
* Rename FileManager + various tweaks
* Add basic throttling
* Improve bg thread synchronization
* Clean
* Clean
* Rename based on feedback
* Rename FileQuery
* Rename properties
* Rename remaining fields
* Add todos for nav success/failures
Co-authored-by: Esteban Margaron <emargaron@microsoft.com>
* [Peek] Add customized title bar (#22600)
* Add basic button UI
* Add function to get default app name and to open file in default app
* Correct error output
* Add filename to titlebar
* Remove titlebar text from Resw
* Add basic button UI
* Add function to get default app name and to open file in default app
* Add filename to titlebar
* Correct error output
* Remove titlebar text from Resw
* Add SetDragRectangles
* Correct logic, update function name
* Add localization
* Cleanup and adaptive width
* Add fileIndex/NumberOfFiles for multiple files activation
* Refine titlebar styles
* Update error message; Return HResult from native methods; Update variable initialisation and string null testing
* Titlebar height and adaptive width refinement
* Add fallback to launch app picker if fail to open default app
* Temp change to hide AppTitle_FileCount
* Update launch button to command; Add keyboard accelerator
* Update titlebar inactive background color
* Update tooltip to add keyboard accelerator
* Add comments to resw file
* Fix accidental deletion from previous merge
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
* Fix crash
* Fix wrong thread exception
* Make CurrentItemIndex setter private
* Update titlebar filecount text
* Fix titlebar draggable region and interactive region (bump WinAppSdk to latest)
* [Peek] Unsupported File Previewer - Formatting string from resources (#22609)
* Moving to string resource usage
* Moving ReadableStringHelper to common project
* Fix comments
* [Peek] Fix foregrounding (#22633)
* Fixing foregrounding
* Get window handle inside BringToForeground extension method
Co-authored-by: Daniel Chau <dancha@microsoft.com>
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] ImagePreviewer - Handle error states (#22637)
* add better preview state handling
* add error handling in imagepreviewer and better state handling
* fix error handling so exception is not bubbled up
* improve performance and hook up unsupported previewer on error
* remove commented code
* address pr comments
* [Peek] add PDF viewing support (#22636)
* [Peek] add PDF viewing support
* Fixed issue which would redirect some HTML and PDF files to external browser
* Fixed refactored interface name
* [Peek] Refine titlebar adaptive width (#22642)
* Adjust adaptive width of titlebar
* Remove visualstate setters for AppTitle_FileCount
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
* [Peek] New File Explorer tabs break Shell API to get selected files (#22641)
* fix FE tab bug
* remove unnecessary unsafe keyword
* [Peek] add extra logic to properly render PNG files with transparency (#22613)
* [Peek] added extra logic to render PNG files with proper transparency
* Moved logic to ThumbnailHelper
Cleanup
* Created a separated previewer for PNG to only load the preview image with thumbnail logic
* removed unused code
* Updated state loading change
* [Peek] Unsupported File Previewer - Setting Window Size (#22645)
* Adding setting for unsupported file window
* Fix
* [Peek] Add tooltip to File (#22640)
* Add tooltip to File
* Add placeholder text for no tooltip
* Address comments
* Use StringBuilder
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
* Add full image quality support (#22654)
* [Peek] Window foregrounding simplification and fixes + keep window visible if FE single selection changed (#22657)
* Use different apis to bring to foreground removing remote thread wait and work as well as library loading
* Keep window open if single selected file in FE is different
* Removed unused methods
* [Peek] Add cancellation token OnFilePropertyChanged (#22643)
* Cancel file loading before opening another file
* Add omitted cancellation checks
* Catch task cancelled exception; Add more cancellation checkpoints
* Add cancellation checkpoint beofre GetBitmapFromHBitmapAsync
* Correct typo
* Update to pass cancellation token individually to each async methods
* Add lost cancellationToken source
* Add cancellation token to PngPreviewer
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
* [Peek] Unsupported File Previewer - Preserve Transparency For File Icons (#22650)
* Preserving transparency or icons
* Remove TODO
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Update some installer build steps + assets update (#22683)
* Fix settings & peek.ui.wpf
* Add back missing icon
* Add missing files and actions to installer
* Keep window open if the selected file in explorer is different (only works for single file selection)
* Undo last
* [Peek] Add copy keyboard accelerator (#22647)
* add copy keyboard accelerator
* Fix comments
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] add WV2 improvements (behavior and UX) (#22685)
* [Peek] added logic to get max monitor size for opening WebView2
* Removed ununsed dependency property
* Added workaround for cases where the web page would not finish navigating in a quick timing, for example google.com.
* Remove window extensions from common and use nullable size argument instead
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Merge main, self-contained .NET and fix WebView2 user data dir issue (#22899)
* Merge remote-tracking branch 'origin/main' into peek
* Test sc
* Set WebView2 user data dir
* spellcheck
* Fix comment
* Move check if higher quality image is already loaded to the exact line where we change the Preview bitmap (#23083)
* Fix opening Peek when FE window is set to full name path (#23082)
* Move check for png thubmnail loading priority
* Remove Peek.UI.WPF project
* Remove duplicated method in powertoys setup
* [Peek] Fix selecting files from the correct focused opened File Explorer tab & from Desktop (#23489)
* Get file based on active tab handle instead of window title
* Refactor code to get active tab
* Getting all items from the shell API working again, except for desktop
* Refactor and cleanup com & native code
* Add back removed peek xaml assets in Product.wxs
* Remove some dependencies that do not seem necessary in Product.wxs
* [Peek] Small images (#23554)
* change stretch value
* compare with actual window size
* consider scaling factor
* set max size
* clean up
* clean up
* clean up previewers
* scaling factor in bitmap previewer
* max image size property
* [Peek]Handle errors for HEIC/HEIF and fall back to default previewer if there is no thumbnail (#22684)
* Handle errors when getting filesize by falling back to default previewer
* Bringing back other file types that are fixed with these code changes
---------
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Add unsupported file icon fallback (#23735)
* Refactor icon retrieval, refactor hbitmap to bitmap conversion, add icon fallback
* Add svg to assets in installer
* [Peek] Refactoring of file system models, removal of PngPreviewer, retrieving of folder size via Scripting com reference and other fixes (#23955)
* Refactor icon retrieval, refactor hbitmap to bitmap conversion, add icon fallback
* Add svg to assets in installer
* - Refactor File class into IFileSystemItem, FileItem & FolderItem
- Display size for folders using Scripting namespace
- Remove default app buttons for files or folders not supporting it
* Add better content type via storage apis
* Add check for storagefile in PngPreviewer
* Fix png stretching
* Remove png previewer
* Rename ThumbnailOptions.None to ThumbnailOptions.ResizeToFit
* [Peek] Removed monitor percentage evaluation for the UnsupportedFilePreview control (#24002)
* Remove settings for percentage of windows and keep default min size.
* Fix margin on unsupported control
* Use nullable Size for image size & open file on background thread (#24004)
* [Peek] SVG support (#24237)
* svg previewer
* svg size
* set scaling factor
* set image size
* changed image source type
* non nullable image size
* notify svg previewer changed
* uncomment
* rename BitmapPreviewer
* move svg support
* remove svg previewer
* [Peek] Implementation of a performant and reliable Neighboring Files Query (#24943)
* Use IShellItemArray as the backing array of item
* Finalize and cleanup NFQ implementation
* Cleanup remainder of the code
* Remove unused using
* [Peek] Pin the window position (#24927)
* [Peek] Telemetry and logging (#25231)
* text preview
* scrolling
* changed size
* webview2 preview
* common preview project
* previewpane: use common project
* peek: use common
* previewpane: moved md
* peek: md
* previewpane: clean up
* clean up
* moved monaco files
* moved formatters
* rename
* moved common monaco helper
* dev files support
* installer
* removed versions
* warnings: culture info
* warnings: names
* clean up
* warnings: dispose
* warnings: default values
* warnings
* warnings: charset
* warnings: exceptions
* suppress warning
* installer: added peek
* changed peek guid
* monaco folders
* peek deps
* peek files
* peek resources
* removed additional monaco folder
* set host name
* Update installer
* hardcode monaco path
* leave single webview control
* moved path to common
* project
* more meaningful todos
* moved temp folder cleanup
* todo
* extension check
* spell: monaco
* spellcheck
* spellcheck
* fix id
* fix spelling
* key to spelling
* id fix
* Fix monaco resolution at install time
* Fix user install. Add needed files
* installer: remove peek localization files. It's a WinUI app
* installer:fix signing
* removed unused
* settings: flyout enable/disable for Peek
* simplify string
* property changed handle
* [Peek][Settings] Peek OOBE page (#25895)
* [Peek] GPO (#25918)
* Add Native methods file to exception
* Fix merge issue on solution file
* Adjust spellcheck
* Remove boilerplate code
* Add module interface telemetry
* Remove change to README.md
* Add entry to README
* Clean up some non-changes
* Fix order of Peek in Settings menu
* [Settings] Make peek descriptions more descriptive
---------
Co-authored-by: Michael Salmon <miksalmon@users.noreply.github.com>
Co-authored-by: Michael Salmon 🐟 <michaelpsalmon@outlook.com>
Co-authored-by: Alireza Ebadi Ghajari <alirezae@microsoft.com>
Co-authored-by: Jessie Su <Jessie.Su@microsoft.com>
Co-authored-by: sujessie <102062556+sujessie@users.noreply.github.com>
Co-authored-by: Daniel Chau <d.chau@alumni.ubc.ca>
Co-authored-by: Daniel Chau <dancha@microsoft.com>
Co-authored-by: jth-ms <73617023+jth-ms@users.noreply.github.com>
Co-authored-by: Robson <rp.pontin@gmail.com>
Co-authored-by: estebanm123 <49930791+estebanm123@users.noreply.github.com>
Co-authored-by: Esteban Margaron <emargaron@microsoft.com>
Co-authored-by: Yawen Hou <Sytta@users.noreply.github.com>
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
Co-authored-by: Jojo Zhou <39350350+Joanna-Zhou@users.noreply.github.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
Co-authored-by: Seraphima Zykova <zykovas91@gmail.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2023-05-10 10:43:03 -07:00
|
|
|
var formatter = FilePreviewCommon.MonacoHelper.Formatters.SingleOrDefault(f => f.LangSet == _vsCodeLangSet);
|
2022-08-24 13:08:10 +02:00
|
|
|
if (formatter != null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
fileContent = formatter.Format(fileContent);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogError($"Failed to apply formatting to {filePath}", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-16 19:32:49 +02:00
|
|
|
fileReader.Close();
|
|
|
|
|
_base64FileCode = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(fileContent));
|
|
|
|
|
Logger.LogInfo("Reading requested file ended");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// prepping index html to load in
|
[Peek] Powertoys Peek MVP (#25922)
* Peek (#22498)
* Add peek dll project
* add spacebar preview and launch on hotkey press
* add todo
* add process handle to handle continuous press of hotkey
* add tool to stop all powertoys processes
* Add a blank Peek page and update nav menu
* Add some initial content to Peek page including a toggle
* refactor settings parsing
* rename spacebar peek to peek viewer
* rename script to stop powertoys processes
* remove tool
* Adding FileUtils for retrieving selected file in File Explorer
* Remove unnecessary SndPeekSettings
* Add shortcut setting
* Set the shortcut to ctrl+space
* Launching viewer with selected FE file
* Add PeekUI WinUI3 project with interop events
* Moving FileTypeUtils into PeekFileUtils project
* execute winui3 app on hotkey
* Fix paths with spaces
* remove winui3 project
* Resolve comment
* add wpf app with toggle visibility on hotkey
* fix visibility on startup
* remove window properties and add todos
* Fixed hidden extension and system file handling
* wip
* Add working WPF app with FileExplorer querying
* remove c++ projects
* Move native awaiter
* Working Image control with image files
* Resize and move window based on explorer monitor
* Image render, window positioning and sizing clean up
* add window management logic and selection logic
* add extension methods to add circular iterating capability to linkedlistnode
* Add OnArrowKeyPresshandler
* Added titlebar with file name and scaling with titlebar height
* fix flashing window on startup and process kept alive when powertoys exits
* remove wait for debugger loop in ui
* Add KeyIsDown method
* Fix KeyDown issue with Key handled and check for repeat
* Add thumbnail logic
* Add all folder items if only one item is selected
* File type helper
* Using hresult
* Add cancellation and rotation handling
* Use extension instead of path
* fIX CONFLICTS
* Fixing some file type checks
* Add new icon for Peek
* Update page with the new Peek icon
* Initialize IsEnabled and hook ActivationShortcut to dllmain
* add icon to taskbar and titlebar
* Add theme sensitive backgrounds
* rename event handlers
* add settings image
* Move window data into obserable object
* Refactor viewmodel, interop and helpers
* Clean up
* Add loading spinner
* Add todos
* Fix conflicts
* Move native code into its own folder
* Add peek to installer
* Fix building peek and peekui projects
* Replace UWP namespaces to WinAppSDK
* Working WASDK placeholder project
* Add exit when powertoys runner exit
* Working winui3 with image display
* Add WIC project with <TreatWarningAsErros> false for now
* Fit content to window
* Use Size from Windows.Foundation
* Change order
* Add some todos
* Refactored native/interop code and added helpers to imagepreviewer
* Rename projects
* Move some code
* Remove using
Co-authored-by: Michael Salmon <miksalmon@users.noreply.github.com>
Co-authored-by: Michael Salmon 🐟 <michaelpsalmon@outlook.com>
Co-authored-by: Alireza Ebadi Ghajari <alirezae@microsoft.com>
Co-authored-by: Jessie Su <Jessie.Su@microsoft.com>
Co-authored-by: sujessie <102062556+sujessie@users.noreply.github.com>
* Bump Microsoft.Windows.SDK.BuildTools version
* [Peek] Plugin pattern to enable any file type previewing (#22475)
* [Peek] Fetching image size through PropertyStore (#22530)
* Fetching metadata from PropertySTore
* Releasing objects to fix crash
* Creating new PropertyHelper
Co-authored-by: Daniel Chau <dancha@microsoft.com>
* Juliata/filetypes (#22538)
* Using the same list of file extensions as Lightbox's AppxManifest, and ensuring we convert file extension to lowercase
* Add IsFileTypeSupported to IPreviewer
* respond to PR comments
* Add scale awareness to window centering (#22541)
* [Peek] Fix installer builds, project configs and update assets (#22540)
* Update installer
* Fix installer errors
* Fix peek vcxproj
* Add package signing
* Add peek to arm64
* Add back ARM64 toMeasureToolUI
* Add versions to project
* Update assets and icons
* Add correct icon
* [Peek] Enable PropertyStore for offline files (#22567)
* Enabling PropertyStore for offline files
Co-authored-by: Daniel Chau <dancha@microsoft.com>
* [Peek] Adding unsupported file previewer (#22598)
* Unsupported file previewer
* Fix file display info
* Fix property store calls
* Update TODO
* [Peek] Add WebView2 integration (#22506)
* First commit with WIP logic to support WV2 in Peek module
* Minor code cleanup and try/catch block
* Added control to wrap WebView2 logic
* Cleanup
* Added logic to handle HTML previewing
Properly update FilePreview according to file type
* Code cleanup
Updated comments
* Updated comment
* Removed comment
* Code cleanup
* Improved opening of web browser preview to avoid "blank" or "seeing previous page" issue
Removed unused method
Added xaml fallback to guarantee default/starting state
* Removed folder
* Updated factory logic to match master
* address code review
* addressed PR review
* address PR review
* Address PR review
* address PR review
* Address PR review
* [Peek] Add basic file querying and navigation (#22589)
* Refactor to facilitate file data initialization
* Extract file-related code to new FileManager class
* Add temp basic version
* Clean + add todo for cancellations
* Fix various nav-related issues
* Temp - start moving iteration-related code to bg thread
* Minor tweaks
* Add FEHelper todo
* Rename FileManager + various tweaks
* Add basic throttling
* Improve bg thread synchronization
* Clean
* Clean
* Rename based on feedback
* Rename FileQuery
* Rename properties
* Rename remaining fields
* Add todos for nav success/failures
Co-authored-by: Esteban Margaron <emargaron@microsoft.com>
* [Peek] Add customized title bar (#22600)
* Add basic button UI
* Add function to get default app name and to open file in default app
* Correct error output
* Add filename to titlebar
* Remove titlebar text from Resw
* Add basic button UI
* Add function to get default app name and to open file in default app
* Add filename to titlebar
* Correct error output
* Remove titlebar text from Resw
* Add SetDragRectangles
* Correct logic, update function name
* Add localization
* Cleanup and adaptive width
* Add fileIndex/NumberOfFiles for multiple files activation
* Refine titlebar styles
* Update error message; Return HResult from native methods; Update variable initialisation and string null testing
* Titlebar height and adaptive width refinement
* Add fallback to launch app picker if fail to open default app
* Temp change to hide AppTitle_FileCount
* Update launch button to command; Add keyboard accelerator
* Update titlebar inactive background color
* Update tooltip to add keyboard accelerator
* Add comments to resw file
* Fix accidental deletion from previous merge
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
* Fix crash
* Fix wrong thread exception
* Make CurrentItemIndex setter private
* Update titlebar filecount text
* Fix titlebar draggable region and interactive region (bump WinAppSdk to latest)
* [Peek] Unsupported File Previewer - Formatting string from resources (#22609)
* Moving to string resource usage
* Moving ReadableStringHelper to common project
* Fix comments
* [Peek] Fix foregrounding (#22633)
* Fixing foregrounding
* Get window handle inside BringToForeground extension method
Co-authored-by: Daniel Chau <dancha@microsoft.com>
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] ImagePreviewer - Handle error states (#22637)
* add better preview state handling
* add error handling in imagepreviewer and better state handling
* fix error handling so exception is not bubbled up
* improve performance and hook up unsupported previewer on error
* remove commented code
* address pr comments
* [Peek] add PDF viewing support (#22636)
* [Peek] add PDF viewing support
* Fixed issue which would redirect some HTML and PDF files to external browser
* Fixed refactored interface name
* [Peek] Refine titlebar adaptive width (#22642)
* Adjust adaptive width of titlebar
* Remove visualstate setters for AppTitle_FileCount
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
* [Peek] New File Explorer tabs break Shell API to get selected files (#22641)
* fix FE tab bug
* remove unnecessary unsafe keyword
* [Peek] add extra logic to properly render PNG files with transparency (#22613)
* [Peek] added extra logic to render PNG files with proper transparency
* Moved logic to ThumbnailHelper
Cleanup
* Created a separated previewer for PNG to only load the preview image with thumbnail logic
* removed unused code
* Updated state loading change
* [Peek] Unsupported File Previewer - Setting Window Size (#22645)
* Adding setting for unsupported file window
* Fix
* [Peek] Add tooltip to File (#22640)
* Add tooltip to File
* Add placeholder text for no tooltip
* Address comments
* Use StringBuilder
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
* Add full image quality support (#22654)
* [Peek] Window foregrounding simplification and fixes + keep window visible if FE single selection changed (#22657)
* Use different apis to bring to foreground removing remote thread wait and work as well as library loading
* Keep window open if single selected file in FE is different
* Removed unused methods
* [Peek] Add cancellation token OnFilePropertyChanged (#22643)
* Cancel file loading before opening another file
* Add omitted cancellation checks
* Catch task cancelled exception; Add more cancellation checkpoints
* Add cancellation checkpoint beofre GetBitmapFromHBitmapAsync
* Correct typo
* Update to pass cancellation token individually to each async methods
* Add lost cancellationToken source
* Add cancellation token to PngPreviewer
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
* [Peek] Unsupported File Previewer - Preserve Transparency For File Icons (#22650)
* Preserving transparency or icons
* Remove TODO
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Update some installer build steps + assets update (#22683)
* Fix settings & peek.ui.wpf
* Add back missing icon
* Add missing files and actions to installer
* Keep window open if the selected file in explorer is different (only works for single file selection)
* Undo last
* [Peek] Add copy keyboard accelerator (#22647)
* add copy keyboard accelerator
* Fix comments
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] add WV2 improvements (behavior and UX) (#22685)
* [Peek] added logic to get max monitor size for opening WebView2
* Removed ununsed dependency property
* Added workaround for cases where the web page would not finish navigating in a quick timing, for example google.com.
* Remove window extensions from common and use nullable size argument instead
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Merge main, self-contained .NET and fix WebView2 user data dir issue (#22899)
* Merge remote-tracking branch 'origin/main' into peek
* Test sc
* Set WebView2 user data dir
* spellcheck
* Fix comment
* Move check if higher quality image is already loaded to the exact line where we change the Preview bitmap (#23083)
* Fix opening Peek when FE window is set to full name path (#23082)
* Move check for png thubmnail loading priority
* Remove Peek.UI.WPF project
* Remove duplicated method in powertoys setup
* [Peek] Fix selecting files from the correct focused opened File Explorer tab & from Desktop (#23489)
* Get file based on active tab handle instead of window title
* Refactor code to get active tab
* Getting all items from the shell API working again, except for desktop
* Refactor and cleanup com & native code
* Add back removed peek xaml assets in Product.wxs
* Remove some dependencies that do not seem necessary in Product.wxs
* [Peek] Small images (#23554)
* change stretch value
* compare with actual window size
* consider scaling factor
* set max size
* clean up
* clean up
* clean up previewers
* scaling factor in bitmap previewer
* max image size property
* [Peek]Handle errors for HEIC/HEIF and fall back to default previewer if there is no thumbnail (#22684)
* Handle errors when getting filesize by falling back to default previewer
* Bringing back other file types that are fixed with these code changes
---------
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Add unsupported file icon fallback (#23735)
* Refactor icon retrieval, refactor hbitmap to bitmap conversion, add icon fallback
* Add svg to assets in installer
* [Peek] Refactoring of file system models, removal of PngPreviewer, retrieving of folder size via Scripting com reference and other fixes (#23955)
* Refactor icon retrieval, refactor hbitmap to bitmap conversion, add icon fallback
* Add svg to assets in installer
* - Refactor File class into IFileSystemItem, FileItem & FolderItem
- Display size for folders using Scripting namespace
- Remove default app buttons for files or folders not supporting it
* Add better content type via storage apis
* Add check for storagefile in PngPreviewer
* Fix png stretching
* Remove png previewer
* Rename ThumbnailOptions.None to ThumbnailOptions.ResizeToFit
* [Peek] Removed monitor percentage evaluation for the UnsupportedFilePreview control (#24002)
* Remove settings for percentage of windows and keep default min size.
* Fix margin on unsupported control
* Use nullable Size for image size & open file on background thread (#24004)
* [Peek] SVG support (#24237)
* svg previewer
* svg size
* set scaling factor
* set image size
* changed image source type
* non nullable image size
* notify svg previewer changed
* uncomment
* rename BitmapPreviewer
* move svg support
* remove svg previewer
* [Peek] Implementation of a performant and reliable Neighboring Files Query (#24943)
* Use IShellItemArray as the backing array of item
* Finalize and cleanup NFQ implementation
* Cleanup remainder of the code
* Remove unused using
* [Peek] Pin the window position (#24927)
* [Peek] Telemetry and logging (#25231)
* text preview
* scrolling
* changed size
* webview2 preview
* common preview project
* previewpane: use common project
* peek: use common
* previewpane: moved md
* peek: md
* previewpane: clean up
* clean up
* moved monaco files
* moved formatters
* rename
* moved common monaco helper
* dev files support
* installer
* removed versions
* warnings: culture info
* warnings: names
* clean up
* warnings: dispose
* warnings: default values
* warnings
* warnings: charset
* warnings: exceptions
* suppress warning
* installer: added peek
* changed peek guid
* monaco folders
* peek deps
* peek files
* peek resources
* removed additional monaco folder
* set host name
* Update installer
* hardcode monaco path
* leave single webview control
* moved path to common
* project
* more meaningful todos
* moved temp folder cleanup
* todo
* extension check
* spell: monaco
* spellcheck
* spellcheck
* fix id
* fix spelling
* key to spelling
* id fix
* Fix monaco resolution at install time
* Fix user install. Add needed files
* installer: remove peek localization files. It's a WinUI app
* installer:fix signing
* removed unused
* settings: flyout enable/disable for Peek
* simplify string
* property changed handle
* [Peek][Settings] Peek OOBE page (#25895)
* [Peek] GPO (#25918)
* Add Native methods file to exception
* Fix merge issue on solution file
* Adjust spellcheck
* Remove boilerplate code
* Add module interface telemetry
* Remove change to README.md
* Add entry to README
* Clean up some non-changes
* Fix order of Peek in Settings menu
* [Settings] Make peek descriptions more descriptive
---------
Co-authored-by: Michael Salmon <miksalmon@users.noreply.github.com>
Co-authored-by: Michael Salmon 🐟 <michaelpsalmon@outlook.com>
Co-authored-by: Alireza Ebadi Ghajari <alirezae@microsoft.com>
Co-authored-by: Jessie Su <Jessie.Su@microsoft.com>
Co-authored-by: sujessie <102062556+sujessie@users.noreply.github.com>
Co-authored-by: Daniel Chau <d.chau@alumni.ubc.ca>
Co-authored-by: Daniel Chau <dancha@microsoft.com>
Co-authored-by: jth-ms <73617023+jth-ms@users.noreply.github.com>
Co-authored-by: Robson <rp.pontin@gmail.com>
Co-authored-by: estebanm123 <49930791+estebanm123@users.noreply.github.com>
Co-authored-by: Esteban Margaron <emargaron@microsoft.com>
Co-authored-by: Yawen Hou <Sytta@users.noreply.github.com>
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
Co-authored-by: Jojo Zhou <39350350+Joanna-Zhou@users.noreply.github.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
Co-authored-by: Seraphima Zykova <zykovas91@gmail.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2023-05-10 10:43:03 -07:00
|
|
|
_html = FilePreviewCommon.MonacoHelper.ReadIndexHtml();
|
2022-08-16 19:32:49 +02:00
|
|
|
_html = _html.Replace("[[PT_LANG]]", _vsCodeLangSet, StringComparison.InvariantCulture);
|
|
|
|
|
_html = _html.Replace("[[PT_WRAP]]", _settings.Wrap ? "1" : "0", StringComparison.InvariantCulture);
|
|
|
|
|
_html = _html.Replace("[[PT_THEME]]", Settings.GetTheme(), StringComparison.InvariantCulture);
|
2024-04-24 14:17:29 +02:00
|
|
|
_html = _html.Replace("[[PT_STICKY_SCROLL]]", _settings.StickyScroll ? "1" : "0", StringComparison.InvariantCulture);
|
|
|
|
|
_html = _html.Replace("[[PT_FONT_SIZE]]", _settings.FontSize.ToString(CultureInfo.InvariantCulture), StringComparison.InvariantCulture);
|
2022-08-16 19:32:49 +02:00
|
|
|
_html = _html.Replace("[[PT_CODE]]", _base64FileCode, StringComparison.InvariantCulture);
|
2024-04-19 15:09:46 +02:00
|
|
|
_html = _html.Replace("[[PT_STICKY_SCROLL]]", _settings.StickyScroll ? "1" : "0", StringComparison.InvariantCulture);
|
[Peek] Powertoys Peek MVP (#25922)
* Peek (#22498)
* Add peek dll project
* add spacebar preview and launch on hotkey press
* add todo
* add process handle to handle continuous press of hotkey
* add tool to stop all powertoys processes
* Add a blank Peek page and update nav menu
* Add some initial content to Peek page including a toggle
* refactor settings parsing
* rename spacebar peek to peek viewer
* rename script to stop powertoys processes
* remove tool
* Adding FileUtils for retrieving selected file in File Explorer
* Remove unnecessary SndPeekSettings
* Add shortcut setting
* Set the shortcut to ctrl+space
* Launching viewer with selected FE file
* Add PeekUI WinUI3 project with interop events
* Moving FileTypeUtils into PeekFileUtils project
* execute winui3 app on hotkey
* Fix paths with spaces
* remove winui3 project
* Resolve comment
* add wpf app with toggle visibility on hotkey
* fix visibility on startup
* remove window properties and add todos
* Fixed hidden extension and system file handling
* wip
* Add working WPF app with FileExplorer querying
* remove c++ projects
* Move native awaiter
* Working Image control with image files
* Resize and move window based on explorer monitor
* Image render, window positioning and sizing clean up
* add window management logic and selection logic
* add extension methods to add circular iterating capability to linkedlistnode
* Add OnArrowKeyPresshandler
* Added titlebar with file name and scaling with titlebar height
* fix flashing window on startup and process kept alive when powertoys exits
* remove wait for debugger loop in ui
* Add KeyIsDown method
* Fix KeyDown issue with Key handled and check for repeat
* Add thumbnail logic
* Add all folder items if only one item is selected
* File type helper
* Using hresult
* Add cancellation and rotation handling
* Use extension instead of path
* fIX CONFLICTS
* Fixing some file type checks
* Add new icon for Peek
* Update page with the new Peek icon
* Initialize IsEnabled and hook ActivationShortcut to dllmain
* add icon to taskbar and titlebar
* Add theme sensitive backgrounds
* rename event handlers
* add settings image
* Move window data into obserable object
* Refactor viewmodel, interop and helpers
* Clean up
* Add loading spinner
* Add todos
* Fix conflicts
* Move native code into its own folder
* Add peek to installer
* Fix building peek and peekui projects
* Replace UWP namespaces to WinAppSDK
* Working WASDK placeholder project
* Add exit when powertoys runner exit
* Working winui3 with image display
* Add WIC project with <TreatWarningAsErros> false for now
* Fit content to window
* Use Size from Windows.Foundation
* Change order
* Add some todos
* Refactored native/interop code and added helpers to imagepreviewer
* Rename projects
* Move some code
* Remove using
Co-authored-by: Michael Salmon <miksalmon@users.noreply.github.com>
Co-authored-by: Michael Salmon 🐟 <michaelpsalmon@outlook.com>
Co-authored-by: Alireza Ebadi Ghajari <alirezae@microsoft.com>
Co-authored-by: Jessie Su <Jessie.Su@microsoft.com>
Co-authored-by: sujessie <102062556+sujessie@users.noreply.github.com>
* Bump Microsoft.Windows.SDK.BuildTools version
* [Peek] Plugin pattern to enable any file type previewing (#22475)
* [Peek] Fetching image size through PropertyStore (#22530)
* Fetching metadata from PropertySTore
* Releasing objects to fix crash
* Creating new PropertyHelper
Co-authored-by: Daniel Chau <dancha@microsoft.com>
* Juliata/filetypes (#22538)
* Using the same list of file extensions as Lightbox's AppxManifest, and ensuring we convert file extension to lowercase
* Add IsFileTypeSupported to IPreviewer
* respond to PR comments
* Add scale awareness to window centering (#22541)
* [Peek] Fix installer builds, project configs and update assets (#22540)
* Update installer
* Fix installer errors
* Fix peek vcxproj
* Add package signing
* Add peek to arm64
* Add back ARM64 toMeasureToolUI
* Add versions to project
* Update assets and icons
* Add correct icon
* [Peek] Enable PropertyStore for offline files (#22567)
* Enabling PropertyStore for offline files
Co-authored-by: Daniel Chau <dancha@microsoft.com>
* [Peek] Adding unsupported file previewer (#22598)
* Unsupported file previewer
* Fix file display info
* Fix property store calls
* Update TODO
* [Peek] Add WebView2 integration (#22506)
* First commit with WIP logic to support WV2 in Peek module
* Minor code cleanup and try/catch block
* Added control to wrap WebView2 logic
* Cleanup
* Added logic to handle HTML previewing
Properly update FilePreview according to file type
* Code cleanup
Updated comments
* Updated comment
* Removed comment
* Code cleanup
* Improved opening of web browser preview to avoid "blank" or "seeing previous page" issue
Removed unused method
Added xaml fallback to guarantee default/starting state
* Removed folder
* Updated factory logic to match master
* address code review
* addressed PR review
* address PR review
* Address PR review
* address PR review
* Address PR review
* [Peek] Add basic file querying and navigation (#22589)
* Refactor to facilitate file data initialization
* Extract file-related code to new FileManager class
* Add temp basic version
* Clean + add todo for cancellations
* Fix various nav-related issues
* Temp - start moving iteration-related code to bg thread
* Minor tweaks
* Add FEHelper todo
* Rename FileManager + various tweaks
* Add basic throttling
* Improve bg thread synchronization
* Clean
* Clean
* Rename based on feedback
* Rename FileQuery
* Rename properties
* Rename remaining fields
* Add todos for nav success/failures
Co-authored-by: Esteban Margaron <emargaron@microsoft.com>
* [Peek] Add customized title bar (#22600)
* Add basic button UI
* Add function to get default app name and to open file in default app
* Correct error output
* Add filename to titlebar
* Remove titlebar text from Resw
* Add basic button UI
* Add function to get default app name and to open file in default app
* Add filename to titlebar
* Correct error output
* Remove titlebar text from Resw
* Add SetDragRectangles
* Correct logic, update function name
* Add localization
* Cleanup and adaptive width
* Add fileIndex/NumberOfFiles for multiple files activation
* Refine titlebar styles
* Update error message; Return HResult from native methods; Update variable initialisation and string null testing
* Titlebar height and adaptive width refinement
* Add fallback to launch app picker if fail to open default app
* Temp change to hide AppTitle_FileCount
* Update launch button to command; Add keyboard accelerator
* Update titlebar inactive background color
* Update tooltip to add keyboard accelerator
* Add comments to resw file
* Fix accidental deletion from previous merge
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
* Fix crash
* Fix wrong thread exception
* Make CurrentItemIndex setter private
* Update titlebar filecount text
* Fix titlebar draggable region and interactive region (bump WinAppSdk to latest)
* [Peek] Unsupported File Previewer - Formatting string from resources (#22609)
* Moving to string resource usage
* Moving ReadableStringHelper to common project
* Fix comments
* [Peek] Fix foregrounding (#22633)
* Fixing foregrounding
* Get window handle inside BringToForeground extension method
Co-authored-by: Daniel Chau <dancha@microsoft.com>
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] ImagePreviewer - Handle error states (#22637)
* add better preview state handling
* add error handling in imagepreviewer and better state handling
* fix error handling so exception is not bubbled up
* improve performance and hook up unsupported previewer on error
* remove commented code
* address pr comments
* [Peek] add PDF viewing support (#22636)
* [Peek] add PDF viewing support
* Fixed issue which would redirect some HTML and PDF files to external browser
* Fixed refactored interface name
* [Peek] Refine titlebar adaptive width (#22642)
* Adjust adaptive width of titlebar
* Remove visualstate setters for AppTitle_FileCount
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
* [Peek] New File Explorer tabs break Shell API to get selected files (#22641)
* fix FE tab bug
* remove unnecessary unsafe keyword
* [Peek] add extra logic to properly render PNG files with transparency (#22613)
* [Peek] added extra logic to render PNG files with proper transparency
* Moved logic to ThumbnailHelper
Cleanup
* Created a separated previewer for PNG to only load the preview image with thumbnail logic
* removed unused code
* Updated state loading change
* [Peek] Unsupported File Previewer - Setting Window Size (#22645)
* Adding setting for unsupported file window
* Fix
* [Peek] Add tooltip to File (#22640)
* Add tooltip to File
* Add placeholder text for no tooltip
* Address comments
* Use StringBuilder
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
* Add full image quality support (#22654)
* [Peek] Window foregrounding simplification and fixes + keep window visible if FE single selection changed (#22657)
* Use different apis to bring to foreground removing remote thread wait and work as well as library loading
* Keep window open if single selected file in FE is different
* Removed unused methods
* [Peek] Add cancellation token OnFilePropertyChanged (#22643)
* Cancel file loading before opening another file
* Add omitted cancellation checks
* Catch task cancelled exception; Add more cancellation checkpoints
* Add cancellation checkpoint beofre GetBitmapFromHBitmapAsync
* Correct typo
* Update to pass cancellation token individually to each async methods
* Add lost cancellationToken source
* Add cancellation token to PngPreviewer
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
* [Peek] Unsupported File Previewer - Preserve Transparency For File Icons (#22650)
* Preserving transparency or icons
* Remove TODO
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Update some installer build steps + assets update (#22683)
* Fix settings & peek.ui.wpf
* Add back missing icon
* Add missing files and actions to installer
* Keep window open if the selected file in explorer is different (only works for single file selection)
* Undo last
* [Peek] Add copy keyboard accelerator (#22647)
* add copy keyboard accelerator
* Fix comments
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] add WV2 improvements (behavior and UX) (#22685)
* [Peek] added logic to get max monitor size for opening WebView2
* Removed ununsed dependency property
* Added workaround for cases where the web page would not finish navigating in a quick timing, for example google.com.
* Remove window extensions from common and use nullable size argument instead
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Merge main, self-contained .NET and fix WebView2 user data dir issue (#22899)
* Merge remote-tracking branch 'origin/main' into peek
* Test sc
* Set WebView2 user data dir
* spellcheck
* Fix comment
* Move check if higher quality image is already loaded to the exact line where we change the Preview bitmap (#23083)
* Fix opening Peek when FE window is set to full name path (#23082)
* Move check for png thubmnail loading priority
* Remove Peek.UI.WPF project
* Remove duplicated method in powertoys setup
* [Peek] Fix selecting files from the correct focused opened File Explorer tab & from Desktop (#23489)
* Get file based on active tab handle instead of window title
* Refactor code to get active tab
* Getting all items from the shell API working again, except for desktop
* Refactor and cleanup com & native code
* Add back removed peek xaml assets in Product.wxs
* Remove some dependencies that do not seem necessary in Product.wxs
* [Peek] Small images (#23554)
* change stretch value
* compare with actual window size
* consider scaling factor
* set max size
* clean up
* clean up
* clean up previewers
* scaling factor in bitmap previewer
* max image size property
* [Peek]Handle errors for HEIC/HEIF and fall back to default previewer if there is no thumbnail (#22684)
* Handle errors when getting filesize by falling back to default previewer
* Bringing back other file types that are fixed with these code changes
---------
Co-authored-by: Samuel Chapleau <sachaple@microsoft.com>
* [Peek] Add unsupported file icon fallback (#23735)
* Refactor icon retrieval, refactor hbitmap to bitmap conversion, add icon fallback
* Add svg to assets in installer
* [Peek] Refactoring of file system models, removal of PngPreviewer, retrieving of folder size via Scripting com reference and other fixes (#23955)
* Refactor icon retrieval, refactor hbitmap to bitmap conversion, add icon fallback
* Add svg to assets in installer
* - Refactor File class into IFileSystemItem, FileItem & FolderItem
- Display size for folders using Scripting namespace
- Remove default app buttons for files or folders not supporting it
* Add better content type via storage apis
* Add check for storagefile in PngPreviewer
* Fix png stretching
* Remove png previewer
* Rename ThumbnailOptions.None to ThumbnailOptions.ResizeToFit
* [Peek] Removed monitor percentage evaluation for the UnsupportedFilePreview control (#24002)
* Remove settings for percentage of windows and keep default min size.
* Fix margin on unsupported control
* Use nullable Size for image size & open file on background thread (#24004)
* [Peek] SVG support (#24237)
* svg previewer
* svg size
* set scaling factor
* set image size
* changed image source type
* non nullable image size
* notify svg previewer changed
* uncomment
* rename BitmapPreviewer
* move svg support
* remove svg previewer
* [Peek] Implementation of a performant and reliable Neighboring Files Query (#24943)
* Use IShellItemArray as the backing array of item
* Finalize and cleanup NFQ implementation
* Cleanup remainder of the code
* Remove unused using
* [Peek] Pin the window position (#24927)
* [Peek] Telemetry and logging (#25231)
* text preview
* scrolling
* changed size
* webview2 preview
* common preview project
* previewpane: use common project
* peek: use common
* previewpane: moved md
* peek: md
* previewpane: clean up
* clean up
* moved monaco files
* moved formatters
* rename
* moved common monaco helper
* dev files support
* installer
* removed versions
* warnings: culture info
* warnings: names
* clean up
* warnings: dispose
* warnings: default values
* warnings
* warnings: charset
* warnings: exceptions
* suppress warning
* installer: added peek
* changed peek guid
* monaco folders
* peek deps
* peek files
* peek resources
* removed additional monaco folder
* set host name
* Update installer
* hardcode monaco path
* leave single webview control
* moved path to common
* project
* more meaningful todos
* moved temp folder cleanup
* todo
* extension check
* spell: monaco
* spellcheck
* spellcheck
* fix id
* fix spelling
* key to spelling
* id fix
* Fix monaco resolution at install time
* Fix user install. Add needed files
* installer: remove peek localization files. It's a WinUI app
* installer:fix signing
* removed unused
* settings: flyout enable/disable for Peek
* simplify string
* property changed handle
* [Peek][Settings] Peek OOBE page (#25895)
* [Peek] GPO (#25918)
* Add Native methods file to exception
* Fix merge issue on solution file
* Adjust spellcheck
* Remove boilerplate code
* Add module interface telemetry
* Remove change to README.md
* Add entry to README
* Clean up some non-changes
* Fix order of Peek in Settings menu
* [Settings] Make peek descriptions more descriptive
---------
Co-authored-by: Michael Salmon <miksalmon@users.noreply.github.com>
Co-authored-by: Michael Salmon 🐟 <michaelpsalmon@outlook.com>
Co-authored-by: Alireza Ebadi Ghajari <alirezae@microsoft.com>
Co-authored-by: Jessie Su <Jessie.Su@microsoft.com>
Co-authored-by: sujessie <102062556+sujessie@users.noreply.github.com>
Co-authored-by: Daniel Chau <d.chau@alumni.ubc.ca>
Co-authored-by: Daniel Chau <dancha@microsoft.com>
Co-authored-by: jth-ms <73617023+jth-ms@users.noreply.github.com>
Co-authored-by: Robson <rp.pontin@gmail.com>
Co-authored-by: estebanm123 <49930791+estebanm123@users.noreply.github.com>
Co-authored-by: Esteban Margaron <emargaron@microsoft.com>
Co-authored-by: Yawen Hou <Sytta@users.noreply.github.com>
Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
Co-authored-by: Jojo Zhou <39350350+Joanna-Zhou@users.noreply.github.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
Co-authored-by: Seraphima Zykova <zykovas91@gmail.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
2023-05-10 10:43:03 -07:00
|
|
|
_html = _html.Replace("[[PT_URL]]", FilePreviewCommon.MonacoHelper.VirtualHostName, StringComparison.InvariantCulture);
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void DownloadLink_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
await Launcher.LaunchUriAsync(new Uri("https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section"));
|
2022-08-16 19:32:49 +02:00
|
|
|
Logger.LogTrace();
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
2022-10-26 14:02:31 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when RichtextBox is resized.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender">Reference to resized control.</param>
|
|
|
|
|
/// <param name="e">Provides data for the ContentsResized event.</param>
|
|
|
|
|
private void RTBContentsResized(object sender, ContentsResizedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var richTextBox = sender as RichTextBox;
|
|
|
|
|
richTextBox.Height = e.NewRectangle.Height + 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Occurs when form is resized.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender">Reference to resized control.</param>
|
|
|
|
|
/// <param name="e">Provides data for the resize event.</param>
|
|
|
|
|
private void FormResized(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_infoBarAdded)
|
|
|
|
|
{
|
|
|
|
|
_textBox.Width = Width;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds a Text Box in Controls for showing information about blocked elements.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message">Message to be displayed in textbox.</param>
|
|
|
|
|
private void AddTextBoxControl(string message)
|
|
|
|
|
{
|
2023-02-22 12:59:30 +01:00
|
|
|
Controls.Remove(_loading);
|
|
|
|
|
Controls.Remove(_loadingBar);
|
|
|
|
|
Controls.Remove(_loadingBackground);
|
|
|
|
|
|
2022-10-26 14:02:31 +01:00
|
|
|
_textBox = new RichTextBox();
|
|
|
|
|
_textBox.Text = message;
|
|
|
|
|
_textBox.BackColor = Color.LightYellow;
|
|
|
|
|
_textBox.Multiline = true;
|
|
|
|
|
_textBox.Dock = DockStyle.Top;
|
|
|
|
|
_textBox.ReadOnly = true;
|
|
|
|
|
_textBox.ContentsResized += RTBContentsResized;
|
|
|
|
|
_textBox.ScrollBars = RichTextBoxScrollBars.None;
|
|
|
|
|
_textBox.BorderStyle = BorderStyle.None;
|
|
|
|
|
Controls.Add(_textBox);
|
|
|
|
|
}
|
2022-01-25 21:02:10 +01:00
|
|
|
}
|
|
|
|
|
}
|