Пример #1
0
        public PiHoleApi()
        {
            _app = new LCDApp("Pi-hole Stats", false, false, false);
            // _app.WaitForClose();
            _app.PushToForeground();

            var lineVer = new LCDLine
            {
                Start = new Point((LCDApp.DefaultSize.Width / 2) - 1, 0),
                End   = new Point((LCDApp.DefaultSize.Width / 2) - 1, LCDApp.DefaultSize.Height - 1)
            };

            var lineHor = new LCDLine
            {
                Start = new Point(0, (LCDApp.DefaultSize.Height / 2) - 1),
                End   = new Point(LCDApp.DefaultSize.Width - 1, (LCDApp.DefaultSize.Height / 2) - 1)
            };

            _lblTotDomains = new LCDLabel
            {
                Font     = PixelFonts.Small,
                AutoSize = true
            };
            _lblQueriesToday = new LCDLabel
            {
                Font     = PixelFonts.Small,
                AutoSize = true
            };
            _lblBlockedToday = new LCDLabel
            {
                Font     = PixelFonts.Small,
                AutoSize = true
            };
            _lblPercToday = new LCDLabel
            {
                Font     = PixelFonts.Small,
                AutoSize = true
            };

            // Create an app instance.


            // Add the label control to the app.
            _app.Controls.Add(lineVer);
            _app.Controls.Add(lineHor);
            _app.Controls.Add(_lblTotDomains);
            _app.Controls.Add(_lblQueriesToday);
            _app.Controls.Add(_lblBlockedToday);
            _app.Controls.Add(_lblPercToday);

            UpdateVisibility();

            UpdateStats();


            TimerCallback tDelegate = TimerCallback;

            _t = new Timer(tDelegate, null, 0, 5000);
        }
Пример #2
0
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        private static void Main()
        {
            var f = new LCDApp("LCDApp", false, false, false);

            var label = new LCDLabel
            {
                Font      = PixelFonts.Small,
                Size      = f.Size,
                Text      = "Align me!",
                TextAlign = ContentAlignment.BottomRight,
            };
//            var label = new LCDLabel
//            {
//                Font = PixelFonts.Small,
//                Location = new Point(2, 2),
//                AutoSize = true,
//                Size = f.Size,
//                MergeMethod = MergeMethods.Transparent,
//                Text = "Push ze button."
//            };
            var line = new LCDLine
            {
                Start = new Point(0, 0),
                End   = new Point(f.Width - 1, f.Height - 1)
            };
            var rectangle = new LCDRectangle
            {
                Location = new Point(0, 0),
                Size     = new Size(40, 40),
                Style    = RectangleStyle.Bordered
            };

            var ellipse = new LCDEllipse
            {
                Location = new Point(40, 20),
                Size     = new Size(50, 20)
            };

            var progressBar = new LCDProgressBar
            {
                Location  = new Point(12, 14),
                Size      = new Size(136, 6),
                Style     = BorderStyle.Border,
                Direction = ProgressBarDirection.Right,
                Value     = 50
            };

            var picture = new LCDPicture
            {
                Location    = new Point(100, 10),
                Size        = Resources.gtech.Size,
                Image       = Resources.gtech,
                MergeMethod = MergeMethods.Overlay
            };

            var marq = new LCDMarquee
            {
                Text     = "Lorem",
                Size     = new Size(LCDApp.DefaultSize.Width, 10),
                Location = new Point(0, 10),
            };

            var graph = new LCDSimpleGraph
            {
                Location = new Point(70, 30),
                Size     = new Size(40, 10),
                Style    = BorderStyle.Border
            };

            (new Timer {
                Interval = 500, Enabled = true
            }).Tick += (sender, args) =>
            {
                graph.PushValue(new Random().Next(0, 100));
            };

            var tabControl = new LCDTabControl();

            var tabPage = new LCDTabPage
            {
                Icon = new LCDLabel
                {
                    AutoSize = true,
                    Text     = "A",
                    Font     = PixelFonts.Title
                }
            };

            var tabPage2 = new LCDTabPage
            {
                Icon = new LCDLabel
                {
                    AutoSize = true,
                    Text     = "B",
                    Font     = PixelFonts.Title
                }
            };

            tabPage.Controls.Add(label);
            tabPage.Controls.Add(line);
            tabPage.Controls.Add(marq);

            tabPage2.Controls.Add(rectangle);
            tabPage2.Controls.Add(ellipse);
            tabPage2.Controls.Add(progressBar);
            tabPage2.Controls.Add(picture);
            tabPage2.Controls.Add(graph);

            tabControl.TabPages.Add(tabPage);
            tabControl.TabPages.Add(tabPage2);
            tabControl.TabPages.Add(new LCDTabPage
            {
                Icon = new LCDLabel {
                    AutoSize = true, Font = PixelFonts.Title, Text = "1"
                }
            });
            tabControl.TabPages.Add(new LCDTabPage
            {
                Icon = new LCDLabel {
                    AutoSize = true, Font = PixelFonts.Title, Text = "2"
                }
            });
            tabControl.TabPages.Add(new LCDTabPage
            {
                Icon = new LCDLabel {
                    AutoSize = true, Font = PixelFonts.Title, Text = "3"
                }
            });
            tabControl.TabPages.Add(new LCDTabPage
            {
                Icon = new LCDLabel {
                    AutoSize = true, Font = PixelFonts.Title, Text = "4"
                }
            });
            tabControl.SelectedTab = tabPage;

            f.Controls.Add(tabControl);

            f.ButtonDown += (sender, args) =>
            {
                if (args.Button == 2)
                {
                    tabControl.ShowMenu();
                }
                if (args.Button == 3)
                {
                    f.Dispose();
                }
            };

            f.PushToForeground();
            f.WaitForClose();
        }