git_bsmd/AIS/AISAdmin/Main.cs

113 lines
3.0 KiB
C#

using bsmd.AIS2Service;
namespace AISAdmin
{
public partial class Main : Form
{
private AIS_SQLiteStorage? _storage;
private List<MonitorGroup>? _monitorGroups;
private List<MonitorZone>? _monitorZones;
public Main()
{
InitializeComponent();
}
private void buttonZoneUp_Click(object sender, EventArgs e)
{
}
private void buttonZoneDown_Click(object sender, EventArgs e)
{
}
private void buttonImportZone_Click(object sender, EventArgs e)
{
}
private void buttonEditZone_Click(object sender, EventArgs e)
{
}
private void buttonDeleteZone_Click(object sender, EventArgs e)
{
}
private void buttonSaveZone_Click(object sender, EventArgs e)
{
}
private void buttonNewGroup_Click(object sender, EventArgs e)
{
this.textBoxGroup.ReadOnly = false;
this.buttonSaveGroup.Enabled = true;
}
private void buttonEditGroup_Click(object sender, EventArgs e)
{
}
private void buttonDeleteGroup_Click(object sender, EventArgs e)
{
}
private void buttonSaveGroup_Click(object sender, EventArgs e)
{
if(this.textBoxGroup.Text != null)
{
string groupName = this.textBoxGroup.Text.Trim();
if(groupName.Length > 0)
{
MonitorGroup mg = new MonitorGroup(-1, groupName);
if(_storage.Save(mg))
{
this._monitorGroups?.Add(mg);
this.comboBoxGroup.SelectedItem = mg;
}
}
}
this.buttonSaveGroup.Enabled = false;
this.textBoxGroup.ReadOnly = true;
}
private void Main_Load(object sender, EventArgs e)
{
_storage = new AIS_SQLiteStorage(null);
_monitorGroups = _storage.LoadGroups();
_monitorZones = _storage.LoadMonitorZones();
this.comboBoxGroup.DataSource = _monitorGroups;
this.comboBoxGroup.DisplayMember = "Name";
}
private void comboBoxGroup_SelectedIndexChanged(object sender, EventArgs e)
{
MonitorGroup mGroup = (MonitorGroup) this.comboBoxGroup.SelectedItem;
if (mGroup != null)
{
this.textBoxGroup.Text = mGroup.Name;
List<MonitorZone> groupZones = new List<MonitorZone>();
foreach(MonitorZone mZone in _monitorZones)
{
if (mZone.MonitorGroupId == mGroup.Id)
groupZones.Add(mZone);
}
groupZones.Sort();
this.listBoxZones.DataSource = groupZones;
}
else
{
this.listBoxZones.DataSource = null;
this.textBoxGroup.ResetText();
}
}
}
}