예제 #1
0
        public override void Process(StreamDeckSharp.IStreamDeck deck)
        {
            if (baseBitMap == null)
            {
                baseBitMap = (Bitmap)Bitmap.FromFile("StopWatch.bmp");
            }
            if (runningBitMap == null)
            {
                runningBitMap = (Bitmap)Bitmap.FromFile("StopWatch-Running.bmp");
            }
            Bitmap tempBitmap = new Bitmap(baseBitMap.Width, baseBitMap.Height);
            var    graph      = Graphics.FromImage(tempBitmap);

            if (state == "Stopped")
            {
                graph.DrawImage(baseBitMap, 0, 0);
            }
            else
            {
                graph.DrawImage(runningBitMap, 0, 0);
                if (state == "Running")
                {
                    System.Drawing.Pen redPen = new Pen(Color.Red, 1);
                    graph.DrawEllipse(redPen, 7, 13, 57, 57);
                }
                graph.DrawString(st.Elapsed.ToString().Substring(0, 8), new System.Drawing.Font("Arial", 8), new System.Drawing.SolidBrush(Color.Black), 15, 32);
            }

            theBitmap = tempBitmap;
        }
예제 #2
0
        public override void Process(StreamDeckSharp.IStreamDeck deck)
        {
            if (baseBitMap == null)
            {
                baseBitMap = (Bitmap)Bitmap.FromFile("Speaker.bmp");
            }
            Bitmap tempBitmap = new Bitmap(baseBitMap.Width, baseBitMap.Height);

            if (dev == null)
            {
                NAudio.CoreAudioApi.MMDeviceEnumerator enu = new NAudio.CoreAudioApi.MMDeviceEnumerator();
                var devices = enu.EnumerateAudioEndPoints(NAudio.CoreAudioApi.DataFlow.Render, NAudio.CoreAudioApi.DeviceState.All);
                foreach (var d in devices)
                {
                    try
                    {
                        if (d.FriendlyName == OutputDeviceName)
                        {
                            dev = d;
                            break;
                        }
                    }
                    catch (Exception exc)
                    {
                    }
                }
            }
            if (dev != null)
            {
                try
                {
                    //"XSplit  Stream  Audio  Renderer")
                    {
                        if (base.enabled)

                        {
                            int pct = (int)(Math.Round(dev.AudioMeterInformation.MasterPeakValue * 100));
                            Console.Write("");

                            System.Drawing.Brush GreenPen  = new SolidBrush(Color.Green);
                            System.Drawing.Brush YellowPen = new SolidBrush(Color.Yellow);
                            System.Drawing.Brush RedPen    = new SolidBrush(Color.Red);
                            using (var graph = Graphics.FromImage(tempBitmap))
                            {
                                graph.DrawImage(baseBitMap, 0, 0);

                                int properWith = 72 * pct / 100;
                                if (pct > 95)
                                {
                                    graph.FillRectangle(RedPen, 0, 0, properWith, 72 - 0);
                                }
                                else
                                {
                                    if (pct > 75)
                                    {
                                        graph.FillRectangle(YellowPen, 0, 0, properWith, 72 - 0);
                                    }
                                    else
                                    {
                                        graph.FillRectangle(GreenPen, 0, 0, properWith, 72 - 0);
                                    }
                                }
                            }
                            theBitmap = tempBitmap;
                        }
                    }
                }
                catch (Exception exc)
                {
                }
            }
        }