GUI/SoundGraphDisplay.cs
author StephaneLenclud
Sun, 03 Feb 2013 19:06:01 +0100
branchMiniDisplay
changeset 434 480652d72031
parent 433 090259cfd699
child 435 9ffcd8ed8537
permissions -rw-r--r--
Now fetching some of our Sound Graph DLL function pointers.
StephaneLenclud@433
     1
/*
StephaneLenclud@433
     2
 
StephaneLenclud@433
     3
  This Source Code Form is subject to the terms of the Mozilla Public
StephaneLenclud@433
     4
  License, v. 2.0. If a copy of the MPL was not distributed with this
StephaneLenclud@433
     5
  file, You can obtain one at http://mozilla.org/MPL/2.0/.
StephaneLenclud@433
     6
 
StephaneLenclud@433
     7
  Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
StephaneLenclud@433
     8
	
StephaneLenclud@433
     9
*/
StephaneLenclud@433
    10
StephaneLenclud@433
    11
using System;
StephaneLenclud@433
    12
using System.Collections.Generic;
StephaneLenclud@433
    13
using System.Drawing;
StephaneLenclud@433
    14
using System.Text;
StephaneLenclud@433
    15
using System.Windows.Forms;
StephaneLenclud@433
    16
using OpenHardwareMonitor.Hardware;
StephaneLenclud@433
    17
using OpenHardwareMonitor.Utilities;
StephaneLenclud@433
    18
using System.Runtime.InteropServices;
StephaneLenclud@433
    19
StephaneLenclud@433
    20
StephaneLenclud@433
    21
StephaneLenclud@433
    22
static class NativeMethods
StephaneLenclud@433
    23
{
StephaneLenclud@433
    24
    [System.Flags]
StephaneLenclud@433
    25
    public enum LoadLibraryFlags : uint
StephaneLenclud@433
    26
    {
StephaneLenclud@433
    27
        DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
StephaneLenclud@433
    28
        LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
StephaneLenclud@433
    29
        LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
StephaneLenclud@433
    30
        LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
StephaneLenclud@433
    31
        LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
StephaneLenclud@433
    32
        LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
StephaneLenclud@433
    33
    }
StephaneLenclud@433
    34
StephaneLenclud@433
    35
StephaneLenclud@433
    36
    [DllImport("kernel32.dll", SetLastError = true)]
StephaneLenclud@433
    37
    public static extern IntPtr LoadLibrary(string dllToLoad);
StephaneLenclud@433
    38
StephaneLenclud@433
    39
    [DllImport("kernel32.dll")]
StephaneLenclud@433
    40
    public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryFlags dwFlags);
StephaneLenclud@433
    41
StephaneLenclud@433
    42
    [DllImport("kernel32.dll", SetLastError = true)]
StephaneLenclud@433
    43
    public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
StephaneLenclud@433
    44
StephaneLenclud@433
    45
    [DllImport("kernel32.dll", SetLastError = true)]
StephaneLenclud@433
    46
    public static extern bool FreeLibrary(IntPtr hModule);
StephaneLenclud@433
    47
}
StephaneLenclud@433
    48
StephaneLenclud@434
    49
/**
StephaneLenclud@434
    50
Definitions taken from public Sound Graph APIs.
StephaneLenclud@434
    51
 */
StephaneLenclud@434
    52
