Skip to content

Commit 790d7fb

Browse files
authored
Add files via upload
1 parent 504bc62 commit 790d7fb

File tree

57 files changed

+1287
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1287
-0
lines changed

PingerAppV2.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.40629.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PingerAppV2", "PingerAppV2\PingerAppV2.csproj", "{A5E0C4B0-F319-43F6-ABE5-E5827146270B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A5E0C4B0-F319-43F6-ABE5-E5827146270B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A5E0C4B0-F319-43F6-ABE5-E5827146270B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A5E0C4B0-F319-43F6-ABE5-E5827146270B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A5E0C4B0-F319-43F6-ABE5-E5827146270B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

PingerAppV2.v12.suo

21.5 KB
Binary file not shown.

PingerAppV2/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

PingerAppV2/App.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application x:Class="PingerAppV2.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<Application.Resources>
6+
7+
</Application.Resources>
8+
</Application>

PingerAppV2/App.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace PingerAppV2
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}

PingerAppV2/MainWindow.xaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<Window x:Class="PingerAppV2.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
ResizeMode="NoResize"
5+
Title="Pinger App V2" Height="350" Width="588">
6+
<Grid x:Name="grid">
7+
<VisualStateManager.VisualStateGroups>
8+
<VisualStateGroup x:Name="StartStateGroup">
9+
<VisualState x:Name="StartStateOff"/>
10+
<VisualState x:Name="StartStateOn"/>
11+
</VisualStateGroup>
12+
</VisualStateManager.VisualStateGroups>
13+
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Vertical">
14+
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0" Orientation="Horizontal">
15+
<Button x:Name="BtnSelectFoler" Height="30" Width="100" Content="Select Folder" Click="BtnSelectFoler_OnClick"></Button>
16+
<Label Margin="10,0,0,0" Content="Delimeter: " />
17+
<TextBox x:Name="TxtDelimeter" Margin="10,0,0,0" Width="100" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"/>
18+
<Button x:Name="BtnStart" Margin="10,0,0,0" Height="30" Width="100" Content="Start" Click="BtnStart_OnClick"></Button>
19+
</StackPanel>
20+
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,0,0,0" Orientation="Horizontal">
21+
<StackPanel Orientation="Vertical">
22+
<Label VerticalAlignment="Top" HorizontalAlignment="Center" Content="All Devices"/>
23+
<ListView x:Name="ListAllDevices" ItemsSource="{Binding DeviceIPs}" Width="175" Height="200" ScrollViewer.VerticalScrollBarVisibility="Visible"/>
24+
</StackPanel>
25+
<StackPanel Margin="10,0,0,0" Orientation="Vertical">
26+
<Label VerticalAlignment="Top" HorizontalAlignment="Center" Content="Success Devices"/>
27+
<ListView x:Name="ListSuccessDevices" ItemsSource="{Binding SuccessfulIp}" Width="175" Height="200" ScrollViewer.VerticalScrollBarVisibility="Visible"/>
28+
</StackPanel>
29+
<StackPanel Margin="10,0,0,0" Orientation="Vertical">
30+
<Label VerticalAlignment="Top" HorizontalAlignment="Center" Content="Failed Devices"/>
31+
<ListView x:Name="ListFailedDevices" ItemsSource="{Binding FailedIp}" Width="175" Height="200" ScrollViewer.VerticalScrollBarVisibility="Visible"/>
32+
</StackPanel>
33+
34+
</StackPanel>
35+
</StackPanel>
36+
</Grid>
37+
</Window>

