forked from mendix/ExtensionAPI-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyDocumentContextMenuExtension.cs
More file actions
22 lines (19 loc) · 973 Bytes
/
MyDocumentContextMenuExtension.cs
File metadata and controls
22 lines (19 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Mendix.StudioPro.ExtensionsAPI.Model.Microflows;
using Mendix.StudioPro.ExtensionsAPI.Model.Pages;
using Mendix.StudioPro.ExtensionsAPI.Model.Projects;
using Mendix.StudioPro.ExtensionsAPI.UI.Menu;
using Mendix.StudioPro.ExtensionsAPI.UI.Services;
using System.ComponentModel.Composition;
namespace MyCompany.MyProject.MendixExtension;
[method: ImportingConstructor]
[Export(typeof(ContextMenuExtension<>))]
class MyDocumentContextMenuExtension(IMessageBoxService messageBoxService) : ContextMenuExtension<IDocument>
{
public override IEnumerable<MenuViewModel> GetContextMenus(IDocument document)
{
if (document is IMicroflow microflow)
yield return new MenuViewModel("This document is a microflow", () => messageBoxService.ShowInformation(microflow.Name));
else if (document is IPage page)
yield return new MenuViewModel("This document is a page", () => messageBoxService.ShowInformation(page.Name));
}
}