CreatePopupSampleExtension.cs 1.0 KB

123456789101112131415161718192021222324252627282930
  1. using System.Threading.Tasks;
  2. using PixiEditor.Extensions.Sdk;
  3. using PixiEditor.Extensions.Sdk.Api.FlyUI;
  4. namespace CreatePopupSample;
  5. public class CreatePopupSampleExtension : PixiEditorExtension
  6. {
  7. /// <summary>
  8. /// This method is called when extension is loaded.
  9. /// All extensions are first loaded and then initialized. This method is called before <see cref="OnInitialized"/>.
  10. /// </summary>
  11. public override void OnLoaded()
  12. {
  13. }
  14. /// <summary>
  15. /// This method is called when extension is initialized. After this method is called, you can use Api property to access PixiEditor API.
  16. /// </summary>
  17. public override void OnInitialized()
  18. {
  19. var popup = Api.WindowProvider.CreatePopupWindow("Hello World", new Text("Hello from popup!"));
  20. popup.ShowDialog().Completed += (result) =>
  21. {
  22. string resultStr = result.HasValue ? result.Value.ToString() : "null";
  23. Api.Logger.Log($"Popup closed with result: {resultStr}");
  24. };
  25. }
  26. }