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