static class SoundGraph
StephaneLenclud@434
    53
{
StephaneLenclud@434
    54
    /**DSPResult
StephaneLenclud@434
    55
    @brief	These enumeration values represent the returned result for iMON Display API function calls.\n
StephaneLenclud@434
    56
			    All iMON Display API function calls return one of this result values.\n
StephaneLenclud@434
    57
			    For meaning of each result, refer the comment of each line below*/
StephaneLenclud@434
    58
    public enum DSPResult : uint
StephaneLenclud@434
    59
    {
StephaneLenclud@434
    60
	    DSP_SUCCEEDED = 0,				//// Function Call Succeeded Without Error
StephaneLenclud@434
    61
	    DSP_E_FAIL,						//// Unspecified Failure
StephaneLenclud@434
    62
	    DSP_E_OUTOFMEMORY,				//// Failed to Allocate Necessary Memory
StephaneLenclud@434
    63
	    DSP_E_INVALIDARG,				//// One or More Arguments Are Not Valid
StephaneLenclud@434
    64
	    DSP_E_NOT_INITED,				//// API is Not Initialized
StephaneLenclud@434
    65
	    DSP_E_POINTER,					//// Pointer is Not Valid
StephaneLenclud@434
    66
StephaneLenclud@434
    67
	    DSP_S_INITED = 0x1000,			//// API is Initialized
StephaneLenclud@434
    68
	    DSP_S_NOT_INITED,				//// API is Not Initialized
StephaneLenclud@434
    69
	    DSP_S_IN_PLUGIN_MODE,			//// API Can Control iMON Display (Display Plug-in Mode)
StephaneLenclud@434
    70
	    DSP_S_NOT_IN_PLUGIN_MODE,		//// API Can't Control iMON Display
StephaneLenclud@434
    71
    };
StephaneLenclud@434
    72
StephaneLenclud@434
    73
StephaneLenclud@434
    74
    /**DSPNInitResult
StephaneLenclud@434
    75
    @brief	These enumeration values represent the result status for requesting Display Plug-in Mode to iMON.\n
StephaneLenclud@434
    76
			    iMON Display API notifies one of this result values to the caller application after requesting Display Plug-in Mode to iMON.\n
StephaneLenclud@434
    77
			    For more information, refer the comment of each line below*/
StephaneLenclud@434
    78
    public enum DSPNInitResult : uint
StephaneLenclud@434
    79
    {
StephaneLenclud@434
    80
	    DSPN_SUCCEEDED = 0,				//// Display Plug-in Mode is Initialized Successfully
StephaneLenclud@434
    81
	    DSPN_ERR_IN_USED = 0x0100,		//// Display Plug-in is Already Used by Other Application
StephaneLenclud@434
    82
	    DSPN_ERR_HW_DISCONNECTED,		//// iMON HW is Not Connected
StephaneLenclud@434
    83
	    DSPN_ERR_NOT_SUPPORTED_HW,		//// The Connected iMON HW doesn't Support Display Plug-in
StephaneLenclud@434
    84
	    DSPN_ERR_PLUGIN_DISABLED,		//// Display Plug-in Mode Option is Disabled
StephaneLenclud@434
    85
	    DSPN_ERR_IMON_NO_REPLY,			//// The Latest iMON is Not Installed or iMON Not Running
StephaneLenclud@434
    86
	    DSPN_ERR_UNKNOWN = 0x0200,		//// Unknown Failure
StephaneLenclud@434
    87
    };
StephaneLenclud@434
    88
StephaneLenclud@434
    89
StephaneLenclud@434
    90
    /**DSPType
StephaneLenclud@434
    91
    @brief	These enumeration values represent display type.\n
StephaneLenclud@434
    92
			    Currently iMON Display API supports VFD and LCD products.*/
StephaneLenclud@434
    93
    public enum DSPType : uint
StephaneLenclud@434
    94
    {
StephaneLenclud@434
    95
	    DSPN_DSP_NONE	= 0,
StephaneLenclud@434
    96
	    DSPN_DSP_VFD	= 0x01,			//// VFD products
StephaneLenclud@434
    97
	    DSPN_DSP_LCD	= 0x02,			//// LCD products
StephaneLenclud@434
    98
    };
StephaneLenclud@434
    99
StephaneLenclud@434
   100
StephaneLenclud@434
   101
    /**DSPNotifyCode
StephaneLenclud@434
   102
    @brief	These enumeration values represent the notification codes.\n
StephaneLenclud@434
   103
			    iMON Display API will send or post message to the caller application.\n
StephaneLenclud@434
   104
			    The caller application should assign the message and the winodw handle to receivce message with IMON_Display_Init fucntion.\n
StephaneLenclud@434
   105
			    These enumeration values are used with WPARAM parameter of the message.\n 
StephaneLenclud@434
   106
			    For more information, see the explanation of each notification code below*/
StephaneLenclud@434
   107
    public enum DSPNotifyCode : uint
StephaneLenclud@434
   108
    {
StephaneLenclud@434
   109
	    /**DSPNM_PLUGIN_SUCCEED
StephaneLenclud@434
   110
	    @brief	When API succeeds to get the control for the display, API will post caller-specified message with DSPNM_PLUGIN_SUCCEED as WPARAM parameter.\n
StephaneLenclud@434
   111
				    LPARAM represents DSPType. This value can be 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
StephaneLenclud@434
   112
	    DSPNM_PLUGIN_SUCCEED = 0,
StephaneLenclud@434
   113
StephaneLenclud@434
   114
	    /**DSPNM_PLUGIN_FAILED
StephaneLenclud@434
   115
	    @brief	When API fails to get the control for the display, API will post caller-specified message with DSPNM_PLUGIN_FAILED as WPARAM parameter.\n
StephaneLenclud@434
   116
				    LPARAM represents error code with DSPNResult.*/
StephaneLenclud@434
   117
	    DSPNM_PLUGIN_FAILED,
StephaneLenclud@434
   118
StephaneLenclud@434
   119
	    /**DSPNM_IMON_RESTARTED
StephaneLenclud@434
   120
	    @brief	When iMON starts, API will post caller-specified message with DSPNM_IMON_RESTARTED as WPARAM parameter.\n
StephaneLenclud@434
   121
				    LPARAM represents DSPType. This value can be 0 (No Display), 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
StephaneLenclud@434
   122
	    DSPNM_IMON_RESTARTED,
StephaneLenclud@434
   123
StephaneLenclud@434
   124
	    /**DSPNM_IMON_CLOSED
StephaneLenclud@434
   125
	    @brief	When iMON closed, API will post caller-specified message with DSPNM_IMON_CLOSED as WPARAM parameter.\n
StephaneLenclud@434
   126
				    LPARAM is not used.*/
StephaneLenclud@434
   127
	    DSPNM_IMON_CLOSED,
StephaneLenclud@434
   128
StephaneLenclud@434
   129
	    /**DSPNM_HW_CONNECTED
StephaneLenclud@434
   130
	    @brief	When iMON HW newly connected, API will post caller-specified message with DSPNM_HW_CONNECTED as WPARAM parameter.\n
StephaneLenclud@434
   131
				    LPARAM represents DSPType. This value can be 0 (No Display), 0x01 (VFD), 0x02 (LCD) or 0x03 (VFD+LCD).*/
StephaneLenclud@434
   132
	    DSPNM_HW_CONNECTED,
StephaneLenclud@434
   133
StephaneLenclud@434
   134
	    /**DSPNM_HW_DISCONNECTED
StephaneLenclud@434
   135
	    @brief	When iMON HW disconnected, API will post caller-specified message with DSPNM_HW_DISCONNECTED as WPARAM parameter.\n
StephaneLenclud@434
   136
				    LPARAM is DSPNResult value, DSPN_ERR_HW_DISCONNECTED.*/
StephaneLenclud@434
   137
	    DSPNM_HW_DISCONNECTED,
StephaneLenclud@434
   138
StephaneLenclud@434
   139
StephaneLenclud@434
   140
	    /**DSPNM_LCD_TEXT_SCROLL_DONE
StephaneLenclud@434
   141
	    @brief	When iMON LCD finishes scrolling Text, API will post caller-specified message with DSPNM_LCD_TEXT_SCROLL_DONE as WPARAM parameter.\n
StephaneLenclud@434
   142
				    The caller application may need to know when text scroll is finished, for sending next text.\n
StephaneLenclud@434
   143
				    LPARAM is not used.*/
StephaneLenclud@434
   144
	    DSPNM_LCD_TEXT_SCROLL_DONE = 0x1000,
StephaneLenclud@434
   145
    };
StephaneLenclud@434
   146
StephaneLenclud@434
   147
    /// Functions
StephaneLenclud@434
   148
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
StephaneLenclud@434
   149
    public delegate DSPResult IMON_Display_Uninit();
StephaneLenclud@434
   150
StephaneLenclud@434
   151
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
StephaneLenclud@434
   152
    public delegate DSPResult IMON_Display_Init(IntPtr hwndNoti, uint uMsgNotification);
StephaneLenclud@434
   153
StephaneLenclud@434
   154
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
StephaneLenclud@434
   155
    public delegate DSPResult IMON_Display_IsInited();
StephaneLenclud@434
   156
StephaneLenclud@434
   157
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
StephaneLenclud@434
   158
    public delegate DSPResult IMON_Display_IsPluginModeEnabled();
StephaneLenclud@434
   159
StephaneLenclud@434
   160
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
StephaneLenclud@434
   161
    public delegate DSPResult IMON_Display_SetVfdText(
StephaneLenclud@434
   162
        [MarshalAs(UnmanagedType.LPWStr)] string lpsz1stLine,
StephaneLenclud@434
   163
        [MarshalAs(UnmanagedType.LPWStr)] string lpsz2ndLine);
StephaneLenclud@434
   164
StephaneLenclud@434
   165
    //IMONDSPAPI DSPResult IMON_Display_SetVfdText(LPCTSTR lpsz1stLine, LPCTSTR lpsz2ndLine);
StephaneLenclud@434
   166
StephaneLenclud@434
   167
}
StephaneLenclud@434
   168
