-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #396 from orangebobolink/main
Add save as and open example for SukiUi.Dock to SukiUi.Demo
- Loading branch information
Showing
7 changed files
with
191 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.ApplicationLifetimes; | ||
using Avalonia.Platform.Storage; | ||
using Avalonia.VisualTree; | ||
|
||
namespace SukiUI.Demo.Common | ||
{ | ||
internal static class StorageService | ||
{ | ||
public static FilePickerFileType All { get; } = new("All") | ||
{ | ||
Patterns = ["*.*"], | ||
MimeTypes = ["*/*"] | ||
}; | ||
|
||
public static FilePickerFileType Json { get; } = new("Json") | ||
{ | ||
Patterns = ["*.json"], | ||
AppleUniformTypeIdentifiers = ["public.json"], | ||
MimeTypes = ["application/json"] | ||
}; | ||
|
||
public static IStorageProvider? GetStorageProvider() | ||
{ | ||
if (Avalonia.Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } window }) | ||
{ | ||
return window.StorageProvider; | ||
} | ||
|
||
if (Avalonia.Application.Current?.ApplicationLifetime is ISingleViewApplicationLifetime | ||
{ | ||
MainView: { } mainView | ||
}) | ||
{ | ||
var visualRoot = mainView.GetVisualRoot(); | ||
if (visualRoot is TopLevel topLevel) | ||
{ | ||
return topLevel.StorageProvider; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters