view ServerMonitor/Controls/ServerSummaryControl.cs @ 34:9c0e18d65e8b

Build NuGet from source instead of using the NuGet package to fix the update notification always showing when the program is run from Windows startup.
author Brad Greco <brad@bgreco.net>
date Sat, 13 Jul 2019 12:09:10 -0400
parents 7127d5b5ac75
children
line wrap: on
line source

using System;
using System.Windows.Forms;

namespace ServerMonitorApp
{
    public partial class ServerSummaryControl : UserControl
    {
        public new event EventHandler Click;

        public Server Server { get; private set; }

        public ServerSummaryControl(Server server)
        {
            InitializeComponent();

            foreach (Control control in new Control[] { this, ServerPictureBox, ServerNameLabel })
            {
                control.Cursor = Cursors.Hand;
                control.Click += Control_Click;
            }
            Server = server;
            ServerNameLabel.Text = Server.Name;
            StatusPictureBox.Parent = ServerPictureBox;
            StatusPictureBox.Image = Server.Status.GetImage();
        }

        public override void Refresh()
        {
            StatusPictureBox.Image = Server.Status.GetImage();
            base.Refresh();
        }

        private void Control_Click(object sender, EventArgs e)
        {
            Click?.Invoke(this, e);
        }
    }
}