GUI/MainForm.cs
author moel.mich
Sat, 05 Jun 2010 11:15:16 +0000
changeset 132 680ed54e05ca
parent 126 2354fdb91ac4
child 133 9ad699538c89
permissions -rw-r--r--
Fixed Issue 23.
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@110
    63
    private UpdateVisitor updateVisitor = new UpdateVisitor();
moel@1
    64
moel@28
    65
    public MainForm() {      
moel@1
    66
      InitializeComponent();
moel@1
    67
      this.Font = SystemFonts.MessageBoxFont;
moel@1
    68
      treeView.Font = SystemFonts.MessageBoxFont;
moel@63
    69
      plotPanel.Font = SystemFonts.MessageBoxFont;
moel@1
    70
      
moel@1
    71
      nodeCheckBox.IsVisibleValueNeeded += 
moel@1
    72
        new EventHandler<NodeControlValueEventArgs>(
moel@1
    73
          nodeCheckBox_IsVisibleValueNeeded);
moel@1
    74
      nodeCheckBox.CheckStateChanged += 
moel@1
    75
        new EventHandler<TreePathEventArgs>(UpdatePlotSelection);
moel@1
    76
      nodeTextBoxText.DrawText += 
moel@1
    77
        new EventHandler<DrawEventArgs>(nodeTextBoxText_DrawText);
moel@1
    78
      nodeTextBoxValue.DrawText +=
moel@1
    79
        new EventHandler<DrawEventArgs>(nodeTextBoxText_DrawText);
moel@1
    80
      nodeTextBoxMin.DrawText +=
moel@1
    81
        new EventHandler<DrawEventArgs>(nodeTextBoxText_DrawText);
moel@1
    82
      nodeTextBoxMax.DrawText +=
moel@1
    83
        new EventHandler<DrawEventArgs>(nodeTextBoxText_DrawText);
moel@1
    84
      nodeTextBoxLimit.DrawText += 
moel@1
    85
        new EventHandler<DrawEventArgs>(nodeTextBoxLimit_DrawText);
moel@1
    86
moel@1
    87
      if (Utilities.Config.Contains("mainForm.Location.X")) {
moel@1
    88
        int x = Utilities.Config.Get("mainForm.Location.X", Location.X);
moel@1
    89
        x = x < 0 ? 0 : x;
moel@1
    90
        int y = Utilities.Config.Get("mainForm.Location.Y", Location.Y);
moel@1
    91
        y = y < 0 ? 0 : y;
moel@1
    92
        this.Location = new Point(x, y);
moel@1
    93
      } else {
moel@1
    94
        StartPosition = FormStartPosition.CenterScreen;
moel@1
    95
      }
moel@1
    96
moel@1
    97
      Width = Utilities.Config.Get("mainForm.Width", Width);
moel@1
    98
      Height = Utilities.Config.Get("mainForm.Height", Height);
moel@113
    99
moel@113
   100
      foreach (TreeColumn column in treeView.Columns) 
moel@113
   101
        column.Width = Math.Max(20, Math.Min(400, 
moel@113
   102
          Config.Get("treeView.Columns." + column.Header + ".Width",
moel@113
   103
          column.Width)));
moel@113
   104
moel@1
   105
      treeModel = new TreeModel();
moel@1
   106
      root = new Node(System.Environment.MachineName);
moel@1
   107
      root.Image = Utilities.EmbeddedResources.GetImage("computer.png");
moel@1
   108
      
moel@1
   109
      treeModel.Nodes.Add(root);
moel@1
   110
      treeView.Model = treeModel;
moel@40
   111
      
moel@40
   112
      notifyIcon = new NotifyIcon();
moel@40
   113
      notifyIcon.ContextMenuStrip = this.notifyContextMenuStrip;
moel@40
   114
      notifyIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico");
moel@40
   115
      notifyIcon.Text = "Open Hardware Monitor";      
moel@82
   116
      notifyIcon.DoubleClick += new EventHandler(this.hideShowClick);
moel@40
   117
moel@40
   118
      sensorSystemTray = new SensorSystemTray(computer);
moel@1
   119
moel@28
   120
      computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
moel@28
   121
      computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
moel@28
   122
      computer.Open();
moel@28
   123
moel@86
   124
      timer.Enabled = true;
moel@86
   125
moel@111
   126
      plotColorPalette = new Color[13];
moel@1
   127
      plotColorPalette[0] = Color.Blue;
moel@1
   128
      plotColorPalette[1] = Color.OrangeRed;
moel@1
   129
      plotColorPalette[2] = Color.Green;
moel@1
   130
      plotColorPalette[3] = Color.LightSeaGreen;
moel@1
   131
      plotColorPalette[4] = Color.Goldenrod;
moel@1
   132
      plotColorPalette[5] = Color.DarkViolet;
moel@1
   133
      plotColorPalette[6] = Color.YellowGreen;
moel@1
   134
      plotColorPalette[7] = Color.SaddleBrown;
moel@111
   135
      plotColorPalette[8] = Color.RoyalBlue;
moel@111
   136
      plotColorPalette[9] = Color.DeepPink;
moel@111
   137
      plotColorPalette[10] = Color.MediumSeaGreen;
moel@111
   138
      plotColorPalette[11] = Color.Olive;
moel@111
   139
      plotColorPalette[12] = Color.Firebrick;
moel@1
   140
moel@111
   141
      hiddenMenuItem.Checked = Config.Get(hiddenMenuItem.Name, false);
moel@28
   142
      plotMenuItem.Checked = Config.Get(plotMenuItem.Name, false);
moel@111
   143
moel@111
   144
      valueMenuItem.Checked = Config.Get(valueMenuItem.Name, true);
moel@28
   145
      minMenuItem.Checked = Config.Get(minMenuItem.Name, false);
moel@28
   146
      maxMenuItem.Checked = Config.Get(maxMenuItem.Name, true);
moel@28
   147
      limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false);
moel@1
   148
moel@55
   149
      startMinMenuItem.Checked = Config.Get(startMinMenuItem.Name, false); 
moel@28
   150
      minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true);
moel@82
   151
      startupMenuItem.Checked = startupManager.Startup;
moel@122
   152
      hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true);
moel@122
   153
moel@122
   154
      celciusToolStripMenuItem.Checked = 
moel@122
   155
        UnitManager.TemperatureUnit == TemperatureUnit.Celcius;
moel@122
   156
      fahrenheitToolStripMenuItem.Checked = !celciusToolStripMenuItem.Checked;
moel@55
   157
moel@125
   158
      // Hide the system tray and auto startup menu items on Unix
moel@125
   159
      int p = (int)System.Environment.OSVersion.Platform;
moel@125
   160
      if ((p == 4) || (p == 128)) {
moel@125
   161
        minTrayMenuItem.Visible = false;
moel@125
   162
        startupMenuItem.Visible = false;
moel@125
   163
      }
moel@125
   164
      
moel@55
   165
      if (startMinMenuItem.Checked) {
moel@82
   166
        if (!minTrayMenuItem.Checked) {
moel@55
   167
          WindowState = FormWindowState.Minimized;
moel@55
   168
          Show();
moel@55
   169
        }
moel@55
   170
      } else {
moel@55
   171
        Show();
moel@55
   172
      }
moel@70
   173
moel@71
   174
      // Create a handle, otherwise calling Close() does not fire FormClosed     
moel@71
   175
      IntPtr handle = Handle;
moel@128
   176
moel@128
   177
      // Make sure the settings are saved when the user logs off
moel@128
   178
      Microsoft.Win32.SystemEvents.SessionEnded +=
moel@128
   179
        delegate(object sender, Microsoft.Win32.SessionEndedEventArgs e) {
moel@128
   180
          SaveConfiguration();
moel@128
   181
        };
moel@1
   182
    }
moel@128
   183
    
moel@64
   184
    private void SubHardwareAdded(IHardware hardware, Node node) {
moel@64
   185
      Node hardwareNode = new HardwareNode(hardware);
moel@64
   186
      node.Nodes.Add(hardwareNode);
moel@64
   187
      foreach (IHardware subHardware in hardware.SubHardware)
moel@64
   188
        SubHardwareAdded(subHardware, hardwareNode);  
moel@64
   189
    }
