//*** All the public functions ***//
/// <summary>
/// ProgWin Constructor
/// </summary>
/// <param name="e">editor type</param>
/// <param name="sconn">Swarm Connection Object</param>
/// <param name="ip">Self IP</param>
/// <param name="port">Self Port</param>
/// <param name="pid">PID of the program</param>
/// <param name="uname">Self USername</param>
public ProgWin(editorType e, SwarmConnection sconn, string ip, string port, string pid, string uname, string Prog)
{
InitializeComponent();
et = e;
err.ProgWinError += new ErrorNotification(ShowError);
plot.image += new PlotReceiver.BmpImage(EnablePlot);
Controller = new executor();
Controller.resEvent += new executor.result(Display);
keywords = Controller.frontEnd.getKeywords();
err.SetExecutorObject(Controller);
err.SetPlotObject(plot);
username = uname;
progName = Prog;
//Swarm Operations
SC = sconn;
SM = new SwarmMemory(SC);
IP = ip;
Port = port;
PID = pid;
SM.PermissionListCh += new SwarmMemory.PermissionListChanged(progUserListChange);
SM.rnBtnClicked += new SwarmMemory.RunButtonClick(RunClicked);
SM.srcChanged += new SwarmMemory.SourceCodeChanged(CollabEditing);
SM.CloseP += new SwarmMemory.CloseProgram(SM_CloseP);
SM.RerunP += new SwarmMemory.RerunProgram(SM_RerunP);
SC.DisconnectChanged += new SwarmConnection.DisconnectEventHandler(SM_CloseP);
SM.FinalResult += new SwarmMemory.GetFinalResult(SM_FinalResult);
SM.createTheObjects(PID, IP, Port); //Finally the swarm memory object
SC.InsertProgtoSC(SM);
err.SetSwarmMemoryObject(SM);
//Exec Operations
Controller.setPlotObject(plot);
Controller.setSMObject(SM);
worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
prog = new TextRange(rtbInput.Document.ContentStart, rtbInput.Document.ContentEnd).Text;
userColor.Add(Colors.Brown);
userColor.Add(Colors.Yellow);
userColor.Add(Colors.Green);
}