GUI/MainForm.cs
author moel.mich
Sat, 01 May 2010 15:55:19 +0000
changeset 107 b94ce6a3aaf4
parent 83 3fdadd4a830f
child 110 411b72b73d8f
permissions -rw-r--r--
Fixed the "System.ComponentModel.Win32Exception: An error occurred in sending the command to the application" error in the about-box link code.
moel@1
     1
/*
moel@1
     2
  
moel@1
     3
  Version: MPL 1.1/GPL 2.0/LGPL 2.1
moel@1
     4
moel@1
     5
  The contents of this file are subject to the Mozilla Public License Version
moel@1
     6
  1.1 (the "License"); you may not use this file except in compliance with
moel@1
     7
  the License. You may obtain a copy of the License at
moel@1
     8
 
moel@1
     9
  http://www.mozilla.org/MPL/
moel@1
    10
moel@1
    11
  Software distributed under the License is distributed on an "AS IS" basis,
moel@1
    12
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
moel@1
    13
  for the specific language governing rights and limitations under the License.
moel@1
    14
moel@1
    15
  The Original Code is the Open Hardware Monitor code.
moel@1
    16
moel@1
    17
  The Initial Developer of the Original Code is 
moel@1
    18
  Michael Möller <m.moeller@gmx.ch>.
moel@1
    19
  Portions created by the Initial Developer are Copyright (C) 2009-2010
moel@1
    20
  the Initial Developer. All Rights Reserved.
moel@1
    21
moel@1
    22
  Contributor(s):
moel@1
    23
moel@1
    24
  Alternatively, the contents of this file may be used under the terms of
moel@1
    25
  either the GNU General Public License Version 2 or later (the "GPL"), or
moel@1
    26
  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
moel@1
    27
  in which case the provisions of the GPL or the LGPL are applicable instead
moel@1
    28
  of those above. If you wish to allow use of your version of this file only
moel@1
    29
  under the terms of either the GPL or the LGPL, and not to allow others to
moel@1
    30
  use your version of this file under the terms of the MPL, indicate your
moel@1
    31
  decision by deleting the provisions above and replace them with the notice
moel@1
    32
  and other provisions required by the GPL or the LGPL. If you do not delete
moel@1
    33
  the provisions above, a recipient may use your version of this file under
moel@1
    34
  the terms of any one of the MPL, the GPL or the LGPL.
moel@1
    35
 
moel@1
    36
*/
moel@1
    37
moel@1
    38
using System;
moel@1
    39
using System.Collections.Generic;
moel@1
    40
using System.ComponentModel;
moel@1
    41
using System.Configuration;
moel@1
    42
using System.Drawing;
moel@83
    43
using System.IO;
moel@1
    44
using System.Text;
moel@1
    45
using System.Windows.Forms;
moel@1
    46
using Aga.Controls.Tree;
moel@1
    47
using Aga.Controls.Tree.NodeControls;
moel@1
    48
using OpenHardwareMonitor.Hardware;
moel@28
    49
using OpenHardwareMonitor.Utilities;
moel@1
    50
moel@1
    51
