BabylonActionsBuilderActionItem.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using Autodesk.Max;
  2. using System.Windows.Forms;
  3. using ActionItem = Autodesk.Max.Plugins.ActionItem;
  4. namespace Max2Babylon
  5. {
  6. public class BabylonActionsBuilderActionItem : ActionItem
  7. {
  8. private ActionsBuilderForm _form = null;
  9. public override bool ExecuteAction()
  10. {
  11. if (Loader.Core.SelNodeCount > 1)
  12. {
  13. Loader.Core.PushPrompt("Actions Builder only supports one Node");
  14. }
  15. else
  16. {
  17. IINode node = null;
  18. SClass_ID type;
  19. if (Loader.Core.SelNodeCount == 0)
  20. type = SClass_ID.Scene;
  21. else
  22. {
  23. node = Loader.Core.GetSelNode(0);
  24. type = node.ObjectRef.Eval(0).Obj.SuperClassID;
  25. }
  26. if (type == SClass_ID.Geomobject || type == SClass_ID.Scene)
  27. {
  28. if (_form == null)
  29. _form = new ActionsBuilderForm(this);
  30. _form.WindowState = FormWindowState.Maximized;
  31. _form.ShowDialog();
  32. //Application.Run(_form);
  33. }
  34. }
  35. return true;
  36. }
  37. public void Close()
  38. {
  39. if (_form == null)
  40. return;
  41. _form.Dispose();
  42. _form = null;
  43. }
  44. public override int Id_
  45. {
  46. get { return 2; }
  47. }
  48. public override string ButtonText
  49. {
  50. get { return "Babylon Actions Builder"; }
  51. }
  52. public override string MenuText
  53. {
  54. get { return "Babylon Actions Builder"; }
  55. }
  56. public override string DescriptionText
  57. {
  58. get { return "UI graph to build custom actions on selected object"; }
  59. }
  60. public override string CategoryText
  61. {
  62. get { return "Babylon"; }
  63. }
  64. public override bool IsChecked_
  65. {
  66. get { return false; }
  67. }
  68. public override bool IsItemVisible
  69. {
  70. get { return true; }
  71. }
  72. public override bool IsEnabled_
  73. {
  74. get { return true; }
  75. }
  76. }
  77. }