Dialoger

Dialoger som vill använda Dynamix objektmodell och tillståndshantering ska ärvas från Dynamix.UI.Dialog (eller en subklass).

Exempel:

  1. C#
  1. namespace MySite.UI.Dialogs.News
  2. {
  3. /// <summary>
  4. /// News management dialog.
  5. /// </summary>
  6. public class News : Dynamix.UI.Dialog
  7. {
  8. }
  9. #region Web Form Designer generated code
  10. override protected void OnInit(EventArgs e)
  11. {
  12. //
  13. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  14. //
  15. InitializeComponent();
  16. base.OnInit(e);
  17. }
  18. /// <summary>
  19. /// Required method for Designer support - do not modify
  20. /// the contents of this method with the code editor.
  21. /// </summary>
  22. private void InitializeComponent()
  23. {
  24. this.Load += new System.EventHandler(this.Page_Load);
  25. }
  26. #endregion
  27. }

För att referera till dialogen från kod, till exempel för att binda dialogen till en knapp eller meny skapas normalt en statisk funktion DialogInfo enligt:

  1. C#
  1. public static DialogInfo DialogInfo()
  2. {
  3. Url url = new Url( "/Lib/News/UI/Dialogs/News.aspx" );
  4. DialogInfo info = new DialogInfo( url, 902, 648 );
  5. info.OpenAsModal = false;
  6. info.WindowName = "MySite_News";
  7. return info;
  8. }

I detta fallet öppnas dialogen som icke-modal, dvs det öppnande fönstret kan fortsätta ha fokus. Det går inte att skicka med objekttillstånd till sådana fönster. Detta läge används framförallt av Dynamix-verktyg.

Verktyg

Ett Dynamix-verktyg består av en huvuddialog samt en definition. Definitionen görs med en klass som ärvs från Dynamix.Tool:

  1. C#
  1. using System;
  2. using System.Runtime.Serialization;
  3. using Dynamix;
  4. namespace MySite.Tools
  5. {
  6. [Serializable]
  7. [Dynamix.Definitions.Tool]
  8. public class News : Tool
  9. {
  10. protected News( ObjectID id ) : base( id ) {}
  11. protected News( SerializationInfo info, StreamingContext context )
  12. : base( info, context ) {}
  13. public News() : base() {}
  14. // The name of the tool as displayed in the editor UI
  15. public override string Name
  16. {
  17. get { return "Nyheter"; }
  18. }
  19. // The icon of the tool as displayed in the editor UI
  20. public override string IconUrl
  21. {
  22. get { return Dynamix.Util.Icon16( "news" ); }
  23. }
  24. // The tool's dialog
  25. public override Dynamix.UI.DialogInfo DialogInfo()
  26. {
  27. return MySite.UI.Dialogs.News.News.DialogInfo();
  28. }
  29. // Utility function for easy access from code
  30. public static News Instance
  31. {
  32. get { return (News)GetInstance( typeof( News ) ); }
  33. }
  34. }
  35. }