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
17 changes: 17 additions & 0 deletions Wpf/Help.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Window x:Class="GIC.Wpf.Help"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GIC.Wpf"
mc:Ignorable="d"
Title="Help" SizeToContent="WidthAndHeight" ResizeMode="NoResize">
<Grid>
<TextBlock TextWrapping="Wrap" Margin="0,44,0,0" HorizontalAlignment="Center" Width="536" Height="80" VerticalAlignment="Top"><Run Text="Below is a list of all possible IP Addresses that this computer has. This "/><Run Text="information "/><Run Text="will be required to use on the app running on your phone or Tablet."/><LineBreak/><Run/><LineBreak/><Run Text="Optionally, clicking the button below will send a small &quot;ping&quot; out to a Google DNS server - this is done to find which IP Address is likely the one you want to use. "/><Run Language="en-ca" Text=" "/><Run Text="THIS IS OPTIONAL."/></TextBlock>
<Button Content="Online Help Guide" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="29" Width="189" Click="Button_Click"/>
<ListBox Name="lstAddresses" Margin="10,157,287,10"/>
<Label Content="Possible IP Addresses" HorizontalAlignment="Left" Height="23" Margin="10,129,0,0" VerticalAlignment="Top" Width="208" FontWeight="Bold"/>
<Button Content="Click to Find IP Address most likely to be used" Margin="299,157,10,0" Click="Button_Click_1" Height="53" VerticalAlignment="Top"/>
<TextBox Name="txtPreferred" Margin="299,215,10,165" Text="" TextWrapping="Wrap"/>
</Grid>
</Window>
78 changes: 78 additions & 0 deletions Wpf/Help.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Windows;

namespace GIC.Wpf
{
/// <summary>
/// Interaction logic for Help.xaml
/// </summary>
public partial class Help : Window
{
public Help()
{
InitializeComponent();
List<string> addresses = AllIPAddresses();
lstAddresses.ItemsSource = addresses;
}

private string PreferredIPAddress()
{
try
{
string localIP;
using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0))
{
socket.Connect("8.8.8.8", 65530);
IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint;
localIP = endPoint.Address.ToString();
}

return localIP;
} catch (Exception)
{
return null;
}

}

private List<string> AllIPAddresses()
{
try
{
List<string> addresses = new List<string>();
string strHostName = string.Empty;
// Getting Ip address of local machine...
// First get the host name of local machine.
strHostName = Dns.GetHostName();

// Then using host name, get the IP address list..
IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
IPAddress[] addr = ipEntry.AddressList;

for (int i = 0; i < addr.Length; i++)
{
addresses.Add(addr[i].ToString());
}
return addresses;
} catch (Exception)
{
return null;
}

}

private void Button_Click(object sender, RoutedEventArgs e)
{
Process.Start("explorer.exe", "https://github.com/Terence-D/GamingInterfaceCommandServer/wiki");
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
txtPreferred.Text = PreferredIPAddress();
}
}
}
6 changes: 3 additions & 3 deletions Wpf/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using GIC.Common;
using GIC.Common.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -48,7 +47,7 @@ private void TextBoxPasting(object sender, DataObjectPastingEventArgs e)
}
}

private new void PreviewTextInput (object sender, TextCompositionEventArgs e) {
private new void PreviewTextInput(object sender, TextCompositionEventArgs e) {
e.Handled = !IsTextAllowed(e.Text);
}

Expand Down Expand Up @@ -197,7 +196,8 @@ private void btnAbout_Click(object sender, RoutedEventArgs e)

private void btnHelp_Click(object sender, RoutedEventArgs e)
{
Process.Start("explorer.exe", "https://github.com/Terence-D/GamingInterfaceCommandServer/wiki");
Help window = new Help();
window.Show();
}
}
}