Edit Username, New Chat Dialog
This commit is contained in:
21
PolyChat/Views/EditUsernameDialog.xaml
Normal file
21
PolyChat/Views/EditUsernameDialog.xaml
Normal file
@@ -0,0 +1,21 @@
|
||||
<ContentDialog x:Class="PolyChat.Views.EditUsernameDialog"
|
||||
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:local="using:PolyChat.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
x:Name="ContentDialog"
|
||||
Title="Change Username"
|
||||
PrimaryButtonText="Save"
|
||||
SecondaryButtonText="Cancel"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="16"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox x:Name="input" KeyUp="OnKeyUp" PlaceholderText="Marco Sattler"/>
|
||||
<TextBlock Grid.Row="1" x:Name="textError" Text="Username cannot be empty" VerticalAlignment="Center" Foreground="{ThemeResource SystemErrorTextColor}"/>
|
||||
</Grid>
|
||||
</ContentDialog>
|
||||
51
PolyChat/Views/EditUsernameDialog.xaml.cs
Normal file
51
PolyChat/Views/EditUsernameDialog.xaml.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using PolyChat.Models;
|
||||
using PolyChat.Util;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
namespace PolyChat.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class EditUsernameDialog : ContentDialog
|
||||
{
|
||||
public EditUsernameDialog(string initialValue)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
if (initialValue == null || initialValue.Length == 0) IsSecondaryButtonEnabled = false;
|
||||
else input.Text = initialValue;
|
||||
validate();
|
||||
}
|
||||
|
||||
public string getValue()
|
||||
{
|
||||
return input.Text;
|
||||
}
|
||||
|
||||
private void OnKeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
|
||||
{
|
||||
validate();
|
||||
}
|
||||
|
||||
private void validate()
|
||||
{
|
||||
if (input.Text.Length == 0)
|
||||
{
|
||||
textError.Visibility = Visibility.Visible;
|
||||
IsPrimaryButtonEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
textError.Visibility = Visibility.Collapsed;
|
||||
IsPrimaryButtonEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,17 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
x:Name="ContentDialog"
|
||||
Title="Connect to"
|
||||
PrimaryButtonClick="OnConnect"
|
||||
PrimaryButtonText="Connect"
|
||||
SecondaryButtonClick="OnClose"
|
||||
SecondaryButtonText="Cancel"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<TextBox x:Name="inputIP" PlaceholderText="192.168.1.1" VerticalAlignment="Center"/>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox x:Name="input" KeyUp="OnKeyUp" PlaceholderText="Partner Code"/>
|
||||
<TextBlock Grid.Row="1" x:Name="textSuccess" Text="Looking good" VerticalAlignment="Top" Foreground="{ThemeResource SystemAccentColor}" Visibility="Collapsed"/>
|
||||
<TextBlock Grid.Row="1" x:Name="textError" Text="Invalid or empty Code" VerticalAlignment="Top" Foreground="{ThemeResource SystemErrorTextColor}" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
</ContentDialog>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using PolyChat.Models;
|
||||
using PolyChat.Util;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
@@ -17,19 +19,27 @@ namespace PolyChat.Views
|
||||
public NewChatDialog()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
IsPrimaryButtonEnabled = false;
|
||||
}
|
||||
|
||||
public string getText()
|
||||
public string getValue()
|
||||
{
|
||||
return inputIP.Text;
|
||||
return input.Text;
|
||||
}
|
||||
|
||||
public void OnConnect(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnClose(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
private void OnKeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
|
||||
{
|
||||
if (!IP.ValidateIP(IP.GetIPfromCode(input.Text)))
|
||||
{
|
||||
textSuccess.Visibility = Visibility.Collapsed;
|
||||
textError.Visibility = Visibility.Visible;
|
||||
IsPrimaryButtonEnabled = false;
|
||||
} else
|
||||
{
|
||||
textSuccess.Visibility = Visibility.Visible;
|
||||
textError.Visibility = Visibility.Collapsed;
|
||||
IsPrimaryButtonEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user