StephaneLenclud@434
   169
StephaneLenclud@433
   170
StephaneLenclud@433
   171
namespace OpenHardwareMonitor.GUI
StephaneLenclud@433
   172
{
StephaneLenclud@433
   173
    public class SoundGraphDisplay : IDisposable
StephaneLenclud@433
   174
    {
StephaneLenclud@433
   175
        private IComputer computer;
StephaneLenclud@433
   176
        private PersistentSettings settings;
StephaneLenclud@433
   177
        private UnitManager unitManager;
StephaneLenclud@433
   178
        private List<SensorFrontView> list = new List<SensorFrontView>();
StephaneLenclud@433
   179
        //private bool mainIconEnabled = false;
StephaneLenclud@433
   180
        //private NotifyIconAdv mainIcon;
StephaneLenclud@433
   181
        IntPtr iSoundGraphDll;
StephaneLenclud@434
   182
        SoundGraph.IMON_Display_Uninit iIMON_Display_Uninit;
StephaneLenclud@434
   183
        SoundGraph.IMON_Display_Init iIMON_Display_Init;
StephaneLenclud@434
   184
        SoundGraph.IMON_Display_IsInited iIMON_Display_IsInited;
StephaneLenclud@434
   185
        SoundGraph.IMON_Display_IsPluginModeEnabled iIMON_Display_IsPluginModeEnabled;
StephaneLenclud@434
   186
        SoundGraph.IMON_Display_SetVfdText iIMON_Display_SetVfdText;
StephaneLenclud@433
   187
StephaneLenclud@433
   188
        public SoundGraphDisplay(IComputer computer, PersistentSettings settings,
StephaneLenclud@433
   189
          UnitManager unitManager)
StephaneLenclud@433
   190
        {
StephaneLenclud@433
   191
            this.computer = computer;
StephaneLenclud@433
   192
            this.settings = settings;
StephaneLenclud@433
   193
            this.unitManager = unitManager;
StephaneLenclud@433
   194
            computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
StephaneLenclud@433
   195
            computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
StephaneLenclud@433
   196
StephaneLenclud@433
   197
            //Try loading SoundGraph iMON Disaply DLL
StephaneLenclud@433
   198
            iSoundGraphDll = NativeMethods.LoadLibraryEx(@"iMONDisplay.dll", IntPtr.Zero, NativeMethods.LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH);
StephaneLenclud@433
   199
            int err=Marshal.GetLastWin32Error(); //If you 193  it means you need build for x86
StephaneLenclud@433
   200
            if (err == 193)
StephaneLenclud@433
   201
            {
StephaneLenclud@433
   202
                Console.Write(@"iMON: Cannot load x86 DLL from x64 process.");
StephaneLenclud@433
   203
            }
StephaneLenclud@433
   204
            else if (err != 0)
StephaneLenclud@433
   205
            {
StephaneLenclud@433
   206
                Console.Write(@"iMON: Error: %i - Failed to load iMONDisplay.dll", err);
StephaneLenclud@433
   207
            }
StephaneLenclud@433
   208
            else
StephaneLenclud@433
   209
            {
StephaneLenclud@433
   210
                Console.Write(@"iMON: DLL loaded.");
StephaneLenclud@434
   211
                //Gather our function pointers
StephaneLenclud@434
   212
                //TODO: Check returned pointers for validity
StephaneLenclud@434
   213
                IntPtr functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_Uninit");
StephaneLenclud@434
   214
                iIMON_Display_Uninit = (SoundGraph.IMON_Display_Uninit)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_Uninit));
StephaneLenclud@434
   215
                
StephaneLenclud@434
   216
                functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_Init");
StephaneLenclud@434
   217
                iIMON_Display_Init = (SoundGraph.IMON_Display_Init)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_Init));
