Пример #1
0
        private static void CreateMonochromeGdiPages(LcdDevice monoDevice)
        {
            // Image notUsing;
            Image myImage;

            myImage = (Image)GenerateMap();

            LcdGdiPage page1 = new LcdGdiPage(monoDevice)
            {
                Children =
                {
                    new LcdGdiImage((Image)GenerateMap()),

                    /*
                     * new LcdGdiScrollViewer {
                     *  Child = new LcdGdiText("Hello World! This display is " + monoDevice.PixelWidth.ToString() + "x" + monoDevice.PixelHeight.ToString()),
                     *  HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                     *  VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                     *  Margin = new MarginF(0.0f, 0.0f, 0.0f, 0.0f),
                     *                          AutoScrollX = true,
                     * } */
                }
            };

            page1.Updating += Page_Updating;
            monoDevice.Pages.Add(page1);
            monoDevice.CurrentPage = page1;
        }
Пример #2
0
 void SubscribeToImageChange(LcdDevice device)
 {
     if (device != null)
     {
         device.ImageChanged += OnImageChanged;
     }
 }
Пример #3
0
        /// This event handler is called whenever the soft buttons are pressed or released.

        private void monoDeviceSoftButtonsChanged(object sender, LcdSoftButtonsEventArgs e)
        {
            LcdDevice device = (LcdDevice)sender;

            // First button
            if ((e.SoftButtons & LcdSoftButtons.Button0) == LcdSoftButtons.Button0)
            {
                m_showTitles = !m_showTitles;
            }

            // Second button
            if ((e.SoftButtons & LcdSoftButtons.Button1) == LcdSoftButtons.Button1)
            {
            }

            // Third button
            if ((e.SoftButtons & LcdSoftButtons.Button2) == LcdSoftButtons.Button2)
            {
            }

            // Fourth button
            if ((e.SoftButtons & LcdSoftButtons.Button3) == LcdSoftButtons.Button3)
            {
                //m_keepRunning = false;
            }
        }
Пример #4
0
        /// This event handler is called whenever the soft buttons are pressed or released.

        private void monoDeviceSoftButtonsChanged(object sender, LcdSoftButtonsEventArgs e)
        {
            LcdDevice device = (LcdDevice)sender;

            // First button
            if ((e.SoftButtons & LcdSoftButtons.Button0) == LcdSoftButtons.Button0)
            {
                m_showTitles = !m_showTitles;
            }

            // Second button
            if ((e.SoftButtons & LcdSoftButtons.Button1) == LcdSoftButtons.Button1)
            {
                keybd_event(Convert.ToByte(Keys.MediaPreviousTrack), 0, 0x00, 0); //KEYDOWN PrevTrack Key
                keybd_event(Convert.ToByte(Keys.MediaPreviousTrack), 0, 0x02, 0); //KEYUP PrevTrack Key
            }

            // Third button
            if ((e.SoftButtons & LcdSoftButtons.Button2) == LcdSoftButtons.Button2)
            {
                keybd_event(Convert.ToByte(Keys.MediaPlayPause), 0, 0x00, 0); //KEYDOWN PlayPause Key
                keybd_event(Convert.ToByte(Keys.MediaPlayPause), 0, 0x02, 0); //KEYUP PlayPause Key
            }

            // Fourth button
            if ((e.SoftButtons & LcdSoftButtons.Button3) == LcdSoftButtons.Button3)
            {
                //m_keepRunning = false;
                keybd_event(Convert.ToByte(Keys.MediaNextTrack), 0, 0x00, 0); //KEYDOWN NextTrack Key
                keybd_event(Convert.ToByte(Keys.MediaNextTrack), 0, 0x02, 0); //KEYUP NextTrack Key
            }
        }
Пример #5
0
        private static void CreateMonochromeGdiPages(LcdDevice monoDevice)
        {
            // Image notUsing;
            Image myImage;

            myImage = (Image)GenerateMap();

            LcdGdiPage page1 = new LcdGdiPage(monoDevice)
            {
                Children = {
                    new LcdGdiImage((Image)GenerateMap()),
                    /*
                    new LcdGdiScrollViewer {
                        Child = new LcdGdiText("Hello World! This display is " + monoDevice.PixelWidth.ToString() + "x" + monoDevice.PixelHeight.ToString()),
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                       	Margin = new MarginF(0.0f, 0.0f, 0.0f, 0.0f),
                        AutoScrollX = true,
                    } */
                }
            };
            page1.Updating += Page_Updating;
            monoDevice.Pages.Add(page1);
            monoDevice.CurrentPage = page1;
        }
