From: <br...@us...> - 2008-08-15 12:50:45
|
Revision: 323 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=323&view=rev Author: brus07 Date: 2008-08-15 12:50:52 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Added new view for log message. This is the grid with color rows. Modified Paths: -------------- ACMServer/trunk/ACMServer/Tester/Form1.Designer.cs ACMServer/trunk/ACMServer/Tester/Form1.cs ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs Modified: ACMServer/trunk/ACMServer/Tester/Form1.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Form1.Designer.cs 2008-08-14 23:18:22 UTC (rev 322) +++ ACMServer/trunk/ACMServer/Tester/Form1.Designer.cs 2008-08-15 12:50:52 UTC (rev 323) @@ -29,6 +29,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); @@ -36,19 +37,25 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.timer1 = new System.Windows.Forms.Timer(this.components); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.dataGridViewLog = new System.Windows.Forms.DataGridView(); this.statusStrip1.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.tabPage2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewLog)).BeginInit(); this.SuspendLayout(); // // 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(12, 70); + this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox1.Location = new System.Drawing.Point(3, 3); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBox1.Size = new System.Drawing.Size(268, 178); + this.textBox1.Size = new System.Drawing.Size(254, 146); this.textBox1.TabIndex = 0; // // button1 @@ -100,22 +107,83 @@ this.timer1.Enabled = true; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // + // tabControl1 + // + this.tabControl1.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.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Location = new System.Drawing.Point(12, 70); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(268, 178); + this.tabControl1.TabIndex = 7; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.textBox1); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(260, 152); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "TextLog"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.dataGridViewLog); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(260, 152); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "GridLog"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // dataGridViewLog + // + this.dataGridViewLog.AllowUserToAddRows = false; + this.dataGridViewLog.AllowUserToDeleteRows = false; + this.dataGridViewLog.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; + this.dataGridViewLog.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridViewLog.DefaultCellStyle = dataGridViewCellStyle1; + this.dataGridViewLog.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewLog.Location = new System.Drawing.Point(3, 3); + this.dataGridViewLog.Name = "dataGridViewLog"; + this.dataGridViewLog.ReadOnly = true; + this.dataGridViewLog.Size = new System.Drawing.Size(254, 146); + this.dataGridViewLog.TabIndex = 0; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(292, 273); + this.Controls.Add(this.tabControl1); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.textBox3); this.Controls.Add(this.button2); this.Controls.Add(this.button1); - this.Controls.Add(this.textBox1); this.Name = "Form1"; this.Text = "Tester"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); + this.tabPage2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridViewLog)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -130,6 +198,10 @@ private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.Timer timer1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.DataGridView dataGridViewLog; } } Modified: ACMServer/trunk/ACMServer/Tester/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Form1.cs 2008-08-14 23:18:22 UTC (rev 322) +++ ACMServer/trunk/ACMServer/Tester/Form1.cs 2008-08-15 12:50:52 UTC (rev 323) @@ -22,8 +22,20 @@ string ip = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString(); textBox3.Text = ip; + + initGrid(); } + DataTable tableLog = new DataTable(); + private void initGrid() + { + tableLog.Columns.Add(new DataColumn("Time")); + tableLog.Columns.Add(new DataColumn("Text")); + tableLog.Columns.Add(new DataColumn("Type")); + + dataGridViewLog.DataSource = tableLog; + } + private void button1_Click(object sender, EventArgs e) { if (socket == null) @@ -70,6 +82,88 @@ } } + public void AddText(string type, string text) + { + AddText(type + ": " + text); + AddTextToGridLog(new LogMessage(text, type)); + } + + public class LogMessage + { + public LogMessage(string _text, string _type) + { + text = _text; + type = _type; + } + + string text; + public string Text + { + get + { + return text; + } + } + + string type; + public string Type + { + get + { + return type; + } + } + public Color Color + { + get + { + if (type == "SystemR") + return Color.LightBlue; + if (type == "SystemS") + return Color.LightSkyBlue; + if (type == "Receive") + return Color.LightGreen; + if (type == "Send") + return Color.LimeGreen; + return Color.White; + } + } + + public string Time + { + get + { + return DateTime.Now.ToLongTimeString() + "." + DateTime.Now.Millisecond.ToString(); + } + } + } + + delegate void AddTextToGridLogCallback(LogMessage text); + public void AddTextToGridLog(LogMessage text) + { + if (this.dataGridViewLog.InvokeRequired) + { + AddTextToGridLogCallback d = new AddTextToGridLogCallback(AddTextToGridLog); + this.Invoke(d, new object[] { text }); + } + else + { + DataRow row = tableLog.NewRow(); + row[0] = text.Time; + row[1] = text.Text; + row[2] = text.Type; + //table.Rows.Add(row); + tableLog.Rows.InsertAt(row, 0); + + int c = tableLog.Rows.Count - 1; + c = 0; + dataGridViewLog.Rows[c].DefaultCellStyle.BackColor = text.Color; + + dataGridViewLog.Update(); + + } + } + delegate void UpdateTextLogCallback(string message); private void UpdateTextLog(string message) { Modified: ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs =================================================================== --- ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs 2008-08-14 23:18:22 UTC (rev 322) +++ ACMServer/trunk/ACMServer/Tester/Library/SocketClientGate.cs 2008-08-15 12:50:52 UTC (rev 323) @@ -21,7 +21,7 @@ { if (SystemMessage(message) == true) return; - OnAddLogText("Receive: "+message); + OnAddLogText("Receive", message); //OnDataArrived(message); AddWork(message); } @@ -50,7 +50,7 @@ string[] mes = message.Split(chars); if (mes[0] == "test") { - OnAddLogText("_sys_Receive: " + message); + OnAddLogText("SystemR", message); string result = ""; if (IsBusy() == true) { @@ -64,7 +64,7 @@ { result += " " + mes[i]; } - OnAddLogText("\t_sys_Send: " + result); + OnAddLogText("SystemS", result); base.Send(result); return true; } @@ -90,7 +90,7 @@ { if (IsBusy() == true) { - OnAddLogText("--------- busy ---------"); + OnAddLogText("info", "--------- busy ---------"); return; } @@ -146,18 +146,18 @@ lock (this) { Result res = Result.CreateFromXml(result); - OnAddLogText("\tSend: " + res.Submit.id + " result - " + res.res); + OnAddLogText("Send", "ID " + res.Submit.id + " result - " + res.res); this.Send(result); } } - public delegate void AddLogTextDelegate(string s); + public delegate void AddLogTextDelegate(string type, string text); public event AddLogTextDelegate onAddLogText; - private void OnAddLogText(string message) + private void OnAddLogText(string type, string text) { if (onAddLogText != null) - onAddLogText(message); + onAddLogText(type,text); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |