diff --git a/Pages/ConfigPage.xaml b/Pages/ConfigPage.xaml index bcc2f5d..14e6fbc 100644 --- a/Pages/ConfigPage.xaml +++ b/Pages/ConfigPage.xaml @@ -11,7 +11,7 @@ - + diff --git a/Pages/ProductKeyPage.xaml.cs b/Pages/ProductKeyPage.xaml.cs index 4f9e985..079b6a8 100644 --- a/Pages/ProductKeyPage.xaml.cs +++ b/Pages/ProductKeyPage.xaml.cs @@ -34,9 +34,33 @@ namespace InstaSoftOfficeTool.Pages if (_suppressAutoTab) return; var tb = (TextBox)sender; + var raw = tb.Text; - var cleaned = Regex.Replace(tb.Text, "[^A-Za-z0-9]", ""); - if (cleaned != tb.Text) + // Detect full key paste (contains dash or longer than 5 chars with alphanumerics) + var allAlphaNum = Regex.Replace(raw, "[^A-Za-z0-9]", ""); + if (allAlphaNum.Length > 5 && tb == _keyBoxes[0]) + { + // Full key pasted — distribute across all boxes + _suppressAutoTab = true; + for (int i = 0; i < 5; i++) + { + int start = i * 5; + if (start < allAlphaNum.Length) + { + int len = System.Math.Min(5, allAlphaNum.Length - start); + _keyBoxes[i].Text = allAlphaNum.Substring(start, len).ToUpper(); + } + } + _suppressAutoTab = false; + _keyBoxes[4].Focus(); + _keyBoxes[4].CaretIndex = _keyBoxes[4].Text.Length; + ValidationMessage.Visibility = Visibility.Collapsed; + return; + } + + // Clean non-alphanumeric chars + var cleaned = Regex.Replace(raw, "[^A-Za-z0-9]", ""); + if (cleaned != raw) { _suppressAutoTab = true; tb.Text = cleaned; @@ -44,6 +68,7 @@ namespace InstaSoftOfficeTool.Pages _suppressAutoTab = false; } + // Auto-tab to next box when 5 chars entered if (tb.Text.Length == 5) { for (int i = 0; i < _keyBoxes.Length - 1; i++) diff --git a/Pages/VersionPage.xaml b/Pages/VersionPage.xaml index 04f5e85..0940fe3 100644 --- a/Pages/VersionPage.xaml +++ b/Pages/VersionPage.xaml @@ -20,7 +20,7 @@ GroupName="Version" IsChecked="True" Margin="0,0,0,10"> - @@ -29,7 +29,7 @@ GroupName="Version" Margin="0,0,0,10"> - @@ -38,7 +38,7 @@ GroupName="Version" Margin="0,0,0,10"> -