namespace OpenHardwareMonitor.GUI {
moel@1
    52
  public partial class MainForm : Form {
moel@1
    53
moel@28
    54
    private Computer computer = new Computer();
moel@1
    55
    private Node root;
moel@1
    56
    private TreeModel treeModel;
moel@1
    57
    private IDictionary<ISensor, Color> sensorPlotColors = 
moel@1
    58
      new Dictionary<ISensor, Color>();
moel@1
    59
    private Color[] plotColorPalette;
moel@40
    60
    private SensorSystemTray sensorSystemTray;
moel@40
    61
    private NotifyIcon notifyIcon;
moel@82
    62
    private StartupManager startupManager = new StartupManager();
moel@1
    63
moel@28
    64
    public MainForm() {      
moel@1
    65
      InitializeComponent();
moel@1
    66
      this.Font = SystemFonts.MessageBoxFont;
moel@1
    67
      treeView.Font = SystemFonts.MessageBoxFont;
moel@63
    68
      plotPanel.Font = SystemFonts.MessageBoxFont;
moel@1
    69
      
moel@1
    70
      nodeCheckBox.IsVisibleValueNeeded += 
moel@1
    71
        new EventHandler<NodeControlValueEventArgs>(
moel@1
    72
          nodeCheckBox_IsVisibleValueNeeded);
moel@1
    73
      nodeCheckBox.CheckStateChanged += 
moel@1
    74
        new EventHandler<TreePathEventArgs>(UpdatePlotSelection);
moel@1
    75
      nodeTextBoxText.DrawText += 
moel@1
    76
        new EventHandler<DrawEventArgs>(nodeTextBoxText_DrawText);
moel@1
    77
      nodeTextBoxValue.DrawText +=
moel@1
    78
        new EventHandler<DrawEventArgs>(nodeTextBoxText_DrawText);
moel@1
    79
      nodeTextBoxMin.DrawText +=
moel@1
    80
        new EventHandler<DrawEventArgs>(nodeTextBoxText_DrawText);
moel@1
    81
      nodeTextBoxMax.DrawText +=
moel@1
    82
        new EventHandler<DrawEventArgs>(nodeTextBoxText_DrawText);
moel@1
    83
      nodeTextBoxLimit.DrawText += 
moel@1
    84
        new EventHandler<DrawEventArgs>(nodeTextBoxLimit_DrawText);
moel@1
    85
moel@1
    86
      if (Utilities.Config.Contains("mainForm.Location.X")) {
moel@1
    87
        int x = Utilities.Config.Get("mainForm.Location.X", Location.X);
moel@1
    88
        x = x < 0 ? 0 : x;
moel@1
    89
        int y = Utilities.Config.Get("mainForm.Location.Y", Location.Y);
moel@1
    90
        y = y < 0 ? 0 : y;
moel@1
    91
        this.Location = new Point(x, y);
moel@1
    92
      } else {
moel@1
    93
        StartPosition = FormStartPosition.CenterScreen;
moel@1
    94
      }
moel@1
    95
moel@1
    96
      Width = Utilities.Config.Get("mainForm.Width", Width);
moel@1
    97
      Height = Utilities.Config.Get("mainForm.Height", Height);
moel@1
    98
         
moel@1
    99
      treeModel = new TreeModel();
moel@1
   100
      root = new Node(System.Environment.MachineName);
moel@1
   101
      root.Image = Utilities.EmbeddedResources.GetImage("computer.png");
moel@1
   102
      
moel@1
   103
      treeModel.Nodes.Add(root);
moel@1
   104
      treeView.Model = treeModel;
moel@40
   105
      
moel@40
   106
      notifyIcon = new NotifyIcon();
moel@40
   107
      notifyIcon.ContextMenuStrip = this.notifyContextMenuStrip;
moel@40
   108
      notifyIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico");
moel@40
   109
      notifyIcon.Text = "Open Hardware Monitor";      
moel@82
   110
      notifyIcon.DoubleClick += new EventHandler(this.hideShowClick);
moel@40
   111
moel@40
   112
      sensorSystemTray = new SensorSystemTray(computer);
moel@1
   113
moel@28
   114
      computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
moel@28
   115
      computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
moel@28
   116
      computer.Open();
moel@28
   117
moel@86
   118
      timer.Enabled = true;
moel@86
   119
moel@1
   120
      plotColorPalette = new Color[14];
moel@1
   121
      plotColorPalette[0] = Color.Blue;
moel@1
   122
      plotColorPalette[1] = Color.OrangeRed;
moel@1
   123
      plotColorPalette[2] = Color.Green;
moel@1
   124
      plotColorPalette[3] = Color.LightSeaGreen;
moel@1
   125
      plotColorPalette[4] = Color.Goldenrod;
moel@1
   126
      plotColorPalette[5] = Color.DarkViolet;
moel@1
   127
      plotColorPalette[6] = Color.YellowGreen;
moel@1
   128
      plotColorPalette[7] = Color.SaddleBrown;
moel@1
   129
      plotColorPalette[8] = Color.Gray;
moel@1
   130
      plotColorPalette[9] = Color.RoyalBlue;
moel@1
   131
      plotColorPalette[10] = Color.DeepPink;
moel@1
   132
      plotColorPalette[11] = Color.MediumSeaGreen;
moel@1
   133
      plotColorPalette[12] = Color.Olive;
moel@1
   134
      plotColorPalette[13] = Color.Firebrick;
moel@1
   135
moel@28
   136
      plotMenuItem.Checked = Config.Get(plotMenuItem.Name, false);
moel@28
   137
      minMenuItem.Checked = Config.Get(minMenuItem.Name, false);
moel@28
   138
      maxMenuItem.Checked = Config.Get(maxMenuItem.Name, true);
moel@28
   139
      limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false);
moel@1
   140
moel@55
   141
      startMinMenuItem.Checked = Config.Get(startMinMenuItem.Name, false); 
moel@28
   142
      minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true);
moel@82
   143
      startupMenuItem.Checked = startupManager.Startup;
moel@28
   144
      hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true);
