{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/comments/88803181","pull_request_review_id":9365935,"id":88803181,"diff_hunk":"@@ -0,0 +1,303 @@\n+﻿// ******************************************************************\n+// Copyright (c) Microsoft. All rights reserved.\n+// This code is licensed under the MIT License (MIT).\n+// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH\n+// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.\n+// ******************************************************************\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Text.RegularExpressions;\n+using Windows.ApplicationModel.DataTransfer;\n+using Windows.UI.Xaml;\n+using Windows.UI.Xaml.Controls;\n+\n+namespace Microsoft.Toolkit.Uwp.UI.Controls\n+{\n+    /// <summary>\n+    /// TextBox Mask property allows a user to more easily enter fixed width text in TextBox control\n+    /// where you would like them to enter the data in a certain format\n+    /// </summary>\n+    public partial class TextBoxMask\n+    {\n+        private const string DefaultPlaceHolder = \"_\";\n+        private static readonly KeyValuePair<char, string> AlphaCharacterRepresentation = new KeyValuePair<char, string>('a', \"[A-Za-z]\");\n+        private static readonly KeyValuePair<char, string> NumericCharacterRepresentation = new KeyValuePair<char, string>('9', \"[0-9]\");\n+        private static readonly KeyValuePair<char, string> AlphaNumericRepresentation = new KeyValuePair<char, string>('*', \"[A-Za-z0-9]\");\n+\n+        private static void OnMaskChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\n+        {\n+            InitTextBoxMask(d, e);\n+        }\n+\n+        private static void OnPlaceHolderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\n+        {\n+            InitTextBoxMask(d, e);\n+        }\n+\n+        private static void OnCustomMaskChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\n+        {\n+            InitTextBoxMask(d, e);\n+        }\n+\n+        private static void InitTextBoxMask(DependencyObject d, DependencyPropertyChangedEventArgs e)\n+        {\n+            var textbox = d as TextBox;\n+\n+            // incase no value is provided us it as normal textbox\n+            var mask = textbox?.GetValue(MaskProperty) as string;\n+            if (string.IsNullOrWhiteSpace(mask))\n+            {\n+                return;\n+            }\n+\n+            var placeHolderValue = textbox.GetValue(PlaceHolderProperty) as string;\n+            if (string.IsNullOrEmpty(placeHolderValue))\n+            {\n+                return;\n+            }\n+\n+            var placeHolder = placeHolderValue[0];\n+\n+            var representationDictionary = textbox.GetValue(RepresentationDictionaryProperty) as Dictionary<char, string>;\n+            representationDictionary = new Dictionary<char, string>();\n+            representationDictionary.Add(AlphaCharacterRepresentation.Key, AlphaCharacterRepresentation.Value);\n+            representationDictionary.Add(NumericCharacterRepresentation.Key, NumericCharacterRepresentation.Value);\n+            representationDictionary.Add(AlphaNumericRepresentation.Key, AlphaNumericRepresentation.Value);\n+\n+            var customDictionaryValue = textbox.GetValue(CustomMaskProperty) as string;\n+            if (!string.IsNullOrWhiteSpace(customDictionaryValue))\n+            {\n+                var customRoles = customDictionaryValue.Split(',');\n+                foreach (var role in customRoles)\n+                {\n+                    var roleValues = role.Split(':');\n+                    if (roleValues.Length != 2)\n+                    {\n+                        throw new Exception(\"Invalid custom mask\");","path":"Microsoft.Toolkit.Uwp.UI.Controls/TextBoxMask/TextBoxMask.cs","position":82,"original_position":82,"commit_id":"18eb34f0020da2410a10b6206422a2a16e93c0e0","original_commit_id":"18eb34f0020da2410a10b6206422a2a16e93c0e0","user":{"login":"IbraheemOsama","id":6191377,"avatar_url":"https://avatars.githubusercontent.com/u/6191377?v=3","gravatar_id":"","url":"https://api.github.com/users/IbraheemOsama","html_url":"https://github.com/IbraheemOsama","followers_url":"https://api.github.com/users/IbraheemOsama/followers","following_url":"https://api.github.com/users/IbraheemOsama/following{/other_user}","gists_url":"https://api.github.com/users/IbraheemOsama/gists{/gist_id}","starred_url":"https://api.github.com/users/IbraheemOsama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IbraheemOsama/subscriptions","organizations_url":"https://api.github.com/users/IbraheemOsama/orgs","repos_url":"https://api.github.com/users/IbraheemOsama/repos","events_url":"https://api.github.com/users/IbraheemOsama/events{/privacy}","received_events_url":"https://api.github.com/users/IbraheemOsama/received_events","type":"User","site_admin":false},"body":"Make sense, will use ArgumentException","created_at":"2016-11-20T14:52:53Z","updated_at":"2016-11-20T14:52:53Z","html_url":"https://github.com/Microsoft/UWPCommunityToolkit/pull/640#discussion_r88803181","pull_request_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/640","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/comments/88803181"},"html":{"href":"https://github.com/Microsoft/UWPCommunityToolkit/pull/640#discussion_r88803181"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/640"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/640","id":94518860,"html_url":"https://github.com/Microsoft/UWPCommunityToolkit/pull/640","diff_url":"https://github.com/Microsoft/UWPCommunityToolkit/pull/640.diff","patch_url":"https://github.com/Microsoft/UWPCommunityToolkit/pull/640.patch","issue_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/issues/640","number":640,"state":"open","locked":false,"title":"Adding Text box mask property","user":{"login":"IbraheemOsama","id":6191377,"avatar_url":"https://avatars.githubusercontent.com/u/6191377?v=3","gravatar_id":"","url":"https://api.github.com/users/IbraheemOsama","html_url":"https://github.com/IbraheemOsama","followers_url":"https://api.github.com/users/IbraheemOsama/followers","following_url":"https://api.github.com/users/IbraheemOsama/following{/other_user}","gists_url":"https://api.github.com/users/IbraheemOsama/gists{/gist_id}","starred_url":"https://api.github.com/users/IbraheemOsama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IbraheemOsama/subscriptions","organizations_url":"https://api.github.com/users/IbraheemOsama/orgs","repos_url":"https://api.github.com/users/IbraheemOsama/repos","events_url":"https://api.github.com/users/IbraheemOsama/events{/privacy}","received_events_url":"https://api.github.com/users/IbraheemOsama/received_events","type":"User","site_admin":false},"body":"Adding Text box mask property for issue #153 ","created_at":"2016-11-20T14:04:47Z","updated_at":"2016-11-20T14:52:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e3afe0cd9a3683ed09f438610ead09db40d652a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/640/commits","review_comments_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/640/comments","review_comment_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/issues/640/comments","statuses_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/statuses/18eb34f0020da2410a10b6206422a2a16e93c0e0","head":{"label":"IbraheemOsama:TextBoxMask","ref":"TextBoxMask","sha":"18eb34f0020da2410a10b6206422a2a16e93c0e0","user":{"login":"IbraheemOsama","id":6191377,"avatar_url":"https://avatars.githubusercontent.com/u/6191377?v=3","gravatar_id":"","url":"https://api.github.com/users/IbraheemOsama","html_url":"https://github.com/IbraheemOsama","followers_url":"https://api.github.com/users/IbraheemOsama/followers","following_url":"https://api.github.com/users/IbraheemOsama/following{/other_user}","gists_url":"https://api.github.com/users/IbraheemOsama/gists{/gist_id}","starred_url":"https://api.github.com/users/IbraheemOsama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IbraheemOsama/subscriptions","organizations_url":"https://api.github.com/users/IbraheemOsama/orgs","repos_url":"https://api.github.com/users/IbraheemOsama/repos","events_url":"https://api.github.com/users/IbraheemOsama/events{/privacy}","received_events_url":"https://api.github.com/users/IbraheemOsama/received_events","type":"User","site_admin":false},"repo":{"id":66025254,"name":"UWPCommunityToolkit","full_name":"IbraheemOsama/UWPCommunityToolkit","owner":{"login":"IbraheemOsama","id":6191377,"avatar_url":"https://avatars.githubusercontent.com/u/6191377?v=3","gravatar_id":"","url":"https://api.github.com/users/IbraheemOsama","html_url":"https://github.com/IbraheemOsama","followers_url":"https://api.github.com/users/IbraheemOsama/followers","following_url":"https://api.github.com/users/IbraheemOsama/following{/other_user}","gists_url":"https://api.github.com/users/IbraheemOsama/gists{/gist_id}","starred_url":"https://api.github.com/users/IbraheemOsama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IbraheemOsama/subscriptions","organizations_url":"https://api.github.com/users/IbraheemOsama/orgs","repos_url":"https://api.github.com/users/IbraheemOsama/repos","events_url":"https://api.github.com/users/IbraheemOsama/events{/privacy}","received_events_url":"https://api.github.com/users/IbraheemOsama/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/IbraheemOsama/UWPCommunityToolkit","description":"The UWP Community Toolkit is a collection of helper functions, custom controls, and app services. It simplifies and demonstrates common developer tasks building UWP apps for Windows 10.","fork":true,"url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit","forks_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/forks","keys_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/teams","hooks_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/hooks","issue_events_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/issues/events{/number}","events_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/events","assignees_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/assignees{/user}","branches_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/branches{/branch}","tags_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/tags","blobs_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/languages","stargazers_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/stargazers","contributors_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/contributors","subscribers_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/subscribers","subscription_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/subscription","commits_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/contents/{+path}","compare_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/merges","archive_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/downloads","issues_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/issues{/number}","pulls_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/labels{/name}","releases_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/releases{/id}","deployments_url":"https://api.github.com/repos/IbraheemOsama/UWPCommunityToolkit/deployments","created_at":"2016-08-18T19:35:49Z","updated_at":"2016-08-18T19:35:51Z","pushed_at":"2016-11-20T14:02:09Z","git_url":"git://github.com/IbraheemOsama/UWPCommunityToolkit.git","ssh_url":"git@github.com:IbraheemOsama/UWPCommunityToolkit.git","clone_url":"https://github.com/IbraheemOsama/UWPCommunityToolkit.git","svn_url":"https://github.com/IbraheemOsama/UWPCommunityToolkit","homepage":"","size":73968,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"Microsoft:dev","ref":"dev","sha":"34bec3c4061fc8ca7b52d17236db8a7cf895fbf7","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":61403402,"name":"UWPCommunityToolkit","full_name":"Microsoft/UWPCommunityToolkit","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/UWPCommunityToolkit","description":"The UWP Community Toolkit is a collection of helper functions, custom controls, and app services. It simplifies and demonstrates common developer tasks building UWP apps for Windows 10. The toolkit is part of the .NET Foundation.","fork":false,"url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit","forks_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/forks","keys_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/teams","hooks_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/events","assignees_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/tags","blobs_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/languages","stargazers_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/subscription","commits_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/merges","archive_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/downloads","issues_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/deployments","created_at":"2016-06-17T21:29:46Z","updated_at":"2016-11-20T02:21:55Z","pushed_at":"2016-11-20T14:04:47Z","git_url":"git://github.com/Microsoft/UWPCommunityToolkit.git","ssh_url":"git@github.com:Microsoft/UWPCommunityToolkit.git","clone_url":"https://github.com/Microsoft/UWPCommunityToolkit.git","svn_url":"https://github.com/Microsoft/UWPCommunityToolkit","homepage":"http://docs.uwpcommunitytoolkit.com","size":225087,"stargazers_count":880,"watchers_count":880,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":218,"mirror_url":null,"open_issues_count":60,"forks":218,"open_issues":60,"watchers":880,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/640"},"html":{"href":"https://github.com/Microsoft/UWPCommunityToolkit/pull/640"},"issue":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/issues/640"},"comments":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/issues/640/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/640/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/pulls/640/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/UWPCommunityToolkit/statuses/18eb34f0020da2410a10b6206422a2a16e93c0e0"}}}}
{"actor":{"display_login":"IbraheemOsama"}}