Files
maui-linux/Services/PortalFolderPickerService.cs
Dave Friedel f6eadaad57 Verify Views files against decompiled, extract embedded types
Fixed files:
- SkiaImageButton.cs: Added SVG support with multi-path search
- SkiaNavigationPage.cs: Added LinuxApplication.IsGtkMode check
- SkiaRefreshView.cs: Added ICommand support (Command, CommandParameter)
- SkiaTemplatedView.cs: Added missing using statements

Extracted embedded types to separate files (matching decompiled pattern):
- From SkiaMenuBar.cs: MenuBarItem, MenuItem, SkiaMenuFlyout, MenuItemClickedEventArgs
- From SkiaNavigationPage.cs: NavigationEventArgs
- From SkiaTabbedPage.cs: TabItem
- From SkiaVisualStateManager.cs: SkiaVisualStateGroupList, SkiaVisualStateGroup, SkiaVisualState, SkiaVisualStateSetter
- From SkiaSwipeView.cs: SwipeItem, SwipeStartedEventArgs, SwipeEndedEventArgs
- From SkiaFlyoutPage.cs: FlyoutLayoutBehavior (already separate)
- From SkiaIndicatorView.cs: IndicatorShape (already separate)
- From SkiaBorder.cs: SkiaFrame
- From SkiaCarouselView.cs: PositionChangedEventArgs
- From SkiaCollectionView.cs: SkiaSelectionMode, ItemsLayoutOrientation
- From SkiaContentPresenter.cs: LayoutAlignment

Verified matching decompiled:
- SkiaContextMenu.cs, SkiaFlexLayout.cs, SkiaGraphicsView.cs

Build: 0 errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 17:02:39 -05:00

78 lines
2.3 KiB
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
namespace Microsoft.Maui.Platform.Linux.Services;
public class PortalFolderPickerService
{
public async Task<FolderPickerResult> PickAsync(FolderPickerOptions? options = null, CancellationToken cancellationToken = default)
{
options ??= new FolderPickerOptions();
string? result = null;
if (IsCommandAvailable("zenity"))
{
var args = $"--file-selection --directory --title=\"{options.Title ?? "Select Folder"}\"";
result = await Task.Run(() => RunCommand("zenity", args)?.Trim(), cancellationToken);
}
else if (IsCommandAvailable("kdialog"))
{
var args = $"--getexistingdirectory . --title \"{options.Title ?? "Select Folder"}\"";
result = await Task.Run(() => RunCommand("kdialog", args)?.Trim(), cancellationToken);
}
if (!string.IsNullOrEmpty(result) && Directory.Exists(result))
{
return new FolderPickerResult(new FolderResult(result));
}
return new FolderPickerResult(null);
}
public async Task<FolderPickerResult> PickAsync(CancellationToken cancellationToken = default)
{
return await PickAsync(null, cancellationToken);
}
private bool IsCommandAvailable(string command)
{
try
{
return !string.IsNullOrWhiteSpace(RunCommand("which", command));
}
catch
{
return false;
}
}
private string? RunCommand(string command, string arguments)
{
try
{
using var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = command,
Arguments = arguments,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
}
};
process.Start();
var result = process.StandardOutput.ReadToEnd();
process.WaitForExit(30000);
return result;
}
catch
{
return null;
}
}
}