Changed a lot

This commit is contained in:
2015-03-04 22:21:34 +00:00
parent cd21034b41
commit 8264cbfa7b
54 changed files with 2014 additions and 529 deletions
@@ -13,27 +13,31 @@ namespace NetMonitorTray.View
public class Tray : OwnView
{
private NotifyIcon trayi;
private Dictionary<string, Tuple<string, Bitmap, bool, bool>> menuOpenVpnService;
private Dictionary<string, Tuple<string, Bitmap, bool, bool>> menuNetwork;
private Dictionary<string, Dictionary<string, Tuple<string, Bitmap, bool, bool>>> menuVpn;
private Dictionary<string, Dictionary<string, Tuple<string, Bitmap, bool, bool>>> menuNetwork;
private Icon[] iconlist = { new Icon(Resources.IconNothing, 40, 40), new Icon(Resources.IconWorking, 40, 40), new Icon(Resources.IconConnected, 40, 40) };
public Tray()
{
this.initIcon();
Model.Tray.Instance.setObserver(this);
this.init();
this.Model = Models.Tray.Instance;
this.Model.setObserver(this);
}
public override void update()
{
this.menuOpenVpnService = Model.Tray.Instance.getMenuOpenVpnService();
this.menuNetwork = Model.Tray.Instance.getMenuNetwork();
this.menuVpn = this.Model.getMenuVpn();
this.menuNetwork = this.Model.getMenuNetwork();
this.trayi.ContextMenuStrip = this.genMenu();
this.trayi.Icon = (this.Model.connectedStatus ? this.iconlist[2] : this.iconlist[0]);
}
private void initIcon()
override protected void init()
{
this.trayi = new NotifyIcon();
this.trayi.Visible = true;
this.trayi.Icon = new Icon(Resources.IconNothing, 40, 40);
this.trayi.Icon = this.iconlist[0];
this.trayi.Text = "NetMonitorTray";
this.trayi.DoubleClick += Controller.Tray.Click_Tray;
this.trayi.BalloonTipClicked += Controller.Tray.Click_Ballon;
@@ -48,10 +52,15 @@ namespace NetMonitorTray.View
m1.Name = "Open";
menu.Items.Add(m1);
menu.Items.Add(new ToolStripSeparator());
menu.Items.AddRange(this.genMenuIt(this.menuNetwork, Controller.Tray.Click_Network));
menu.Items.Add(new ToolStripSeparator());
menu.Items.AddRange(this.genMenuIt(this.menuOpenVpnService, Controller.Tray.Click_Service));
menu.Items.Add(new ToolStripSeparator());
foreach (String adapter in this.menuNetwork.Keys)
{
menu.Items.AddRange(this.genMenuIt(this.menuNetwork[adapter], Controller.Tray.Click_Network));
menu.Items.Add(new ToolStripSeparator());
}
foreach(String adapter in this.menuVpn.Keys) {
menu.Items.AddRange(this.genMenuIt(this.menuVpn[adapter], Controller.Tray.Click_Vpn));
menu.Items.Add(new ToolStripSeparator());
}
ToolStripMenuItem m2 = new ToolStripMenuItem("Beenden");
m2.Image = Resources.MenuImagesQuit;
m2.Click += Controller.Tray.Click_Quit;
@@ -90,21 +99,28 @@ namespace NetMonitorTray.View
this.trayi.ShowBalloonTip(100);
}
internal void Dispose()
override public void Dispose()
{
this.trayi.Visible = false;
Application.ExitThread();
}
internal void setService(bool run)
internal void setVpn(bool run, string ip)
{
this.showBallonTooltip((run ? "Service erfolgreich gestartet." : "Service erfolgreich beendet"), ToolTipIcon.Info);
Model.Tray.Instance.setService(run);
this.showBallonTooltip((run ? "OpenVpn erfolgreich gestartet.\n"+ip : "OpenVpn erfolgreich beendet\n"+ip), ToolTipIcon.Info);
this.Model.connectedStatus = run;
}
internal void showError(string text)
{
this.showBallonTooltip(text, ToolTipIcon.Error);
}
public Models.Tray Model { get; private set; }
internal void setWorkingIcon()
{
this.trayi.Icon = this.iconlist[1];
}
}
}
+45
View File
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using NetMonitorTray.Properties;
using BlubbFish.Utils;
namespace NetMonitorTray.View
{
public class Window : OwnView
{
private ViewWindowForm form;
public Window()
{
this.form = new ViewWindowForm();
this.init();
this.Model.setObserver(this);
}
public override void update()
{
this.form.UpdateForm();
}
protected override void init()
{
this.Model = Models.Window.Instance;
this.form.SetModel(this.Model);
this.form.Show();
}
public override void Dispose()
{
this.form.BeginInvoke((Action)(() =>
{
this.form.Dispose();
}));
}
public Models.Window Model { get; private set; }
}
}
+209
View File
@@ -0,0 +1,209 @@
namespace NetMonitorTray.View
{
partial class ViewWindowForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.networks = new System.Windows.Forms.TabPage();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.buttonNetworkAdd = new System.Windows.Forms.Button();
this.openvpn = new System.Windows.Forms.TabPage();
this.global = new System.Windows.Forms.TabPage();
this.label1 = new System.Windows.Forms.Label();
this.logBox = new System.Windows.Forms.TextBox();
this.tabControl1.SuspendLayout();
this.networks.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
//
this.statusStrip1.Location = new System.Drawing.Point(0, 336);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(780, 22);
this.statusStrip1.SizingGrip = false;
this.statusStrip1.TabIndex = 0;
this.statusStrip1.Text = "statusStrip1";
//
// tabControl1
//
this.tabControl1.Controls.Add(this.networks);
this.tabControl1.Controls.Add(this.openvpn);
this.tabControl1.Controls.Add(this.global);
this.tabControl1.Location = new System.Drawing.Point(12, 12);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(591, 321);
this.tabControl1.TabIndex = 1;
//
// networks
//
this.networks.Controls.Add(this.groupBox2);
this.networks.Controls.Add(this.groupBox1);
this.networks.Location = new System.Drawing.Point(4, 22);
this.networks.Name = "networks";
this.networks.Padding = new System.Windows.Forms.Padding(3);
this.networks.Size = new System.Drawing.Size(583, 295);
this.networks.TabIndex = 0;
this.networks.Text = "Netzwerke";
this.networks.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Location = new System.Drawing.Point(189, 6);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(388, 283);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "groupBox2";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.listView1);
this.groupBox1.Controls.Add(this.buttonNetworkAdd);
this.groupBox1.Location = new System.Drawing.Point(6, 6);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(177, 283);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(7, 19);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.ShowGroups = false;
this.listView1.Size = new System.Drawing.Size(164, 226);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "ID";
//
// columnHeader2
//
this.columnHeader2.Text = "Label";
this.columnHeader2.Width = 100;
//
// buttonNetworkAdd
//
this.buttonNetworkAdd.Location = new System.Drawing.Point(7, 251);
this.buttonNetworkAdd.Name = "buttonNetworkAdd";
this.buttonNetworkAdd.Size = new System.Drawing.Size(164, 23);
this.buttonNetworkAdd.TabIndex = 1;
this.buttonNetworkAdd.Text = "Netzwerk Hinzufügen";
this.buttonNetworkAdd.UseVisualStyleBackColor = true;
//
// openvpn
//
this.openvpn.Location = new System.Drawing.Point(4, 22);
this.openvpn.Name = "openvpn";
this.openvpn.Padding = new System.Windows.Forms.Padding(3);
this.openvpn.Size = new System.Drawing.Size(583, 295);
this.openvpn.TabIndex = 1;
this.openvpn.Text = "OpenVPN";
this.openvpn.UseVisualStyleBackColor = true;
//
// global
//
this.global.Location = new System.Drawing.Point(4, 22);
this.global.Name = "global";
this.global.Size = new System.Drawing.Size(583, 295);
this.global.TabIndex = 2;
this.global.Text = "Einstellungen";
this.global.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(609, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 2;
this.label1.Text = "label1";
//
// logBox
//
this.logBox.Location = new System.Drawing.Point(609, 34);
this.logBox.Multiline = true;
this.logBox.Name = "logBox";
this.logBox.Size = new System.Drawing.Size(163, 295);
this.logBox.TabIndex = 3;
//
// ViewWindowForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(780, 358);
this.Controls.Add(this.logBox);
this.Controls.Add(this.label1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.statusStrip1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "ViewWindowForm";
this.Text = "NetMonitorTray";
this.tabControl1.ResumeLayout(false);
this.networks.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage networks;
private System.Windows.Forms.TabPage openvpn;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox logBox;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button buttonNetworkAdd;
private System.Windows.Forms.TabPage global;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
}
}
+44
View File
@@ -0,0 +1,44 @@
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 NetMonitorTray.View
{
public partial class ViewWindowForm : Form
{
private Models.Window model;
public ViewWindowForm()
{
InitializeComponent();
this.FormClosed += Controller.Window.FormClosed;
listView1.ItemActivate += Controller.Window.NetworkSelected;
}
public void UpdateForm()
{
this.BeginInvoke((Action)(() =>
{
this.logBox.Text = "Loaded";
List<string> networks = this.model.Networks;
foreach(string network in networks) {
ListViewItem item = new ListViewItem();
item.Text = network;
item.SubItems.Add(this.model.getNetworkProperty(network, "Name"));
listView1.Items.Add(item);
}
}));
}
public void SetModel(Models.Window window)
{
this.model = window;
}
}
}
+123
View File
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>