This section explains how to use the command line compiler to build a simple application

Without Visual Studio

Note

The source code for this example can be found in the Examples\Example2 directory

You can also use the command line compiler (csc) to compile an application.

Copy the code below and paste in a new file named HelloAMIgoWorld.cs.

Then type: csc /t:winexe HelloAMIgoWorld.cs /r:[path]AMIgo.dll to build the program. This is an exact equivalent of the Hello AMIgo World.

CopyC#
  1using System;
  2using System.Drawing;
  3using System.Windows.Forms;
  4using AMIgo;
  5
  6// A simple AMIgo application to be used with the command line compiler
  7public class Form1 : System.Windows.Forms.Form
  8{
  9    private AMI_Client AMI_Cli; // The AMI_Client object
 10    private AstSite ASite; // A site definition object
 11    private AMIgoCommandPanel ACmdPanel; // AMIgo Command panel
 12    private AMIgoStatusStrip AStatusStrip; // AMIgo Status Strip
 13    private ListViewLines ALinesListView; // AMIgo Lines ListView display
 14    private ListViewChannels AChannelsListView; // AMIgo Channels ListView display
 15    private SplitContainer splitContainer1; // For the two list view
 16    //+============================================================+
 17    public Form1()
 18    {
 19        //this.Load += new EventHandler(Form1_Load);
 20        SetupLayout();
 21    }
 22    //+============================================================+
 23    private void Form1_Load(System.Object sender, System.EventArgs e)
 24    {
 25      SetupLayout();
 26      //if (AMI_Cli.AutoStart == false)
 27      //  AMI_Cli.Start(this);
 28    }
 29    //+============================================================+
 30    private void SetupLayout()
 31    {
 32      this.Size = new Size(800, 600); // Set the main form size
 33      // Create a new AstSite object with Host and manager account info. for the target system.
 34      ASite = new AstSite("Site Name", "Host or domain", "5038", "MyUserName", "MyPassword", false);
 35      // Create a new AMI_Client object with a reference to the main form (this) and the AstSite object
 36      //AMI_Cli = new AMI_Client(this, ASite);
 37      // Or start and use the Connection button to connect
 38      // NOTE: The 'this' parameter which represents the main form will be used to
 39      // synchronize the events with the main thread. 
 40      AMI_Cli = new AMI_Client(this);
 41      // If you use the next constructor, the events will not be synchronised to the main thread.
 42      // You will need to call Invoke for any update to the User Interface.
 43      //AMI_Cli = new AMI_Client();
 44
 45      // Setup events handlers for the peers and channels details events.
 46      AMI_Cli.PeerDetailsEvent += new StatusEventHandler(AMI_Cli_PeerDetailsEventHandler);
 47      AMI_Cli.ChannelDetailsEvent += new StatusEventHandler(AMI_Cli_ChannelDetailsEventHandler);
 48      // Create a new AMIgo command panel and set it to dock to the top of the form.
 49      ACmdPanel = new AMIgoCommandPanel(AMI_Cli);
 50      ACmdPanel.Dock = DockStyle.Top;
 51      // Create a new AMIgo Status strip  and set it to dock to the bottom of the form.
 52      AStatusStrip = new AMIgoStatusStrip(AMI_Cli);
 53      AStatusStrip.Dock = DockStyle.Bottom;
 54      // Create a split container, with horizontal splitter and blue background
 55      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
 56      this.splitContainer1.Location = new System.Drawing.Point(0, 30);
 57      this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
 58      this.splitContainer1.BackColor = System.Drawing.SystemColors.ActiveCaption;
 59      // Set is to fill the remaining space on the form.
 60      this.splitContainer1.Dock = DockStyle.Fill;
 61
 62      // Create an AMIgo ListViewLines and set it to fill it's container 
 63      ALinesListView = new ListViewLines(AMI_Cli);
 64      //this.ALinesListView.Location = new System.Drawing.Point(0, 0);
 65      ALinesListView.Dock = DockStyle.Fill;
 66
 67      // Create an AMIgo ListViewChannels and set it to fill it's container 
 68      AChannelsListView = new ListViewChannels(AMI_Cli);
 69      //this.ALinesListView.Location = new System.Drawing.Point(0, 0);
 70      AChannelsListView.Dock = DockStyle.Fill;
 71      // Set the ListViewLines in the top panel and the ListViewChannels in the bottom panel
 72      // of the split container
 73      this.splitContainer1.Panel1.Controls.Add(this.ALinesListView);
 74      this.splitContainer1.Panel2.Controls.Add(this.AChannelsListView);
 75
 76      // Add the Command Panel, Status strip and splitcontainer to the form.
 77      this.Controls.Add(this.splitContainer1);
 78      this.Controls.Add(this.AStatusStrip);
 79      this.Controls.Add(this.ACmdPanel);
 80    }
 81    //+============================================================+
 82    // This event is triggered in the AMI_Client thread but synchronised to the main form's thread.
 83    // So it is safe to update UI elements from within this event handler.
 84    private void AMI_Cli_PeerDetailsEventHandler(object sender, StringMsgEventArgs ev)
 85    {
 86      AMIgoDisplayForm df = new AMIgoDisplayForm("Peer Details", ev.string_msg);
 87      df.Show();
 88    }
 89    //+============================================================+
 90    private void AMI_Cli_ChannelDetailsEventHandler(object sender, StringMsgEventArgs ev)
 91    {
 92      AMIgoDisplayForm df = new AMIgoDisplayForm("Channel Details", ev.string_msg);
 93      df.Show();
 94    }
 95    //+============================================================+
 96    [STAThreadAttribute()]
 97    static void Main()
 98    {
 99      Form1 app = null;
100      try
101      {
102        app = new Form1();
103        Application.EnableVisualStyles();
104        Application.Run(app);
105      }
106      catch (Exception ex)
107      {
108        MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
109      }
110    }
111}