StephaneLenclud@434
   218
                
StephaneLenclud@434
   219
                functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_IsInited");
StephaneLenclud@434
   220
                iIMON_Display_IsInited = (SoundGraph.IMON_Display_IsInited)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_IsInited));
StephaneLenclud@434
   221
                
StephaneLenclud@434
   222
                functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_IsPluginModeEnabled");
StephaneLenclud@434
   223
                iIMON_Display_IsPluginModeEnabled = (SoundGraph.IMON_Display_IsPluginModeEnabled)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_IsPluginModeEnabled));
StephaneLenclud@434
   224
StephaneLenclud@434
   225
                functionPointer = NativeMethods.GetProcAddress(iSoundGraphDll, "IMON_Display_SetVfdText");
StephaneLenclud@434
   226
                iIMON_Display_SetVfdText = (SoundGraph.IMON_Display_SetVfdText)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(SoundGraph.IMON_Display_SetVfdText));
StephaneLenclud@434
   227
StephaneLenclud@433
   228
            }
StephaneLenclud@433
   229
        }
StephaneLenclud@433
   230
StephaneLenclud@433
   231
        private void HardwareRemoved(IHardware hardware)
StephaneLenclud@433
   232
        {
StephaneLenclud@433
   233
            hardware.SensorAdded -= new SensorEventHandler(SensorAdded);
StephaneLenclud@433
   234
            hardware.SensorRemoved -= new SensorEventHandler(SensorRemoved);
StephaneLenclud@433
   235
            foreach (ISensor sensor in hardware.Sensors)
StephaneLenclud@433
   236
                SensorRemoved(sensor);
StephaneLenclud@433
   237
            foreach (IHardware subHardware in hardware.SubHardware)
StephaneLenclud@433
   238
                HardwareRemoved(subHardware);
StephaneLenclud@433
   239
        }
