[Dev file previewer]Add option to set custom max file size and fix styling issue (#23689)

* [Dev file previewer] Add option to set costum max file size and fix style issue
This commit is contained in:
Aaron Junker
2023-02-13 19:57:33 +01:00
committed by GitHub
parent bc4bde8cee
commit 00e10d38c2
6 changed files with 63 additions and 4 deletions

View File

@@ -212,6 +212,7 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
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;
downloadLink.ForeColor = Settings.TextColor;
Controls.Add(downloadLink);
}
});
@@ -222,6 +223,7 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
Controls.Remove(_loadingBar);
Controls.Remove(_loadingBackground);
Label text = new Label();
text.ForeColor = Settings.TextColor;
text.Text = Resources.Exception_Occurred;
text.Text += e.Message;
text.Text += "\n" + e.Source;
@@ -244,6 +246,7 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
Controls.Remove(_loadingBackground);
Label errorMessage = new Label();
errorMessage.Text = Resources.Max_File_Size_Error.Replace("%1", (_settings.MaxFileSize / 1000).ToString(CultureInfo.CurrentCulture), StringComparison.InvariantCulture);
errorMessage.ForeColor = Settings.TextColor;
errorMessage.Width = 500;
errorMessage.Height = 50;
Controls.Add(errorMessage);

View File

@@ -58,11 +58,24 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
}
/// <summary>
/// Max file size for displaying (in bytes).
/// Gets Max file size for displaying (in bytes).
/// </summary>
private readonly long _maxFileSize = 50000;
public long MaxFileSize => _maxFileSize;
public double MaxFileSize
{
get
{
try
{
return moduleSettings.GetSettings<PowerPreviewSettings>(PowerPreviewSettings.ModuleName).Properties.MonacoPreviewMaxFileSize.Value * 1000;
}
catch (FileNotFoundException)
{
// Couldn't read the settings.
// Assume default of 50000.
return 50000;
}
}
}
/// <summary>
/// Gets the color of the window background.