aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/UniteSignupDialog.cs
diff options
context:
space:
mode:
authorRogueAI42 <[email protected]>2017-07-02 03:31:42 +1000
committerRogueAI42 <[email protected]>2017-07-02 03:31:42 +1000
commit1e5a7ea9b3269966811f0bd96b0614375347c79f (patch)
tree21c0d775920b8327e7cde0b25c565705a49767aa /ShiftOS.WinForms/UniteSignupDialog.cs
parent33c5ff881eb7035fafe1fe75557f2fd82b14958c (diff)
downloadshiftos_thereturn-1e5a7ea9b3269966811f0bd96b0614375347c79f.tar.gz
shiftos_thereturn-1e5a7ea9b3269966811f0bd96b0614375347c79f.tar.bz2
shiftos_thereturn-1e5a7ea9b3269966811f0bd96b0614375347c79f.zip
Some improvements to the OOBE
Not done, but I need to get to sleep and this seems like a good milestone.
Diffstat (limited to 'ShiftOS.WinForms/UniteSignupDialog.cs')
-rw-r--r--ShiftOS.WinForms/UniteSignupDialog.cs37
1 files changed, 35 insertions, 2 deletions
diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs
index 87629ce..ab926dc 100644
--- a/ShiftOS.WinForms/UniteSignupDialog.cs
+++ b/ShiftOS.WinForms/UniteSignupDialog.cs
@@ -11,14 +11,33 @@ using ShiftOS.Engine;
using Newtonsoft.Json;
using System.Net;
using ShiftOS.Objects;
+using System.Runtime.InteropServices;
namespace ShiftOS.WinForms
{
public partial class UniteSignupDialog : UserControl, IShiftOSWindow
{
+ // sets a placeholder value on a control using Windows API voodoo
+ private static void SetPlaceholder(Control ctl, string txt)
+ {
+ IntPtr str = IntPtr.Zero;
+ try
+ {
+ str = Marshal.StringToHGlobalUni(txt);
+ var msgSetPlaceholder = Message.Create(ctl.Handle, 0x1501, IntPtr.Zero, str);
+ NativeWindow.FromHandle(ctl.Handle).DefWndProc(ref msgSetPlaceholder);
+ }
+ finally
+ {
+ if (str != IntPtr.Zero)
+ Marshal.FreeHGlobal(str);
+ }
+ }
+
public class SignupCredentials
{
public string SystemName { get; set; }
+ public string Username { get; set; }
public string RootPassword { get; set; }
}
@@ -30,10 +49,13 @@ namespace ShiftOS.WinForms
private Action<SignupCredentials> Callback { get; set; }
-
public void OnLoad()
{
this.ParentForm.AcceptButton = btnlogin;
+ SetPlaceholder(txtsys, "Hostname");
+ SetPlaceholder(txtuname, "Username");
+ SetPlaceholder(txtroot, "Password");
+ txtroot.Size = txtuname.Size; // AppearanceManager stop breaking my design REEEEE
}
public void OnSkinLoad()
@@ -52,22 +74,33 @@ namespace ShiftOS.WinForms
private void btnlogin_Click(object sender, EventArgs e)
{
string sys = txtsys.Text;
+ string uname = txtuname.Text;
string root = txtroot.Text;
+ // validation
+
if (string.IsNullOrWhiteSpace(sys))
{
Infobox.Show("{TITLE_EMPTY_SYSNAME}", "{MSG_EMPTY_SYSNAME}");
return;
}
- if(sys.Length < 5)
+
+ if (sys.Length < 5)
{
Infobox.Show("{TITLE_VALIDATION_ERROR}", "{MSG_VALIDATION_ERROR_SYSNAME_LENGTH}");
return;
}
+ if (string.IsNullOrWhiteSpace(uname))
+ {
+ Infobox.Show("{TITLE_VALIDATION_ERROR}", "You must provide a username.");
+ return;
+ }
+
Callback?.Invoke(new SignupCredentials
{
SystemName = sys,
+ Username = uname,
RootPassword = root
});
AppearanceManager.Close(this);