moel@64
   190
moel@28
   191
    private void HardwareAdded(IHardware hardware) {
moel@64
   192
      Node hardwareNode = new HardwareNode(hardware);
moel@64
   193
      root.Nodes.Add(hardwareNode);
moel@64
   194
      foreach (IHardware subHardware in hardware.SubHardware)
moel@64
   195
        SubHardwareAdded(subHardware, hardwareNode);     
moel@1
   196
    }
moel@1
   197
moel@28
   198
    private void HardwareRemoved(IHardware hardware) {      
moel@1
   199
      List<Node> nodesToRemove = new List<Node>();
moel@28
   200
      foreach (Node node in root.Nodes) {
moel@28
   201
        HardwareNode hardwareNode = node as HardwareNode;
moel@28
   202
        if (hardwareNode != null && hardwareNode.Hardware == hardware)
moel@28
   203
          nodesToRemove.Add(node);
moel@28
   204
      }
moel@1
   205
      foreach (Node node in nodesToRemove)
moel@1
   206
        root.Nodes.Remove(node);
moel@1
   207
    }
moel@1
   208
moel@1
   209
    private void nodeTextBoxLimit_DrawText(object sender, DrawEventArgs e) {
moel@1
   210
      SensorNode sensorNode = e.Node.Tag as SensorNode;
moel@1
   211
      if (sensorNode != null) 
moel@1
   212
        e.Text = sensorNode.ValueToString(sensorNode.Sensor.Limit);
moel@1
   213
    }
moel@1
   214
moel@111
   215
    private void nodeTextBoxText_DrawText(object sender, DrawEventArgs e) {       
moel@111
   216
      Node node = e.Node.Tag as Node;
moel@111
   217
      if (node != null) {
moel@1
   218
        Color color;
moel@111
   219
        if (node.IsVisible) {
moel@111
   220
          SensorNode sensorNode = node as SensorNode;
moel@111
   221
          if (plotMenuItem.Checked && sensorNode != null &&
moel@111
   222
            sensorPlotColors.TryGetValue(sensorNode.Sensor, out color))
moel@111
   223
            e.TextColor = color;
moel@111
   224
        } else {
moel@111
   225
          e.TextColor = Color.DarkGray;
moel@111
   226
        }
moel@1
   227
      }
moel@1
   228
    }
moel@1
   229
moel@1
   230
    private void UpdatePlotSelection(object sender, 
moel@1
   231
      TreePathEventArgs e) 
moel@1
   232
    {
moel@1
   233
      List<ISensor> selected = new List<ISensor>();
moel@1
   234
      IDictionary<ISensor, Color> colors = new Dictionary<ISensor, Color>();
moel@1
   235
      int colorIndex = 0;
moel@1
   236
      foreach (TreeNodeAdv node in treeView.AllNodes) {
moel@1
   237
        SensorNode sensorNode = node.Tag as SensorNode;
moel@1
   238
        if (sensorNode != null && 
moel@1
   239
          sensorNode.Sensor.SensorType == SensorType.Temperature) {
moel@1
   240
          if (sensorNode.Plot) {
moel@1
   241
            colors.Add(sensorNode.Sensor,
moel@1
   242
              plotColorPalette[colorIndex % plotColorPalette.Length]);
moel@1
   243
            selected.Add(sensorNode.Sensor);
moel@1
   244
          }
moel@1
   245
          colorIndex++;
moel@1
   246
        }
moel@1
   247
      }
moel@1
   248
      sensorPlotColors = colors;
moel@1
   249
      plotPanel.SetSensors(selected, colors);
moel@1
   250
    }
moel@1
   251
moel@1
   252
    private void nodeCheckBox_IsVisibleValueNeeded(object sender, 
moel@1
   253
      NodeControlValueEventArgs e) {
moel@1
   254
      SensorNode node = e.Node.Tag as SensorNode;
moel@1
   255
      e.Value = (node != null) && 
moel@1
   256
        (node.Sensor.SensorType == SensorType.Temperature) && 
moel@1
   257
        plotMenuItem.Checked;
moel@1
   258
    }
moel@1
   259
moel@1
   260
    private void exitToolStripMenuItem_Click(object sender, EventArgs e) {
moel@70
   261
      Close();      
moel@1
   262
    }
moel@1
   263
moel@86
   264
    private void timer_Tick(object sender, EventArgs e) {
moel@110
   265
      computer.Accept(updateVisitor);
moel@1
   266
      treeView.Invalidate();
moel@1
   267
      plotPanel.Invalidate();
moel@40
   268
      sensorSystemTray.Redraw();
moel@1
   269
    }
moel@1
   270
moel@128
   271
    private void SaveConfiguration() {
moel@111
   272
      Config.Set(hiddenMenuItem.Name, hiddenMenuItem.Checked);
moel@28
   273
      Config.Set(plotMenuItem.Name, plotMenuItem.Checked);
moel@111
   274
moel@111
   275
      Config.Set(valueMenuItem.Name, valueMenuItem.Checked);
moel@28
   276
      Config.Set(minMenuItem.Name, minMenuItem.Checked);
moel@28
   277
      Config.Set(maxMenuItem.Name, maxMenuItem.Checked);
moel@28
   278
      Config.Set(limitMenuItem.Name, limitMenuItem.Checked);
moel@1
   279
moel@55
   280
      Config.Set(startMinMenuItem.Name, startMinMenuItem.Checked);
moel@28
   281
      Config.Set(minTrayMenuItem.Name, minTrayMenuItem.Checked);
moel@128
   282
      Config.Set(hddMenuItem.Name, hddMenuItem.Checked);
moel@1
   283
moel@14
   284
      if (WindowState != FormWindowState.Minimized) {
moel@28
   285
        Config.Set("mainForm.Location.X", Location.X);
moel@28
   286
        Config.Set("mainForm.Location.Y", Location.Y);
moel@28
   287
        Config.Set("mainForm.Width", Width);
moel@28
   288
        Config.Set("mainForm.Height", Height);
moel@14
   289
      }
moel@86
   290
moel@128
   291
      foreach (TreeColumn column in treeView.Columns)
moel@128
   292
        Config.Set("treeView.Columns." + column.Header + ".Width",
moel@113
   293
          column.Width);
moel@113
   294
moel@128
   295
      Config.Save();
moel@128
   296
    }
moel@128
   297
moel@128
   298
    private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
moel@128
   299
      SaveConfiguration();
moel@128
   300
moel@86
   301
      timer.Enabled = false;
moel@40
   302
      sensorSystemTray.Dispose();
moel@40
   303
      notifyIcon.Dispose();
moel@28
   304
      computer.Close();
moel@1
   305
    }
moel@1
   306
moel@1
   307
    private void aboutToolStripMenuItem_Click(object sender, EventArgs e) {
moel@1
   308
      new AboutBox().ShowDialog();
moel@1
   309
    }
moel@1
   310
moel@1
   311
    private void plotToolStripMenuItem_CheckedChanged(object sender, 
moel@1
   312
      EventArgs e) 
moel@1
   313
    {
moel@1
   314
      splitContainer.Panel2Collapsed = !plotMenuItem.Checked;
moel@1
   315
      treeView.Invalidate();
moel@1
   316
    }
moel@1
   317
moel@1
   318
    private void treeView_Click(object sender, EventArgs e) {
moel@1
   319
      
moel@1
   320
      MouseEventArgs m = e as MouseEventArgs;
moel@1
   321
      if (m == null || m.Button != MouseButtons.Right)
moel@1
   322
        return;
moel@1
   323
moel@1
   324
      NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y));
