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

Lots more progress
author Brad Greco <brad@bgreco.net>
date Sun, 10 Feb 2019 20:51:26 -0500
parents 453ecc1ed9ea
children 7127d5b5ac75
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
{
    [CheckType(typeof(DiskSpaceCheck))]
    public partial class DiskSpaceCheckControl : CheckControl
    {
        public DiskSpaceCheckControl()
        {
            InitializeComponent();
        }

        private void DiskSpaceCheckControl_Load(object sender, EventArgs e)
        {
            FreeSpaceUnitsComboBox.SelectedIndex = 1;
        }

        public override void LoadCheck(Check check1)
        {
            DiskSpaceCheck check = (DiskSpaceCheck)check1;
            DeviceTextBox.Text = check.Device;
            FreeSpaceTextBox.Text = check.MinFreeSpace.ToString();
            FreeSpaceUnitsComboBox.SelectedIndex = (int)check.FreeSpaceUnits;
        }

        public override void UpdateCheck(Check check1)
        {
            DiskSpaceCheck check = (DiskSpaceCheck)check1;
            check.Device = DeviceTextBox.Text.Trim();
            check.FreeSpaceUnits = (FreeSpaceUnits)FreeSpaceUnitsComboBox.SelectedIndex;
            try
            {
                check.MinFreeSpace = double.Parse(FreeSpaceTextBox.Text);
            }
            catch
            {
                check.MinFreeSpace = 0;
                throw new UpdateCheckException("Free space must be numeric.");
            }
        }
    }
}