Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions Source/NETworkManager.Model/Common/AsyncObservableCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Source: http://www.thomaslevesque.com/2009/04/17/wpf-binding-to-an-asynchronous-collection/

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Threading;

namespace NETworkManager.Model.Common
{
public class AsyncObservableCollection<T> : ObservableCollection<T>
{
private SynchronizationContext _synchronizationContext = SynchronizationContext.Current;

public AsyncObservableCollection()
{

}

public AsyncObservableCollection(IEnumerable<T> list) : base(list)
{

}

protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (SynchronizationContext.Current == _synchronizationContext)
{
// Execute the CollectionChanged event on the current thread
RaiseCollectionChanged(e);
}
else
{
// Raises the CollectionChanged event on the creator thread
_synchronizationContext.Send(RaiseCollectionChanged, e);
}
}

private void RaiseCollectionChanged(object param)
{
// We are in the creator thread, call the base implementation directly
base.OnCollectionChanged((NotifyCollectionChangedEventArgs)param);
}

protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (SynchronizationContext.Current == _synchronizationContext)
{
// Execute the PropertyChanged event on the current thread
RaisePropertyChanged(e);
}
else
{
// Raises the PropertyChanged event on the creator thread
_synchronizationContext.Send(RaisePropertyChanged, e);
}
}

private void RaisePropertyChanged(object param)
{
// We are in the creator thread, call the base implementation directly
base.OnPropertyChanged((PropertyChangedEventArgs)param);
}
}
}
9 changes: 5 additions & 4 deletions Source/NETworkManager.Model/NETworkManager.Model.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common\AsyncObservableCollection.cs" />
<Compile Include="Network\NetworkInterface.cs" />
<Compile Include="Network\NetworkInterfaceConfig.cs" />
<Compile Include="Network\NetworkInterfaceInfo.cs" />
<Compile Include="Temp\Ping.cs" />
<Compile Include="Temp\PingArgs.cs" />
<Compile Include="Temp\PingOptions.cs" />
<Compile Include="Temp\PingInfo.cs" />
<Compile Include="Network\Ping.cs" />
<Compile Include="Network\PingArgs.cs" />
<Compile Include="Network\PingOptions.cs" />
<Compile Include="Network\PingInfo.cs" />
<Compile Include="Network\Subnet.cs" />
<Compile Include="Network\SubnetInfo.cs" />
<Compile Include="Network\Subnetmask.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void SendAsync(IPAddress ipAddress, PingOptions pingOptions, Cancellation
System.Net.NetworkInformation.PingOptions options = new System.Net.NetworkInformation.PingOptions
{
Ttl = pingOptions.TTL,
DontFragment = pingOptions.DontFragement
DontFragment = pingOptions.DontFragment
};

using (System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ public class PingOptions
public int Timeout { get; set; }
public byte[] Buffer { get; set; }
public int TTL { get; set; }
public bool DontFragement { get; set; }
public bool DontFragment { get; set; }

public PingOptions()
{

}

public PingOptions(int attempts, int waitTime, int timeout, byte[] buffer, int ttl, bool dontFragement)
public PingOptions(int attempts, int waitTime, int timeout, byte[] buffer, int ttl, bool dontFragment)
{
Attempts = attempts;
WaitTime = waitTime;
Timeout = timeout;
Buffer = buffer;
TTL = ttl;
DontFragement = dontFragement;
DontFragment = dontFragment;
}
}
}
6 changes: 6 additions & 0 deletions Source/NETworkManager/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
<setting name="HotKey_ShowWindowEnabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="Ping_DontFragment" serializeAs="String">
<value>True</value>
</setting>
<setting name="Ping_TTL" serializeAs="String">
<value>64</value>
</setting>
</NETworkManager.Properties.Settings>
</userSettings>
</configuration>
28 changes: 28 additions & 0 deletions Source/NETworkManager/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Source/NETworkManager/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,11 @@
<Setting Name="HotKey_ShowWindowEnabled" Provider="SettingsProviderPortable" Roaming="true" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="Ping_DontFragment" Provider="SettingsProviderPortable" Roaming="true" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="Ping_TTL" Provider="SettingsProviderPortable" Roaming="true" Type="System.Int32" Scope="User">
<Value Profile="(Default)">64</Value>
</Setting>
</Settings>
</SettingsFile>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<system:String x:Key="String_Header_Route">Route</system:String>
<system:String x:Key="String_Header_MaximumHopsReached">Maximale Hops erreicht</system:String>
<system:String x:Key="String_Header_CanceledByUser">Vom Benutzer abgebrochen</system:String>
<system:String x:Key="String_Header_DontFragment">Nicht fragmentieren</system:String>

