VisualTreeSampleExtension.cs 1.3 KB

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