StephaneLenclud@433
   240
StephaneLenclud@433
   241
        private void HardwareAdded(IHardware hardware)
StephaneLenclud@433
   242
        {
StephaneLenclud@433
   243
            foreach (ISensor sensor in hardware.Sensors)
StephaneLenclud@433
   244
                SensorAdded(sensor);
StephaneLenclud@433
   245
            hardware.SensorAdded += new SensorEventHandler(SensorAdded);
StephaneLenclud@433
   246
            hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
StephaneLenclud@433
   247
            foreach (IHardware subHardware in hardware.SubHardware)
StephaneLenclud@433
   248
                HardwareAdded(subHardware);
StephaneLenclud@433
   249
        }
StephaneLenclud@433
   250
StephaneLenclud@433
   251
        private void SensorAdded(ISensor sensor)
StephaneLenclud@433
   252
        {
StephaneLenclud@433
   253
            if (settings.GetValue(new Identifier(sensor.Identifier,
StephaneLenclud@433
   254
              "tray").ToString(), false))
StephaneLenclud@433
   255
                Add(sensor, false);
StephaneLenclud@433
   256
        }
StephaneLenclud@433
   257
StephaneLenclud@433
   258
        private void SensorRemoved(ISensor sensor)
StephaneLenclud@433
   259
        {
StephaneLenclud@433
   260
            if (Contains(sensor))
StephaneLenclud@433
   261
                Remove(sensor, false);
StephaneLenclud@433
   262
        }
