GUI/MainForm.cs
branchMiniDisplay
changeset 435 9ffcd8ed8537
parent 434 480652d72031
child 436 e9aefd454d1e
     1.1 --- a/GUI/MainForm.cs	Sun Feb 03 19:06:01 2013 +0100
     1.2 +++ b/GUI/MainForm.cs	Mon Feb 04 00:47:01 2013 +0100
     1.3 @@ -25,6 +25,7 @@
     1.4  using OpenHardwareMonitor.WMI;
     1.5  using OpenHardwareMonitor.Utilities;
     1.6  
     1.7 +
     1.8  namespace OpenHardwareMonitor.GUI {
     1.9    public partial class MainForm : Form {
    1.10  
    1.11 @@ -133,17 +134,6 @@
    1.12        systemTray.ExitCommand += exitClick;
    1.13    
    1.14        soundGraphDisplay = new SoundGraphDisplay(computer, settings, unitManager);
    1.15 -      if (soundGraphDisplay.IsDllLoaded)
    1.16 -      {
    1.17 -          //Try init
    1.18 -          //NativeWindow window;
    1.19 -          
    1.20 -
    1.21 -          //= Window.GetWindow(this);
    1.22 -          //var wih = new WindowInteropHelper(window);
    1.23 -          //IntPtr hWnd = wih.Handle;
    1.24 -      }
    1.25 -      
    1.26   
    1.27  
    1.28        int p = (int)Environment.OSVersion.Platform;
    1.29 @@ -328,6 +318,20 @@
    1.30  
    1.31        InitializePlotForm();
    1.32  
    1.33 +      //
    1.34 +      if (soundGraphDisplay.IsDllLoaded)
    1.35 +      {
    1.36 +          //Try init
    1.37 +          //NativeWindow window;
    1.38 +          soundGraphDisplay.Init(Handle);
    1.39 +
    1.40 +          //= Window.GetWindow(this);
    1.41 +          //var wih = new WindowInteropHelper(window);
    1.42 +          //IntPtr hWnd = wih.Handle;
    1.43 +      }
    1.44 +      
    1.45 +
    1.46 +
    1.47        startupMenuItem.Visible = startupManager.IsAvailable;
    1.48        
    1.49        if (startMinMenuItem.Checked) {
    1.50 @@ -773,25 +777,64 @@
    1.51        const int SC_MINIMIZE = 0xF020;
    1.52        const int SC_CLOSE = 0xF060;
    1.53  
    1.54 -      if (minimizeToTray.Value && 
    1.55 -        m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_MINIMIZE) {
    1.56 -        SysTrayHideShow();
    1.57 -      } else if (minimizeOnClose.Value &&
    1.58 -        m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_CLOSE) {
    1.59 -        /*
    1.60 -         * Apparently the user wants to minimize rather than close
    1.61 -         * Now we still need to check if we're going to the tray or not
    1.62 -         * 
    1.63 -         * Note: the correct way to do this would be to send out SC_MINIMIZE,
    1.64 -         * but since the code here is so simple,
    1.65 -         * that would just be a waste of time.
    1.66 -         */
    1.67 -        if (minimizeToTray.Value)
    1.68 +      if (m.Msg == SoundGraph.WM_DSP_PLUGIN_NOTIFY)
    1.69 +      {
    1.70 +        //Handling messages from our iMON Display
    1.71 +          switch ((SoundGraph.DSPNotifyCode)m.WParam.ToInt32())
    1.72 +          {
    1.73 +              case SoundGraph.DSPNotifyCode.DSPNM_PLUGIN_SUCCEED:
    1.74 +              case SoundGraph.DSPNotifyCode.DSPNM_IMON_RESTARTED:
    1.75 +              case SoundGraph.DSPNotifyCode.DSPNM_HW_CONNECTED:
    1.76 +                  {
    1.77 +                      //Connection with our display is now open
    1.78 +                      //Check if we have LCD or VFD
    1.79 +                      //if ((lParam & DSPN_DSP_VFD) == DSPN_DSP_VFD) m_bVfdConnected = TRUE;
    1.80 +                      //if ((lParam & DSPN_DSP_LCD) == DSPN_DSP_LCD) m_bLcdConnected = TRUE;
    1.81 +                      soundGraphDisplay.DisplayPluginMessage(m.WParam.ToInt32(),false);
    1.82 +                  }
    1.83 +                  break;
    1.84 +
    1.85 +              case SoundGraph.DSPNotifyCode.DSPNM_PLUGIN_FAILED:
    1.86 +              case SoundGraph.DSPNotifyCode.DSPNM_HW_DISCONNECTED:
    1.87 +              case SoundGraph.DSPNotifyCode.DSPNM_IMON_CLOSED:
    1.88 +                  {
    1.89 +                      //Connection with our display is closed
    1.90 +                      soundGraphDisplay.DisplayPluginMessage(m.LParam.ToInt32(), true);
    1.91 +                  }
    1.92 +                  break;
    1.93 +
    1.94 +              case SoundGraph.DSPNotifyCode.DSPNM_LCD_TEXT_SCROLL_DONE:
    1.95 +                  {
    1.96 +                      //Scroll finnished
    1.97 +                  }
    1.98 +                  break;
    1.99 +          }
   1.100 +
   1.101 +      }
   1.102 +      else if (minimizeToTray.Value &&
   1.103 +        m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_MINIMIZE)
   1.104 +      {
   1.105            SysTrayHideShow();
   1.106 -        else
   1.107 -          WindowState = FormWindowState.Minimized;
   1.108 -      } else {      
   1.109 -        base.WndProc(ref m);
   1.110 +      }
   1.111 +      else if (minimizeOnClose.Value &&
   1.112 +      m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_CLOSE)
   1.113 +      {
   1.114 +          /*
   1.115 +           * Apparently the user wants to minimize rather than close
   1.116 +           * Now we still need to check if we're going to the tray or not
   1.117 +           * 
   1.118 +           * Note: the correct way to do this would be to send out SC_MINIMIZE,
   1.119 +           * but since the code here is so simple,
   1.120 +           * that would just be a waste of time.
   1.121 +           */
   1.122 +          if (minimizeToTray.Value)
   1.123 +              SysTrayHideShow();
   1.124 +          else
   1.125 +              WindowState = FormWindowState.Minimized;
   1.126 +      }
   1.127 +      else
   1.128 +      {
   1.129 +          base.WndProc(ref m);
   1.130        }
   1.131      }
   1.132