using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Windows.Forms; using BCG.Utilities; namespace BCG { /// /// Summary description for RouteInput. /// public class RouteInput : System.Windows.Forms.UserControl { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; // private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridTextBoxColumn2; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridTextBoxColumn3; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridTextBoxColumn4; private System.Windows.Forms.DataGridView myDataGrid; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridTextBoxColumn1; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public RouteInput() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // TODO: Add any initialization after the InitializeComponent call } public void setRoutes(PubSubRoute [] routes) { DataTable myTable = new DataTable(); DataColumn colItem = new DataColumn("tagRegExp",Type.GetType("System.String")); myTable.Columns.Add(colItem); colItem = new DataColumn("ip",Type.GetType("System.String")); myTable.Columns.Add(colItem); colItem = new DataColumn("queue",Type.GetType("System.String")); myTable.Columns.Add(colItem); colItem = new DataColumn("order",Type.GetType("System.Int32")); myTable.Columns.Add(colItem); DataRow NewRow; int n = 1; foreach (PubSubRoute r in PubSub3Config.instance.getRouting()) foreach (string url in r.getAllPubSubs()) { NewRow = myTable.NewRow(); NewRow["order"] = 10 * n++; NewRow["tagRegExp"] = r.tagRegExp; NewRow["ip"] = new MSMQSubAddress(url).ip; NewRow["queue"] = new MSMQSubAddress(url).simpleQueueName; myTable.Rows.Add(NewRow); } myTable.AcceptChanges(); myDataGrid.DataSource = myTable; } public PubSubRoute[] getRoutes() { DataTable dt = myDataGrid.DataSource as DataTable; dt.AcceptChanges(); dt.DefaultView.Sort = "order"; PubSubRoute [] routes = new PubSubRoute[dt.Rows.Count]; int i = 0; foreach (DataRowView r in dt.DefaultView) { Console.WriteLine(r.ToString()); bts.Log.Gen.info(r.ToString()); routes[i++] = new PubSubRoute(new MSMQSubAddress(r["ip"].ToString(),r["queue"].ToString()).ToString(), r["tagRegExp"].ToString()); } return routes; } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Component Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.myDataGrid = new System.Windows.Forms.DataGrid(); // this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle(); this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn(); this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.myDataGrid)).BeginInit(); this.SuspendLayout(); // // label1 // this.label1.Location = new System.Drawing.Point(0, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 0); this.label1.TabIndex = 3; this.label1.Text = "IP"; // // label2 // this.label2.Location = new System.Drawing.Point(0, 0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(0, 0); this.label2.TabIndex = 4; this.label2.Text = "IP"; // // myDataGrid // this.myDataGrid.BackgroundColor = System.Drawing.Color.LightGoldenrodYellow; this.myDataGrid.CaptionText = "PubSub Routes"; this.myDataGrid.DataMember = ""; this.myDataGrid.Dock = System.Windows.Forms.DockStyle.Fill; this.myDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; this.myDataGrid.Location = new System.Drawing.Point(0, 0); this.myDataGrid.Name = "myDataGrid"; this.myDataGrid.Size = new System.Drawing.Size(392, 480); this.myDataGrid.TabIndex = 5; // this.myDataGrid.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] { // this.dataGridTableStyle1}); // // dataGridTableStyle1 // // this.dataGridTableStyle1.DataGrid = this.myDataGrid; // this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] { // this.dataGridTextBoxColumn2, // this.dataGridTextBoxColumn3, // this.dataGridTextBoxColumn4, // this.dataGridTextBoxColumn1}); // this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText; // this.dataGridTableStyle1.MappingName = ""; // // dataGridTextBoxColumn2 // this.dataGridTextBoxColumn2.Format = ""; this.dataGridTextBoxColumn2.FormatInfo = null; this.dataGridTextBoxColumn2.HeaderText = "Tag Regexp"; this.dataGridTextBoxColumn2.MappingName = "tagRegexp"; this.dataGridTextBoxColumn2.NullText = ""; this.dataGridTextBoxColumn2.Width = 112; // // dataGridTextBoxColumn3 // this.dataGridTextBoxColumn3.Format = ""; this.dataGridTextBoxColumn3.FormatInfo = null; this.dataGridTextBoxColumn3.HeaderText = "PubSub IP"; this.dataGridTextBoxColumn3.MappingName = "ip"; this.dataGridTextBoxColumn3.NullText = ""; this.dataGridTextBoxColumn3.Width = 110; // // dataGridTextBoxColumn4 // this.dataGridTextBoxColumn4.Format = ""; this.dataGridTextBoxColumn4.FormatInfo = null; this.dataGridTextBoxColumn4.HeaderText = "Queue Name"; this.dataGridTextBoxColumn4.MappingName = "queue"; this.dataGridTextBoxColumn4.NullText = ""; this.dataGridTextBoxColumn4.Width = 80; // // dataGridTextBoxColumn1 // this.dataGridTextBoxColumn1.Format = ""; this.dataGridTextBoxColumn1.FormatInfo = null; this.dataGridTextBoxColumn1.HeaderText = "Order"; this.dataGridTextBoxColumn1.MappingName = "order"; this.dataGridTextBoxColumn1.Width = 40; // // RouteInput // this.Controls.Add(this.myDataGrid); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Name = "RouteInput"; this.Size = new System.Drawing.Size(392, 480); ((System.ComponentModel.ISupportInitialize)(this.myDataGrid)).EndInit(); this.ResumeLayout(false); } #endregion } }