moel@111
   325
      if (info.Control != null) {
moel@40
   326
        SensorNode node = info.Node.Tag as SensorNode;
moel@40
   327
        if (node != null && node.Sensor != null) {
moel@40
   328
moel@40
   329
          sensorContextMenuStrip.Items.Clear();
moel@63
   330
          if (node.Sensor.Parameters.Length > 0) {
moel@63
   331
            ToolStripMenuItem item = new ToolStripMenuItem("Parameters...");
moel@63
   332
            item.Click += delegate(object obj, EventArgs args) {
moel@63
   333
              ShowParameterForm(node.Sensor);
moel@63
   334
            };
moel@63
   335
            sensorContextMenuStrip.Items.Add(item);
moel@63
   336
          }
moel@111
   337
          if (node.IsVisible) {
moel@111
   338
            ToolStripMenuItem item = new ToolStripMenuItem("Hide");
moel@111
   339
            item.Click += delegate(object obj, EventArgs args) {
moel@111
   340
              node.IsVisible = false;
moel@111
   341
            };
moel@111
   342
            sensorContextMenuStrip.Items.Add(item);
moel@111
   343
          } else {
moel@111
   344
            ToolStripMenuItem item = new ToolStripMenuItem("Unhide");
moel@111
   345
            item.Click += delegate(object obj, EventArgs args) {
moel@111
   346
              node.IsVisible = true;
moel@111
   347
            };
moel@111
   348
            sensorContextMenuStrip.Items.Add(item);
moel@111
   349
          }         
moel@40
   350
          if (sensorSystemTray.Contains(node.Sensor)) {
moel@40
   351
            ToolStripMenuItem item = new ToolStripMenuItem("Remove From Tray");
moel@40
   352
            item.Click += delegate(object obj, EventArgs args) {
moel@40
   353
              sensorSystemTray.Remove(node.Sensor);
moel@40
   354
            };
moel@40
   355
            sensorContextMenuStrip.Items.Add(item);
moel@40
   356
          } else {
moel@40
   357
            ToolStripMenuItem item = new ToolStripMenuItem("Add To Tray");
moel@40
   358
            item.Click += delegate(object obj, EventArgs args) {
moel@42
   359
              sensorSystemTray.Add(node.Sensor, true);
moel@40
   360
            };
moel@40
   361
            sensorContextMenuStrip.Items.Add(item);
moel@40
   362
          }
moel@40
   363
          sensorContextMenuStrip.Show(treeView, m.X, m.Y);
moel@40
   364
        }
moel@40
   365
      }
moel@1
   366
    }
moel@1
   367
moel@1
   368
    private void saveReportToolStripMenuItem_Click(object sender, EventArgs e) {
moel@83
   369
      string report = computer.GetReport();
moel@83
   370
      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
moel@83
   371
        using (TextWriter w = new StreamWriter(saveFileDialog.FileName)) {
moel@83
   372
          w.Write(report);
moel@83
   373
        }
moel@83
   374
      }
moel@1
   375
    }
moel@1
   376
moel@1
   377
    private void hddsensorsToolStripMenuItem_CheckedChanged(object sender, 
moel@1
   378
      EventArgs e) 
moel@1
   379
    {
moel@28
   380
      computer.HDDEnabled = hddMenuItem.Checked;
moel@28
   381
      UpdatePlotSelection(null, null);      
moel@1
   382
    }
moel@1
   383
moel@82
   384
    private void SysTrayHideShow() {
moel@82
   385
      Visible = !Visible;
moel@82
   386
      if (Visible)
moel@82
   387
        Activate();    
moel@27
   388
    }
moel@27
   389
moel@27
   390
    protected override void WndProc(ref Message m) {
moel@27
   391
      const int WM_SYSCOMMAND = 0x112;
moel@27
   392
      const int SC_MINIMIZE = 0xF020;
moel@28
   393
      if (minTrayMenuItem.Checked && 
moel@28
   394
        m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE) {
moel@82
   395
        SysTrayHideShow();
moel@27
   396
      } else {      
moel@27
   397
        base.WndProc(ref m);
moel@27
   398
      }
moel@27
   399
    }
moel@27
   400
moel@82
   401
    private void hideShowClick(object sender, EventArgs e) {
moel@82
   402
      SysTrayHideShow();
moel@27
   403
    }
moel@27
   404
