Changed a lot
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
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;
|
||||
|
||||
namespace NetMonitorTray.Models {
|
||||
public class Tray : OwnModel<Tray> {
|
||||
private InIReader networks;
|
||||
private InIReader vpns;
|
||||
private Tray() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
override protected void init() {
|
||||
this.networks = InIReader.getInstance("network.ini");
|
||||
this.vpns = InIReader.getInstance("vpn.ini");
|
||||
}
|
||||
|
||||
internal Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>> getMenuNetwork() {
|
||||
Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>> ret = new Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>>();
|
||||
List<String> l = this.networks.getSections();
|
||||
foreach(String name in l) {
|
||||
String adapter = this.networks.getValue(name, "Adapter");
|
||||
if(ret.Keys.Contains(adapter)) {
|
||||
ret[adapter].Add(adapter + "|" + name, new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk " + this.networks.getValue(name, "Name"), Properties.Resources.MenuImagesNetwork, true, (this.NetworkSelected.Keys.Contains(adapter) && this.NetworkSelected[adapter] == name)));
|
||||
} else {
|
||||
Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> tmp = new Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>();
|
||||
tmp.Add(adapter + "|" + name, new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk " + this.networks.getValue(name, "Name"), Properties.Resources.MenuImagesNetwork, true, (this.NetworkSelected.Keys.Contains(adapter) && this.NetworkSelected[adapter] == name)));
|
||||
ret.Add(adapter, tmp);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>> getMenuVpn() {
|
||||
Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>> ret = new Dictionary<string, Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>>();
|
||||
List<String> l = this.vpns.getSections();
|
||||
Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> tmp = new Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>();
|
||||
|
||||
foreach(String vpn in l) {
|
||||
String name = this.vpns.getValue(vpn, "Name");
|
||||
String conf = this.vpns.getValue(vpn, "Config");
|
||||
tmp.Add(vpn + "|" + conf, new Tuple<string, System.Drawing.Bitmap, bool, bool>("VPN " + name, Properties.Resources.MenuImagesOpenvpn, true, (this.VpnSelected.Keys.Contains(conf) && this.VpnSelected[conf] == "connected")));
|
||||
|
||||
}
|
||||
ret.Add("OpenVpn", tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private bool connectedStatusValue = false;
|
||||
internal bool connectedStatus {
|
||||
get { return connectedStatusValue; }
|
||||
set { connectedStatusValue = value; this.update(); }
|
||||
}
|
||||
|
||||
private Dictionary<String, String> VpnSelectedValue = new Dictionary<string, string>();
|
||||
/// <summary>
|
||||
/// Item1 = configfile
|
||||
/// Item2 = status ("unknown";"connected";"disconnected")
|
||||
/// </summary>
|
||||
internal Dictionary<String, String> VpnSelected {
|
||||
get { return VpnSelectedValue; }
|
||||
set { VpnSelectedValue = value; this.update(); }
|
||||
}
|
||||
|
||||
private Dictionary<String, String> networkSelectedValue = new Dictionary<string, string>();
|
||||
/// <summary>
|
||||
/// Item1 = adapter
|
||||
/// Item2 = network
|
||||
/// </summary>
|
||||
public Dictionary<String, String> NetworkSelected {
|
||||
get { return networkSelectedValue; }
|
||||
set { networkSelectedValue = value; this.update(); }
|
||||
}
|
||||
|
||||
internal List<string> getAdapterList() {
|
||||
List<String> ret = new List<string>();
|
||||
List<String> l = this.networks.getSections();
|
||||
foreach(String name in l) {
|
||||
String adapter = this.networks.getValue(name, "Adapter");
|
||||
if(!ret.Contains(adapter)) {
|
||||
ret.Add(adapter);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal List<string> getVpnList() {
|
||||
List<String> ret = new List<string>();
|
||||
List<String> l = this.vpns.getSections();
|
||||
foreach(String name in l) {
|
||||
String adapter = this.vpns.getValue(name, "Config");
|
||||
if(!ret.Contains(adapter)) {
|
||||
ret.Add(adapter);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
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;
|
||||
|
||||
namespace NetMonitorTray.Models
|
||||
{
|
||||
public class Window : OwnModel<Window>
|
||||
{
|
||||
private InIReader networkfile;
|
||||
private Window()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
override protected void init()
|
||||
{
|
||||
this.networkfile = InIReader.getInstance("network.ini");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Listet alle Netzwerke auf
|
||||
/// </summary>
|
||||
public List<string> Networks
|
||||
{
|
||||
get { return this.networkfile.getSections(); }
|
||||
}
|
||||
|
||||
public string getNetworkProperty(string network, string property)
|
||||
{
|
||||
return this.networkfile.getValue(network, property);
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
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;
|
||||
|
||||
namespace NetMonitorTray.Model
|
||||
{
|
||||
public class Tray : OwnModel<Tray>
|
||||
{
|
||||
private bool serviceRun;
|
||||
private Tray()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
private void init()
|
||||
{
|
||||
this.serviceRun = false;
|
||||
}
|
||||
|
||||
internal Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> getMenuNetwork()
|
||||
{
|
||||
Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> ret = new Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>();
|
||||
ret.Add("network1", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk Home", null, true, false));
|
||||
ret.Add("network2", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk Arbeit", null, true, false));
|
||||
ret.Add("network3", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Netzwerk Test", null, true, false));
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> getMenuOpenVpnService()
|
||||
{
|
||||
Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>> ret = new Dictionary<string, Tuple<string, System.Drawing.Bitmap, bool, bool>>();
|
||||
ret.Add("StartService", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Service Starten", Properties.Resources.MenuImagesServerConnect, !this.serviceRun, !this.serviceRun));
|
||||
ret.Add("StopService", new Tuple<string, System.Drawing.Bitmap, bool, bool>("Service Stoppen", Properties.Resources.MenuImagesServerDisconnect, this.serviceRun, this.serviceRun));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setService(bool run)
|
||||
{
|
||||
this.serviceRun = run;
|
||||
this.update();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user