2015-03-04 23:21:34 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using NetMonitorTray.Properties;
|
|
|
|
|
using BlubbFish.Utils;
|
2015-11-16 01:10:59 +01:00
|
|
|
|
using NetMonitorUtils;
|
2015-03-04 23:21:34 +01:00
|
|
|
|
|
2015-11-16 01:10:59 +01:00
|
|
|
|
namespace NetMonitorTray.Models {
|
|
|
|
|
public class Window : OwnModel<Window> {
|
|
|
|
|
private InIReader networkfile;
|
|
|
|
|
private InIReader vpnfile;
|
|
|
|
|
private InIReader settingsfile;
|
|
|
|
|
private NetworkSetter networksetter;
|
|
|
|
|
private Window() {
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected void init() {
|
|
|
|
|
this.networkfile = InIReader.getInstance("network.ini");
|
|
|
|
|
this.vpnfile = InIReader.getInstance("vpn.ini");
|
|
|
|
|
this.settingsfile = InIReader.getInstance("config.ini");
|
|
|
|
|
this.networksetter = new NetworkSetter("network.ini", "config.ini");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Listet alle Netzwerke auf
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<string> Networks {
|
|
|
|
|
get { return this.networkfile.getSections(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<string> Vpns {
|
|
|
|
|
get { return this.vpnfile.getSections(); }
|
|
|
|
|
}
|
2015-03-04 23:21:34 +01:00
|
|
|
|
|
2015-11-16 01:10:59 +01:00
|
|
|
|
|
2015-03-04 23:21:34 +01:00
|
|
|
|
|
2015-11-16 01:10:59 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fügt ein neues Netzwerk hinzu
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">Netzwerkid</param>
|
|
|
|
|
/// <returns>true if added, false if error</returns>
|
|
|
|
|
public bool addNetwork(string name) {
|
|
|
|
|
if(this.networkfile.addSection(name)) {
|
|
|
|
|
this.update();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Löscht ein Netzwerk
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="name">Netzwerkid</param>
|
|
|
|
|
/// <returns>true if deleted, false if error</returns>
|
|
|
|
|
public bool removeNetwork(string name) {
|
|
|
|
|
if(this.networkfile.removeSection(name)) {
|
|
|
|
|
this.update();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-03-04 23:21:34 +01:00
|
|
|
|
|
2015-11-16 01:10:59 +01:00
|
|
|
|
internal string getVpnProperty(string vpn, string property) {
|
|
|
|
|
return this.vpnfile.getValue(vpn, property);
|
|
|
|
|
}
|
2015-03-04 23:21:34 +01:00
|
|
|
|
|
2015-11-16 01:10:59 +01:00
|
|
|
|
public string getNetworkProperty(string network, string property) {
|
|
|
|
|
return this.networkfile.getValue(network, property);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string getSettingsProperty(string setting, string property) {
|
|
|
|
|
return this.settingsfile.getValue(setting, property);
|
|
|
|
|
}
|
2015-03-04 23:21:34 +01:00
|
|
|
|
|
2015-11-16 01:10:59 +01:00
|
|
|
|
public List<string> getNetworkAdapters() {
|
|
|
|
|
return this.networksetter.getAdapters();
|
2015-03-04 23:21:34 +01:00
|
|
|
|
}
|
2015-11-16 01:10:59 +01:00
|
|
|
|
}
|
2015-03-04 23:21:34 +01:00
|
|
|
|
}
|