PingerAppV2/MainWindow.xaml.cs

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.ComponentModel;
5+
using System.IO;
6+
using System.Linq;
7+
using System.Net;
8+
using System.Net.NetworkInformation;
9+
using System.Windows;
10+
using System.Windows.Media;
11+
using Microsoft.Win32;
12+
13+
namespace PingerAppV2
14+
{
15+
/// <summary>
16+
/// Interaction logic for MainWindow.xaml
17+
/// </summary>
18+
public partial class MainWindow : Window, INotifyPropertyChanged
19+
{
20+
private string _delimeter = string.Empty;
21+
private string _filePath = string.Empty;
22+
private readonly List<string> _readLines = new List<string>();
23+
private ObservableCollection<string> _deviceIPs = new ObservableCollection<string>();
24+
private ObservableCollection<string> _successfulIp = new ObservableCollection<string>();
25+
private ObservableCollection<string> _failedIp = new ObservableCollection<string>();
26+
27+
public ObservableCollection<string> DeviceIPs
28+
{
29+
get { return _deviceIPs; }
30+
set
31+
{
32+
_deviceIPs = value;
33+
OnPropertyChanged("DeviceIPs");
34+
}
35+
}
36+
public ObservableCollection<string> SuccessfulIp
37+
{
38+
get { return _successfulIp; }
39+
set
40+
{
41+
_successfulIp = value;
42+
OnPropertyChanged("SuccessfulIp");
43+
}
44+
}
45+
public ObservableCollection<string> FailedIp
46+
{
47+
get { return _failedIp; }
48+
set
49+
{
50+
_failedIp = value;
51+
OnPropertyChanged("FailedIp");
52+
}
53+
}
54+
55+
public MainWindow()
56+
{
57+
InitializeComponent();
58+
DataContext = this;
59+
}
60+
61+
private void BtnSelectFoler_OnClick(object sender, RoutedEventArgs e)
62+
{
63+
var openFileDialog1 = new OpenFileDialog()
64+
{
65+
FileName = "Select a file",
66+
Title = "Get File"
67+
};
68+
69+
if (openFileDialog1.ShowDialog() == true)
70+
{
71+
_filePath = openFileDialog1.FileName;
72+
}
73+
}
74+
75+
private void BtnStart_OnClick(object sender, RoutedEventArgs e)
76+
{
77+
_delimeter = TxtDelimeter.Text;
78+
if (string.IsNullOrEmpty(_delimeter))
79+
{
80+
MessageBox.Show("Delimeter Should be Determined Before Start.");
81+
}
82+
else
83+
{
84+
using (var sr = new StreamReader(_filePath))
85+
{
86+
while (!sr.EndOfStream)
87+
{
88+
_readLines.Add(sr.ReadLine());
89+
}
90+
}
91+
}
92+
93+
var splicedLines = Split(_readLines.Skip(1).ToList());
94+
foreach (var lineArrays in splicedLines)
95+
{
96+
var ip = string.Empty;
97+
foreach (var item in lineArrays)
98+
{
99+
IPAddress temp;
100+
if (IPAddress.TryParse(item, out temp))
101+
{
102+
ip = item;
103+
break;
104+
}
105+
}
106+
107+
if (!DeviceIPs.Contains(ip))
108+
{
109+
DeviceIPs.Add(ip);
110+
}
111+
}
112+
113+
StartPing(DeviceIPs.ToList());
114+
}
115+
116+
private IEnumerable<string[]> Split(IEnumerable<string> input)
117+
{
118+
return input.Select(item => item.Split(_delimeter.FirstOrDefault()));
119+
}
120+
121+
private void StartPing(IEnumerable<string> ipLine)
122+
{
123+
VisualStateManager.GoToElementState(grid, StartStateOn.Name, true);
124+
var backgroundWorker = new BackgroundWorker();
125+
backgroundWorker.DoWork += backgroundWorker_DoWork;
126+
backgroundWorker.RunWorkerAsync(ipLine);
127+
}
128+
129+
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
130+
{
131+
var ipLine = e.Argument as IEnumerable<string>;
132+
if (ipLine != null)
133+
{
134+
if (Dispatcher != null)
135+
{
136+
Dispatcher.Invoke(() =>
137+
{
138+
foreach (var line in ipLine)
139+
{
140+
try
141+
{
142+
var myPing = new Ping();
143+
var reply = myPing.Send(line, 100);
144+
if (reply != null && reply.Status == IPStatus.Success)
145+
{
146+
if (!SuccessfulIp.Contains(line))
147+
{
148+
SuccessfulIp.Add(line);
149+
}
150+
continue;
151+
}
152+
}
153+
catch (Exception)
154+
{
155+
// ignored
156+
}
157+
if (!FailedIp.Contains(line))
158+
{
159+
FailedIp.Add(line);
160+
}
161+
}
162+
VisualStateManager.GoToElementState(grid, StartStateOff.Name, true);
163+
});
164+
}
165+
}
166+
}
167+
168+
// Property Change function to notify clients
169+
public event PropertyChangedEventHandler PropertyChanged;
170+
private void OnPropertyChanged(string propertyName)
171+
{
172+
if (PropertyChanged != null)
173+
{
174+
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
175+
}
176+
}
177+
}
178+
}

