From: <br...@us...> - 2008-06-28 11:13:18
|
Revision: 284 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=284&view=rev Author: brus07 Date: 2008-06-28 04:13:25 -0700 (Sat, 28 Jun 2008) Log Message: ----------- Logging in plugin textBox control socketServerGate work. Show in plugin statusBar count of clients. Modified Paths: -------------- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGatePlugin.cs ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.Designer.cs ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.cs ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.resx Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs 2008-06-27 09:38:51 UTC (rev 283) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGate.cs 2008-06-28 11:13:25 UTC (rev 284) @@ -39,15 +39,46 @@ base.Send(submitList.Items[index].ToString()); } } + + OnLogMessage("SocketServerGate::Send(message)"); + string ids = ""; + for (int i = 0; i < submitList.Items.Length; i++) + { + ids += " " + submitList.Items[i].id.ToString(); + } + OnLogMessage("\t ID: " + ids); } } + + public class LogMessageEventArgs : EventArgs + { + public string message; + public LogMessageEventArgs(string mes) + { + message = mes; + } + } + + public event EventHandler<LogMessageEventArgs> LogMessage; + private void OnLogMessage(string p) + { + EventHandler<LogMessageEventArgs> temp = LogMessage; + if (temp != null) + temp(this, new LogMessageEventArgs(p)); + } + + protected void DataArrived(string message) { Result result = Result.CreateFromXml(message); dataContainer.Return(result); if (onDataArrived != null) onDataArrived(result.ToStringX()); + + + OnLogMessage("SocketServerGate::DataArrived(message)"); + OnLogMessage("\t " + result.res + " for " + result.Submit.id.ToString()); } } } Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGatePlugin.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGatePlugin.cs 2008-06-27 09:38:51 UTC (rev 283) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/SocketServerGatePlugin.cs 2008-06-28 11:13:25 UTC (rev 284) @@ -13,7 +13,9 @@ socketServerGate = SocketServerGate.GetInstance(); socketServerGate.onDataArrived += DataArrived; - base.Control = new TestUserControl(); + base.Control = new SocketServerGatePluginUserControl(); + + socketServerGate.LogMessage += new EventHandler<SocketServerGate.LogMessageEventArgs>(socketServerGate_LogMessage); } public override void Send(string message) @@ -27,5 +29,17 @@ WorkingData("SocketServerGatePlugin::Send CountClients = " + socketServerGate.CountClients().ToString()); socketServerGate.Send(message); } + + private void AddTextToContorl(string message) + { + string result = DateTime.Now.ToLongTimeString() + "." + DateTime.Now.Millisecond.ToString(); + result += " " + message + Environment.NewLine; + ((SocketServerGatePluginUserControl)base.Control).AddText(result); + } + + void socketServerGate_LogMessage(object sender, SocketServerGate.LogMessageEventArgs e) + { + AddTextToContorl(e.message); + } } } Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.Designer.cs 2008-06-27 09:38:51 UTC (rev 283) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.Designer.cs 2008-06-28 11:13:25 UTC (rev 284) @@ -1,6 +1,6 @@ namespace SocketServerGatePlugin { - partial class TestUserControl + partial class SocketServerGatePluginUserControl { /// <summary> /// Required designer variable. @@ -28,51 +28,72 @@ /// </summary> private void InitializeComponent() { - this.setButton = new System.Windows.Forms.Button(); + this.components = new System.ComponentModel.Container(); this.textBox1 = new System.Windows.Forms.TextBox(); - this.clearButton = new System.Windows.Forms.Button(); + this.socketGateStatusStrip = new System.Windows.Forms.StatusStrip(); + this.clientsCountToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.clientCountTimer = new System.Windows.Forms.Timer(this.components); + this.autoScrollCheckBox = new System.Windows.Forms.CheckBox(); + this.socketGateStatusStrip.SuspendLayout(); this.SuspendLayout(); // - // setButton - // - this.setButton.Location = new System.Drawing.Point(3, 3); - this.setButton.Name = "setButton"; - this.setButton.Size = new System.Drawing.Size(63, 23); - this.setButton.TabIndex = 0; - this.setButton.Text = "setButton"; - this.setButton.UseVisualStyleBackColor = true; - this.setButton.Click += new System.EventHandler(this.setButton_Click); - // // textBox1 // this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.textBox1.Location = new System.Drawing.Point(3, 32); + this.textBox1.Location = new System.Drawing.Point(3, 26); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBox1.Size = new System.Drawing.Size(144, 115); + this.textBox1.Size = new System.Drawing.Size(211, 130); this.textBox1.TabIndex = 1; // - // clearButton + // socketGateStatusStrip // - this.clearButton.Location = new System.Drawing.Point(72, 3); - this.clearButton.Name = "clearButton"; - this.clearButton.Size = new System.Drawing.Size(75, 23); - this.clearButton.TabIndex = 2; - this.clearButton.Text = "clearButton"; - this.clearButton.UseVisualStyleBackColor = true; - this.clearButton.Click += new System.EventHandler(this.clearButton_Click); + this.socketGateStatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.clientsCountToolStripStatusLabel}); + this.socketGateStatusStrip.Location = new System.Drawing.Point(0, 159); + this.socketGateStatusStrip.Name = "socketGateStatusStrip"; + this.socketGateStatusStrip.Size = new System.Drawing.Size(217, 22); + this.socketGateStatusStrip.TabIndex = 3; + this.socketGateStatusStrip.Text = "statusStrip1"; // - // TestUserControl + // clientsCountToolStripStatusLabel // + this.clientsCountToolStripStatusLabel.Name = "clientsCountToolStripStatusLabel"; + this.clientsCountToolStripStatusLabel.Size = new System.Drawing.Size(87, 17); + this.clientsCountToolStripStatusLabel.Text = "CountOfClients: "; + // + // clientCountTimer + // + this.clientCountTimer.Tick += new System.EventHandler(this.clientCountTimer_Tick); + // + // autoScrollCheckBox + // + this.autoScrollCheckBox.AutoSize = true; + this.autoScrollCheckBox.Checked = true; + this.autoScrollCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; + this.autoScrollCheckBox.Enabled = false; + this.autoScrollCheckBox.Location = new System.Drawing.Point(3, 3); + this.autoScrollCheckBox.Name = "autoScrollCheckBox"; + this.autoScrollCheckBox.Size = new System.Drawing.Size(74, 17); + this.autoScrollCheckBox.TabIndex = 4; + this.autoScrollCheckBox.Text = "AutoScroll"; + this.autoScrollCheckBox.UseVisualStyleBackColor = true; + // + // SocketServerGatePluginUserControl + // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.clearButton); + this.Controls.Add(this.autoScrollCheckBox); + this.Controls.Add(this.socketGateStatusStrip); this.Controls.Add(this.textBox1); - this.Controls.Add(this.setButton); - this.Name = "TestUserControl"; + this.Name = "SocketServerGatePluginUserControl"; + this.Size = new System.Drawing.Size(217, 181); + this.Load += new System.EventHandler(this.SocketServerGatePluginUserControl_Load); + this.socketGateStatusStrip.ResumeLayout(false); + this.socketGateStatusStrip.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -80,8 +101,10 @@ #endregion - private System.Windows.Forms.Button setButton; private System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.Button clearButton; + private System.Windows.Forms.StatusStrip socketGateStatusStrip; + private System.Windows.Forms.ToolStripStatusLabel clientsCountToolStripStatusLabel; + private System.Windows.Forms.Timer clientCountTimer; + private System.Windows.Forms.CheckBox autoScrollCheckBox; } } Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.cs 2008-06-27 09:38:51 UTC (rev 283) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.cs 2008-06-28 11:13:25 UTC (rev 284) @@ -5,24 +5,61 @@ using System.Data; using System.Text; using System.Windows.Forms; +using AcmContester.Plugins.MediatorPlugins.SocketServerGatePlugin; namespace SocketServerGatePlugin { - public partial class TestUserControl : UserControl + public partial class SocketServerGatePluginUserControl : UserControl { - public TestUserControl() + public SocketServerGatePluginUserControl() { InitializeComponent(); } - private void clearButton_Click(object sender, EventArgs e) + delegate void AddTextCallback(string text); + public void AddText(string text) { - textBox1.Text = ""; + if (this.textBox1.InvokeRequired) + { + AddTextCallback d = new AddTextCallback(AddText); + this.Invoke(d, new object[] { text }); + } + else + { + textBox1.Text += text; + if (autoScrollCheckBox.Checked) + { + textBox1.Select(textBox1.Text.Length, 0); + textBox1.ScrollToCaret(); + } + } } - private void setButton_Click(object sender, EventArgs e) + delegate void UpdateClientsCountStatusCallback(int clientsCount); + public void UpdateClientsCountStatus(int clientsCount) { - textBox1.Text = "A"; + if (this.socketGateStatusStrip.InvokeRequired) + { + UpdateClientsCountStatusCallback d = new UpdateClientsCountStatusCallback(UpdateClientsCountStatus); + this.Invoke(d, new object[] { clientsCount }); + } + else + { + clientsCountToolStripStatusLabel.Text = "CountOfClients: "; + clientsCountToolStripStatusLabel.Text += clientsCount.ToString(); + } } + + private void clientCountTimer_Tick(object sender, EventArgs e) + { + SocketServerGate gate = SocketServerGate.GetInstance(); + int count = gate.CountClients(); + UpdateClientsCountStatus(count); + } + + private void SocketServerGatePluginUserControl_Load(object sender, EventArgs e) + { + clientCountTimer.Enabled = true; + } } } Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.resx =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.resx 2008-06-27 09:38:51 UTC (rev 283) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/SocketServerGatePlugin/TestUserControl.resx 2008-06-28 11:13:25 UTC (rev 284) @@ -117,4 +117,10 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <metadata name="socketGateStatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> + <metadata name="clientCountTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>178, 17</value> + </metadata> </root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |