Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2518


Ignore:
Timestamp:
11/23/09 10:25:17 (14 years ago)
Author:
epitzer
Message:

Use DataGrid to monitor several grid client instances inside a single grid application. (#805)

Location:
trunk/sources/HeuristicLab.Grid/3.2
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Grid/3.2/ClientForm.cs

    r1529 r2518  
    3737
    3838namespace HeuristicLab.Grid {
     39
     40
    3941  public partial class ClientForm : Form {
    40     private GridClient client;
     42
     43    private List<ClientController> clientControllers;
     44
    4145    public ClientForm() {
    4246      InitializeComponent();
    43 
    44       client = new GridClient();
     47      clientControllers = new List<ClientController>();
     48      nClientsControl.Value = Environment.ProcessorCount;
     49      clientControllerBindingSource.DataSource = clientControllers;
    4550      UpdateControl();
    4651    }
    4752
    4853    private void startButton_Click(object sender, EventArgs e) {
    49       client.Start(addressTextBox.Text);
     54      foreach (var client in clientControllers) {
     55        client.Client.Start(addressTextBox.Text);
     56      }
    5057      UpdateControl();
    5158    }
    5259
    5360    private void stopButton_Click(object sender, EventArgs e) {
    54       client.Stop();
     61      foreach (var client in clientControllers) {
     62        client.Client.Stop();
     63      }
    5564      UpdateControl();
    5665    }
    5766
    5867    private void UpdateControl() {
    59       if(client.Waiting) {
    60         startButton.Enabled = false;
    61         stopButton.Enabled = true;
    62         statusTextBox.Text = "Waiting for engine";
    63       } else if(client.Executing) {
    64         startButton.Enabled = false;
    65         stopButton.Enabled = true;
    66         statusTextBox.Text = "Executing engine";
    67       } else if(client.Stopped) {
    68         startButton.Enabled = true;
    69         stopButton.Enabled = false;
    70         statusTextBox.Text = "Stopped";
     68      foreach (var client in clientControllers) {
     69        if (client.Client.Waiting) {
     70          startButton.Enabled = false;
     71          stopButton.Enabled = true;
     72          client.Status = "Waiting for engine";
     73        } else if (client.Client.Executing) {
     74          startButton.Enabled = false;
     75          stopButton.Enabled = true;
     76          client.Status = "Executing engine";
     77        } else if (client.Client.Stopped) {
     78          startButton.Enabled = true;
     79          stopButton.Enabled = false;
     80          client.Status = "Stopped";
     81        }
     82        client.Message = client.Client.StatusMessage;
    7183      }
    72       statusStrip.Text = client.StatusMessage;
     84      clientGrid.Invalidate();
    7385    }
    7486
     
    7688      UpdateControl();
    7789    }
     90
     91    private void nClientsControl_ValueChanged(object sender, EventArgs e) {
     92      if (nClientsControl.Value < 0)
     93        nClientsControl.Value = 0;
     94      while (clientControllers.Count < nClientsControl.Value)
     95        clientControllers.Add(new ClientController() { Client = new GridClient() });
     96      while (clientControllers.Count > nClientsControl.Value) {
     97        try {
     98          clientControllers[clientControllers.Count - 1].Client.Stop();
     99          clientControllers.RemoveAt(clientControllers.Count - 1);
     100        } catch { }
     101      }
     102      clientGrid.Invalidate();
     103    }
    78104  }
    79105}
  • trunk/sources/HeuristicLab.Grid/3.2/ClientForm.designer.cs

    r1529 r2518  
    5050      this.startButton = new System.Windows.Forms.Button();
    5151      this.addressTextBox = new System.Windows.Forms.TextBox();
    52       this.statusLabel = new System.Windows.Forms.Label();
    53       this.statusTextBox = new System.Windows.Forms.TextBox();
    54       this.statusStrip = new System.Windows.Forms.StatusStrip();
    5552      this.timer = new System.Windows.Forms.Timer(this.components);
     53      this.nClientsControl = new System.Windows.Forms.NumericUpDown();
     54      this.clientGrid = new System.Windows.Forms.DataGridView();
     55      this.clientControllerBindingSource = new System.Windows.Forms.BindingSource(this.components);
     56      this.clientDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
     57      this.statusDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
     58      this.messageDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
     59      this.runningDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     60      ((System.ComponentModel.ISupportInitialize)(this.nClientsControl)).BeginInit();
     61      ((System.ComponentModel.ISupportInitialize)(this.clientGrid)).BeginInit();
     62      ((System.ComponentModel.ISupportInitialize)(this.clientControllerBindingSource)).BeginInit();
    5663      this.SuspendLayout();
    5764      //
     
    6976      this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    7077      this.stopButton.Enabled = false;
    71       this.stopButton.Location = new System.Drawing.Point(96, 61);
     78      this.stopButton.Location = new System.Drawing.Point(93, 142);
    7279      this.stopButton.Name = "stopButton";
    7380      this.stopButton.Size = new System.Drawing.Size(75, 23);
    7481      this.stopButton.TabIndex = 6;
    75       this.stopButton.Text = "St&op";
     82      this.stopButton.Text = "St&op All";
    7683      this.stopButton.UseVisualStyleBackColor = true;
    7784      this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
     
    8087      //
    8188      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    82       this.startButton.Location = new System.Drawing.Point(12, 61);
     89      this.startButton.Location = new System.Drawing.Point(12, 142);
    8390      this.startButton.Name = "startButton";
    8491      this.startButton.Size = new System.Drawing.Size(75, 23);
    8592      this.startButton.TabIndex = 5;
    86       this.startButton.Text = "St&art";
     93      this.startButton.Text = "St&art All";
    8794      this.startButton.UseVisualStyleBackColor = true;
    8895      this.startButton.Click += new System.EventHandler(this.startButton_Click);
     
    9097      // addressTextBox
    9198      //
     99      this.addressTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     100                  | System.Windows.Forms.AnchorStyles.Right)));
    92101      this.addressTextBox.Location = new System.Drawing.Point(96, 6);
    93102      this.addressTextBox.Name = "addressTextBox";
    94       this.addressTextBox.Size = new System.Drawing.Size(222, 20);
     103      this.addressTextBox.Size = new System.Drawing.Size(263, 20);
    95104      this.addressTextBox.TabIndex = 4;
    96       //
    97       // statusLabel
    98       //
    99       this.statusLabel.AutoSize = true;
    100       this.statusLabel.Location = new System.Drawing.Point(12, 33);
    101       this.statusLabel.Name = "statusLabel";
    102       this.statusLabel.Size = new System.Drawing.Size(67, 13);
    103       this.statusLabel.TabIndex = 8;
    104       this.statusLabel.Text = "&Client status:";
    105       //
    106       // statusTextBox
    107       //
    108       this.statusTextBox.Location = new System.Drawing.Point(96, 30);
    109       this.statusTextBox.Name = "statusTextBox";
    110       this.statusTextBox.ReadOnly = true;
    111       this.statusTextBox.Size = new System.Drawing.Size(222, 20);
    112       this.statusTextBox.TabIndex = 9;
    113       //
    114       // statusStrip
    115       //
    116       this.statusStrip.Location = new System.Drawing.Point(0, 87);
    117       this.statusStrip.Name = "statusStrip";
    118       this.statusStrip.Size = new System.Drawing.Size(330, 22);
    119       this.statusStrip.TabIndex = 10;
    120       this.statusStrip.Text = "statusStrip1";
    121105      //
    122106      // timer
     
    126110      this.timer.Tick += new System.EventHandler(this.timer_Tick);
    127111      //
     112      // nClientsControl
     113      //
     114      this.nClientsControl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     115      this.nClientsControl.Location = new System.Drawing.Point(365, 6);
     116      this.nClientsControl.Name = "nClientsControl";
     117      this.nClientsControl.Size = new System.Drawing.Size(48, 20);
     118      this.nClientsControl.TabIndex = 11;
     119      this.nClientsControl.ValueChanged += new System.EventHandler(this.nClientsControl_ValueChanged);
     120      //
     121      // clientGrid
     122      //
     123      this.clientGrid.AllowUserToAddRows = false;
     124      this.clientGrid.AllowUserToDeleteRows = false;
     125      this.clientGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     126                  | System.Windows.Forms.AnchorStyles.Left)
     127                  | System.Windows.Forms.AnchorStyles.Right)));
     128      this.clientGrid.AutoGenerateColumns = false;
     129      this.clientGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
     130      this.clientGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
     131            this.clientDataGridViewTextBoxColumn,
     132            this.statusDataGridViewTextBoxColumn,
     133            this.messageDataGridViewTextBoxColumn,
     134            this.runningDataGridViewCheckBoxColumn});
     135      this.clientGrid.DataSource = this.clientControllerBindingSource;
     136      this.clientGrid.Location = new System.Drawing.Point(12, 32);
     137      this.clientGrid.Name = "clientGrid";
     138      this.clientGrid.RowHeadersVisible = false;
     139      this.clientGrid.Size = new System.Drawing.Size(401, 104);
     140      this.clientGrid.TabIndex = 12;
     141      //
     142      // clientControllerBindingSource
     143      //
     144      this.clientControllerBindingSource.DataSource = typeof(HeuristicLab.Grid.ClientController);
     145      //
     146      // clientDataGridViewTextBoxColumn
     147      //
     148      this.clientDataGridViewTextBoxColumn.DataPropertyName = "Client";
     149      this.clientDataGridViewTextBoxColumn.HeaderText = "Client";
     150      this.clientDataGridViewTextBoxColumn.Name = "clientDataGridViewTextBoxColumn";
     151      this.clientDataGridViewTextBoxColumn.ReadOnly = true;
     152      this.clientDataGridViewTextBoxColumn.Visible = false;
     153      //
     154      // statusDataGridViewTextBoxColumn
     155      //
     156      this.statusDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     157      this.statusDataGridViewTextBoxColumn.DataPropertyName = "Status";
     158      this.statusDataGridViewTextBoxColumn.HeaderText = "Status";
     159      this.statusDataGridViewTextBoxColumn.Name = "statusDataGridViewTextBoxColumn";
     160      this.statusDataGridViewTextBoxColumn.ReadOnly = true;
     161      //
     162      // messageDataGridViewTextBoxColumn
     163      //
     164      this.messageDataGridViewTextBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     165      this.messageDataGridViewTextBoxColumn.DataPropertyName = "Message";
     166      this.messageDataGridViewTextBoxColumn.HeaderText = "Message";
     167      this.messageDataGridViewTextBoxColumn.Name = "messageDataGridViewTextBoxColumn";
     168      this.messageDataGridViewTextBoxColumn.ReadOnly = true;
     169      //
     170      // runningDataGridViewCheckBoxColumn
     171      //
     172      this.runningDataGridViewCheckBoxColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     173      this.runningDataGridViewCheckBoxColumn.DataPropertyName = "Running";
     174      this.runningDataGridViewCheckBoxColumn.HeaderText = "Running";
     175      this.runningDataGridViewCheckBoxColumn.Name = "runningDataGridViewCheckBoxColumn";
     176      this.runningDataGridViewCheckBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
     177      //
    128178      // ClientForm
    129179      //
    130180      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    131181      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    132       this.ClientSize = new System.Drawing.Size(330, 109);
    133       this.Controls.Add(this.statusStrip);
    134       this.Controls.Add(this.statusTextBox);
    135       this.Controls.Add(this.statusLabel);
     182      this.ClientSize = new System.Drawing.Size(425, 177);
     183      this.Controls.Add(this.clientGrid);
     184      this.Controls.Add(this.nClientsControl);
    136185      this.Controls.Add(this.label1);
    137186      this.Controls.Add(this.stopButton);
     
    140189      this.Name = "ClientForm";
    141190      this.Text = "Grid Client";
     191      ((System.ComponentModel.ISupportInitialize)(this.nClientsControl)).EndInit();
     192      ((System.ComponentModel.ISupportInitialize)(this.clientGrid)).EndInit();
     193      ((System.ComponentModel.ISupportInitialize)(this.clientControllerBindingSource)).EndInit();
    142194      this.ResumeLayout(false);
    143195      this.PerformLayout();
     
    151203    private System.Windows.Forms.Button startButton;
    152204    private System.Windows.Forms.TextBox addressTextBox;
    153     private System.Windows.Forms.Label statusLabel;
    154     private System.Windows.Forms.TextBox statusTextBox;
    155     private System.Windows.Forms.StatusStrip statusStrip;
    156205    private System.Windows.Forms.Timer timer;
     206    private System.Windows.Forms.NumericUpDown nClientsControl;
     207    private System.Windows.Forms.DataGridView clientGrid;
     208    private System.Windows.Forms.BindingSource clientControllerBindingSource;
     209    private System.Windows.Forms.DataGridViewTextBoxColumn clientDataGridViewTextBoxColumn;
     210    private System.Windows.Forms.DataGridViewTextBoxColumn statusDataGridViewTextBoxColumn;
     211    private System.Windows.Forms.DataGridViewTextBoxColumn messageDataGridViewTextBoxColumn;
     212    private System.Windows.Forms.DataGridViewCheckBoxColumn runningDataGridViewCheckBoxColumn;
    157213  }
    158214}
  • trunk/sources/HeuristicLab.Grid/3.2/ClientForm.resx

    r1529 r2518  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
    120   <metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    121     <value>17, 17</value>
    122   </metadata>
    123120  <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    124121    <value>121, 17</value>
    125122  </metadata>
     123  <metadata name="clientControllerBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     124    <value>201, 17</value>
     125  </metadata>
    126126</root>
  • trunk/sources/HeuristicLab.Grid/3.2/HeuristicLab.Grid-3.2.csproj

    r2058 r2518  
    7373      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    7474    </Reference>
    75     <Reference Include="System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
    76       <SpecificVersion>False</SpecificVersion>
    77       <HintPath>..\HeuristicLab.SQLite\System.Data.SQLite.DLL</HintPath>
     75    <Reference Include="System.Data.DataSetExtensions">
     76      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    7877    </Reference>
    7978    <Reference Include="System.Drawing" />
     
    9291  </ItemGroup>
    9392  <ItemGroup>
     93    <Compile Include="ClientController.cs" />
    9494    <Compile Include="ClientForm.cs">
    9595      <SubType>Form</SubType>
     
    148148    <None Include="HeuristicLab.snk" />
    149149    <None Include="Properties\AssemblyInfo.frame" />
     150    <None Include="Properties\DataSources\ClientController.datasource" />
    150151  </ItemGroup>
    151152  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Note: See TracChangeset for help on using the changeset viewer.