Exemple #1
0
        public MainForm()
        {
            InitializeComponent();

            //check which devices are available

            if (!MysticLightSDK.IsAvailable(true))
            {
                tabControl.TabPages.RemoveByKey("pageMysticLight");
            }

            if (!LogitechGSDK.IsAvailable(true))
            {
                tabControl.TabPages.RemoveByKey("pageLogitechG");
            }

            //preparing images

            bmpRaw  = new Bitmap((int)Math.Round((int)NumBoxScale.Value * RATIO), (int)NumBoxScale.Value, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            bmpProc = new Bitmap((int)Math.Round((int)NumBoxScale.Value * RATIO), (int)NumBoxScale.Value, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);

            //preparing background thread for image processing

            mainLoop.WorkerSupportsCancellation = true;
            mainLoop.DoWork             += new DoWorkEventHandler(MainLoop);
            mainLoop.RunWorkerCompleted += new RunWorkerCompletedEventHandler(MainLoopCompleted);

            //preparing necessary hooks

            Hook.GlobalEvents().MouseDown += async(sender, e) =>
            {
                Console.WriteLine($"Mouse {e.Button} Down");
            };
        }
Exemple #2
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            if (!mainLoop.IsBusy)
            {
                //code actually works with these enabled, but I'm being safe
                NumBoxX.Enabled     = false;
                NumBoxY.Enabled     = false;
                NumBoxScale.Enabled = false;
                ComboRes.Enabled    = false;

                if (MysticLightSDK.IsAvailable())
                {
                    MysticLightSDK.Init(false);
                }

                if (LogitechGSDK.IsAvailable())
                {
                    LogitechGSDK.Init(false);
                }

                LightsOff();

                mainLoop.RunWorkerAsync();
                StatusLabel.Text = "0";
                //StatusLabel.Text = "Scanning...";
            }
        }
Exemple #3
0
        private void LightsOff()
        {
            if (MysticLightSDK.Ready())
            {
                MysticLightSDK.setLEDs(System.Windows.Media.Color.FromRgb(0, 0, 0));
            }

            if (LogitechGSDK.Ready())
            {
                //LogitechGSDK.LogiLedSetLighting(0, 0, 0);
            }
        }
Exemple #4
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (mainLoop.IsBusy)
            {
                closePending = true;
                mainLoop.CancelAsync();
                e.Cancel = true;
                Hide();
                return;
            }

            MysticLightSDK.Shutdown();
            LogitechGSDK.Shutdown();

            base.OnFormClosing(e);
        }
Exemple #5
0
        private void UpdateLights()
        {
            Random rnd = new Random();
            int    r, g, b;

            HsvToRgb(rnd.Next(0, 360), 1, 1, out r, out g, out b);

            //START OF EFFECT
            if (MysticLightSDK.Ready())
            {
                MysticLightSDK.setLEDs(System.Windows.Media.Color.FromRgb((byte)r, (byte)g, (byte)b));
            }

            if (LogitechGSDK.Ready())
            {
                LogitechGSDK.LogiLedSetLighting(r * 100 / 255, g * 100 / 255, b * 100 / 255);
            }

            Thread.Sleep(FIRERATE_MS);

            //END OF EFFECT
            LightsOff();
        }
Exemple #6
0
        private void BtnStop_Click(object sender, EventArgs e)
        {
            if (mainLoop.IsBusy)
            {
                NumBoxX.Enabled     = true;
                NumBoxY.Enabled     = true;
                NumBoxScale.Enabled = true;
                ComboRes.Enabled    = true;

                if (MysticLightSDK.Ready())
                {
                    MysticLightSDK.Shutdown();
                }

                if (LogitechGSDK.Ready())
                {
                    LogitechGSDK.Shutdown();
                }

                mainLoop.CancelAsync();
                StatusLabel.Text = "Stopped.";
            }
            LightsOff();
        }