From: <br...@us...> - 2008-10-21 07:44:11
|
Revision: 419 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=419&view=rev Author: brus07 Date: 2008-10-21 07:44:02 +0000 (Tue, 21 Oct 2008) Log Message: ----------- Added to PluginsFramework UserControl for work with plugins in all application equally (one app, one MediatorKernelGUI, one MediatorKernel, one Config, many Plugins). Modified Paths: -------------- ACMServer/trunk/ACMServer/Mediator/Form1.Designer.cs ACMServer/trunk/ACMServer/Mediator/Form1.cs ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj Added Paths: ----------- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.Designer.cs ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.cs ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.resx Modified: ACMServer/trunk/ACMServer/Mediator/Form1.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Form1.Designer.cs 2008-10-14 22:35:16 UTC (rev 418) +++ ACMServer/trunk/ACMServer/Mediator/Form1.Designer.cs 2008-10-21 07:44:02 UTC (rev 419) @@ -33,11 +33,7 @@ this.button3 = new System.Windows.Forms.Button(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.textBox2 = new System.Windows.Forms.TextBox(); - this.textBox3 = new System.Windows.Forms.TextBox(); - this.tabControl1 = new System.Windows.Forms.TabControl(); - this.tabPage1 = new System.Windows.Forms.TabPage(); - this.tabControl1.SuspendLayout(); - this.tabPage1.SuspendLayout(); + this.panel1 = new System.Windows.Forms.Panel(); this.SuspendLayout(); // // button2 @@ -87,57 +83,31 @@ this.textBox2.Size = new System.Drawing.Size(110, 20); this.textBox2.TabIndex = 11; // - // textBox3 + // panel1 // - this.textBox3.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBox3.Location = new System.Drawing.Point(3, 3); - this.textBox3.Multiline = true; - this.textBox3.Name = "textBox3"; - this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBox3.Size = new System.Drawing.Size(343, 190); - this.textBox3.TabIndex = 12; - // - // tabControl1 - // - this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.panel1.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.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(357, 222); - this.tabControl1.TabIndex = 13; + this.panel1.Location = new System.Drawing.Point(12, 70); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(357, 222); + this.panel1.TabIndex = 12; // - // tabPage1 - // - this.tabPage1.Controls.Add(this.textBox3); - 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(349, 196); - this.tabPage1.TabIndex = 0; - this.tabPage1.Text = "Main"; - this.tabPage1.UseVisualStyleBackColor = true; - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(369, 317); - this.Controls.Add(this.tabControl1); this.Controls.Add(this.textBox2); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.button3); this.Controls.Add(this.label1); this.Controls.Add(this.button2); + this.Controls.Add(this.panel1); this.Name = "Form1"; this.Text = "Gate"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); - this.tabControl1.ResumeLayout(false); - this.tabPage1.ResumeLayout(false); - this.tabPage1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -150,9 +120,7 @@ private System.Windows.Forms.Button button3; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.TextBox textBox2; - private System.Windows.Forms.TextBox textBox3; - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.Panel panel1; } } Modified: ACMServer/trunk/ACMServer/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-14 22:35:16 UTC (rev 418) +++ ACMServer/trunk/ACMServer/Mediator/Form1.cs 2008-10-21 07:44:02 UTC (rev 419) @@ -15,6 +15,7 @@ { public partial class Form1 : Form { + MediatorKernelGUI kernel; public Form1() { @@ -23,56 +24,14 @@ textBox2.Text = s; } - MediatorKernel kernel; private void button2_Click(object sender, EventArgs e) { - kernel = new MediatorKernel(); - System.Threading.ThreadPool.QueueUserWorkItem(RunLoadDll); + kernel = new MediatorKernelGUI("Dll_Tester", "Dll_Web"); + kernel.Dock = DockStyle.Fill; + this.panel1.Controls.Add(kernel); } - void RunLoadDll(Object ob) - { - kernel.AddControl += new EventHandler<AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs>(kernel_AddControl); - kernel.LoadLists("Dll_Tester", "Dll_Web"); - } - - delegate void AddControlCallback(object sender, AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs e); - void kernel_AddControl(object sender, AcmContester.Plugins.PluginsFramework.MediatorKernel.ControlEventArgs e) - { - if (this.tabControl1.InvokeRequired) - { - AddControlCallback d = new AddControlCallback(kernel_AddControl); - this.Invoke(d, new object[] { sender, e }); - } - else - { - Control control = e.Control; - control.Dock = DockStyle.Fill; - string name = e.Name; - TabPage page = new TabPage(name); - page.Controls.Add(control); - tabControl1.TabPages.Add(page); - } - } - - delegate void UpdateTextLogCallback(string message, TextBox textBox); - private void UpdateTextLog(string message, TextBox textBox) - { - if (textBox.InvokeRequired) - { - UpdateTextLogCallback d = new UpdateTextLogCallback(UpdateTextLog); - this.Invoke(d, new object[] { message }); - } - else - { - textBox.Text += message; - textBox.Select(textBox3.Text.Length, 0); - textBox.ScrollToCaret(); - } - - } - private void button3_Click(object sender, EventArgs e) { Disconnnect(); Added: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.Designer.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.Designer.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.Designer.cs 2008-10-21 07:44:02 UTC (rev 419) @@ -0,0 +1,58 @@ +namespace AcmContester.Plugins.PluginsFramework +{ + partial class MediatorKernelGUI + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.SuspendLayout(); + // + // tabControl1 + // + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(0, 0); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(359, 282); + this.tabControl1.TabIndex = 0; + // + // MediatorKernelGUI + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.tabControl1); + this.Name = "MediatorKernelGUI"; + this.Size = new System.Drawing.Size(359, 282); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + } +} Added: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.cs (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.cs 2008-10-21 07:44:02 UTC (rev 419) @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using AcmContester.Plugins.PluginsFramework; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Plugins.PluginsFramework +{ + public partial class MediatorKernelGUI : UserControl + { + MediatorKernel mediator = new MediatorKernel(); + + private MediatorKernelGUI() + { + InitializeComponent(); + } + + public MediatorKernelGUI(string testerFolderPath, string clientFolderPath) + { + InitializeComponent(); + LoadLists(testerFolderPath, clientFolderPath); + } + + private void LoadLists(string testerFolderPath, string clientFolderPath) + { + List<string> list = new List<string>(); + list.Add(testerFolderPath); + list.Add(clientFolderPath); + System.Threading.ThreadPool.QueueUserWorkItem(RunLoadDll,list); + } + + private void RunLoadDll(Object ob) + { + if (ob is List<string> == false) + throw new ArgumentException(); + List<string> list = (List<string>)ob; + if (list.Count != 2) + throw new ArgumentException(); + string testerFolderPath = list[0]; + string clientFolderPath = list[1]; + + mediator.AddControl += new EventHandler<MediatorKernel.ControlEventArgs>(mediator_AddControl); + mediator.LoadLists(testerFolderPath, clientFolderPath); + } + + private delegate void AddControlCallback(object sender, MediatorKernel.ControlEventArgs e); + private void mediator_AddControl(object sender, MediatorKernel.ControlEventArgs e) + { + if (this.tabControl1.InvokeRequired) + { + AddControlCallback d = new AddControlCallback(mediator_AddControl); + this.Invoke(d, new object[] { sender, e }); + } + else + { + Control control = e.Control; + control.Dock = DockStyle.Fill; + string name = e.Name; + TabPage page = new TabPage(name); + page.Controls.Add(control); + tabControl1.TabPages.Add(page); + } + } + + public void SendToAll(SystemMessage message) + { + mediator.SendToAll(message); + } + } +} Added: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.resx =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.resx (rev 0) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/MediatorKernelGUI.resx 2008-10-21 07:44:02 UTC (rev 419) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file Modified: ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj 2008-10-14 22:35:16 UTC (rev 418) +++ ACMServer/trunk/ACMServer/Plugins/PluginsFramework/PluginsFramework.csproj 2008-10-21 07:44:02 UTC (rev 419) @@ -29,11 +29,20 @@ </PropertyGroup> <ItemGroup> <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="BaseMediatorPlugin.cs" /> <Compile Include="MediatorKernel.cs" /> + <Compile Include="MediatorKernelGUI.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="MediatorKernelGUI.Designer.cs"> + <DependentUpon>MediatorKernelGUI.cs</DependentUpon> + </Compile> <Compile Include="PluginsLoader.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> @@ -43,6 +52,12 @@ <Name>LibraryExtention</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="MediatorKernelGUI.resx"> + <SubType>Designer</SubType> + <DependentUpon>MediatorKernelGUI.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |