# HG changeset patch
# User moel.mich
# Date 1285880361 0
# Node ID 551243a66b326d416d16f9ee01929a5a2b5fa9dd
# Parent  958e9fe8afdf92f4dd40b58a02ea39bc3e1fa413
Fixed some problems when compiling in Mono and running on Linux.

diff -r 958e9fe8afdf -r 551243a66b32 GUI/Gadget.cs
--- a/GUI/Gadget.cs	Thu Sep 30 16:51:09 2010 +0000
+++ b/GUI/Gadget.cs	Thu Sep 30 20:59:21 2010 +0000
@@ -1,4 +1,4 @@
-/*
+/*
   
   Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
@@ -166,14 +166,17 @@
       }
       set {
         if (value != window.Visible) {
+          window.Visible = value;
           if (value)
-            Redraw();
-          window.Visible = value;
+            Redraw();          
         }
       }
     }
 
     public void Redraw() {
+      if (!window.Visible)
+        return;
+      
       if (window.Size != buffer.Size) {
         DisposeBuffer();
         CreateBuffer();
diff -r 958e9fe8afdf -r 551243a66b32 GUI/GadgetWindow.cs
--- a/GUI/GadgetWindow.cs	Thu Sep 30 16:51:09 2010 +0000
+++ b/GUI/GadgetWindow.cs	Thu Sep 30 20:59:21 2010 +0000
@@ -1,4 +1,4 @@
-/*
+/*
   
   Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
@@ -69,7 +69,7 @@
       // prevent window from fading to a glass sheet when peek is invoked
       try {
         bool value = true;
-        int r = NativeMethods.DwmSetWindowAttribute(Handle,
+        NativeMethods.DwmSetWindowAttribute(Handle,
           WindowAttribute.DWMWA_EXCLUDED_FROM_PEEK, ref value,
           Marshal.SizeOf(value));
       } catch (DllNotFoundException) { } catch (EntryPointNotFoundException) { }
diff -r 958e9fe8afdf -r 551243a66b32 GUI/MainForm.cs
--- a/GUI/MainForm.cs	Thu Sep 30 16:51:09 2010 +0000
+++ b/GUI/MainForm.cs	Thu Sep 30 20:59:21 2010 +0000
@@ -87,16 +87,7 @@
 
       // set the DockStyle here, to avoid conflicts with the MainMenu
       this.splitContainer.Dock = DockStyle.Fill;
-      
-      int p = (int)Environment.OSVersion.Platform;
-      if ((p == 4) || (p == 128)) {
-        splitContainer.BorderStyle = BorderStyle.None;
-        splitContainer.Border3DStyle = Border3DStyle.Adjust;
-        splitContainer.SplitterWidth = 4;
-        treeView.BorderStyle = BorderStyle.Fixed3D;
-        plotPanel.BorderStyle = BorderStyle.Fixed3D;
-      }
-      
+            
       this.Font = SystemFonts.MessageBoxFont;
       treeView.Font = SystemFonts.MessageBoxFont;
       plotPanel.Font = SystemFonts.MessageBoxFont;
@@ -141,7 +132,18 @@
       systemTray.HideShowCommand += hideShowClick;
       systemTray.ExitCommand += exitClick;
 
-      gadget = new SensorGadget(computer, settings, unitManager);
+      int p = (int)Environment.OSVersion.Platform;
+      if ((p == 4) || (p == 128)) { // Unix
+        splitContainer.BorderStyle = BorderStyle.None;
+        splitContainer.Border3DStyle = Border3DStyle.Adjust;
+        splitContainer.SplitterWidth = 4;
+        treeView.BorderStyle = BorderStyle.Fixed3D;
+        plotPanel.BorderStyle = BorderStyle.Fixed3D;
+        gadgetMenuItem.Visible = false;
+        minCloseMenuItem.Visible = false;
+      } else { // Windows
+        gadget = new SensorGadget(computer, settings, unitManager);
+      }          
 
       computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
       computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
@@ -218,7 +220,8 @@
 
       showGadget = new UserOption("gadgetMenuItem", false, gadgetMenuItem, settings);
       showGadget.Changed += delegate(object sender, EventArgs e) {
-        gadget.Visible = showGadget.Value;
+        if (gadget != null) 
+          gadget.Visible = showGadget.Value;
       };
 
       celciusMenuItem.Checked = 
@@ -330,8 +333,9 @@
       computer.Accept(updateVisitor);
       treeView.Invalidate();
       plotPanel.Invalidate();
-      systemTray.Redraw();
-      gadget.Redraw();
+      systemTray.Redraw(); 
+      if (gadget != null)
+        gadget.Redraw();
     }
 
     private void SaveConfiguration() {
@@ -478,18 +482,6 @@
       SysTrayHideShow();
     }
 
-    private void removeMenuItem_Click(object sender, EventArgs e) {
-      MenuItem item = sender as MenuItem;
-      if (item == null)
-        return;
-
-      ISensor sensor = item.Parent.Tag as ISensor;
-      if (sensor == null)
-        return;
-
-      systemTray.Remove(sensor);
-    }
-
     private void ShowParameterForm(ISensor sensor) {
       ParameterForm form = new ParameterForm();
       form.Parameters = sensor.Parameters;
diff -r 958e9fe8afdf -r 551243a66b32 GUI/SensorGadget.cs
--- a/GUI/SensorGadget.cs	Thu Sep 30 16:51:09 2010 +0000
+++ b/GUI/SensorGadget.cs	Thu Sep 30 20:59:21 2010 +0000
@@ -1,4 +1,4 @@
-/*
+/*
   
   Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
@@ -391,7 +391,6 @@
     protected override void OnPaint(PaintEventArgs e) {
       Graphics g = e.Graphics;
       int w = Size.Width;
-      int h = Size.Height;
 
       g.Clear(Color.Transparent);
       
diff -r 958e9fe8afdf -r 551243a66b32 GUI/SensorNotifyIcon.cs
--- a/GUI/SensorNotifyIcon.cs	Thu Sep 30 16:51:09 2010 +0000
+++ b/GUI/SensorNotifyIcon.cs	Thu Sep 30 20:59:21 2010 +0000
@@ -1,4 +1,4 @@
-/*
+/*
   
   Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
@@ -187,7 +187,6 @@
         new Rectangle(0, 0, bitmap.Width, bitmap.Height),
         ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
 
-      int stride = data.Stride;
       IntPtr Scan0 = data.Scan0;
 
       int numBytes = bitmap.Width * bitmap.Height * 4;
diff -r 958e9fe8afdf -r 551243a66b32 Hardware/Mainboard/SuperIOHardware.cs
--- a/Hardware/Mainboard/SuperIOHardware.cs	Thu Sep 30 16:51:09 2010 +0000
+++ b/Hardware/Mainboard/SuperIOHardware.cs	Thu Sep 30 20:59:21 2010 +0000
@@ -702,11 +702,19 @@
       public readonly float Vf;
       public readonly bool Hidden;
 
+      public Voltage(string name, int index) :
+        this(name, index, false) { }
+      
       public Voltage(string name, int index, bool hidden) :
         this(name, index, 0, 1, 0, hidden) { }
-
+      
+      public Voltage(string name, int index, float ri, float rf) :
+        this(name, index, ri, rf, 0, false) { }
+      
+      // float ri = 0, float rf = 1, float vf = 0, bool hidden = false) 
+      
       public Voltage(string name, int index, 
-        float ri = 0, float rf = 1, float vf = 0, bool hidden = false) 
+        float ri, float rf, float vf, bool hidden) 
       {
         this.Name = name;
         this.Index = index;