moel@1
   145
moel@28
   146
      voltMenuItem.Checked = Config.Get(voltMenuItem.Name, true);
moel@28
   147
      clocksMenuItem.Checked = Config.Get(clocksMenuItem.Name, true);
moel@28
   148
      loadMenuItem.Checked = Config.Get(loadMenuItem.Name, true);
moel@28
   149
      tempMenuItem.Checked = Config.Get(tempMenuItem.Name, true);
moel@28
   150
      fansMenuItem.Checked = Config.Get(fansMenuItem.Name, true);
moel@83
   151
      flowsMenuItem.Checked = Config.Get(flowsMenuItem.Name, true);    
moel@55
   152
moel@55
   153
      if (startMinMenuItem.Checked) {
moel@82
   154
        if (!minTrayMenuItem.Checked) {
moel@55
   155
          WindowState = FormWindowState.Minimized;
moel@55
   156
          Show();
moel@55
   157
        }
moel@55
   158
      } else {
moel@55
   159
        Show();
moel@55
   160
      }
moel@70
   161
moel@71
   162
      // Create a handle, otherwise calling Close() does not fire FormClosed     
moel@71
   163
      IntPtr handle = Handle;
moel@1
   164
    }
moel@1
   165
moel@64
   166
    private void SubHardwareAdded(IHardware hardware, Node node) {
moel@64
   167
      Node hardwareNode = new HardwareNode(hardware);
moel@64
   168
      node.Nodes.Add(hardwareNode);
moel@64
   169
      foreach (IHardware subHardware in hardware.SubHardware)
moel@64
   170
        SubHardwareAdded(subHardware, hardwareNode);  
moel@64
   171
    }
moel@64
   172
moel@28
   173
    private void HardwareAdded(IHardware hardware) {
moel@64
   174
      Node hardwareNode = new HardwareNode(hardware);
moel@64
   175
      root.Nodes.Add(hardwareNode);
moel@64
   176
      foreach (IHardware subHardware in hardware.SubHardware)
moel@64
   177
        SubHardwareAdded(subHardware, hardwareNode);     
moel@1
   178
    }
moel@1
   179
moel@28
   180
    private void HardwareRemoved(IHardware hardware) {      
moel@1
   181
      List<Node> nodesToRemove = new List<Node>();
moel@28
   182
      foreach (Node node in root.Nodes) {
moel@28
   183
        HardwareNode hardwareNode = node as HardwareNode;
moel@28
   184
        if (hardwareNode != null && hardwareNode.Hardware == hardware)
moel@28
   185
          nodesToRemove.Add(node);
moel@28
   186
      }
moel@1
   187
      foreach (Node node in nodesToRemove)
moel@1
   188
        root.Nodes.Remove(node);
moel@1
   189
    }
moel@1
   190
moel@1
   191
    private void nodeTextBoxLimit_DrawText(object sender, DrawEventArgs e) {
moel@1
   192
      SensorNode sensorNode = e.Node.Tag as SensorNode;
moel@1
   193
      if (sensorNode != null) 
moel@1
   194
        e.Text = sensorNode.ValueToString(sensorNode.Sensor.Limit);
moel@1
   195
    }
moel@1
   196
moel@1
   197
    private void nodeTextBoxText_DrawText(object sender, DrawEventArgs e) {
moel@1
   198
      if (!plotMenuItem.Checked)
moel@1
   199
        return;      
moel@1
   200
moel@1
   201
      SensorNode sensorNode = e.Node.Tag as SensorNode;
moel@1
   202
      if (sensorNode != null) {
moel@1
   203
        Color color;
moel@1
   204
        if (sensorPlotColors.TryGetValue(sensorNode.Sensor, out color)) 
moel@1
   205
          e.TextColor = color;        
moel@1
   206
      }
moel@1
   207
    }
moel@1
   208
moel@1
   209
    private void UpdatePlotSelection(object sender, 
moel@1
   210
      TreePathEventArgs e) 
