view ServerMonitor/Controls/DiskSpaceCheckControl.cs @ 7:8486ab7d2357

Add/remove files
author Brad Greco <brad@bgreco.net>
date Fri, 01 Mar 2019 21:39:22 -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.");
            }
        }
    }
}