StephaneLenclud@433
   263
StephaneLenclud@433
   264
        public void Dispose()
StephaneLenclud@433
   265
        {
StephaneLenclud@433
   266
            foreach (SensorFrontView icon in list)
StephaneLenclud@433
   267
                icon.Dispose();
StephaneLenclud@433
   268
StephaneLenclud@433
   269
            //Unload our DLL
StephaneLenclud@433
   270
            if (iSoundGraphDll != IntPtr.Zero)
StephaneLenclud@433
   271
            {
StephaneLenclud@433
   272
                bool result = NativeMethods.FreeLibrary(iSoundGraphDll);
StephaneLenclud@433
   273
            }
StephaneLenclud@433
   274
StephaneLenclud@433
   275
        }
StephaneLenclud@433
   276
StephaneLenclud@433
   277
        public void Redraw()
StephaneLenclud@433
   278
        {
StephaneLenclud@433
   279
            foreach (SensorFrontView icon in list)
StephaneLenclud@433
   280
                icon.Update();
StephaneLenclud@433
   281
        }
StephaneLenclud@433
   282
StephaneLenclud@433
   283
        public bool Contains(ISensor sensor)
StephaneLenclud@433
   284
        {
StephaneLenclud@433
   285
            foreach (SensorFrontView icon in list)
StephaneLenclud@433
   286
                if (icon.Sensor == sensor)
StephaneLenclud@433
   287
                    return true;
StephaneLenclud@433
   288
            return false;
StephaneLenclud@433
   289
        }
StephaneLenclud@433
   290
StephaneLenclud@433
   291
        public void Add(ISensor sensor, bool balloonTip)
StephaneLenclud@433
   292
        {
StephaneLenclud@433
   293
            if (Contains(sensor))
StephaneLenclud@433
   294
            {
StephaneLenclud@433
   295
                return;
StephaneLenclud@433
   296
            }
StephaneLenclud@433
   297
            else
StephaneLenclud@433
   298
            {
StephaneLenclud@433
   299
                //SL:
StephaneLenclud@433
   300
                //list.Add(new SensorFrontView(this, sensor, balloonTip, settings, unitManager));
StephaneLenclud@433
   301
                //UpdateMainIconVisibilty();
StephaneLenclud@433
   302
                //settings.SetValue(new Identifier(sensor.Identifier, "tray").ToString(), true);
StephaneLenclud@433
   303
            }
StephaneLenclud@433
   304
        }
StephaneLenclud@433
   305
StephaneLenclud@433
   306
        public void Remove(ISensor sensor)
StephaneLenclud@433
   307
        {
StephaneLenclud@433
   308
            Remove(sensor, true);
StephaneLenclud@433
   309
        }
StephaneLenclud@433
   310
StephaneLenclud@433
   311
        private void Remove(ISensor sensor, bool deleteConfig)
