view ServerMonitor/Controls/ServerSummaryControl.cs @ 4:3142e52cbe69

Lots more progress
author Brad Greco <brad@bgreco.net>
date Sun, 10 Feb 2019 20:51:26 -0500
parents 3e1a2131f897
children 052aa62cb42a
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
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.GetIcon();
        }

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

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