forked from s434786/DINO_SCRUM
Dodano sprawdzenie polaczenia
This commit is contained in:
parent
8eb4e0d538
commit
3d1be2f568
@ -17,8 +17,13 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Magazyn Owoców" MinHeight="259" Height="500" MaxWidth="590" MinWidth="590" Width="590" >
|
Title="Magazyn Owoców" MinHeight="259" Height="500" MaxWidth="590" MinWidth="590" Width="590" >
|
||||||
<Grid>
|
<Grid>
|
||||||
<ListBox MouseDoubleClick="fruitListMouseDoubleClick" x:Name="fruitList" Margin="10,51,10,89"/>
|
<Grid.RowDefinitions>
|
||||||
<Button Name="sum" Content="Wartość magazynu" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="35" Click="Value_Click" HorizontalAlignment="Right" Width="163"/>
|
<RowDefinition Height="435*"/>
|
||||||
|
<RowDefinition Height="0*"/>
|
||||||
|
<RowDefinition Height="34*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<ListBox MouseDoubleClick="fruitListMouseDoubleClick" x:Name="fruitList" Margin="10,51,10,55"/>
|
||||||
|
<Button Name="sum" Content="Wartość magazynu" Margin="0,0,10,10" VerticalAlignment="Bottom" Height="35" Click="Value_Click" HorizontalAlignment="Right" Width="163" Grid.RowSpan="3"/>
|
||||||
<Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
|
<Label Content="Lista owoców:" FontWeight="Bold" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Width="100"/>
|
||||||
<Label Content="Nazwa owocu:" FontWeight="Bold" HorizontalAlignment="Left" Margin="91,25,0,0" VerticalAlignment="Top" Width="100"/>
|
<Label Content="Nazwa owocu:" FontWeight="Bold" HorizontalAlignment="Left" Margin="91,25,0,0" VerticalAlignment="Top" Width="100"/>
|
||||||
|
|
||||||
@ -27,9 +32,11 @@
|
|||||||
<Label Content="Cena 1szt:" FontWeight="Bold" HorizontalAlignment="Left" Margin="360,25,0,0" VerticalAlignment="Top" Width="73"/>
|
<Label Content="Cena 1szt:" FontWeight="Bold" HorizontalAlignment="Left" Margin="360,25,0,0" VerticalAlignment="Top" Width="73"/>
|
||||||
<Label Content="Wartość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="438,25,0,0" VerticalAlignment="Top" Width="65"/>
|
<Label Content="Wartość:" FontWeight="Bold" HorizontalAlignment="Left" Margin="438,25,0,0" VerticalAlignment="Top" Width="65"/>
|
||||||
|
|
||||||
<Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,52" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/>
|
<Button x:Name="prevButton" Content="Poprzednia" HorizontalAlignment="Left" Margin="10,0,0,18" VerticalAlignment="Bottom" Width="105" Click="prevButton_Click"/>
|
||||||
<Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,52" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/>
|
<Button x:Name="nextButton" Content="Następna" HorizontalAlignment="Right" Margin="0,0,10,18" VerticalAlignment="Bottom" Width="105" Click="nextButton_Click"/>
|
||||||
<TextBlock x:Name="pageBlock" FontSize="16" Margin="274,0,273,59" TextWrapping="Wrap" Text="NaN" Height="19" VerticalAlignment="Bottom"/>
|
<TextBlock x:Name="pageBlock" FontSize="16" Margin="274,0,273,25" TextWrapping="Wrap" Text="NaN" Height="19" VerticalAlignment="Bottom"/>
|
||||||
|
<Label Content="Status:" HorizontalAlignment="Left" Margin="4,0,0,14" VerticalAlignment="Bottom" Grid.RowSpan="3"/>
|
||||||
|
<TextBlock Name="netStatus" HorizontalAlignment="Left" Margin="50,0,0,19" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Bottom" Grid.RowSpan="3"/>
|
||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -21,6 +21,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using Magazyn.Windows;
|
using Magazyn.Windows;
|
||||||
using Magazyn.Tools;
|
using Magazyn.Tools;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
|
||||||
namespace Magazyn
|
namespace Magazyn
|
||||||
{
|
{
|
||||||
@ -32,6 +33,7 @@ namespace Magazyn
|
|||||||
|
|
||||||
bool firstPage;
|
bool firstPage;
|
||||||
bool lastPage;
|
bool lastPage;
|
||||||
|
bool netConn;
|
||||||
|
|
||||||
HttpClient client;
|
HttpClient client;
|
||||||
|
|
||||||
@ -42,6 +44,11 @@ namespace Magazyn
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
client = new HttpClient();
|
client = new HttpClient();
|
||||||
this.Loaded += MainWindowLoaded;
|
this.Loaded += MainWindowLoaded;
|
||||||
|
netConn = checkInternetConnection();
|
||||||
|
if (netConn)
|
||||||
|
netStatus.Text = "Połączony";
|
||||||
|
else
|
||||||
|
netStatus.Text = "Rozłączony";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindowLoaded(object sender, EventArgs e)
|
private void MainWindowLoaded(object sender, EventArgs e)
|
||||||
@ -84,6 +91,8 @@ namespace Magazyn
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshListOfFruits()
|
private void RefreshListOfFruits()
|
||||||
|
{
|
||||||
|
if (netConn)
|
||||||
{
|
{
|
||||||
pageBlock.Text = page.ToString();
|
pageBlock.Text = page.ToString();
|
||||||
|
|
||||||
@ -113,6 +122,7 @@ namespace Magazyn
|
|||||||
|
|
||||||
UpdateListOfFruits(fruits);
|
UpdateListOfFruits(fruits);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateListOfFruits(Fruit[] list)
|
private void UpdateListOfFruits(Fruit[] list)
|
||||||
{
|
{
|
||||||
@ -178,6 +188,17 @@ namespace Magazyn
|
|||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Boolean checkInternetConnection()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new Ping().Send("www.google.com").Status == IPStatus.Success;
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user