moel@40
   405
    private void removeToolStripMenuItem_Click(object sender, EventArgs e) {
moel@40
   406
      ToolStripMenuItem item = sender as ToolStripMenuItem;
moel@40
   407
      if (item == null)
moel@40
   408
        return;
moel@40
   409
moel@40
   410
      ISensor sensor = item.Owner.Tag as ISensor;
moel@40
   411
      if (sensor == null)
moel@40
   412
        return;
moel@40
   413
moel@40
   414
      sensorSystemTray.Remove(sensor);
moel@40
   415
    }
moel@63
   416
moel@63
   417
    private void ShowParameterForm(ISensor sensor) {
moel@63
   418
      ParameterForm form = new ParameterForm();
moel@63
   419
      form.Parameters = sensor.Parameters;
moel@63
   420
      form.captionLabel.Text = sensor.Name;
moel@63
   421
      form.ShowDialog();
moel@63
   422
    }
moel@63
   423
moel@63
   424
    private void treeView_NodeMouseDoubleClick(object sender, 
moel@63
   425
      TreeNodeAdvMouseEventArgs e) {
moel@63
   426
      SensorNode node = e.Node.Tag as SensorNode;
moel@63
   427
      if (node != null && node.Sensor != null && 
moel@63
   428
        node.Sensor.Parameters.Length > 0) {
moel@63
   429
        ShowParameterForm(node.Sensor);
moel@63
   430
      }
moel@63
   431
    }
moel@82
   432
moel@82
   433
    private void runOnWindowsStartupToolStripMenuItem_CheckedChanged(
moel@82
   434
      object sender, EventArgs e) 
moel@82
   435
    {
moel@82
   436
      startupManager.Startup = startupMenuItem.Checked;
moel@82
   437
    }
moel@82
   438
moel@82
   439
    private void minTrayMenuItem_CheckedChanged(object sender, EventArgs e) {
moel@82
   440
      notifyIcon.Visible = minTrayMenuItem.Checked;
moel@82
   441
    }
moel@111
   442
moel@111
   443
    private void hiddenSensorsMenuItem_CheckedChanged(object sender, 
moel@111
   444
      EventArgs e) {
moel@111
   445
      treeModel.ForceVisible = hiddenMenuItem.Checked;
moel@111
   446
    }
moel@111
   447
moel@111
   448
    private void valueMenuItem_CheckedChanged(object sender, EventArgs e) {
moel@111
   449
      treeView.Columns[1].IsVisible = valueMenuItem.Checked;
moel@111
   450
    }
moel@111
   451
moel@111
   452
    private void minMenuItem_CheckedChanged(object sender, EventArgs e) {
moel@111
   453
      treeView.Columns[2].IsVisible = minMenuItem.Checked;
moel@111
   454
    }
moel@111
   455
moel@111
   456
    private void maxMenuItem_CheckedChanged(object sender, EventArgs e) {
moel@111
   457
      treeView.Columns[3].IsVisible = maxMenuItem.Checked;
moel@111
   458
    }
moel@111
   459
moel@111
   460
    private void limitMenuItem_CheckedChanged(object sender, EventArgs e) {
moel@111
   461
      treeView.Columns[4].IsVisible = limitMenuItem.Checked;
moel@111
   462
    }
moel@122
   463
moel@122
   464
    private void celciusToolStripMenuItem_Click(object sender, EventArgs e) {
moel@122
   465
      celciusToolStripMenuItem.Checked = true;
moel@122
   466
      fahrenheitToolStripMenuItem.Checked = false;
moel@122
   467
      UnitManager.TemperatureUnit = TemperatureUnit.Celcius;
moel@122
   468
    }
moel@122
   469
moel@122
   470
    private void fahrenheitToolStripMenuItem_Click(object sender, EventArgs e) {
moel@122
   471
      celciusToolStripMenuItem.Checked = false;
moel@122
   472
      fahrenheitToolStripMenuItem.Checked = true;
moel@122
   473
      UnitManager.TemperatureUnit = TemperatureUnit.Fahrenheit;
moel@122
   474
    }
moel@1
   475
  }
moel@1
   476
}