From 3b4e200daab3e61339177b4fb5974993d0142c70 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Thu, 12 Sep 2013 11:54:19 +0200 Subject: [PATCH] edit utilities --- .../Utility/Lui/Button/AddPersonButton.cs | 30 ++++++++-------- .../Utility/Lui/MessageBoxes/MessageBoxes.cs | 2 +- .../CampusAppWP8/Utility/StringManager.cs | 36 ++++++++++--------- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/AddPersonButton.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/AddPersonButton.cs index 0f434b53..02f4df6d 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/AddPersonButton.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Button/AddPersonButton.cs @@ -1,5 +1,5 @@ //----------------------------------------------------------------------- -// +// // Company copyright tag. // // stubbfel @@ -18,26 +18,26 @@ namespace CampusAppWP8.Utility.Lui.Button /// Stubbfel, 12.09.2013. public class AddPersonButton : System.Windows.Controls.Button { - /// The icon. - private static BitmapImage icon = new BitmapImage(new Uri(Icons.AddContact, UriKind.Relative)); - - /// Initializes a new instance of the AddPersonButton class. - /// Stubbfel, 12.09.2013. - public AddPersonButton() - : base() - { - this.Content = new Image - { - Source = icon - }; - } - /// The person identifier property. public static readonly DependencyProperty PersonIdProperty = DependencyProperty.Register("PersonID", typeof(object), typeof(AddPersonButton), new PropertyMetadata(false)); /// The function index property. public static readonly DependencyProperty FunctionIndexProperty = DependencyProperty.Register("FunctionIndex", typeof(object), typeof(AddPersonButton), new PropertyMetadata(false)); + /// The icon. + private static BitmapImage icon = new BitmapImage(new Uri(Icons.AddContact, UriKind.Relative)); + + /// Initializes a new instance of the AddPersonButton class. + /// Stubbfel, 12.09.2013. + public AddPersonButton() + : base() + { + this.Content = new Image + { + Source = icon + }; + } + /// Gets or sets the identifier of the person. /// The identifier of the person. public object PersonId diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs index 98b696d5..397e810f 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/MessageBoxes/MessageBoxes.cs @@ -37,7 +37,7 @@ namespace CampusAppWP8.Utility.Lui.MessageBoxes /// Shows the main model information message box. /// Stubbfel, 10.09.2013. /// custom text for the box. - /// . + /// result of the UserInteraction public static MessageBoxResult ShowMainModelInfoMessageBox(string text) { return MessageBox.Show(text, AppResources.MsgBox_InfoHeader, MessageBoxButton.OK); diff --git a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs b/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs index 4c8b93d9..8a87aeae 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/StringManager.cs @@ -7,9 +7,9 @@ //---------------------------------------------------------------------- namespace CampusAppWP8.Utility { - using CampusAppWP8.Resources; using System; using System.Text.RegularExpressions; + using CampusAppWP8.Resources; /// /// Class provides some special StringMethods @@ -23,6 +23,9 @@ namespace CampusAppWP8.Utility /// private static readonly string HtmlTagPattern = "<.*?>"; + /// The mail valid regular expression. + private static readonly string EMailValidRegex = @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$"; + #endregion #region Methods @@ -33,7 +36,7 @@ namespace CampusAppWP8.Utility /// String with Html-Tags /// String without Html-Tags public static string StripHTML(string inputString) - { + { string result = Regex.Replace(inputString, HtmlTagPattern, string.Empty); return System.Net.HttpUtility.HtmlDecode(result); } @@ -48,11 +51,10 @@ namespace CampusAppWP8.Utility return str.ToString() + "\n"; } - /// - /// Method remove(TrimEND!) an Newline to a string - /// - /// input string - /// input string - newlineMethod remove(TrimEND!) an Newline to a string. + /// Stubbfel, 12.09.2013. + /// input string. + /// input string - newline. public static string RemoveNewLine(string str) { return str.TrimEnd('\n'); @@ -67,10 +69,10 @@ namespace CampusAppWP8.Utility // Return true if strIn is in valid e-mail format. try { - return Regex.IsMatch(strIn, - @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + - @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$", - RegexOptions.IgnoreCase); + return Regex.IsMatch( + strIn, + StringManager.EMailValidRegex, + RegexOptions.IgnoreCase); } catch (Exception) { @@ -78,11 +80,11 @@ namespace CampusAppWP8.Utility } } - /// Creates uni telefon number. - /// Stubbfel, 04.09.2013. - /// The input. - /// The new uni telefon number. - public static string CreateUniTelefonNumber(string input) + /// Creates uni telefon number. + /// Stubbfel, 04.09.2013. + /// The input. + /// The new uni telefon number. + public static string CreateUniTelefonNumber(string input) { string result = null; if (input.Length < 5) @@ -95,7 +97,7 @@ namespace CampusAppWP8.Utility } Regex regexObj = new Regex(@"[^\d]"); - result = regexObj.Replace(result.TrimStart('0'), ""); + result = regexObj.Replace(result.TrimStart('0'), string.Empty); result = Constants.DeTelPrefix + result; return result; }