using EgwControlCenter.Core; using EgwControlCenter.Core.Models; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace EgwControlCenter { public partial class TargetSetup : Form { #region Public Constructors public TargetSetup() { InitializeComponent(); LoadPatrolConfig(); ForceReload(); } #endregion Public Constructors #region Private Fields private int minHeight = 120; #endregion Private Fields #region Private Properties /// /// Oggetto gestione conf applicazione /// private ConfigManager AppConf { get; set; } = new ConfigManager("", ""); #endregion Private Properties #region Private Methods private void btnReload_Click(object sender, EventArgs e) { ForceReload(); } private void btnSave_Click(object sender, EventArgs e) { AppConf.SaveConfig(); ForceReload(); } private void FixPosition() { // ricalcolo altezza in base a num oggetti... if (AppConf.CurrPatrolCont.TargetList.Count > 0) { int newHeight = minHeight + 40 * (AppConf.CurrPatrolCont.TargetList.Count + 1); Size = new Size(Size.Width, newHeight); } Rectangle workArea = Screen.GetWorkingArea(this); this.Location = new Point((workArea.Right - Size.Width) / 2, (workArea.Bottom - Size.Height) / 2); } private void LoadPatrolConfig() { string confDir = AccUtils.ConfDir; } private void ForceReload() { AppConf = new ConfigManager(AccUtils.ConfDir, AccUtils.ConfName); // Fix textBox numVeto.Value = AppConf.CurrPatrolCont.VetoCheckMinutes; numRef.Value = AppConf.CurrPatrolCont.RefreshIntSec; // fix GridView var list = new BindingList(AppConf.CurrPatrolCont.TargetList); dgView.DataSource = list; dgView.Columns[0].HeaderCell.Value = "ID"; dgView.Columns[1].HeaderCell.Value = "Tipo"; dgView.Columns[2].HeaderCell.Value = "Base Directory Path"; dgView.Columns[3].HeaderCell.Value = "Act"; // update label tsLabelOut.Text = $"{DateTime.Now: yyyy-MM-dd HH:mm:ss}"; } private void TargetSetup_Load(object sender, EventArgs e) { FixPosition(); } #endregion Private Methods private void numRef_ValueChanged(object sender, EventArgs e) { AppConf.CurrPatrolCont.RefreshIntSec = (int)numRef.Value; } private void numVeto_ValueChanged(object sender, EventArgs e) { AppConf.CurrPatrolCont.VetoCheckMinutes = (int)numVeto.Value; } } }