Skip to content

Commit

Permalink
Use async methods everywhere (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
PieterjanDeClippel authored Nov 9, 2023
1 parent 9faa24d commit 87086bb
Show file tree
Hide file tree
Showing 10 changed files with 463 additions and 382 deletions.
143 changes: 92 additions & 51 deletions MintPlayer.BrowserDialog/BrowserDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions MintPlayer.BrowserDialog/BrowserDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ public BrowserDialog()
InitializeComponent();
}

private void BrowserDialog_Load(object sender, EventArgs e)
private async void BrowserDialog_Load(object sender, EventArgs e)
{
try
{
pnlLoading.Visible = true;
lvBrowsers.Visible = false;


// Suspend the drawing of the listview
lvBrowsers.SuspendLayout();

Expand All @@ -28,7 +32,7 @@ private void BrowserDialog_Load(object sender, EventArgs e)
};

// Get all browsers on the system
browsers = PlatformBrowser.PlatformBrowser.GetInstalledBrowsers();
browsers = await PlatformBrowser.PlatformBrowser.GetInstalledBrowsers();

// Loop through all browsers
var imageCounter = -1;
Expand All @@ -41,8 +45,9 @@ private void BrowserDialog_Load(object sender, EventArgs e)
if (new[] { ".ico", ".cur", ".exe" }.Contains(Path.GetExtension(browser.IconPath)))
{
// Get image
var icon = IconExtractor.Split(browser.IconPath)[browser.IconIndex < 0 ? 0 : browser.IconIndex];
var icons = IconExtractor.ExtractImagesFromIcon(icon);
var split = await IconExtractor.Split(browser.IconPath);
var icon = split[browser.IconIndex < 0 ? 0 : browser.IconIndex];
var icons = await IconExtractor.ExtractImagesFromIcon(icon);
var largestSize = icons.Max(i => i.Width);
var largestIcon = icons.LastOrDefault(i => i.Width == largestSize);
if (largestIcon != null)
Expand All @@ -68,7 +73,7 @@ private void BrowserDialog_Load(object sender, EventArgs e)
}

// Get default browser
defaultBrowser = PlatformBrowser.PlatformBrowser.GetDefaultBrowser(browsers.ToList(), PlatformBrowser.Enums.EProtocolType.Http);
defaultBrowser = await PlatformBrowser.PlatformBrowser.GetDefaultBrowser(browsers.ToList(), PlatformBrowser.Enums.EProtocolType.Http);

// Select default browser
if (browsers.Contains(defaultBrowser!))
Expand All @@ -87,6 +92,8 @@ private void BrowserDialog_Load(object sender, EventArgs e)
}
finally
{
pnlLoading.Visible = false;
lvBrowsers.Visible = true;
lvBrowsers.ResumeLayout();
}
}
Expand Down
50 changes: 25 additions & 25 deletions MintPlayer.BrowserDialog/BrowserDialog.resx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down
2 changes: 1 addition & 1 deletion MintPlayer.BrowserDialog/MintPlayer.BrowserDialog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<RepositoryUrl>https://github.com/MintPlayer/MintPlayer.BrowserDialog</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>Choose webbrowser</PackageTags>
<Version>7.1.0</Version>
<Version>7.2.0</Version>

<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down
Loading

0 comments on commit 87086bb

Please sign in to comment.