PingerAppV2/PingerAppV2.csproj

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{A5E0C4B0-F319-43F6-ABE5-E5827146270B}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>PingerAppV2</RootNamespace>
11+
<AssemblyName>PingerAppV2</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
15+
<WarningLevel>4</WarningLevel>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<PlatformTarget>AnyCPU</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="Microsoft.Expression.Interactions, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
38+
<Reference Include="System" />
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Xml" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Core" />
43+
<Reference Include="System.Xml.Linq" />
44+
<Reference Include="System.Data.DataSetExtensions" />
45+
<Reference Include="System.Xaml">
46+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
47+
</Reference>
48+
<Reference Include="WindowsBase" />
49+
<Reference Include="PresentationCore" />
50+
<Reference Include="PresentationFramework" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<ApplicationDefinition Include="App.xaml">
54+
<Generator>MSBuild:Compile</Generator>
55+
<SubType>Designer</SubType>
56+
</ApplicationDefinition>
57+
<Page Include="MainWindow.xaml">
58+
<Generator>MSBuild:Compile</Generator>
59+
<SubType>Designer</SubType>
60+
</Page>
61+
<Compile Include="App.xaml.cs">
62+
<DependentUpon>App.xaml</DependentUpon>
63+
<SubType>Code</SubType>
64+
</Compile>
65+
<Compile Include="MainWindow.xaml.cs">
66+
<DependentUpon>MainWindow.xaml</DependentUpon>
67+
<SubType>Code</SubType>
68+
</Compile>
69+
</ItemGroup>
70+
<ItemGroup>
71+
<Compile Include="Properties\AssemblyInfo.cs">
72+
<SubType>Code</SubType>
73+
</Compile>
74+
<Compile Include="Properties\Resources.Designer.cs">
75+
<AutoGen>True</AutoGen>
76+
<DesignTime>True</DesignTime>
77+
<DependentUpon>Resources.resx</DependentUpon>
78+
</Compile>
79+
<Compile Include="Properties\Settings.Designer.cs">
80+
<AutoGen>True</AutoGen>
81+
<DependentUpon>Settings.settings</DependentUpon>
82+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
83+
</Compile>
84+
<EmbeddedResource Include="Properties\Resources.resx">
85+
<Generator>ResXFileCodeGenerator</Generator>
86+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
87+
</EmbeddedResource>
88+
<None Include="Properties\Settings.settings">
89+
<Generator>SettingsSingleFileGenerator</Generator>
90+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
91+
</None>
92+
<AppDesigner Include="Properties\" />
93+
</ItemGroup>
94+
<ItemGroup>
95+
<None Include="App.config" />
96+
</ItemGroup>
97+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
98+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
99+
Other similar extension points exist, see Microsoft.Common.targets.
100+
<Target Name="BeforeBuild">
101+
</Target>
102+
<Target Name="AfterBuild">
103+
</Target>
104+
-->
105+
</Project>

0 commit comments

Comments
 (0)