moel@1
   211
    {
moel@1
   212
      List<ISensor> selected = new List<ISensor>();
moel@1
   213
      IDictionary<ISensor, Color> colors = new Dictionary<ISensor, Color>();
moel@1
   214
      int colorIndex = 0;
moel@1
   215
      foreach (TreeNodeAdv node in treeView.AllNodes) {
moel@1
   216
        SensorNode sensorNode = node.Tag as SensorNode;
moel@1
   217
        if (sensorNode != null && 
moel@1
   218
          sensorNode.Sensor.SensorType == SensorType.Temperature) {
moel@1
   219
          if (sensorNode.Plot) {
moel@1
   220
            colors.Add(sensorNode.Sensor,
moel@1
   221
              plotColorPalette[colorIndex % plotColorPalette.Length]);
moel@1
   222
            selected.Add(sensorNode.Sensor);
moel@1
   223
          }
moel@1
   224
          colorIndex++;
moel@1
   225
        }
moel@1
   226
      }
moel@1
   227
      sensorPlotColors = colors;
moel@1
   228
      plotPanel.SetSensors(selected, colors);
moel@1
   229
    }
moel@1
   230
moel@1
   231
    private void nodeCheckBox_IsVisibleValueNeeded(object sender, 
moel@1
   232
      NodeControlValueEventArgs e) {
moel@1
   233
      SensorNode node = e.Node.Tag as SensorNode;
moel@1
   234
      e.Value = (node != null) && 
moel@1
   235
        (node.Sensor.SensorType == SensorType.Temperature) && 
moel@1
   236
        plotMenuItem.Checked;
moel@1
   237
    }
moel@1
   238
moel@1
   239
    private void exitToolStripMenuItem_Click(object sender, EventArgs e) {
moel@70
   240
      Close();      
moel@1
   241
    }
moel@1
   242
moel@86
   243
    private void timer_Tick(object sender, EventArgs e) {
moel@86
   244
      computer.Update();  
moel@1
   245
      treeView.Invalidate();
moel@1
   246
      plotPanel.Invalidate();
moel@40
   247
      sensorSystemTray.Redraw();
moel@1
   248
    }
moel@1
   249
moel@1
   250
    private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
moel@28
   251
            
moel@28
   252
      Config.Set(plotMenuItem.Name, plotMenuItem.Checked);
moel@28
   253
      Config.Set(minMenuItem.Name, minMenuItem.Checked);
moel@28
   254
      Config.Set(maxMenuItem.Name, maxMenuItem.Checked);
moel@28
   255
      Config.Set(limitMenuItem.Name, limitMenuItem.Checked);
moel@1
   256
moel@55
   257
      Config.Set(startMinMenuItem.Name, startMinMenuItem.Checked);
moel@28
   258
      Config.Set(minTrayMenuItem.Name, minTrayMenuItem.Checked);
moel@28
   259
      Config.Set(hddMenuItem.Name, hddMenuItem.Checked);
moel@28
   260
moel@28
   261
      Config.Set(voltMenuItem.Name, voltMenuItem.Checked);
moel@28
   262
      Config.Set(clocksMenuItem.Name, clocksMenuItem.Checked);
moel@28
   263
      Config.Set(loadMenuItem.Name, loadMenuItem.Checked);
moel@28
   264
      Config.Set(tempMenuItem.Name, tempMenuItem.Checked);
moel@28
   265
      Config.Set(fansMenuItem.Name, fansMenuItem.Checked);
moel@82
   266
      Config.Set(flowsMenuItem.Name, flowsMenuItem.Checked);      
moel@1
   267
moel@14
   268
      if (WindowState != FormWindowState.Minimized) {
moel@28
   269
        Config.Set("mainForm.Location.X", Location.X);
moel@28
   270
        Config.Set("mainForm.Location.Y", Location.Y);
moel@28
   271
        Config.Set("mainForm.Width", Width);
moel@28
   272
        Config.Set("mainForm.Height", Height);
moel@14
   273
      }
moel@86
   274
moel@86
   275
      timer.Enabled = false;
moel@86
   276
moel@40
   277
      sensorSystemTray.Dispose();
moel@40
   278
      notifyIcon.Dispose();
moel@28
   279
      computer.Close();
moel@1
   280
    }
moel@1
   281
moel@1
   282
    private void aboutToolStripMenuItem_Click(object sender, EventArgs e) {
moel@1
   283
      new AboutBox().ShowDialog();
moel@1
   284
    }
moel@1
   285
moel@1
   286
    private void plotToolStripMenuItem_CheckedChanged(object sender, 
moel@1
   287
      EventArgs e) 
