Dialoger
Dialoger som vill använda Dynamix objektmodell och tillståndshantering ska ärvas från Dynamix.UI.Dialog (eller en subklass).
Exempel:
- C#
namespace MySite.UI.Dialogs.News
{
/// <summary>
/// News management dialog.
/// </summary>
public class News : Dynamix.UI.Dialog
{
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
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:
- C#
public static DialogInfo DialogInfo()
{
Url url = new Url( "/Lib/News/UI/Dialogs/News.aspx" );
DialogInfo info = new DialogInfo( url, 902, 648 );
info.OpenAsModal = false;
info.WindowName = "MySite_News";
return info;
}
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:
- C#
using System;
using System.Runtime.Serialization;
using Dynamix;
namespace MySite.Tools
{
[Serializable]
[Dynamix.Definitions.Tool]
public class News : Tool
{
protected News( ObjectID id ) : base( id ) {}
protected News( SerializationInfo info, StreamingContext context )
: base( info, context ) {}
public News() : base() {}
// The name of the tool as displayed in the editor UI
public override string Name
{
get { return "Nyheter"; }
}
// The icon of the tool as displayed in the editor UI
public override string IconUrl
{
get { return Dynamix.Util.Icon16( "news" ); }
}
// The tool's dialog
public override Dynamix.UI.DialogInfo DialogInfo()
{
return MySite.UI.Dialogs.News.News.DialogInfo();
}
// Utility function for easy access from code
public static News Instance
{
get { return (News)GetInstance( typeof( News ) ); }
}
}
}