mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
[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:
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user