107 lines
3.1 KiB
C#
107 lines
3.1 KiB
C#
using AppData;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ELMA
|
|
{
|
|
public partial class ConfigMan : Form
|
|
{
|
|
/// <summary>
|
|
/// Oggetto conf setup
|
|
/// </summary>
|
|
public eSetup currSetup = new eSetup();
|
|
|
|
public ConfigMan()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
// mostro la conf attiva
|
|
txtBaseUrl.Text = currSetup.baseUrl;
|
|
txtAppBasePath.Text = currSetup.appBasePath;
|
|
}
|
|
|
|
private void btnApply_Click(object sender, EventArgs e)
|
|
{
|
|
((LogAnalyzer)this.Owner).activeSetup = currSetup;
|
|
doUpdate();
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
currSetup=((LogAnalyzer)this.Owner).activeSetup;
|
|
doUpdate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Carica la conf corrente
|
|
/// </summary>
|
|
/// <param name="filePath"></param>
|
|
private void loadConf(string filePath)
|
|
{
|
|
if (File.Exists(filePath))
|
|
{
|
|
try
|
|
{
|
|
currSetup = JsonConvert.DeserializeObject<eSetup>(File.ReadAllText(filePath));
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Salva conf corrente sul file indicato
|
|
/// </summary>
|
|
/// <param name="filePath"></param>
|
|
private void saveConf(string filePath)
|
|
{
|
|
// .. e lo salvo...
|
|
string rawData = JsonConvert.SerializeObject(currSetup, Formatting.Indented);
|
|
File.WriteAllText(filePath, rawData);
|
|
}
|
|
|
|
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
// salvo la conf corrente...
|
|
OpenFileDialog oFileDialog = new OpenFileDialog();
|
|
oFileDialog.DefaultExt = "jset";
|
|
oFileDialog.Filter = "Conf files (*.jset)|*.jset|All files (*.*)|*.*";
|
|
oFileDialog.InitialDirectory = Utils.confDir;
|
|
oFileDialog.RestoreDirectory = true;
|
|
if (oFileDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
// carico
|
|
loadConf(oFileDialog.FileName);
|
|
}
|
|
}
|
|
|
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
// salvo la conf corrente...
|
|
SaveFileDialog sFileDialog = new SaveFileDialog();
|
|
sFileDialog.DefaultExt = "jset";
|
|
sFileDialog.Filter = "Conf files (*.jset)|*.jset|All files (*.*)|*.*";
|
|
sFileDialog.InitialDirectory = Utils.confDir;
|
|
sFileDialog.RestoreDirectory = true;
|
|
if (sFileDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
// salvo!
|
|
string rawData = JsonConvert.SerializeObject(currSetup, Formatting.Indented);
|
|
saveConf(sFileDialog.FileName);
|
|
}
|
|
}
|
|
}
|
|
}
|