Skip to content
/ Movere Public

Movere is an implementation of managed dialogs for Avalonia.

License

Notifications You must be signed in to change notification settings

jp2masa/Movere

Repository files navigation

Build Status

Package NuGet MyGet
Movere NuGet MyGet
Movere.FileDialogs NuGet MyGet
Movere.Win32 NuGet MyGet

Movere

Movere

Movere is an implementation of managed dialogs for Avalonia. Currently there are message dialogs, as well as open and save file dialogs, and a print dialog (based on System.Drawing.Printing) is WIP.

Getting Started

Registering file dialogs with Avalonia

To use Avalonia storage provider APIs, it's possible to simply register Movere dialogs with AppBuilder:

  1. Import Movere namespace:
using Movere;
  1. Add UseMovereStorageProvider to AppBuilder configuration. Example:
AppBuilder.Configure<App>()
    .UsePlatformDetect()
    .UseMovereStorageProvider();
  1. Then use Avalonia system dialog APIs. Example:
var options = new FilePickerOpenOptions()
{
    ...
};

var result = parent.StorageProvider.OpenFilePickerAsync(options);

(Deprecated) System Dialog APIs

If using the old system dialogs APIs, the AppBuilder extension method is UseMovereSystemDialogs and an example is:

var dialog = new OpenFileDialog();
var result = await dialog.ShowAsync(parent);

Using dialog hosts

To simply use the dialogs (this example is for message dialogs, but it's similar for others):

  1. Create a dialog host for the owner:
var dialogHost = new WindowDialogHost(owner);
// OR
var dialogHost = new OverlayDialogHost(owner);
  1. Pass the host to the view model:
window.DataContext = new ViewModel(dialogHost);
  1. Show dialog from the view model when you need to:
private Task ShowInfoAsync() =>
    _dialogHost
        .ShowMessageDialog(
            new MessageDialogOptions((LocalizedString)"Message Dialog", "Some info")
            {
                Icon = AvaloniaDialogIcon.Info,
                DialogResults = DialogResultSet.OK
            }
        );

Available icons are:

  • DialogIcon.None
  • AvaloniaDialogIcon.Info
  • AvaloniaDialogIcon.Warning
  • AvaloniaDialogIcon.Error

To add your own icon, just call AvaloniaDialogIcon.TryCreate, passing the resource string, e.g avares://My.App/Resources/Icons/MyIcon.png.

Dialog results are extensible as well, and support localization.

Roadmap

  • Maybe separate file explorer view into separate project.
  • Improve styles for dialogs.
  • Add tests.
  • Print dialog.
  • Eventually move file explorer logic to a separate project and create a file explorer application.

Credits

Icons

The project logo is from linea.io.

About

Movere is an implementation of managed dialogs for Avalonia.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •