VisualTreeSampleExtension.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using PixiEditor.Extensions.CommonApi.FlyUI.Properties;
  3. using PixiEditor.Extensions.CommonApi.Windowing;
  4. using PixiEditor.Extensions.Sdk;
  5. using PixiEditor.Extensions.Sdk.Api.FlyUI;
  6. using PixiEditor.Extensions.Sdk.Api.Window;
  7. namespace Sample10_VisualTree;
  8. public class VisualTreeSampleExtension : PixiEditorExtension
  9. {
  10. /// <summary>
  11. /// This method is called when extension is loaded.
  12. /// All extensions are first loaded and then initialized. This method is called before <see cref="OnInitialized"/>.
  13. /// </summary>
  14. public override void OnLoaded()
  15. {
  16. }
  17. /// <summary>
  18. /// This method is called when extension is initialized. After this method is called, you can use Api property to access PixiEditor API.
  19. /// </summary>
  20. public override void OnInitialized()
  21. {
  22. Api.WindowProvider.SubscribeWindowOpened(BuiltInWindowType.StartupWindow, InjectButton);
  23. }
  24. private void InjectButton(PopupWindow window)
  25. {
  26. var button = new Button(new Text("Click me!"));
  27. var element = Api.VisualTreeProvider.FindElement("ExampleFilesGrid", window);
  28. if (element is NativeMultiChildElement panel)
  29. {
  30. panel.AppendChild(0, button);
  31. }
  32. }
  33. public override void OnMainWindowLoaded()
  34. {
  35. // wip
  36. }
  37. }