Пример #6
0
        public int Run(LcdDevice device, PingOptions opts)
        {
            var success = device.Ping(opts.Text);

            Console.WriteLine($"Ping was {(success ? "successful" : "unsuccessful")}.");
            return(success ? 0 : 1);
        }
Пример #7
0
 public int Run <TOp, TOpts>(TOpts opts)
     where TOp : IOp <TOpts>, new()
     where TOpts : GlobalOptionsBase
 {
     if (!string.IsNullOrEmpty(opts.Com))
     {
         _serialPortName = opts.Com;
     }
     if (opts.BaudRate != 0)
     {
         _baudRate = opts.BaudRate;
     }
     try
     {
         using (var device = new LcdDevice(_serialPortName, (LcdBaudRate)_baudRate))
         {
             device.Connect();
             var demo = new TOp();
             return(demo.Run(device, opts));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(1);
     }
 }
        public void setDevice(LcdDevice device)
        {
            if (device != null)
            {
                if (device.DeviceType == LcdDeviceType.Monochrome)
                {
                    monochromeDevice_ = true;

                    logitechLabel.Text = "Monochrome Logitech device found. (G15, G510, ...).";

                    backgroundLabel.Visible         = false;
                    BackgroundDefaultButton.Visible = false;
                    BackgroundCustomButton.Visible  = false;
                    browseButton.Visible            = false;
                }
                else if (device.DeviceType == LcdDeviceType.Qvga)
                {
                    monochromeDevice_ = false;

                    logitechLabel.Text = "Color Logitech device found. (G19).";

                    backgroundLabel.Visible         = true;
                    BackgroundDefaultButton.Visible = true;
                    BackgroundCustomButton.Visible  = true;
                    browseButton.Visible            = true;
                }
            }
        }
Пример #9
0
        public void Run()
        {
            if (_applet == null)
            {
                return;
            }

            _applet.Connect();

            _device = null;
            _waitAre.WaitOne();

            do
            {
                if (_monoArrived)
                {
                    _device = (LcdDeviceMonochrome)_applet.OpenDeviceByType(LcdDeviceType.Monochrome);
                    _device.SoftButtonsChanged += _device_SoftButtonsChanged;
                    Draw();
                }

                if (_applet.IsEnabled && _device != null && !_device.IsDisposed)
                {
                    _device.DoUpdateAndDraw();
                }
            } while (!_mustExit);

            if (_applet.IsEnabled && _device != null && !_device.IsDisposed)
            {
                _device.DoUpdateAndDraw();
            }

            Thread.Sleep(5);
        }
Пример #10
0
 void UnsubscribeFromImageChange(LcdDevice device)
 {
     if (device != null)
     {
         device.ImageChanged += OnImageChanged;
     }
 }
Пример #11
0
        /// <summary>
        /// This event handler is called whenever the soft buttons are pressed or released.
        /// </summary>
        private static void MonoDevice_SoftButtonsChanged(object sender, LcdSoftButtonsEventArgs e)
        {
            LcdDevice device = (LcdDevice)sender;

            Console.WriteLine(e.SoftButtons);

            // First button (remember that buttons start at index 0) is pressed, switch to page one
            if ((e.SoftButtons & LcdSoftButtons.Button0) == LcdSoftButtons.Button0)
            {
                device.CurrentPage = device.Pages[0];
            }

            // Second button is pressed, switch to page two
            if ((e.SoftButtons & LcdSoftButtons.Button1) == LcdSoftButtons.Button1)
            {
                device.CurrentPage = device.Pages[1];
            }

            // Third button is pressed, do a garbage collection (for testing purpose only!)
            if ((e.SoftButtons & LcdSoftButtons.Button2) == LcdSoftButtons.Button2)
            {
                GC.Collect();
            }

            // Fourth button is pressed, exit
            if ((e.SoftButtons & LcdSoftButtons.Button3) == LcdSoftButtons.Button3)
            {
                _mustExit = true;
            }
        }
Пример #12
0
            public LcdGdiPage GetPage(LcdDevice device)
            {
                LcdGdiPage page = new LcdGdiPage(device);

                page.Children.AddRange(new LcdGdiObject[] { _title, _message, _controlYes, _controlNo });

                return(page);
            }
Пример #13
0
        static void InitGraphics(LcdDevice device)
        {
            ConsoleReporter.Report("Initializing Graphics...", ConsoleReporter.ReportStatus.Process, _logEnabled);
            pageList = new List <LcdGdiPage>();

            Draw(device);
            device.CurrentPage           = pageList[0];
            device.SetAsForegroundApplet = true;
            ConsoleReporter.Report("Initializing Graphics done", ConsoleReporter.ReportStatus.Info, _logEnabled);
        }
Пример #14
0
 /// <summary>
 /// Creates a new <see cref="LcdWpfPage"/> for a given QVGA device.
 /// This type of page is not supported on a monochrome device.
 /// </summary>
 /// <param name="device">Device on which to create the page.</param>
 public LcdWpfPage(LcdDevice device)
     : base(device)
 {
     if (device.BitsPerPixel != 32)
     {
         throw new NotSupportedException("LcdWpfPage is only supported on 32-bpp devices.");
     }
     _32BppPixels = new byte[device.PixelWidth * device.PixelHeight * 4];
     _bitmap      = new RenderTargetBitmap(device.PixelWidth, device.PixelHeight, 96.0, 96.0, PixelFormats.Pbgra32);
     _deviceSize  = new Size(device.PixelWidth, device.PixelHeight);
     _deviceRect  = new Rect(new Point(), _deviceSize);
 }
Пример #15
0
        static void Draw(LcdDevice device)
        {
            sview  = new DrawPages.ScrollView(appList, _configButtonEnabled);
            msgBox = new DrawPages.MessageBox_YesNo("QUIT?", "Would you like to quit\nG15 AppStart?");

            pageList.Add(sview.GetPage(device));
            pageList.Add(msgBox.GetPage(device));
            pageList.Add(DrawPages.ConfigScreen.GetPage(device));

            AssignUpdateToAllPages();

            ConsoleReporter.Report("Drawn", ConsoleReporter.ReportStatus.None, _logEnabled);
        }
Пример #16
0
        static void Main(string[] args)
        {
            if (args.Length >= 1)
            {
                _logEnabled = (args[0] == "-debug");
                ConsoleReporter.Report(String.Format("Log {0}", (_logEnabled) ? "enabled" : "disabled"), ConsoleReporter.ReportStatus.Info, _logEnabled);
            }

            Console.WriteLine("{0}\nVersion {1}\n{2}\n", Constants.APP_NAME.ToUpper(), Constants.APP_VERSION, Constants.APP_COPYRIGHT);

            InitDB();
            InitApp();
            InitSettings();

            _device = null;
            _waitAre.WaitOne();
            ConsoleReporter.Report("WaitOne done", ConsoleReporter.ReportStatus.None, _logEnabled);

            do
            {
                if (_monoArrived)
                {
                    ConsoleReporter.Report("Mono Device arrived", ConsoleReporter.ReportStatus.Info, _logEnabled);
                    if (_device == null)
                    {
                        _device = (LcdDeviceMonochrome)_applet.OpenDeviceByType(LcdDeviceType.Monochrome);
                        _device.SoftButtonsChanged += _device_SoftButtonsChanged;
                        InitGraphics(_device);
                    }
                    else
                    {
                        _device.ReOpen();
                    }

                    _monoArrived = false;
                }

                if (_applet.IsEnabled && _device != null && !_device.IsDisposed)
                {
                    _device.DoUpdateAndDraw();
                }
            } while (!_mustExit);

            if (_applet.IsEnabled && _device != null && !_device.IsDisposed)
            {
                _device.DoUpdateAndDraw();
            }

            ConsoleReporter.Report("Applet done! Quitting...", ConsoleReporter.ReportStatus.Process, _logEnabled);
            Thread.Sleep(10);
        }
        public StartupScreen(LcdDevice device, LcdDeviceType type, string backgroundGdi, Plugin plugin, int index)
            : base(device, type, backgroundGdi, plugin, index)
        {
            screenName_ = "StartupScreen";

            if (type == LcdDeviceType.Monochrome)
            {
                createMono();
            }
            else if (type == LcdDeviceType.Qvga)
            {
                createColor();
            }
        }
Пример #18
0
        public int Run(LcdDevice device, ListenOptions opts)
        {
            Console.WriteLine("Press any key to stop listening...");
            EventHandler <KeypadActivityEventArgs> eventHandler =
                delegate(object sender, KeypadActivityEventArgs eventArgs)
            {
                Console.WriteLine($"Keyboard Event: {eventArgs.KeypadAction}");
            };

            device.KeypadActivity += eventHandler;
            Console.ReadKey();
            device.KeypadActivity -= eventHandler;
            return(0);
        }
        public LcdGraphics(LcdDevice lcd)
        {
            //set device
            this.lcd = lcd;

            // Get the images from the assembly
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WinFormTestapp.derpIcon.bmp"))
                mainIcon = Image.FromStream(stream);

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WinFormTestapp.derpIcon_offline.bmp"))
                xMainIcon = Image.FromStream(stream);

            CreateGdiPage();
        }
        private void buttonPressed(object sender, LcdSoftButtonsEventArgs e)
        {
            LcdDevice device = (LcdDevice)sender;

            if (device.DeviceType == LcdDeviceType.Monochrome)
            {
                lcdScreenList_[currentPage_].buttonPressedMonochrome(sender, e);
            }

            else if (device.DeviceType == LcdDeviceType.Qvga)
            {
                lcdScreenList_[currentPage_].buttonPressedColor(sender, e);
            }
        }
Пример #21
0
 public int Run(LcdDevice device, WriteUserFlashOptions opts)
 {
     byte[] data = null;
     if (opts.String != null)
     {
         data = opts.String.ConvertToBytesAsAscii();
     }
     if (opts.HexString != null)
     {
         data = opts.HexString.ConvertToBytesAsHexString();
     }
     device.WriteToUserFlash(data);
     return(0);
 }
        public MainScreen(LcdDevice device, LcdDeviceType type, string backgroundGdi, Plugin plugin, int index)
            : base(device, type, backgroundGdi, plugin, index)
        {
            screenName_ = "MainScreen";
            plugin_.getSongData();

            if (type == LcdDeviceType.Monochrome)
            {
                createMono();
            }
            else if (type == LcdDeviceType.Qvga)
            {
                createColor();
            }
        }
Пример #23
0
        void _Applet_DeviceArrival(object sender, LcdDeviceTypeEventArgs e)
        {
            if (_Device == null)
            {
                Console.WriteLine("Device Arrived!");
                _Device = _Applet.OpenDeviceByType(e.DeviceType);
                _Device.SoftButtonsChanged += new EventHandler <LcdSoftButtonsEventArgs>(_Device_SoftButtonsChanged);

                Pages.Add("NewMessage", new MyLcdGdiPage(_Device, this));
                Pages["NewMessage"].SoftButtonsChanged += new EventHandler <LcdSoftButtonsEventArgs>(NewMessage_SoftButtonsChanged);
                Pages["NewMessage"].Updated            += new EventHandler <UpdateEventArgs>(LCDHandler_Updated);

                Pages["NewMessage"].Add("BG", new LcdGdiRectangle());
                Pages["NewMessage"].Get <LcdGdiRectangle>("BG").Size  = new System.Drawing.SizeF(_Device.PixelWidth, _Device.PixelHeight);
                Pages["NewMessage"].Get <LcdGdiRectangle>("BG").Brush = System.Drawing.Brushes.Black;

                Pages["NewMessage"].Add("Time", new LcdGdiText());
                Pages["NewMessage"].Get <LcdGdiText>("Time").Text = "";
                Pages["NewMessage"].Get <LcdGdiText>("Time").VerticalAlignment   = LcdGdiVerticalAlignment.Top;
                Pages["NewMessage"].Get <LcdGdiText>("Time").HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
                textFont = new System.Drawing.Font(Pages["NewMessage"].Get <LcdGdiText>("Time").Font, System.Drawing.FontStyle.Bold);
                Pages["NewMessage"].Get <LcdGdiText>("Time").Font  = textFont;
                Pages["NewMessage"].Get <LcdGdiText>("Time").Brush = System.Drawing.Brushes.White;

                Pages["NewMessage"].Add("Author", new LcdGdiText());
                Pages["NewMessage"].Get <LcdGdiText>("Author").Text = "";
                Pages["NewMessage"].Get <LcdGdiText>("Author").VerticalAlignment   = LcdGdiVerticalAlignment.Top;
                Pages["NewMessage"].Get <LcdGdiText>("Author").HorizontalAlignment = LcdGdiHorizontalAlignment.Right;
                Pages["NewMessage"].Get <LcdGdiText>("Author").Font  = textFont;
                Pages["NewMessage"].Get <LcdGdiText>("Author").Brush = System.Drawing.Brushes.White;

                System.Drawing.StringFormat MessageFormat = new System.Drawing.StringFormat();
                MessageFormat.Alignment     = System.Drawing.StringAlignment.Center;
                MessageFormat.LineAlignment = System.Drawing.StringAlignment.Center;

                Pages["NewMessage"].Add("Message", new LcdGdiText());
                Pages["NewMessage"].Get <LcdGdiText>("Message").Text                = "";
                Pages["NewMessage"].Get <LcdGdiText>("Message").Margin              = new MarginF(0, 0, 0, 0);
                Pages["NewMessage"].Get <LcdGdiText>("Message").StringFormat        = MessageFormat;
                Pages["NewMessage"].Get <LcdGdiText>("Message").VerticalAlignment   = LcdGdiVerticalAlignment.Stretch;
                Pages["NewMessage"].Get <LcdGdiText>("Message").HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch;
                Pages["NewMessage"].Get <LcdGdiText>("Message").Font                = textFont;
                Pages["NewMessage"].Get <LcdGdiText>("Message").Brush               = System.Drawing.Brushes.White;

                Pages["NewMessage"].SetAsCurrentDevicePage();
            }
        }
Пример #24
0
        public VolumeScreen(LcdDevice device, LcdDeviceType type, string backgroundGdi, Plugin plugin, int index, int volume)
            : base(device, type, backgroundGdi, plugin, index)
        {
            screenName_ = "VolumeScreen";
            plugin_.getSongData();

            volumeChanger_ = volume / 100f;

            if (type == LcdDeviceType.Monochrome)
            {
                createMono();
            }
            else if (type == LcdDeviceType.Qvga)
            {
                createColor();
            }
        }
Пример #25
0
 public int Run(LcdDevice device, MultiFieldOptions opts)
 {
     Field[] fields;
     if (!string.IsNullOrEmpty(opts.File))
     {
         if (!File.Exists(opts.File))
         {
             throw new ArgumentException("File does not exist!");
         }
         var contents = File.ReadAllText(opts.File);
         fields = JsonConvert.DeserializeObject <List <Field> >(contents).ToArray();
         if (fields.Length < 1)
         {
             throw new ArgumentException("File didn't contain any field objects");
         }
     }
     else
     {
         fields = new[]
         {
             new Field {
                 Name = "Version:", Value = "2.1.3.12334"
             },
             new Field {
                 Name = "Label1:", Value = "123.123.123.123"
             },
             new Field {
                 Name = "LabelTwo:", Value = "255.255.255.0"
             },
             new Field {
                 Name = "Long:", Value = "abcdefghijklmnopqrstuvwxyz"
             },
             new Field {
                 Name = "Empty:", Value = ""
             },
             new Field {
                 Name = "ReallyReallyReallyLongLabel:", Value = "abc"
             },
             new Field {
                 Name = "Suuuuuuuperrrrrlong:", Value = "abcdefghijklmnopqrstuvwxyz"
             },
         };
     }
     return(new FieldDisplayer(device, fields).Run());
 }
Пример #26
0
        // Update the Now Playing pagetext fields
        public void updateTextFields(LcdDevice device, LcdGdiPage page, LcdGdiScrollViewer scrollViewer,
                                     LcdGdiScrollViewer scrollViewer2, LcdGdiScrollViewer scrollViewer3, LcdGdiText playTime)
        {
            LcdGdiText track = (LcdGdiText)scrollViewer.Child;

            track.Text = m_playerDetails.currentTrack;


            LcdGdiText album = (LcdGdiText)scrollViewer2.Child;

            album.Text = m_playerDetails.currentAlbum;

            LcdGdiText artist = (LcdGdiText)scrollViewer3.Child;

            artist.Text = m_playerDetails.currentArtist;

            playTime.Text = m_playerDetails.playTime;
        }
Пример #27
0
            public LcdGdiPage GetPage(LcdDevice device)
            {
                LcdGdiPage page = new LcdGdiPage(device);

                if (_enabled)
                {
                    page.Children.AddRange(new LcdGdiObject[] {
                        _item1, _item2, _item3, _imgSelector, _imgControls0, _imgControls1, _imgControls2, _imgControls3
                    });
                }
                else
                {
                    page.Children.AddRange(new LcdGdiObject[] {
                        _item1, _item2, _item3, _imgControls3
                    });
                }

                return(page);
            }
Пример #28
0
            public static LcdGdiPage GetPage(LcdDevice device)
            {
                LcdGdiPage page = new LcdGdiPage(device);

                /*LcdGdiText title = new LcdGdiText();
                 * title.Text = "Config Mode";
                 * title.Font = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Bold);
                 * title.Margin = new MarginF(0, 0, 0, 0);*/

                LcdGdiText message = new LcdGdiText();

                message.Font   = new Font("Microsoft Sans Serif", 7.5f, FontStyle.Regular);
                message.Margin = new MarginF(0, 3, 0, 0);
                message.Text   = "G15 AppStart is currently locked.\nTo continue operation\nclose Config application.";

                page.Children.AddRange(new LcdGdiObject[] { /*title,*/ message });

                return(page);
            }
Пример #29
0
        public int Run(LcdDevice device, KnightRiderOptions opts)
        {
            device.ClearScreen();
            int x = 0, y = 0;

            using (new Timer(state =>
            {
                var oldX = x;
                var oldY = y;
                if (y == 0)
                {
                    x += 4;
                }
                else
                {
                    x -= 4;
                }
                if (x >= 13)
                {
                    x = 12;
                    y++;
                }
                else if (x < 0)
                {
                    x = 0;
                    y--;
                }
                if (device.Connected)
                {
                    device.SendDataToLcd(x, y, "\0\0\0\0");
                    device.SendDataToLcd(oldX, oldY, "    ");
                }
            }, null, 0, 200))
            {
                Console.WriteLine("Press any key to stop...");
                Console.ReadKey();
                if (device.Connected)
                {
                    device.ClearScreen();
                }
            }
            return(0);
        }
        // MusicBee is closing the plugin (plugin is being disabled by user or MusicBee is shutting down)
        public void Close(PluginCloseReason reason)
        {
            if (timer_ != null)
            {
                timer_.Dispose();
                timer_ = null;
            }

            if (reason == PluginCloseReason.StopNoUnload)
            {
                device_ = null;
            }

            lcdScreenList_.Clear();
            currentPage_ = 0;

            if (settings_ != null)
            {
                settings_.Dispose();
                settings_ = null;
            }

            if (device_ != null)
            {
                device_.Dispose();
                device_ = null;
            }

            if (applet_ != null)
            {
                applet_.Dispose();
                applet_ = null;
            }

            settings_ = null;
            device_   = null;


            if (reason == PluginCloseReason.StopNoUnload)
            {
                connectDevice();
            }
        }
        public LyricsScreen(LcdDevice device, LcdDeviceType type, string backgroundGdi, Plugin plugin, int index)
            : base(device, type, backgroundGdi, plugin, index)
        {
            screenName_ = "LyricsScreen";

            plugin_.getSongData();

            if (type == LcdDeviceType.Monochrome)
            {
                maximumTextSize_ = 40;
                createMono();
            }
            else if (type == LcdDeviceType.Qvga)
            {
                mainTextFont_    = new Font(mainTextFont_, FontStyle.Bold);
                maximumTextSize_ = 50;
                createColor();
            }
        }
Пример #32
0
        // Create the Mono Pages
        public void createMonochromeGdiPages(LcdDevice monoDevice)
        {
            // Get the images from the assembly
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SpotifyStatusApplet.lcdIcon.bmp"))
                m_imageOnline = Image.FromStream(stream);
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SpotifyStatusApplet.lcdIcon_offline.bmp"))
                m_imageOffline = Image.FromStream(stream);

            m_nowPlayingPage = new LcdGdiPage(monoDevice)
            {
                Children = {
                    new LcdGdiImage(m_imageOffline),
                    new LcdGdiText{Text = CURRENT_TRACK_FIELD_TITLE + ": ",
                                    Margin = new MarginF(34.0f, 0.0f, 2.0f, 0.0f) },
                    new LcdGdiScrollViewer {
                        Child = new LcdGdiText(""),
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(64.0f, 0.0f, 2.0f, 0.0f),
                        AutoScrollX = true,
                    },
                    new LcdGdiText{Text = CURRENT_ALBUM_FIELD_TITLE + ": ",
                                    Margin = new MarginF(34.0f, 10.0f, 2.0f, 0.0f) },
                    new LcdGdiScrollViewer {
                        Child = new LcdGdiText(""),
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(64.0f, 10.0f, 2.0f, 0.0f),
                        AutoScrollX = true,
                    },
                    new LcdGdiText{Text = CURRENT_ARTIST_FIELD_TITLE + ": ",
                                    Margin = new MarginF(34.0f, 20.0f, 2.0f, 0.0f) },
                    new LcdGdiScrollViewer {
                        Child = new LcdGdiText( ""),
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(64.0f, 20.0f, 2.0f, 0.0f),
                        AutoScrollX = true,
                    },
                    new LcdGdiText{Text = "",
                        Margin = new MarginF(34.0f, 30.0f, 2.0f, 0.0f) },
                    new LcdGdiPolygon(Pens.Black, Brushes.Black, new[] {
                        new PointF(0.0f, 10.0f), new PointF(0.0f, 0.0f), new PointF(10.0f, 5.0f),
                    }, false) {
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Left,
                        VerticalAlignment = LcdGdiVerticalAlignment.Bottom,
                        Margin = new MarginF(0.0f, 0.0f, 5.0f, 5.0f)
                    }
                }
            };
            m_nowPlayingPage.Updating += updateNowPlayingPage;

            m_nowPlayingNoTitlesPage = new LcdGdiPage(monoDevice)
            {
                Children = {
                    new LcdGdiImage(m_imageOffline),
                    new LcdGdiScrollViewer {
                        Child = new LcdGdiText(""),
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(34.0f, 0.0f, 2.0f, 0.0f),
                        AutoScrollX = true,
                    },
                    new LcdGdiScrollViewer {
                        Child = new LcdGdiText(""),
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(34.0f, 10.0f, 2.0f, 0.0f),
                        AutoScrollX = true,
                    },
                    new LcdGdiScrollViewer {
                        Child = new LcdGdiText( ""),
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(34.0f, 20.0f, 2.0f, 0.0f),
                        AutoScrollX = true,
                    },
                    new LcdGdiText{Text = "",
                        Margin = new MarginF(34.0f, 30.0f, 2.0f, 0.0f) },
                    new LcdGdiPolygon(Pens.Black, Brushes.Black, new[] {
                        new PointF(0.0f, 10.0f), new PointF(0.0f, 0.0f), new PointF(10.0f, 5.0f),
                    }, false) {
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Left,
                        VerticalAlignment = LcdGdiVerticalAlignment.Bottom,
                        Margin = new MarginF(0.0f, 0.0f, 5.0f, 5.0f)
                    }
                }
            };
            m_nowPlayingNoTitlesPage.Updating += updateNowPlayingMinPage;

            m_privatePage = new LcdGdiPage(monoDevice)
            {
                Children = {
                    new LcdGdiImage(m_imageOffline),
                    new LcdGdiText{Text = "Warning!",
                                    Margin = new MarginF(24.0f, 0.0f, 2.0f, 0.0f),
                                    HorizontalAlignment = LcdGdiHorizontalAlignment.Center },
                    new LcdGdiText{Text = "Spotify in private mode.",
                                    Margin = new MarginF(24.0f, 10.0f, 2.0f, 0.0f),
                                    HorizontalAlignment = LcdGdiHorizontalAlignment.Center },
                    new LcdGdiText{Text = "No track info.",
                                    Margin = new MarginF(24.0f, 20.0f, 2.0f, 0.0f),
                                    HorizontalAlignment = LcdGdiHorizontalAlignment.Center },
                    new LcdGdiPolygon(Pens.Black, Brushes.Black, new[] {
                        new PointF(0.0f, 10.0f), new PointF(0.0f, 0.0f), new PointF(10.0f, 5.0f),
                    }, false) {
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Left,
                        VerticalAlignment = LcdGdiVerticalAlignment.Bottom,
                        Margin = new MarginF(0.0f, 0.0f, 5.0f, 5.0f)
                    }
                }
            };
            m_privatePage.Updating += updatePrivatePage;

            // Finally add page to the device's Pages collection set the current page
            monoDevice.Pages.Add(m_nowPlayingPage);
            monoDevice.Pages.Add(m_nowPlayingNoTitlesPage);
            if (m_showTitles)
            {
                monoDevice.CurrentPage = m_nowPlayingPage;
            }
            else
            {
                monoDevice.CurrentPage = m_nowPlayingNoTitlesPage;
            }
        }
Пример #33
0
        // Update the Now Playing pagetext fields
        public void updateTextFields(LcdDevice device, LcdGdiPage page, LcdGdiScrollViewer scrollViewer,
            LcdGdiScrollViewer scrollViewer2, LcdGdiScrollViewer scrollViewer3, LcdGdiText playTime)
        {
            LcdGdiText track = (LcdGdiText)scrollViewer.Child;
            track.Text = m_playerDetails.currentTrack;

            LcdGdiText album = (LcdGdiText)scrollViewer2.Child;
            album.Text = m_playerDetails.currentAlbum;

            LcdGdiText artist = (LcdGdiText)scrollViewer3.Child;
            artist.Text = m_playerDetails.currentArtist;

            playTime.Text = m_playerDetails.playTime;
        }
Пример #34
0
        /// <summary>
        /// Creates two new LcdGdiPages for a monochrome device.
        /// </summary>
        /// <param name="monoDevice">Device to use for page creation.</param>
        private static void CreateMonochromeGdiPages(LcdDevice monoDevice)
        {
            // Creates first page
            Page_MainPage = new LcdGdiPage(monoDevice)
            {
                Children =
                {
                    new LcdGdiText
                    {
                        Text = "Baron: ",

                        Margin = new MarginF(0.0f, 5f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)
                    },
                    new LcdGdiText
                    {
                        Text = TimeSpan.FromSeconds(RespawnTimes[(int)Mobs.Baron]).ToString(@"m\:ss"),
                        Tag = TagNames[(int)Mobs.Baron],

                        Margin = new MarginF(28.0f, -2.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif, 16)
                    },
                   new LcdGdiText
                   {
                        Text = "Dragon: ",

                        Margin = new MarginF(75.0f, 5f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)
                    },
                    new LcdGdiText
                    {
                        Text = TimeSpan.FromSeconds(RespawnTimes[(int)Mobs.Dragon]).ToString(@"m\:ss"),
                        Tag = TagNames[(int)Mobs.Dragon],

                        Margin = new MarginF(110.0f, -2.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif, 16)
                    },
                   new LcdGdiText
                   {
                        Text = "Blue Golem: ",

                        Margin = new MarginF(0.0f, 20.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)

                    },
                    new LcdGdiText
                   {
                        Text = TimeSpan.FromSeconds(RespawnTimes[(int)Mobs.Golem_Blue]).ToString(@"m\:ss"),
                        Tag = TagNames[(int)Mobs.Golem_Blue],

                        Margin = new MarginF(55.0f, 20.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)
                    },
                   new LcdGdiText
                   {
                        Text = "Blue Lizard : ",

                        Margin = new MarginF(0.0f, 30.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)
                    },
                    new LcdGdiText
                   {
                        Text = TimeSpan.FromSeconds(RespawnTimes[(int)Mobs.Lizard_Blue]).ToString(@"m\:ss"),
                        Tag = TagNames[(int)Mobs.Lizard_Blue],

                        Margin = new MarginF(55.0f, 30.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)
                    },
                   new LcdGdiText
                   {
                        Text = "Purple Golem: ",
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(75.0f, 20.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)
                   },
                   new LcdGdiText
                   {
                        Text = TimeSpan.FromSeconds(RespawnTimes[(int)Mobs.Golem_Purple]).ToString(@"m\:ss"),
                        Tag = TagNames[(int)Mobs.Golem_Purple],

                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(138.0f, 20.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)
                    },
                   new LcdGdiText
                   {
                        Text = "Purple Lizard : ",
                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(75.0f, 30.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7),
                    },
                    new LcdGdiText
                   {
                        Text = TimeSpan.FromSeconds(RespawnTimes[(int)Mobs.Lizard_Purple]).ToString(@"m\:ss"),
                        Tag = TagNames[(int)Mobs.Lizard_Purple],

                        HorizontalAlignment = LcdGdiHorizontalAlignment.Stretch,
                        VerticalAlignment = LcdGdiVerticalAlignment.Stretch,
                        Margin = new MarginF(138.0f, 30.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,7)
                    },
                    new LcdGdiLine
                    {
                        Pen = Pens.Black,
                        Tag = "currentSelectionLine",
                        StartPoint = new PointF(56.0f, 30.0f),
                        EndPoint = new PointF(74.0f, 30.0f)
                    }
                }
            };
            Page_MainPage.Updating += Page_Updating;
            Page_MainPage.DesiredFramerate = 10;

            // Adds page to the device's Pages collection (not mandatory, but helps for storing pages),
            // and sets the first page as the current page
            monoDevice.Pages.Add(Page_MainPage);
            monoDevice.CurrentPage = Page_MainPage;

            Page_RespawnDragon = new LcdGdiPage(monoDevice)
            {
                Children =
                {
                    new LcdGdiImage
                    {
                        Image = LoLTimer.Resources.img_dragon,
                        Margin = new MarginF(5.0f, 0.0f, 0.0f, 0.0f),
                    },
                    new LcdGdiText
                    {
                        Text = "Dragon",
                        Margin = new MarginF(50.0f, -5.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,22)
                    },
                    new LcdGdiText
                    {
                        Text = "Has Respawned",
                        Margin = new MarginF(48.0f, 25.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif, 11)
                    }
                }
            };
            Page_RespawnBaron = new LcdGdiPage(monoDevice)
            {
                Children =
                {
                    new LcdGdiImage
                    {
                        Image = LoLTimer.Resources.img_baron,
                        Margin = new MarginF(5.0f, 6.0f, 0.0f, 0.0f),
                    },
                    new LcdGdiText
                    {
                        Text = "Baron",
                        Margin = new MarginF(60.0f, -5.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif,22)
                    },
                    new LcdGdiText
                    {
                        Text = "Has Respawned",
                        Margin = new MarginF(48.0f, 25.0f, 0.0f, 0.0f),
                        Font = new Font(FontFamily.GenericSansSerif, 11)
                    }
                }
            };

            monoDevice.Pages.Add(Page_RespawnDragon);
            monoDevice.Pages.Add(Page_RespawnBaron);
        }