SafeDispatch/MotoTrbo_GW/CapacityPlusIP.cs

61 lines
1.7 KiB
C#
Raw Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using System.Net;
using SafeMobileLib;
using Nini.Config;
namespace MotoTrbo_GW
{
public partial class CapacityPlusIP : Telerik.WinControls.UI.RadForm
{
private IConfigSource source = null;
public CapacityPlusIP(String IPfromfile)
{
InitializeComponent();
txMasterIP.Text = IPfromfile;
txMasterIP.Focus();
}
private void txMasterIP_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return) btSave.Focus();
}
private void btSave_Click(object sender, EventArgs e)
{
try
{
IPAddress address = IPAddress.Parse(txMasterIP.Text);
SaveConfig();
System.Threading.Thread.Sleep(100);
Application.Exit();
}
catch (Exception ex)
{
SafeMobileLib.Utils.WriteLine("Your IP is not valid:"+ex.ToString());
FeedbackRadMessageBox.ShowError("Master Radio IP is not valid", "Error");
}
}
public void SaveConfig()
{
source = new IniConfigSource(Main.CFG_FILE);
source.Configs["ARS Service"].Set("MasterRadioIP", txMasterIP.Text);
source.Configs["ARS Service"].Set("CapacityPlusEnabled", "True");
source.Save();
}
private void radLabel2_Click(object sender, EventArgs e)
{
}
}
}