<!-- Normal strings -->
<system:String x:Key="String_ProductName">NETworkManager</system:String>
Expand Down Expand Up @@ -270,8 +271,9 @@

<!-- IPStatus -->
<system:String x:Key="String_IPStatus_Success">Erfolgreich</system:String>
<system:String x:Key="String_IPStatus_DestinationHostUnreachable">Zielhost nicht erreichbar</system:String>
<system:String x:Key="String_IPStatus_TimedOut">Zeitüberschreitung der Anforderung</system:String>
<system:String x:Key="String_IPStatus_DestinationHostUnreachable">Zielhost nicht erreichbar.</system:String>
<system:String x:Key="String_IPStatus_TimedOut">Zeitüberschreitung der Anforderung.</system:String>
<system:String x:Key="String_IPStatus_TtlExpired">Die Gültigkeitsdauer wurde bei der Übertragung überschritten.</system:String>

<!-- Libaries -->
<system:String x:Key="String_Libary_MahAppsMetroName">MahApps.Metro</system:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<system:String x:Key="String_Header_Route">Route</system:String>
<system:String x:Key="String_Header_MaximumHopsReached">Maximum hops reached</system:String>
<system:String x:Key="String_Header_CanceledByUser">Canceled by user</system:String>
<system:String x:Key="String_Header_DontFragment">Don't fragment</system:String>

<!-- Normal strings -->
<system:String x:Key="String_ProductName">NETworkManager</system:String>
Expand Down Expand Up @@ -281,6 +282,7 @@
<system:String x:Key="String_IPStatus_Success">Success</system:String>
<system:String x:Key="String_IPStatus_DestinationHostUnreachable">Destination host unreachable.</system:String>
<system:String x:Key="String_IPStatus_TimedOut">Request timed out.</system:String>
<system:String x:Key="String_IPStatus_TtlExpired">TTL expired in transit.</system:String>

<!-- Libaries -->
<system:String x:Key="String_Libary_MahAppsMetroName">MahApps.Metro</system:String>
Expand Down
57 changes: 1 addition & 56 deletions Source/NETworkManager/ToDo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,4 @@ LEGENDE

Variable beginnt mit Großbuchstaben -> Public
Variable beginnt mit _ -> Private innerhalb einer Klasse
Variable beginnt mit Kleinbuchstabe -> Private innerhalb ein eines Voids/Subroutine


--- Ping stats backup

// // foreach(string s in HostnameOrIPAddressHistory) { MessageBox.Show(s); }

//byte[] buffer = new byte[Buffer];

//do
//{

// PingInfo pingInfo = await Model.Network.Ping.SendAsync(ipAddress);

// PingResults.Add(pingInfo);

// // Some statistics
// if (pingInfo.Status == IPStatus.Success)
// {
// // Some statistics...
// if (PingsTransmitted == 1)
// {
// MinimumTime = pingInfo.Time;
// MaximumTime = pingInfo.Time;
// }
// else
// {
// if (MinimumTime > pingInfo.Time)
// MinimumTime = pingInfo.Time;

// if (MaximumTime < pingInfo.Time)
// MaximumTime = pingInfo.Time;
// }

// PingsReceived++;

// // I just hope this don't slow on large collections
// AverageTime = (int)PingResults.Average(s => s.Time);
// }
// else
// {
// PingsLost++;
// }

// PingsTransmitted++;

// // If ping is canceled... dont wait for example 5 seconds
// for (int i = 0; i < WaitTime; i += 250)
// {
// await Task.Delay(250);

// if (CancelPing)
// break;
// }

//} while (!CancelPing && (Attempts == 0 || PingsTransmitted < Attempts));
Variable beginnt mit Kleinbuchstabe -> Private innerhalb ein eines Voids/Subroutine
Loading