moel@1
   288
    {
moel@1
   289
      splitContainer.Panel2Collapsed = !plotMenuItem.Checked;
moel@1
   290
      treeView.Invalidate();
moel@1
   291
    }
moel@1
   292
moel@1
   293
    private void valueToolStripMenuItem_CheckedChanged(object sender, 
moel@1
   294
      EventArgs e) 
moel@1
   295
    {
moel@1
   296
      treeView.Columns[1].IsVisible = valueToolStripMenuItem.Checked;
moel@1
   297
    }
moel@1
   298
moel@1
   299
    private void minToolStripMenuItem_CheckedChanged(object sender, EventArgs e) 
moel@1
   300
    {
moel@1
   301
      treeView.Columns[2].IsVisible = minMenuItem.Checked;
moel@1
   302
    }
moel@1
   303
moel@1
   304
    private void maxToolStripMenuItem_CheckedChanged(object sender, EventArgs e) 
moel@1
   305
    {
moel@1
   306
      treeView.Columns[3].IsVisible = maxMenuItem.Checked;
moel@1
   307
    }
moel@1
   308
moel@1
   309
    private void limitToolStripMenuItem_CheckedChanged(object sender, 
moel@1
   310
      EventArgs e) {
moel@1
   311
      treeView.Columns[4].IsVisible = limitMenuItem.Checked;
moel@1
   312
    }
moel@1
   313
moel@1
   314
    private void treeView_Click(object sender, EventArgs e) {
moel@1
   315
      
moel@1
   316
      MouseEventArgs m = e as MouseEventArgs;
moel@1
   317
      if (m == null || m.Button != MouseButtons.Right)
moel@1
   318
        return;
moel@1
   319
moel@1
   320
      NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y));
moel@28
   321
      if (info.Control == null) {
moel@1
   322
        columnsContextMenuStrip.Show(treeView, m.X, m.Y);
moel@40
   323
      } else {
moel@40
   324
        SensorNode node = info.Node.Tag as SensorNode;
moel@40
   325
        if (node != null && node.Sensor != null) {
moel@40
   326
moel@40
   327
          sensorContextMenuStrip.Items.Clear();
moel@63
   328
          if (node.Sensor.Parameters.Length > 0) {
moel@63
   329
            ToolStripMenuItem item = new ToolStripMenuItem("Parameters...");
moel@63
   330
            item.Click += delegate(object obj, EventArgs args) {
moel@63
   331
              ShowParameterForm(node.Sensor);
moel@63
   332
            };
moel@63
   333
            sensorContextMenuStrip.Items.Add(item);
moel@63
   334
          }
moel@40
   335
          if (sensorSystemTray.Contains(node.Sensor)) {
moel@40
   336
            ToolStripMenuItem item = new ToolStripMenuItem("Remove From Tray");
moel@40
   337
            item.Click += delegate(object obj, EventArgs args) {
moel@40
   338
              sensorSystemTray.Remove(node.Sensor);
moel@40
   339
            };
moel@40
   340
            sensorContextMenuStrip.Items.Add(item);
moel@40
   341
          } else {
moel@40
   342
            ToolStripMenuItem item = new ToolStripMenuItem("Add To Tray");
moel@40
   343
            item.Click += delegate(object obj, EventArgs args) {
moel@42
   344
              sensorSystemTray.Add(node.Sensor, true);
moel@40
   345
            };
moel@40
   346
            sensorContextMenuStrip.Items.Add(item);
moel@40
   347
          }
moel@40
   348
          sensorContextMenuStrip.Show(treeView, m.X, m.Y);
moel@40
   349
        }
moel@40
   350
      }
moel@1
   351
    }
moel@1
   352
moel@1
   353
    private void saveReportToolStripMenuItem_Click(object sender, EventArgs e) {
moel@83
   354
      string report = computer.GetReport();
moel@83
   355
      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
moel@83
   356
        using (TextWriter w = new StreamWriter(saveFileDialog.FileName)) {
moel@83
   357
          w.Write(report);
moel@83
   358
        }
moel@83
   359
      }
moel@1
   360
    }
moel@1
   361
moel@1
   362
    private void hddsensorsToolStripMenuItem_CheckedChanged(object sender, 
moel@1
   363
      EventArgs e) 
moel@1
   364
    {
moel@28
   365
      computer.HDDEnabled = hddMenuItem.Checked;
moel@28
   366
      UpdateSensorTypeChecked(null, null);
moel@28
   367
      UpdatePlotSelection(null, null);      
moel@1
   368
    }
