-
-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathMainPage.xaml.cs
47 lines (42 loc) · 1.26 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace MauiPaint;
using System.Windows.Input;
public partial class MainPage : ContentPage
{
public MainPage(MainPageViewModel mainPageViewModel, IDeviceInfo deviceInfo)
{
InitializeComponent();
if (deviceInfo.Platform == DevicePlatform.Android || deviceInfo.Platform == DevicePlatform.iOS)
{
AddToolbarItem("New", mainPageViewModel.NewCommand);
AddToolbarItem("Open", mainPageViewModel.OpenCommand);
AddToolbarItem("Save Project", mainPageViewModel.SaveCommand);
AddToolbarItem("Save Image", mainPageViewModel.SaveImageCommand);
AddToolbarItem("Toggle Theme", mainPageViewModel.ToggleThemeCommand);
AddToolbarItem("Help", mainPageViewModel.HelpCommand);
AddToolbarItem("About", mainPageViewModel.AboutCommand);
}
BindingContext = mainPageViewModel;
#if MACCATALYST || WINDOWS
Loaded += (sender, args) =>
{
DrawingView.RegisterDrop(Handler?.MauiContext, async stream =>
{
await mainPageViewModel.OpenFile(stream, CancellationToken.None);
});
};
Unloaded += (sender, args) =>
{
DrawingView.UnRegisterDrop(Handler?.MauiContext);
};
#endif
}
void AddToolbarItem(string text, ICommand command)
{
var toolbarItem = new ToolbarItem()
{
Text = text,
Command = command
};
ToolbarItems.Add(toolbarItem);
}
}