Usuniece konfliktu

This commit is contained in:
Krystian Kabat 2019-01-27 19:31:58 +01:00
commit 9e5a1bde5b
2 changed files with 56 additions and 27 deletions

View File

@ -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>

View File

@ -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,9 @@ namespace Magazyn
} }
private void RefreshListOfFruits() private void RefreshListOfFruits()
{
if (netConn)
{ {
pageBlock.Text = (page+1).ToString(); pageBlock.Text = (page+1).ToString();
@ -113,6 +123,7 @@ namespace Magazyn
UpdateListOfFruits(fruits); UpdateListOfFruits(fruits);
} }
}
private void UpdateListOfFruits(Fruit[] list) private void UpdateListOfFruits(Fruit[] list)
{ {
@ -178,6 +189,17 @@ namespace Magazyn
window.ShowDialog(); window.ShowDialog();
} }
} }
private Boolean checkInternetConnection()
{
try
{
return new Ping().Send("www.google.com").Status == IPStatus.Success;
} catch
{
return false;
}
}
} }
} }