moel@1
   369
moel@64
   370
    private void UpdateSensorTypeVisible(Node node) {
moel@64
   371
      HardwareNode hardwareNode = node as HardwareNode;
moel@64
   372
      if (hardwareNode == null)
moel@64
   373
        return;
moel@64
   374
moel@64
   375
      hardwareNode.SetVisible(SensorType.Voltage, voltMenuItem.Checked);
moel@64
   376
      hardwareNode.SetVisible(SensorType.Clock, clocksMenuItem.Checked);
moel@64
   377
      hardwareNode.SetVisible(SensorType.Load, loadMenuItem.Checked);
moel@64
   378
      hardwareNode.SetVisible(SensorType.Temperature, tempMenuItem.Checked);
moel@64
   379
      hardwareNode.SetVisible(SensorType.Fan, fansMenuItem.Checked);
moel@64
   380
      hardwareNode.SetVisible(SensorType.Flow, flowsMenuItem.Checked);
moel@64
   381
moel@64
   382
      foreach (Node n in node.Nodes)
moel@64
   383
        UpdateSensorTypeVisible(n);
moel@64
   384
    }
moel@64
   385
moel@64
   386
    private void UpdateSensorTypeChecked(object sender, EventArgs e) {          
moel@64
   387
      foreach (HardwareNode node in root.Nodes) 
moel@64
   388
        UpdateSensorTypeVisible(node);
moel@27
   389
    }
moel@27
   390
moel@82
   391
    private void SysTrayHideShow() {
moel@82
   392
      Visible = !Visible;
moel@82
   393
      if (Visible)
moel@82
   394
        Activate();    
moel@27
   395
    }
moel@27
   396
moel@27
   397
    protected override void WndProc(ref Message m) {
moel@27
   398
      const int WM_SYSCOMMAND = 0x112;
moel@27
   399
      const int SC_MINIMIZE = 0xF020;
moel@28
   400
      if (minTrayMenuItem.Checked && 
moel@28
   401
        m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE) {
moel@82
   402
        SysTrayHideShow();
moel@27
   403
      } else {      
moel@27
   404
        base.WndProc(ref m);
moel@27
   405
      }
moel@27
   406
    }
moel@27
   407
moel@82
   408
    private void hideShowClick(object sender, EventArgs e) {
moel@82
   409
      SysTrayHideShow();
moel@27
   410
    }
moel@27
   411
moel@40
   412
    private void removeToolStripMenuItem_Click(object sender, EventArgs e) {
moel@40
   413
      ToolStripMenuItem item = sender as ToolStripMenuItem;
moel@40
   414
      if (item == null)
moel@40
   415
        return;
moel@40
   416
moel@40
   417
      ISensor sensor = item.Owner.Tag as ISensor;
moel@40
   418
      if (sensor == null)
moel@40
   419
        return;
moel@40
   420
moel@40
   421
      sensorSystemTray.Remove(sensor);
moel@40
   422
    }
moel@63
   423
moel@63
   424
    private void ShowParameterForm(ISensor sensor) {
moel@63
   425
      ParameterForm form = new ParameterForm();
moel@63
   426
      form.Parameters = sensor.Parameters;
moel@63
   427
      form.captionLabel.Text = sensor.Name;
moel@63
   428
      form.ShowDialog();
moel@63
   429
    }
moel@63
   430
moel@63
   431
    private void treeView_NodeMouseDoubleClick(object sender, 
moel@63
   432
      TreeNodeAdvMouseEventArgs e) {
moel@63
   433
      SensorNode node = e.Node.Tag as SensorNode;
moel@63
   434
      if (node != null && node.Sensor != null && 
moel@63
   435
        node.Sensor.Parameters.Length > 0) {
moel@63
   436
        ShowParameterForm(node.Sensor);
moel@63
   437
      }
moel@63
   438
    }
moel@82
   439
moel@82
   440
    private void runOnWindowsStartupToolStripMenuItem_CheckedChanged(
moel@82
   441
      object sender, EventArgs e) 
moel@82
   442
    {
moel@82
   443
      startupManager.Startup = startupMenuItem.Checked;
moel@82
   444
    }
moel@82
   445
moel@82
   446
    private void minTrayMenuItem_CheckedChanged(object sender, EventArgs e) {
moel@82
   447
      notifyIcon.Visible = minTrayMenuItem.Checked;
moel@82
   448
    }
moel@1
   449
  }
moel@1
   450
}