diff --git a/windows/WinUI/Views/AboutView.xaml b/windows/WinUI/AboutView.xaml
similarity index 100%
rename from windows/WinUI/Views/AboutView.xaml
rename to windows/WinUI/AboutView.xaml
diff --git a/windows/WinUI/Views/AboutView.xaml.cs b/windows/WinUI/AboutView.xaml.cs
similarity index 100%
rename from windows/WinUI/Views/AboutView.xaml.cs
rename to windows/WinUI/AboutView.xaml.cs
diff --git a/windows/WinUI/JoinNetworkView.xaml b/windows/WinUI/JoinNetworkView.xaml
new file mode 100644
index 000000000..789be1064
--- /dev/null
+++ b/windows/WinUI/JoinNetworkView.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
diff --git a/windows/WinUI/JoinNetworkView.xaml.cs b/windows/WinUI/JoinNetworkView.xaml.cs
new file mode 100644
index 000000000..548a51e6b
--- /dev/null
+++ b/windows/WinUI/JoinNetworkView.xaml.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace WinUI
+{
+ ///
+ /// Interaction logic for JoinNetworkView.xaml
+ ///
+ public partial class JoinNetworkView : Window
+ {
+ Regex charRegex = new Regex("[0-9a-fxA-FX]");
+ Regex wholeStringRegex = new Regex("^[0-9a-fxA-FX]+$");
+
+ public JoinNetworkView()
+ {
+ InitializeComponent();
+
+ DataObject.AddPastingHandler(joinNetworkBox, onPaste);
+ DataObject.AddCopyingHandler(joinNetworkBox, onCopyCut);
+ }
+
+ private void joinNetworkBox_OnTextEntered(object sender, TextCompositionEventArgs e)
+ {
+ e.Handled = !charRegex.IsMatch(e.Text);
+
+ if ( (joinNetworkBox.Text.Length + e.Text.Length) == 16)
+ {
+ joinButton.IsEnabled = true;
+ }
+ else
+ {
+ joinButton.IsEnabled = false;
+ }
+ }
+
+ private void joinNetworkBox_OnKeyDown(object sender, KeyEventArgs e)
+ {
+ if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
+ {
+ if (e.Key == Key.X && joinNetworkBox.IsSelectionActive)
+ {
+ // handle ctrl-x removing characters
+ joinButton.IsEnabled = false;
+ }
+ }
+ else if (e.Key == Key.Delete || e.Key == Key.Back)
+ {
+ if ((joinNetworkBox.Text.Length - 1) == 16)
+ {
+ joinButton.IsEnabled = true;
+ }
+ else
+ {
+ joinButton.IsEnabled = false;
+ }
+ }
+ else
+ {
+ if ((joinNetworkBox.Text.Length + 1) > 16)
+ {
+ e.Handled = true;
+ }
+ }
+ }
+
+ private void onPaste(object sender, DataObjectPastingEventArgs e)
+ {
+ var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true);
+ if (!isText)
+ {
+ joinButton.IsEnabled = false;
+ return;
+ }
+
+ var text = e.SourceDataObject.GetData(DataFormats.UnicodeText) as string;
+
+ if (!wholeStringRegex.IsMatch(text))
+ {
+ e.Handled = true;
+ e.CancelCommand();
+ }
+
+ if (text.Length == 16 || (joinNetworkBox.Text.Length + text.Length) == 16)
+ {
+ joinButton.IsEnabled = true;
+ }
+ else if (text.Length > 16 || (joinNetworkBox.Text.Length + text.Length) > 16)
+ {
+ e.Handled = true;
+ e.CancelCommand();
+ }
+ else
+ {
+ joinButton.IsEnabled = false;
+ }
+ }
+
+ private void onCopyCut(object sender, DataObjectCopyingEventArgs e)
+ {
+
+ }
+
+ private void joinButton_Click(object sender, RoutedEventArgs e)
+ {
+ bool allowDefault = allowDefaultCheckbox.IsChecked.Value;
+ bool allowGlobal = allowGlobalCheckbox.IsChecked.Value;
+ bool allowManaged = allowManagedCheckbox.IsChecked.Value;
+
+ APIHandler.Instance.JoinNetwork(joinNetworkBox.Text, allowManaged, allowGlobal, allowDefault);
+
+ Close();
+ }
+ }
+}
diff --git a/windows/WinUI/Views/NetworkInfoView.xaml b/windows/WinUI/NetworkInfoView.xaml
similarity index 100%
rename from windows/WinUI/Views/NetworkInfoView.xaml
rename to windows/WinUI/NetworkInfoView.xaml
diff --git a/windows/WinUI/Views/NetworkInfoView.xaml.cs b/windows/WinUI/NetworkInfoView.xaml.cs
similarity index 100%
rename from windows/WinUI/Views/NetworkInfoView.xaml.cs
rename to windows/WinUI/NetworkInfoView.xaml.cs
diff --git a/windows/WinUI/Views/NetworkListView.xaml b/windows/WinUI/NetworkListView.xaml
similarity index 100%
rename from windows/WinUI/Views/NetworkListView.xaml
rename to windows/WinUI/NetworkListView.xaml
diff --git a/windows/WinUI/Views/NetworkListView.xaml.cs b/windows/WinUI/NetworkListView.xaml.cs
similarity index 100%
rename from windows/WinUI/Views/NetworkListView.xaml.cs
rename to windows/WinUI/NetworkListView.xaml.cs
diff --git a/windows/WinUI/Views/NetworksPage.xaml b/windows/WinUI/NetworksPage.xaml
similarity index 100%
rename from windows/WinUI/Views/NetworksPage.xaml
rename to windows/WinUI/NetworksPage.xaml
diff --git a/windows/WinUI/Views/NetworksPage.xaml.cs b/windows/WinUI/NetworksPage.xaml.cs
similarity index 100%
rename from windows/WinUI/Views/NetworksPage.xaml.cs
rename to windows/WinUI/NetworksPage.xaml.cs
diff --git a/windows/WinUI/Views/PeersPage.xaml b/windows/WinUI/PeersPage.xaml
similarity index 100%
rename from windows/WinUI/Views/PeersPage.xaml
rename to windows/WinUI/PeersPage.xaml
diff --git a/windows/WinUI/Views/PeersPage.xaml.cs b/windows/WinUI/PeersPage.xaml.cs
similarity index 100%
rename from windows/WinUI/Views/PeersPage.xaml.cs
rename to windows/WinUI/PeersPage.xaml.cs
diff --git a/windows/WinUI/Views/ToolbarItem.xaml b/windows/WinUI/ToolbarItem.xaml
similarity index 100%
rename from windows/WinUI/Views/ToolbarItem.xaml
rename to windows/WinUI/ToolbarItem.xaml
diff --git a/windows/WinUI/Views/ToolbarItem.xaml.cs b/windows/WinUI/ToolbarItem.xaml.cs
similarity index 94%
rename from windows/WinUI/Views/ToolbarItem.xaml.cs
rename to windows/WinUI/ToolbarItem.xaml.cs
index 15aeb24bf..b7ac793f5 100644
--- a/windows/WinUI/Views/ToolbarItem.xaml.cs
+++ b/windows/WinUI/ToolbarItem.xaml.cs
@@ -30,6 +30,7 @@ namespace WinUI
private APIHandler handler = APIHandler.Instance;
private NetworkListView netListView = null;
+ private JoinNetworkView joinNetView = null;
private NetworkMonitor mon = NetworkMonitor.Instance;
@@ -127,12 +128,17 @@ namespace WinUI
private void ToolbarItem_JoinNetworkClicked(object sender, System.EventArgs e)
{
-
+ if (joinNetView == null)
+ {
+ joinNetView = new JoinNetworkView();
+ joinNetView.Closed += JoinNetworkClosed;
+ joinNetView.Show();
+ }
}
private void JoinNetworkClosed(object sender, System.EventArgs e)
{
-
+ joinNetView = null;
}
private void ToolbarItem_NetworkClicked(object sender, System.Windows.RoutedEventArgs e)
diff --git a/windows/WinUI/Views/JoinNetworkView.xaml b/windows/WinUI/Views/JoinNetworkView.xaml
deleted file mode 100644
index b359fcd8b..000000000
--- a/windows/WinUI/Views/JoinNetworkView.xaml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/windows/WinUI/Views/JoinNetworkView.xaml.cs b/windows/WinUI/Views/JoinNetworkView.xaml.cs
deleted file mode 100644
index eca0647ed..000000000
--- a/windows/WinUI/Views/JoinNetworkView.xaml.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-
-namespace WinUI
-{
- ///
- /// Interaction logic for JoinNetworkView.xaml
- ///
- public partial class JoinNetworkView : Window
- {
- public JoinNetworkView()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/windows/WinUI/WinUI.csproj b/windows/WinUI/WinUI.csproj
index 92ee586af..53f715d0c 100644
--- a/windows/WinUI/WinUI.csproj
+++ b/windows/WinUI/WinUI.csproj
@@ -101,6 +101,12 @@
MSBuild:Compile
Designer
+
+ AboutView.xaml
+
+
+ JoinNetworkView.xaml
+
@@ -116,6 +122,14 @@
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer