Lang nichts mehr passiert, refactoring ist geil

This commit is contained in:
2014-07-11 14:38:10 +00:00
parent f019b4e493
commit cd21034b41
62 changed files with 2132 additions and 561 deletions
+84
View File
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NetMonitorTray.Controller
{
public class Tray
{
private static View.Tray tray;
public Tray()
{
tray = new View.Tray();
}
public void view()
{
Application.Run();
}
/// <summary>
/// User klickt auf den Eintrag Beenden
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Quit(object sender, EventArgs e)
{
tray.Dispose();
Application.ExitThread();
}
/// <summary>
/// User klick auf einen Eintrag Service Starten/Stoppen
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Service(object sender, EventArgs e)
{
throw new NotImplementedException();
//tray.showError("Fehler beim Starten/Stoppen von Service!");
/*switch (((ToolStripMenuItem)sender).Name)
{
case "StartService": tray.setService(true); break;
case "StopService": tray.setService(false); break;
}*/
}
/// <summary>
/// User klickt Doppelt auf das TrayIcon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Tray(object sender, EventArgs e)
{
//Doppelklick auf das Trayicon
throw new NotImplementedException();
}
/// <summary>
/// User klickt auf den Tray-Ballon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Ballon(object sender, EventArgs e)
{
throw new NotImplementedException();
}
/// <summary>
/// User klickt auf einen Eintrag Netzwerk
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Network(object sender, EventArgs e)
{
throw new NotImplementedException();
}
/// <summary>
/// User klickt auf den Eintrag Öffnen
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
internal static void Click_Open(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}
+49
View File
@@ -0,0 +1,49 @@
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();
}
}
}
+96
View File
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0B85C838-3295-4FDA-9B07-4F5B3681BE2F}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NetMonitorTray</RootNamespace>
<AssemblyName>NetMonitorTray</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controller\Tray.cs" />
<Compile Include="Models\Tray.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Views\Tray.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
<Content Include="Resources\Icons\door_open.png" />
<Content Include="Resources\Icons\server_connect.png" />
<Content Include="Resources\Icons\server_delete.png" />
<Content Include="Resources\working.ico" />
<Content Include="Resources\nothing.ico" />
<Content Include="Resources\connected.ico" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Utils\Utils\Utils.csproj">
<Project>{fac8ce64-bf13-4ece-8097-aeb5dd060098}</Project>
<Name>Utils</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+18
View File
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NetMonitorTray
{
class Program
{
static void Main(string[] args)
{
Controller.Tray t = new Controller.Tray();
t.view();
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("NetMonitorTray")]
[assembly: AssemblyDescription("NetMonitor TrayLauncher")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BlubbFish")]
[assembly: AssemblyProduct("NetMonitorTray")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("9069ec73-a0b6-4414-b9f0-e3794324b8bd")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+123
View File
@@ -0,0 +1,123 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18444
//
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
// der Code erneut generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace NetMonitorTray.Properties {
using System;
/// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NetMonitorTray.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
/// </summary>
internal static System.Drawing.Icon IconConnected {
get {
object obj = ResourceManager.GetObject("IconConnected", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
/// </summary>
internal static System.Drawing.Icon IconNothing {
get {
object obj = ResourceManager.GetObject("IconNothing", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
/// </summary>
internal static System.Drawing.Icon IconWorking {
get {
object obj = ResourceManager.GetObject("IconWorking", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap MenuImagesQuit {
get {
object obj = ResourceManager.GetObject("MenuImagesQuit", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap MenuImagesServerConnect {
get {
object obj = ResourceManager.GetObject("MenuImagesServerConnect", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap MenuImagesServerDisconnect {
get {
object obj = ResourceManager.GetObject("MenuImagesServerDisconnect", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
+139
View File
@@ -0,0 +1,139 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="IconConnected" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\connected.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconNothing" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\nothing.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconWorking" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\working.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="MenuImagesQuit" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icons\door_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="MenuImagesServerConnect" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icons\server_connect.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="MenuImagesServerDisconnect" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icons\server_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

+110
View File
@@ -0,0 +1,110 @@
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 Tray : OwnView
{
private NotifyIcon trayi;
private Dictionary<string, Tuple<string, Bitmap, bool, bool>> menuOpenVpnService;
private Dictionary<string, Tuple<string, Bitmap, bool, bool>> menuNetwork;
public Tray()
{
this.initIcon();
Model.Tray.Instance.setObserver(this);
}
public override void update()
{
this.menuOpenVpnService = Model.Tray.Instance.getMenuOpenVpnService();
this.menuNetwork = Model.Tray.Instance.getMenuNetwork();
this.trayi.ContextMenuStrip = this.genMenu();
}
private void initIcon()
{
this.trayi = new NotifyIcon();
this.trayi.Visible = true;
this.trayi.Icon = new Icon(Resources.IconNothing, 40, 40);
this.trayi.Text = "NetMonitorTray";
this.trayi.DoubleClick += Controller.Tray.Click_Tray;
this.trayi.BalloonTipClicked += Controller.Tray.Click_Ballon;
}
private ContextMenuStrip genMenu()
{
ContextMenuStrip menu = new ContextMenuStrip();
ToolStripMenuItem m1 = new ToolStripMenuItem("Öffnen");
m1.Image = Resources.MenuImagesQuit;
m1.Click += Controller.Tray.Click_Open;
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());
ToolStripMenuItem m2 = new ToolStripMenuItem("Beenden");
m2.Image = Resources.MenuImagesQuit;
m2.Click += Controller.Tray.Click_Quit;
m2.Name = "Quit";
menu.Items.Add(m2);
return menu;
}
private ToolStripMenuItem[] genMenuIt(Dictionary<string, Tuple<string, Bitmap, bool, bool>> dictionary, EventHandler ev)
{
List<ToolStripMenuItem> l = new List<ToolStripMenuItem>();
foreach (String key in dictionary.Keys)
{
ToolStripMenuItem m = new ToolStripMenuItem(dictionary[key].Item1);
if (dictionary[key].Item2 != null)
{
m.Image = dictionary[key].Item2;
}
m.Click += ev;
m.Name = key;
m.Enabled = dictionary[key].Item3;
if (dictionary[key].Item4)
{
m.Font = new System.Drawing.Font(m.Font, m.Font.Style | FontStyle.Bold);
}
l.Add(m);
}
return l.ToArray();
}
private void showBallonTooltip(string text, ToolTipIcon toolTipIcon, string title = "NetMonitor Tray")
{
this.trayi.BalloonTipIcon = toolTipIcon;
this.trayi.BalloonTipText = text;
this.trayi.BalloonTipTitle = title;
this.trayi.ShowBalloonTip(100);
}
internal void Dispose()
{
this.trayi.Visible = false;
Application.ExitThread();
}
internal void setService(bool run)
{
this.showBallonTooltip((run ? "Service erfolgreich gestartet." : "Service erfolgreich beendet"), ToolTipIcon.Info);
Model.Tray.Instance.setService(run);
}
internal void showError(string text)
{
this.showBallonTooltip(text, ToolTipIcon.Error);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B