StephaneLenclud@433
   312
        {
StephaneLenclud@433
   313
            if (deleteConfig)
StephaneLenclud@433
   314
            {
StephaneLenclud@433
   315
                settings.Remove(
StephaneLenclud@433
   316
                  new Identifier(sensor.Identifier, "tray").ToString());
StephaneLenclud@433
   317
                settings.Remove(
StephaneLenclud@433
   318
                  new Identifier(sensor.Identifier, "traycolor").ToString());
StephaneLenclud@433
   319
            }
StephaneLenclud@433
   320
            SensorFrontView instance = null;
StephaneLenclud@433
   321
            foreach (SensorFrontView icon in list)
StephaneLenclud@433
   322
                if (icon.Sensor == sensor)
StephaneLenclud@433
   323
                    instance = icon;
StephaneLenclud@433
   324
            if (instance != null)
StephaneLenclud@433
   325
            {
StephaneLenclud@433
   326
                list.Remove(instance);
StephaneLenclud@433
   327
                UpdateMainIconVisibilty();
StephaneLenclud@433
   328
                instance.Dispose();
StephaneLenclud@433
   329
            }
StephaneLenclud@433
   330
        }
StephaneLenclud@433
   331
StephaneLenclud@433
   332
StephaneLenclud@433
   333
StephaneLenclud@433
   334
        private void UpdateMainIconVisibilty()
StephaneLenclud@433
   335
        {
StephaneLenclud@433
   336
            /*
StephaneLenclud@433
   337
            if (mainIconEnabled)
StephaneLenclud@433
   338
            {
StephaneLenclud@433
   339
                mainIcon.Visible = list.Count == 0;
StephaneLenclud@433
   340
            }
StephaneLenclud@433
   341
            else
StephaneLenclud@433
   342
            {
StephaneLenclud@433
   343
                mainIcon.Visible = false;
StephaneLenclud@433
   344
            }
StephaneLenclud@433
   345
             */
StephaneLenclud@433
   346
        }
StephaneLenclud@433
   347
StephaneLenclud@434
   348
        private void Init(IntPtr aHWND)
StephaneLenclud@434
   349
        {
StephaneLenclud@434
   350
            //iIMON_Display_Init
StephaneLenclud@434
   351
        }
StephaneLenclud@434
   352
StephaneLenclud@434
   353
        private void Uninit()
StephaneLenclud@434
   354
        {
StephaneLenclud@434
   355
            iIMON_Display_Uninit();
StephaneLenclud@434
   356
        }
StephaneLenclud@434
   357
StephaneLenclud@434
   358
        private void SetText(string aUpperLine, string aLowerLine)
StephaneLenclud@434
   359
        {
StephaneLenclud@434
   360
StephaneLenclud@434
   361
        }
StephaneLenclud@434
   362
StephaneLenclud@433
   363
        /*
StephaneLenclud@433
   364
        public bool IsMainIconEnabled
StephaneLenclud@433
   365
        {
StephaneLenclud@433
   366
            get { return mainIconEnabled; }
StephaneLenclud@433
   367
            set
StephaneLenclud@433
   368
            {
StephaneLenclud@433
   369
                if (mainIconEnabled != value)
StephaneLenclud@433
   370
                {
StephaneLenclud@433
   371
                    mainIconEnabled = value;
StephaneLenclud@433
   372
                    UpdateMainIconVisibilty();
StephaneLenclud@433
   373
                }
StephaneLenclud@433
   374
            }
StephaneLenclud@433
   375
        }*/
StephaneLenclud@434
   376
StephaneLenclud@434
   377
StephaneLenclud@434
   378
        public bool IsDllLoaded
StephaneLenclud@434
   379
        {
StephaneLenclud@434
   380
            get { return iSoundGraphDll!=IntPtr.Zero; }
StephaneLenclud@434
   381
        }
StephaneLenclud@433
   382
    }
StephaneLenclud@433
   383
}