示例#1
0
        private static void StartupLedWiz()
        {
            lock (StartupLocker)
            {
                if (StartedUp == 0)
                {
                    MainWindow         = IntPtr.Zero;
                    deviceList.handles = new uint[LWZ_MAX_DEVICES] {
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
                    };
                    deviceList.numdevices = 0;
                    try
                    {
                        NotifyDelegate del = new NotifyDelegate(Notify);

                        IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(LWZDEVICELIST)));
                        Marshal.StructureToPtr(deviceList, ptr, true);
                        LWZ_SET_NOTIFY(del, (uint)ptr.ToInt32());
                        deviceList = (LWZDEVICELIST)Marshal.PtrToStructure(ptr, typeof(LWZDEVICELIST));
                        Marshal.FreeCoTaskMem(ptr);
                        Log.Debug("Ledwiz devicelist content. Handles: {0}, Num devices: {1}".Build(string.Join(", ", deviceList.handles.Select(H => H.ToString())), deviceList.numdevices));
                    }
                    catch (Exception ex)
                    {
                        Log.Exception("Could not init LedWiz", ex);
                        throw new Exception("Could not init LedWiz", ex);
                    }
                }
                StartedUp++;
            }
        }
示例#2
0
        public void StartupLighting()
        {
            try
            {
                NotifyDelegate del = new NotifyDelegate(Notify);

                IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(LWZDEVICELIST)));
                Marshal.StructureToPtr(deviceList, ptr, true);
                LWZ_SET_NOTIFY(del, (uint)ptr.ToInt32());
                deviceList = (LWZDEVICELIST)Marshal.PtrToStructure(ptr, typeof(LWZDEVICELIST));
                Marshal.FreeCoTaskMem(ptr);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "LEDWiz Error");
            }
        }
示例#3
0
        public void StartupLighting()   //seems like this may be important even I don't care about the pattern just to initialize the device
        {
            try
            {
                NotifyDelegate del = new NotifyDelegate(Notify);

                IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(LWZDEVICELIST)));
                Marshal.StructureToPtr(deviceList, ptr, true);
                LWZ_SET_NOTIFY(del, (uint)ptr.ToInt32());
                deviceList = (LWZDEVICELIST)Marshal.PtrToStructure(ptr, typeof(LWZDEVICELIST));
                Marshal.FreeCoTaskMem(ptr);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "LEDWiz Error");
            }
        }
示例#4
0
        private static void StartupLedWiz()
        {
            lock (StartupLocker)
            {
                if (StartedUp == 0)
                {
                    MainWindow = IntPtr.Zero;
                    deviceList.handles = new uint[LWZ_MAX_DEVICES] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    deviceList.numdevices = 0;
                    try
                    {
                        NotifyDelegate del = new NotifyDelegate(Notify);

                        IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(LWZDEVICELIST)));
                        Marshal.StructureToPtr(deviceList, ptr, true);
                        LWZ_SET_NOTIFY(del, (uint)ptr.ToInt32());
                        deviceList = (LWZDEVICELIST)Marshal.PtrToStructure(ptr, typeof(LWZDEVICELIST));
                        Marshal.FreeCoTaskMem(ptr);
                    }
                    catch (Exception ex)
                    {
                        Log.Exception("Could not init LedWiz", ex);
                        throw new Exception("Could not init LedWiz", ex);
                    }

                }
                StartedUp++;
            }
        }