From: Bowon Ryu Date: Tue, 23 Nov 2021 05:16:08 +0000 (+0900) Subject: [NUI] Add TextMapHelper class X-Git-Tag: accepted/tizen/unified/20231205.024657~1290 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61a84f0f94188057584fc5c76964ce1f0c25619e;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add TextMapHelper class TextUtils contains too many features and is inconsistent. Detach the TextMapHelper functionality from the TextUtils class. This can improves readability and reduces LOCs. Signed-off-by: Bowon Ryu --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 8065761..572bdfa 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -261,7 +261,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetFontStyle(FontStyle fontStyle) { - SetValue(FontStyleProperty, TextUtils.GetFontStyleMap(fontStyle)); + SetValue(FontStyleProperty, TextMapHelper.GetFontStyleMap(fontStyle)); } /// @@ -274,7 +274,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public FontStyle GetFontStyle() { - return TextUtils.GetFontStyleStruct((PropertyMap)GetValue(FontStyleProperty)); + return TextMapHelper.GetFontStyleStruct((PropertyMap)GetValue(FontStyleProperty)); } /// @@ -552,12 +552,12 @@ namespace Tizen.NUI.BaseComponents { if (!String.IsNullOrEmpty(selectionHandleImage.LeftImageUrl)) { - SetValue(SelectionHandleImageLeftProperty, TextUtils.GetFileNameMap(selectionHandleImage.LeftImageUrl)); + SetValue(SelectionHandleImageLeftProperty, TextMapHelper.GetFileNameMap(selectionHandleImage.LeftImageUrl)); } if (!String.IsNullOrEmpty(selectionHandleImage.RightImageUrl)) { - SetValue(SelectionHandleImageRightProperty, TextUtils.GetFileNameMap(selectionHandleImage.RightImageUrl)); + SetValue(SelectionHandleImageRightProperty, TextMapHelper.GetFileNameMap(selectionHandleImage.RightImageUrl)); } } @@ -571,7 +571,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public SelectionHandleImage GetSelectionHandleImage() { - return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleImageLeftProperty), (PropertyMap)GetValue(SelectionHandleImageRightProperty)); + return TextMapHelper.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleImageLeftProperty), (PropertyMap)GetValue(SelectionHandleImageRightProperty)); } /// @@ -637,12 +637,12 @@ namespace Tizen.NUI.BaseComponents { if (!String.IsNullOrEmpty(selectionHandlePressedImage.LeftImageUrl)) { - SetValue(SelectionHandlePressedImageLeftProperty, TextUtils.GetFileNameMap(selectionHandlePressedImage.LeftImageUrl)); + SetValue(SelectionHandlePressedImageLeftProperty, TextMapHelper.GetFileNameMap(selectionHandlePressedImage.LeftImageUrl)); } if (!String.IsNullOrEmpty(selectionHandlePressedImage.RightImageUrl)) { - SetValue(SelectionHandlePressedImageRightProperty, TextUtils.GetFileNameMap(selectionHandlePressedImage.RightImageUrl)); + SetValue(SelectionHandlePressedImageRightProperty, TextMapHelper.GetFileNameMap(selectionHandlePressedImage.RightImageUrl)); } } @@ -656,7 +656,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public SelectionHandleImage GetSelectionHandlePressedImage() { - return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty), (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty)); + return TextMapHelper.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty), (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty)); } /// @@ -722,12 +722,12 @@ namespace Tizen.NUI.BaseComponents { if (!String.IsNullOrEmpty(selectionHandleMarkerImage.LeftImageUrl)) { - SetValue(SelectionHandleMarkerImageLeftProperty, TextUtils.GetFileNameMap(selectionHandleMarkerImage.LeftImageUrl)); + SetValue(SelectionHandleMarkerImageLeftProperty, TextMapHelper.GetFileNameMap(selectionHandleMarkerImage.LeftImageUrl)); } if (!String.IsNullOrEmpty(selectionHandleMarkerImage.RightImageUrl)) { - SetValue(SelectionHandleMarkerImageRightProperty, TextUtils.GetFileNameMap(selectionHandleMarkerImage.RightImageUrl)); + SetValue(SelectionHandleMarkerImageRightProperty, TextMapHelper.GetFileNameMap(selectionHandleMarkerImage.RightImageUrl)); } } @@ -741,7 +741,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public SelectionHandleImage GetSelectionHandleMarkerImage() { - return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty), (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty)); + return TextMapHelper.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty), (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty)); } /// @@ -885,7 +885,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetInputFontStyle(FontStyle fontStyle) { - SetValue(InputFontStyleProperty, TextUtils.GetFontStyleMap(fontStyle)); + SetValue(InputFontStyleProperty, TextMapHelper.GetFontStyleMap(fontStyle)); } /// @@ -898,7 +898,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public FontStyle GetInputFontStyle() { - return TextUtils.GetFontStyleStruct((PropertyMap)GetValue(InputFontStyleProperty)); + return TextMapHelper.GetFontStyleStruct((PropertyMap)GetValue(InputFontStyleProperty)); } /// @@ -996,7 +996,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetUnderline(Underline underline) { - SetValue(UnderlineProperty, TextUtils.GetUnderlineMap(underline)); + SetValue(UnderlineProperty, TextMapHelper.GetUnderlineMap(underline)); } /// @@ -1009,7 +1009,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Underline GetUnderline() { - return TextUtils.GetUnderlineStruct((PropertyMap)GetValue(UnderlineProperty)); + return TextMapHelper.GetUnderlineStruct((PropertyMap)GetValue(UnderlineProperty)); } /// @@ -1072,7 +1072,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetShadow(Tizen.NUI.Text.Shadow shadow) { - SetValue(ShadowProperty, TextUtils.GetShadowMap(shadow)); + SetValue(ShadowProperty, TextMapHelper.GetShadowMap(shadow)); } /// @@ -1085,7 +1085,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Tizen.NUI.Text.Shadow GetShadow() { - return TextUtils.GetShadowStruct((PropertyMap)GetValue(ShadowProperty)); + return TextMapHelper.GetShadowStruct((PropertyMap)GetValue(ShadowProperty)); } /// @@ -1181,7 +1181,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetOutline(Outline outline) { - SetValue(OutlineProperty, TextUtils.GetOutlineMap(outline)); + SetValue(OutlineProperty, TextMapHelper.GetOutlineMap(outline)); } /// @@ -1194,7 +1194,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Outline GetOutline() { - return TextUtils.GetOutlineStruct((PropertyMap)GetValue(OutlineProperty)); + return TextMapHelper.GetOutlineStruct((PropertyMap)GetValue(OutlineProperty)); } /// @@ -1624,7 +1624,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetInputFilter(InputFilter inputFilter) { - SetProperty(TextEditor.Property.InputFilter, new PropertyValue(TextUtils.GetInputFilterMap(inputFilter))); + SetProperty(TextEditor.Property.InputFilter, new PropertyValue(TextMapHelper.GetInputFilterMap(inputFilter))); } /// @@ -1639,7 +1639,7 @@ namespace Tizen.NUI.BaseComponents { var map = new PropertyMap(); GetProperty(TextEditor.Property.InputFilter).Get(map); - return TextUtils.GetInputFilterStruct(map); + return TextMapHelper.GetInputFilterStruct(map); } /// @@ -1790,7 +1790,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetPlaceholder(Placeholder placeholder) { - SetValue(PlaceholderProperty, TextUtils.GetPlaceholderMap(placeholder)); + SetValue(PlaceholderProperty, TextMapHelper.GetPlaceholderMap(placeholder)); } /// @@ -1803,7 +1803,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Placeholder GetPlaceholder() { - return TextUtils.GetPlaceholderStruct((PropertyMap)GetValue(PlaceholderProperty)); + return TextMapHelper.GetPlaceholderStruct((PropertyMap)GetValue(PlaceholderProperty)); } /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index e56b485..330cda1 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -327,7 +327,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetFontStyle(FontStyle fontStyle) { - SetValue(FontStyleProperty, TextUtils.GetFontStyleMap(fontStyle)); + SetValue(FontStyleProperty, TextMapHelper.GetFontStyleMap(fontStyle)); } /// @@ -340,7 +340,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public FontStyle GetFontStyle() { - return TextUtils.GetFontStyleStruct((PropertyMap)GetValue(FontStyleProperty)); + return TextMapHelper.GetFontStyleStruct((PropertyMap)GetValue(FontStyleProperty)); } /// @@ -792,12 +792,12 @@ namespace Tizen.NUI.BaseComponents { if (!String.IsNullOrEmpty(selectionHandleImage.LeftImageUrl)) { - SetValue(SelectionHandleImageLeftProperty, TextUtils.GetFileNameMap(selectionHandleImage.LeftImageUrl)); + SetValue(SelectionHandleImageLeftProperty, TextMapHelper.GetFileNameMap(selectionHandleImage.LeftImageUrl)); } if (!String.IsNullOrEmpty(selectionHandleImage.RightImageUrl)) { - SetValue(SelectionHandleImageRightProperty, TextUtils.GetFileNameMap(selectionHandleImage.RightImageUrl)); + SetValue(SelectionHandleImageRightProperty, TextMapHelper.GetFileNameMap(selectionHandleImage.RightImageUrl)); } } @@ -811,7 +811,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public SelectionHandleImage GetSelectionHandleImage() { - return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleImageLeftProperty), (PropertyMap)GetValue(SelectionHandleImageRightProperty)); + return TextMapHelper.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleImageLeftProperty), (PropertyMap)GetValue(SelectionHandleImageRightProperty)); } /// @@ -877,12 +877,12 @@ namespace Tizen.NUI.BaseComponents { if (!String.IsNullOrEmpty(selectionHandlePressedImage.LeftImageUrl)) { - SetValue(SelectionHandlePressedImageLeftProperty, TextUtils.GetFileNameMap(selectionHandlePressedImage.LeftImageUrl)); + SetValue(SelectionHandlePressedImageLeftProperty, TextMapHelper.GetFileNameMap(selectionHandlePressedImage.LeftImageUrl)); } if (!String.IsNullOrEmpty(selectionHandlePressedImage.RightImageUrl)) { - SetValue(SelectionHandlePressedImageRightProperty, TextUtils.GetFileNameMap(selectionHandlePressedImage.RightImageUrl)); + SetValue(SelectionHandlePressedImageRightProperty, TextMapHelper.GetFileNameMap(selectionHandlePressedImage.RightImageUrl)); } } @@ -896,7 +896,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public SelectionHandleImage GetSelectionHandlePressedImage() { - return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty), (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty)); + return TextMapHelper.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty), (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty)); } /// @@ -962,12 +962,12 @@ namespace Tizen.NUI.BaseComponents { if (!String.IsNullOrEmpty(selectionHandleMarkerImage.LeftImageUrl)) { - SetValue(SelectionHandleMarkerImageLeftProperty, TextUtils.GetFileNameMap(selectionHandleMarkerImage.LeftImageUrl)); + SetValue(SelectionHandleMarkerImageLeftProperty, TextMapHelper.GetFileNameMap(selectionHandleMarkerImage.LeftImageUrl)); } if (!String.IsNullOrEmpty(selectionHandleMarkerImage.RightImageUrl)) { - SetValue(SelectionHandleMarkerImageRightProperty, TextUtils.GetFileNameMap(selectionHandleMarkerImage.RightImageUrl)); + SetValue(SelectionHandleMarkerImageRightProperty, TextMapHelper.GetFileNameMap(selectionHandleMarkerImage.RightImageUrl)); } } @@ -981,7 +981,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public SelectionHandleImage GetSelectionHandleMarkerImage() { - return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty), (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty)); + return TextMapHelper.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty), (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty)); } /// @@ -1156,7 +1156,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetInputFontStyle(FontStyle fontStyle) { - SetValue(InputFontStyleProperty, TextUtils.GetFontStyleMap(fontStyle)); + SetValue(InputFontStyleProperty, TextMapHelper.GetFontStyleMap(fontStyle)); } /// @@ -1169,7 +1169,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public FontStyle GetInputFontStyle() { - return TextUtils.GetFontStyleStruct((PropertyMap)GetValue(InputFontStyleProperty)); + return TextMapHelper.GetFontStyleStruct((PropertyMap)GetValue(InputFontStyleProperty)); } /// @@ -1233,7 +1233,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetUnderline(Underline underline) { - SetValue(UnderlineProperty, TextUtils.GetUnderlineMap(underline)); + SetValue(UnderlineProperty, TextMapHelper.GetUnderlineMap(underline)); } /// @@ -1246,7 +1246,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Underline GetUnderline() { - return TextUtils.GetUnderlineStruct((PropertyMap)GetValue(UnderlineProperty)); + return TextMapHelper.GetUnderlineStruct((PropertyMap)GetValue(UnderlineProperty)); } /// @@ -1309,7 +1309,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetShadow(Tizen.NUI.Text.Shadow shadow) { - SetValue(ShadowProperty, TextUtils.GetShadowMap(shadow)); + SetValue(ShadowProperty, TextMapHelper.GetShadowMap(shadow)); } /// @@ -1322,7 +1322,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Tizen.NUI.Text.Shadow GetShadow() { - return TextUtils.GetShadowStruct((PropertyMap)GetValue(ShadowProperty)); + return TextMapHelper.GetShadowStruct((PropertyMap)GetValue(ShadowProperty)); } /// @@ -1418,7 +1418,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetOutline(Outline outline) { - SetValue(OutlineProperty, TextUtils.GetOutlineMap(outline)); + SetValue(OutlineProperty, TextMapHelper.GetOutlineMap(outline)); } /// @@ -1431,7 +1431,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Outline GetOutline() { - return TextUtils.GetOutlineStruct((PropertyMap)GetValue(OutlineProperty)); + return TextMapHelper.GetOutlineStruct((PropertyMap)GetValue(OutlineProperty)); } /// @@ -1509,7 +1509,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetHiddenInput(HiddenInput hiddenInput) { - SetValue(HiddenInputSettingsProperty, TextUtils.GetHiddenInputMap(hiddenInput)); + SetValue(HiddenInputSettingsProperty, TextMapHelper.GetHiddenInputMap(hiddenInput)); } /// @@ -1522,7 +1522,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public HiddenInput GetHiddenInput() { - return TextUtils.GetHiddenInputStruct((PropertyMap)GetValue(HiddenInputSettingsProperty)); + return TextMapHelper.GetHiddenInputStruct((PropertyMap)GetValue(HiddenInputSettingsProperty)); } /// @@ -1782,7 +1782,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetInputFilter(InputFilter inputFilter) { - SetProperty(TextField.Property.InputFilter, new PropertyValue(TextUtils.GetInputFilterMap(inputFilter))); + SetProperty(TextField.Property.InputFilter, new PropertyValue(TextMapHelper.GetInputFilterMap(inputFilter))); } /// @@ -1797,7 +1797,7 @@ namespace Tizen.NUI.BaseComponents { var map = new PropertyMap(); GetProperty(TextField.Property.InputFilter).Get(map); - return TextUtils.GetInputFilterStruct(map); + return TextMapHelper.GetInputFilterStruct(map); } /// @@ -1948,7 +1948,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetPlaceholder(Placeholder placeholder) { - SetValue(PlaceholderProperty, TextUtils.GetPlaceholderMap(placeholder)); + SetValue(PlaceholderProperty, TextMapHelper.GetPlaceholderMap(placeholder)); } /// @@ -1961,7 +1961,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Placeholder GetPlaceholder() { - return TextUtils.GetPlaceholderStruct((PropertyMap)GetValue(PlaceholderProperty)); + return TextMapHelper.GetPlaceholderStruct((PropertyMap)GetValue(PlaceholderProperty)); } /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 54f1a1e..0885bff 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -294,7 +294,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetFontStyle(FontStyle fontStyle) { - SetValue(FontStyleProperty, TextUtils.GetFontStyleMap(fontStyle)); + SetValue(FontStyleProperty, TextMapHelper.GetFontStyleMap(fontStyle)); } /// @@ -307,7 +307,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public FontStyle GetFontStyle() { - return TextUtils.GetFontStyleStruct((PropertyMap)GetValue(FontStyleProperty)); + return TextMapHelper.GetFontStyleStruct((PropertyMap)GetValue(FontStyleProperty)); } /// @@ -773,7 +773,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetUnderline(Underline underline) { - SetValue(UnderlineProperty, TextUtils.GetUnderlineMap(underline)); + SetValue(UnderlineProperty, TextMapHelper.GetUnderlineMap(underline)); } /// @@ -786,7 +786,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Underline GetUnderline() { - return TextUtils.GetUnderlineStruct((PropertyMap)GetValue(UnderlineProperty)); + return TextMapHelper.GetUnderlineStruct((PropertyMap)GetValue(UnderlineProperty)); } /// @@ -834,7 +834,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetShadow(Tizen.NUI.Text.Shadow shadow) { - SetValue(ShadowProperty, TextUtils.GetShadowMap(shadow)); + SetValue(ShadowProperty, TextMapHelper.GetShadowMap(shadow)); } /// @@ -847,7 +847,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Tizen.NUI.Text.Shadow GetShadow() { - return TextUtils.GetShadowStruct((PropertyMap)GetValue(ShadowProperty)); + return TextMapHelper.GetShadowStruct((PropertyMap)GetValue(ShadowProperty)); } /// @@ -929,7 +929,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetOutline(Outline outline) { - SetValue(OutlineProperty, TextUtils.GetOutlineMap(outline)); + SetValue(OutlineProperty, TextMapHelper.GetOutlineMap(outline)); } /// @@ -942,7 +942,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Outline GetOutline() { - return TextUtils.GetOutlineStruct((PropertyMap)GetValue(OutlineProperty)); + return TextMapHelper.GetOutlineStruct((PropertyMap)GetValue(OutlineProperty)); } /// @@ -1168,7 +1168,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public void SetTextFit(TextFit textFit) { - SetValue(TextFitProperty, TextUtils.GetTextFitMap(textFit)); + SetValue(TextFitProperty, TextMapHelper.GetTextFitMap(textFit)); } /// @@ -1183,7 +1183,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public TextFit GetTextFit() { - return TextUtils.GetTextFitStruct((PropertyMap)GetValue(TextFitProperty)); + return TextMapHelper.GetTextFitStruct((PropertyMap)GetValue(TextFitProperty)); } /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs b/src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs new file mode 100644 index 0000000..4a1986d --- /dev/null +++ b/src/Tizen.NUI/src/public/BaseComponents/TextMapHelper.cs @@ -0,0 +1,670 @@ +/* + * Copyright(c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.ComponentModel; +using Tizen.NUI.Text; + +namespace Tizen.NUI.BaseComponents +{ + /// + /// TextMapHelper converts PropertyMap to struct and struct to PropertyMap. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static class TextMapHelper + { + /// + /// It returns a string value according to FontWidthType. + /// The returned value can be used for FontStyle PropertyMap. + /// The FontWidthType enum value. + /// A string value for FontStyle.Width property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static string GetFontWidthString(FontWidthType fontWidthType) + { + string value = fontWidthType.ToString(); + if (!string.IsNullOrEmpty(value)) + { + char[] charArray = value.ToCharArray(); + charArray[0] = Char.ToLower(charArray[0]); + value = new string(charArray); + } + else + { + value = "none"; // The default value. + } + + return value; + } + + /// + /// It returns a string value according to FontWeightType. + /// The returned value can be used for FontStyle PropertyMap. + /// The FontWeightType enum value. + /// A string value for FontStyle.Weight property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static string GetFontWeightString(FontWeightType fontWeightType) + { + string value = fontWeightType.ToString(); + if (!string.IsNullOrEmpty(value)) + { + char[] charArray = value.ToCharArray(); + charArray[0] = Char.ToLower(charArray[0]); + value = new string(charArray); + } + else + { + value = "none"; // The default value. + } + + return value; + } + + /// + /// It returns a string value according to FontSlantType. + /// The returned value can be used for FontStyle PropertyMap. + /// The FontSlantType enum value. + /// A string value for FontStyle.Slant property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static string GetFontSlantString(FontSlantType fontSlantType) + { + string value = fontSlantType.ToString(); + if (!string.IsNullOrEmpty(value)) + { + char[] charArray = value.ToCharArray(); + charArray[0] = Char.ToLower(charArray[0]); + value = new string(charArray); + } + else + { + value = "none"; // The default value. + } + + return value; + } + + /// + /// It returns a FontWidthType value according to fontWidthString. + /// The returned value can be used for FontStyle PropertyMap. + /// The FontWidth string value. + /// A FontWidthType value for FontStyle.Width property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static FontWidthType GetFontWidthType(string fontWidthString) + { + FontWidthType value; + + if (!(Enum.TryParse(fontWidthString, true, out value) && Enum.IsDefined(typeof(FontWidthType), value))) + { + value = FontWidthType.None; // If parsing fails, set a default value. + } + + return value; + } + + /// + /// It returns a FontWeightType value according to fontWeightString. + /// The returned value can be used for FontStyle PropertyMap. + /// The FontWeight string value. + /// A FontWeightType value for FontStyle.Weight property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static FontWeightType GetFontWeightType(string fontWeightString) + { + FontWeightType value; + + if (!(Enum.TryParse(fontWeightString, true, out value) && Enum.IsDefined(typeof(FontWeightType), value))) + { + value = FontWeightType.None; // If parsing fails, set a default value. + } + + return value; + } + + /// + /// It returns a FontSlantType value according to fontSlantString. + /// The returned value can be used for FontStyle PropertyMap. + /// The FontSlant string value. + /// A FontSlantType value for FontStyle.Slant property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static FontSlantType GetFontSlantType(string fontSlantString) + { + FontSlantType value; + + if (!(Enum.TryParse(fontSlantString, true, out value) && Enum.IsDefined(typeof(FontSlantType), value))) + { + value = FontSlantType.None; // If parsing fails, set a default value. + } + + return value; + } + + /// + /// This method converts a FontStyle struct to a PropertyMap and returns it. + /// The returned map can be used for set FontStyle PropertyMap in the SetFontStyle method. + /// The FontStyle struct value. + /// A PropertyMap for FontStyle property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetFontStyleMap(FontStyle fontStyle) + { + var map = new PropertyMap(); + var width = new PropertyValue(GetFontWidthString(fontStyle.Width)); + var weight = new PropertyValue(GetFontWeightString(fontStyle.Weight)); + var slant = new PropertyValue(GetFontSlantString(fontStyle.Slant)); + + map.Add("width", width); + map.Add("weight", weight); + map.Add("slant", slant); + + return map; + } + + /// + /// This method converts a FontStyle map to a struct and returns it. + /// The returned struct can be returned to the user as a FontStyle in the GetFontStyle method. + /// The FontStyle PropertyMap. + /// A FontStyle struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static FontStyle GetFontStyleStruct(PropertyMap map) + { + string width = "none"; + string weight = "none"; + string slant = "none"; + map.Find(0, "width")?.Get(out width); + map.Find(0, "weight")?.Get(out weight); + map.Find(0, "slant")?.Get(out slant); + + var fontStyle = new FontStyle(); + fontStyle.Width = GetFontWidthType(width); + fontStyle.Weight = GetFontWeightType(weight); + fontStyle.Slant = GetFontSlantType(slant); + + return fontStyle; + } + + /// + /// This method converts a InputFilter struct to a PropertyMap and returns it.
+ /// The returned map can be used for set InputFilter PropertyMap in the SetInputFilter method.
+ /// The InputFilter struct value. + /// A PropertyMap for InputFilter property. + ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetInputFilterMap(InputFilter inputFilter) + { + var map = new PropertyMap(); + var accepted = inputFilter.Accepted != null ? new PropertyValue(inputFilter.Accepted) : new PropertyValue(""); + var rejected = inputFilter.Rejected != null ? new PropertyValue(inputFilter.Rejected) : new PropertyValue(""); + map.Add(0, accepted); + map.Add(1, rejected); + + return map; + } + + /// + /// This method converts a InputFilter map to a struct and returns it.
+ /// The returned struct can be returned to the user as a InputFilter in the GetInputFilter method.
+ /// The InputFilter PropertyMap. + /// A InputFilter struct. + ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public static InputFilter GetInputFilterStruct(PropertyMap map) + { + string accepted = ""; + string rejected = ""; + map.Find(0)?.Get(out accepted); + map.Find(1)?.Get(out rejected); + + var inputFilter = new InputFilter(); + inputFilter.Accepted = accepted; + inputFilter.Rejected = rejected; + + return inputFilter; + + } + + /// + /// This method converts a Underline struct to a PropertyMap and returns it. + /// The returned map can be used for set Underline PropertyMap in the SetUnderline method. + /// The Underline struct value. + /// A PropertyMap for Underline property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetUnderlineMap(Underline underline) + { + var map = new PropertyMap(); + + map.Add("enable", new PropertyValue(underline.Enable)); + + if (underline.Color != null) + map.Add("color", new PropertyValue(underline.Color)); + + if (underline.Height != null) + map.Add("height", new PropertyValue((float)underline.Height)); + + return map; + } + + /// + /// This method converts a Underline map to a struct and returns it. + /// The returned struct can be returned to the user as a Underline in the GetUnderline method. + /// The Underline PropertyMap. + /// A Underline struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Underline GetUnderlineStruct(PropertyMap map) + { + Color color = new Color(); + map.Find(0, "enable").Get(out bool enable); + map.Find(0, "color").Get(color); + map.Find(0, "height").Get(out float height); + + var underline = new Underline(); + underline.Enable = enable; + underline.Color = color; + underline.Height = height; + + return underline; + } + + /// + /// This method converts a Shadow struct to a PropertyMap and returns it. + /// The returned map can be used for set Shadow PropertyMap in the SetShadow method. + /// The Shadow struct value. + /// A PropertyMap for Shadow property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetShadowMap(Tizen.NUI.Text.Shadow shadow) + { + var map = new PropertyMap(); + + if (shadow.Offset != null) + map.Add("offset", new PropertyValue(shadow.Offset)); + + if (shadow.Color != null) + map.Add("color", new PropertyValue(shadow.Color)); + + if (shadow.BlurRadius != null) + map.Add("blurRadius", new PropertyValue((float)shadow.BlurRadius)); + + return map; + } + + /// + /// This method converts a Shadow map to a struct and returns it. + /// The returned struct can be returned to the user as a Shadow in the GetShadow method. + /// The Shadow PropertyMap. + /// A Shadow struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Tizen.NUI.Text.Shadow GetShadowStruct(PropertyMap map) + { + Vector2 offset = new Vector2(); + Color color = new Color(); + map.Find(0, "offset").Get(offset); + map.Find(0, "color").Get(color); + map.Find(0, "blurRadius").Get(out float blurRadius); + + var shadow = new Tizen.NUI.Text.Shadow(); + shadow.Offset = offset; + shadow.Color = color; + shadow.BlurRadius = blurRadius; + + return shadow; + } + + /// + /// This method converts a Outline struct to a PropertyMap and returns it. + /// The returned map can be used for set Outline PropertyMap in the SetOutline method. + /// The Outline struct value. + /// A PropertyMap for Outline property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetOutlineMap(Outline outline) + { + var map = new PropertyMap(); + + if (outline.Color != null) + map.Add("color", new PropertyValue(outline.Color)); + + if (outline.Width != null) + map.Add("width", new PropertyValue((float)outline.Width)); + + return map; + } + + /// + /// This method converts a Outline map to a struct and returns it. + /// The returned struct can be returned to the user as a Outline in the GetOutline method. + /// The Outline PropertyMap. + /// A Outline struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Outline GetOutlineStruct(PropertyMap map) + { + Color color = new Color(); + map.Find(0, "color").Get(color); + map.Find(0, "width").Get(out float width); + + var outline = new Outline(); + outline.Color = color; + outline.Width = width; + + return outline; + } + + /// + /// It returns a string value according to FontSizeType. + /// The returned value can be used for TextFit PropertyMap. + /// The FontSizeType enum value. + /// A string value for TextFit.FontSizeType property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static string GetFontSizeString(FontSizeType fontSizeType) + { + string value = fontSizeType.ToString(); + if (!string.IsNullOrEmpty(value)) + { + char[] charArray = value.ToCharArray(); + charArray[0] = Char.ToLower(charArray[0]); + value = new string(charArray); + } + else + { + value = "pointSize"; // The default value. + } + + return value; + } + + /// + /// It returns a FontSizeType value according to fontSizeString. + /// The returned value can be used for FontStyle PropertyMap. + /// The FontSizeType string value. + /// A FontSizeType value for TextFit.FontSizeType property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static FontSizeType GetFontSizeType(string fontSizeString) + { + FontSizeType value; + + if (!(Enum.TryParse(fontSizeString, true, out value) && Enum.IsDefined(typeof(FontSizeType), value))) + { + value = FontSizeType.PointSize; // If parsing fails, set a default value. + } + + return value; + } + + /// + /// This method converts a TextFit struct to a PropertyMap and returns it. + /// The returned map can be used for set TextFit PropertyMap in the SetTextFit method. + /// The TextFit struct value. + /// A PropertyMap for TextFit property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetTextFitMap(TextFit textFit) + { + var map = new PropertyMap(); + map.Add("enable", new PropertyValue(textFit.Enable)); + map.Add("fontSizeType", new PropertyValue(GetFontSizeString(textFit.FontSizeType))); + + if (textFit.MinSize != null) + map.Add("minSize", new PropertyValue((float)textFit.MinSize)); + + if (textFit.MaxSize != null) + map.Add("maxSize", new PropertyValue((float)textFit.MaxSize)); + + if (textFit.StepSize != null) + map.Add("stepSize", new PropertyValue((float)textFit.StepSize)); + + return map; + } + + /// + /// This method converts a TextFit map to a struct and returns it. + /// The returned struct can be returned to the user as a TextFit in the GetTextFit method. + /// The TextFit PropertyMap. + /// A TextFit struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static TextFit GetTextFitStruct(PropertyMap map) + { + bool enable = false; + float minSize = 0.0f; + float maxSize = 0.0f; + float stepSize = 0.0f; + float fontSize = 0.0f; + string fontSizeType = null; + map.Find(0, "enable")?.Get(out enable); + map.Find(0, "minSize")?.Get(out minSize); + map.Find(0, "maxSize")?.Get(out maxSize); + map.Find(0, "stepSize")?.Get(out stepSize); + map.Find(0, "fontSize")?.Get(out fontSize); + map.Find(0, "fontSizeType")?.Get(out fontSizeType); + + var textFit = new TextFit(); + textFit.Enable = enable; + textFit.MinSize = minSize; + textFit.MaxSize = maxSize; + textFit.StepSize = stepSize; + textFit.FontSize = fontSize; + textFit.FontSizeType = GetFontSizeType(fontSizeType); + + return textFit; + } + + /// + /// This method converts a Placeholder struct to a PropertyMap and returns it. + /// The returned map can be used for set Placeholder PropertyMap in the SetPlaceholder method. + /// The Placeholder struct value. + /// A PropertyMap for Placeholder property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetPlaceholderMap(Placeholder placeholder) + { + var map = new PropertyMap(); + + if (placeholder.Text != null) + map.Add("text", new PropertyValue(placeholder.Text)); + + if (placeholder.TextFocused != null) + map.Add("textFocused", new PropertyValue(placeholder.TextFocused)); + + if (placeholder.Color != null) + map.Add("color", new PropertyValue(placeholder.Color)); + + if (placeholder.FontFamily != null) + map.Add("fontFamily", new PropertyValue(placeholder.FontFamily)); + + if (placeholder.FontStyle != null) + map.Add("fontStyle", new PropertyValue(GetFontStyleMap((FontStyle)placeholder.FontStyle))); + + if (placeholder.PointSize != null && placeholder.PixelSize != null) + map.Add("pointSize", new PropertyValue((float)placeholder.PointSize)); + + else if (placeholder.PointSize != null) + map.Add("pointSize", new PropertyValue((float)placeholder.PointSize)); + + else if (placeholder.PixelSize != null) + map.Add("pixelSize", new PropertyValue((float)placeholder.PixelSize)); + + map.Add("ellipsis", new PropertyValue(placeholder.Ellipsis)); + + return map; + } + + /// + /// This method converts a Placeholder map to a struct and returns it. + /// The returned struct can be returned to the user as a Placeholder in the GetPlaceholder method. + /// The Placeholder PropertyMap. + /// A Placeholder struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Placeholder GetPlaceholderStruct(PropertyMap map) + { + string text = ""; + string textFocused = ""; + Color color = new Color(); + string fontFamily = null; + var fontStyle = new PropertyMap(); + PropertyValue pointSizeValue = null; + PropertyValue pixelSizeValue = null; + bool ellipsis = false; + + map.Find(0)?.Get(out text); + map.Find(1)?.Get(out textFocused); + map.Find(2)?.Get(color); + map.Find(3)?.Get(out fontFamily); + map.Find(4)?.Get(fontStyle); + pointSizeValue = map.Find(5); + pixelSizeValue = map.Find(6); + map.Find(7)?.Get(out ellipsis); + + var placeholder = new Placeholder(); + placeholder.Text = text; + placeholder.TextFocused = textFocused; + placeholder.Color = color; + placeholder.FontFamily = fontFamily; + placeholder.Ellipsis = ellipsis; + placeholder.FontStyle = GetFontStyleStruct(fontStyle); + + if (pointSizeValue != null) + { + pointSizeValue.Get(out float pointSize); + placeholder.PointSize = pointSize; + } + + if (pixelSizeValue != null) + { + pixelSizeValue.Get(out float pixelSize); + placeholder.PixelSize = pixelSize; + } + + return placeholder; + } + + /// + /// This method converts a HiddenInput struct to a PropertyMap and returns it. + /// The returned map can be used for set HiddenInputSettings PropertyMap in the SetHiddenInput method. + /// The HiddenInput struct value. + /// A PropertyMap for HiddenInput property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetHiddenInputMap(HiddenInput hiddenInput) + { + var map = new PropertyMap(); + + map.Add(0, new PropertyValue((int)hiddenInput.Mode)); + + if (hiddenInput.SubstituteCharacter != null) + map.Add(1, new PropertyValue(Convert.ToInt32(hiddenInput.SubstituteCharacter))); + + if (hiddenInput.SubstituteCount != null) + map.Add(2, new PropertyValue((int)hiddenInput.SubstituteCount)); + + if (hiddenInput.ShowLastCharacterDuration != null) + map.Add(3, new PropertyValue((int)hiddenInput.ShowLastCharacterDuration)); + + return map; + } + + /// + /// This method converts a HiddenInputSettings map to a struct and returns it. + /// The returned struct can be returned to the user as a HiddenInput in the GetHiddenInput method. + /// The HiddenInput PropertyMap. + /// A HiddenInput struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static HiddenInput GetHiddenInputStruct(PropertyMap map) + { + PropertyValue value = null; + + var hiddenInput = new HiddenInput(); + + value = map.Find(0); + if (value != null) + { + value.Get(out int mode); + hiddenInput.Mode = (HiddenInputModeType)mode; + } + + value = map.Find(1); + if (value != null) + { + value.Get(out int substituteCharacter); + hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter); + } + + value = map.Find(2); + if (value != null) + { + value.Get(out int substituteCount); + hiddenInput.SubstituteCount = substituteCount; + } + + value = map.Find(3); + if (value != null) + { + value.Get(out int showLastCharacterDuration); + hiddenInput.ShowLastCharacterDuration = showLastCharacterDuration; + } + + return hiddenInput; + } + + /// + /// This method converts a fileName string to a PropertyMap and returns it. + /// The returned map can be used for set SelectionHandleImageLeft, SelectionHandleImageRight PropertyMap in the SetSelectionHandleImage method. + /// The file path string value for SelectionHandleImage. + /// A PropertyMap for SelectionHandleImageLeft, SelectionHandleImageRight properties. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetFileNameMap(string fileName) + { + return new PropertyMap().Add("filename", new PropertyValue(fileName)); + } + + /// + /// This method converts a SelectionHandleImageLeft, SelectionHandleImageRight map to a struct and returns it. + /// The returned struct can be returned to the user as a SelectionHandleImage in the GetSelectionHandleImage method. + /// The SelectionHandleImageLeft PropertyMap. + /// The SelectionHandleImageRight PropertyMap. + /// A SelectionHandleImage struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static SelectionHandleImage GetSelectionHandleImageStruct(PropertyMap leftImageMap, PropertyMap rightImageMap) + { + string leftImageUrl = null; + string rightImageUrl = null; + + var selectionHandleImage = new SelectionHandleImage(); + + leftImageMap.Find(0, "filename")?.Get(out leftImageUrl); + rightImageMap.Find(0, "filename")?.Get(out rightImageUrl); + + selectionHandleImage.LeftImageUrl = leftImageUrl; + selectionHandleImage.RightImageUrl = rightImageUrl; + + return selectionHandleImage; + } + } +} \ No newline at end of file diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs index 5474db0..3c9191b 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs @@ -19,7 +19,6 @@ extern alias TizenSystemSettings; using TizenSystemSettings.Tizen.System; using System; using System.ComponentModel; -using Tizen.NUI.Text; namespace Tizen.NUI.BaseComponents { @@ -1140,646 +1139,6 @@ namespace Tizen.NUI.BaseComponents } /// - /// It returns a string value according to FontWidthType. - /// The returned value can be used for FontStyle PropertyMap. - /// The FontWidthType enum value. - /// A string value for FontStyle.Width property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static string GetFontWidthString(FontWidthType fontWidthType) - { - string value = fontWidthType.ToString(); - if (!string.IsNullOrEmpty(value)) - { - char[] charArray = value.ToCharArray(); - charArray[0] = Char.ToLower(charArray[0]); - value = new string(charArray); - } - else - { - value = "none"; // The default value. - } - - return value; - } - - /// - /// It returns a string value according to FontWeightType. - /// The returned value can be used for FontStyle PropertyMap. - /// The FontWeightType enum value. - /// A string value for FontStyle.Weight property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static string GetFontWeightString(FontWeightType fontWeightType) - { - string value = fontWeightType.ToString(); - if (!string.IsNullOrEmpty(value)) - { - char[] charArray = value.ToCharArray(); - charArray[0] = Char.ToLower(charArray[0]); - value = new string(charArray); - } - else - { - value = "none"; // The default value. - } - - return value; - } - - /// - /// It returns a string value according to FontSlantType. - /// The returned value can be used for FontStyle PropertyMap. - /// The FontSlantType enum value. - /// A string value for FontStyle.Slant property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static string GetFontSlantString(FontSlantType fontSlantType) - { - string value = fontSlantType.ToString(); - if (!string.IsNullOrEmpty(value)) - { - char[] charArray = value.ToCharArray(); - charArray[0] = Char.ToLower(charArray[0]); - value = new string(charArray); - } - else - { - value = "none"; // The default value. - } - - return value; - } - - /// - /// It returns a FontWidthType value according to fontWidthString. - /// The returned value can be used for FontStyle PropertyMap. - /// The FontWidth string value. - /// A FontWidthType value for FontStyle.Width property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static FontWidthType GetFontWidthType(string fontWidthString) - { - FontWidthType value; - - if (!(Enum.TryParse(fontWidthString, true, out value) && Enum.IsDefined(typeof(FontWidthType), value))) - { - value = FontWidthType.None; // If parsing fails, set a default value. - } - - return value; - } - - /// - /// It returns a FontWeightType value according to fontWeightString. - /// The returned value can be used for FontStyle PropertyMap. - /// The FontWeight string value. - /// A FontWeightType value for FontStyle.Weight property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static FontWeightType GetFontWeightType(string fontWeightString) - { - FontWeightType value; - - if (!(Enum.TryParse(fontWeightString, true, out value) && Enum.IsDefined(typeof(FontWeightType), value))) - { - value = FontWeightType.None; // If parsing fails, set a default value. - } - - return value; - } - - /// - /// It returns a FontSlantType value according to fontSlantString. - /// The returned value can be used for FontStyle PropertyMap. - /// The FontSlant string value. - /// A FontSlantType value for FontStyle.Slant property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static FontSlantType GetFontSlantType(string fontSlantString) - { - FontSlantType value; - - if (!(Enum.TryParse(fontSlantString, true, out value) && Enum.IsDefined(typeof(FontSlantType), value))) - { - value = FontSlantType.None; // If parsing fails, set a default value. - } - - return value; - } - - /// - /// This method converts a FontStyle struct to a PropertyMap and returns it. - /// The returned map can be used for set FontStyle PropertyMap in the SetFontStyle method. - /// The FontStyle struct value. - /// A PropertyMap for FontStyle property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetFontStyleMap(FontStyle fontStyle) - { - var map = new PropertyMap(); - var width = new PropertyValue(GetFontWidthString(fontStyle.Width)); - var weight = new PropertyValue(GetFontWeightString(fontStyle.Weight)); - var slant = new PropertyValue(GetFontSlantString(fontStyle.Slant)); - - map.Add("width", width); - map.Add("weight", weight); - map.Add("slant", slant); - - return map; - } - - /// - /// This method converts a FontStyle map to a struct and returns it. - /// The returned struct can be returned to the user as a FontStyle in the GetFontStyle method. - /// The FontStyle PropertyMap. - /// A FontStyle struct. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static FontStyle GetFontStyleStruct(PropertyMap map) - { - string width = "none"; - string weight = "none"; - string slant = "none"; - map.Find(0, "width")?.Get(out width); - map.Find(0, "weight")?.Get(out weight); - map.Find(0, "slant")?.Get(out slant); - - var fontStyle = new FontStyle(); - fontStyle.Width = GetFontWidthType(width); - fontStyle.Weight = GetFontWeightType(weight); - fontStyle.Slant = GetFontSlantType(slant); - - return fontStyle; - } - - /// - /// This method converts a InputFilter struct to a PropertyMap and returns it.
- /// The returned map can be used for set InputFilter PropertyMap in the SetInputFilter method.
- /// The InputFilter struct value. - /// A PropertyMap for InputFilter property. - ///
- [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetInputFilterMap(InputFilter inputFilter) - { - var map = new PropertyMap(); - var accepted = inputFilter.Accepted != null ? new PropertyValue(inputFilter.Accepted) : new PropertyValue(""); - var rejected = inputFilter.Rejected != null ? new PropertyValue(inputFilter.Rejected) : new PropertyValue(""); - map.Add(0, accepted); - map.Add(1, rejected); - - return map; - } - - /// - /// This method converts a InputFilter map to a struct and returns it.
- /// The returned struct can be returned to the user as a InputFilter in the GetInputFilter method.
- /// The InputFilter PropertyMap. - /// A InputFilter struct. - ///
- [EditorBrowsable(EditorBrowsableState.Never)] - public static InputFilter GetInputFilterStruct(PropertyMap map) - { - string accepted = ""; - string rejected = ""; - map.Find(0)?.Get(out accepted); - map.Find(1)?.Get(out rejected); - - var inputFilter = new InputFilter(); - inputFilter.Accepted = accepted; - inputFilter.Rejected = rejected; - - return inputFilter; - - } - - /// - /// This method converts a Underline struct to a PropertyMap and returns it. - /// The returned map can be used for set Underline PropertyMap in the SetUnderline method. - /// The Underline struct value. - /// A PropertyMap for Underline property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetUnderlineMap(Underline underline) - { - var map = new PropertyMap(); - - map.Add("enable", new PropertyValue(underline.Enable)); - - if (underline.Color != null) - map.Add("color", new PropertyValue(underline.Color)); - - if (underline.Height != null) - map.Add("height", new PropertyValue((float)underline.Height)); - - return map; - } - - /// - /// This method converts a Underline map to a struct and returns it. - /// The returned struct can be returned to the user as a Underline in the GetUnderline method. - /// The Underline PropertyMap. - /// A Underline struct. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static Underline GetUnderlineStruct(PropertyMap map) - { - Color color = new Color(); - map.Find(0, "enable").Get(out bool enable); - map.Find(0, "color").Get(color); - map.Find(0, "height").Get(out float height); - - var underline = new Underline(); - underline.Enable = enable; - underline.Color = color; - underline.Height = height; - - return underline; - } - - /// - /// This method converts a Shadow struct to a PropertyMap and returns it. - /// The returned map can be used for set Shadow PropertyMap in the SetShadow method. - /// The Shadow struct value. - /// A PropertyMap for Shadow property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetShadowMap(Tizen.NUI.Text.Shadow shadow) - { - var map = new PropertyMap(); - - if (shadow.Offset != null) - map.Add("offset", new PropertyValue(shadow.Offset)); - - if (shadow.Color != null) - map.Add("color", new PropertyValue(shadow.Color)); - - if (shadow.BlurRadius != null) - map.Add("blurRadius", new PropertyValue((float)shadow.BlurRadius)); - - return map; - } - - /// - /// This method converts a Shadow map to a struct and returns it. - /// The returned struct can be returned to the user as a Shadow in the GetShadow method. - /// The Shadow PropertyMap. - /// A Shadow struct. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static Tizen.NUI.Text.Shadow GetShadowStruct(PropertyMap map) - { - Vector2 offset = new Vector2(); - Color color = new Color(); - map.Find(0, "offset").Get(offset); - map.Find(0, "color").Get(color); - map.Find(0, "blurRadius").Get(out float blurRadius); - - var shadow = new Tizen.NUI.Text.Shadow(); - shadow.Offset = offset; - shadow.Color = color; - shadow.BlurRadius = blurRadius; - - return shadow; - } - - /// - /// This method converts a Outline struct to a PropertyMap and returns it. - /// The returned map can be used for set Outline PropertyMap in the SetOutline method. - /// The Outline struct value. - /// A PropertyMap for Outline property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetOutlineMap(Outline outline) - { - var map = new PropertyMap(); - - if (outline.Color != null) - map.Add("color", new PropertyValue(outline.Color)); - - if (outline.Width != null) - map.Add("width", new PropertyValue((float)outline.Width)); - - return map; - } - - /// - /// This method converts a Outline map to a struct and returns it. - /// The returned struct can be returned to the user as a Outline in the GetOutline method. - /// The Outline PropertyMap. - /// A Outline struct. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static Outline GetOutlineStruct(PropertyMap map) - { - Color color = new Color(); - map.Find(0, "color").Get(color); - map.Find(0, "width").Get(out float width); - - var outline = new Outline(); - outline.Color = color; - outline.Width = width; - - return outline; - } - - /// - /// It returns a string value according to FontSizeType. - /// The returned value can be used for TextFit PropertyMap. - /// The FontSizeType enum value. - /// A string value for TextFit.FontSizeType property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static string GetFontSizeString(FontSizeType fontSizeType) - { - string value = fontSizeType.ToString(); - if (!string.IsNullOrEmpty(value)) - { - char[] charArray = value.ToCharArray(); - charArray[0] = Char.ToLower(charArray[0]); - value = new string(charArray); - } - else - { - value = "pointSize"; // The default value. - } - - return value; - } - - /// - /// It returns a FontSizeType value according to fontSizeString. - /// The returned value can be used for FontStyle PropertyMap. - /// The FontSizeType string value. - /// A FontSizeType value for TextFit.FontSizeType property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static FontSizeType GetFontSizeType(string fontSizeString) - { - FontSizeType value; - - if (!(Enum.TryParse(fontSizeString, true, out value) && Enum.IsDefined(typeof(FontSizeType), value))) - { - value = FontSizeType.PointSize; // If parsing fails, set a default value. - } - - return value; - } - - /// - /// This method converts a TextFit struct to a PropertyMap and returns it. - /// The returned map can be used for set TextFit PropertyMap in the SetTextFit method. - /// The TextFit struct value. - /// A PropertyMap for TextFit property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetTextFitMap(TextFit textFit) - { - var map = new PropertyMap(); - map.Add("enable", new PropertyValue(textFit.Enable)); - map.Add("fontSizeType", new PropertyValue(GetFontSizeString(textFit.FontSizeType))); - - if (textFit.MinSize != null) - map.Add("minSize", new PropertyValue((float)textFit.MinSize)); - - if (textFit.MaxSize != null) - map.Add("maxSize", new PropertyValue((float)textFit.MaxSize)); - - if (textFit.StepSize != null) - map.Add("stepSize", new PropertyValue((float)textFit.StepSize)); - - return map; - } - - /// - /// This method converts a TextFit map to a struct and returns it. - /// The returned struct can be returned to the user as a TextFit in the GetTextFit method. - /// The TextFit PropertyMap. - /// A TextFit struct. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static TextFit GetTextFitStruct(PropertyMap map) - { - bool enable = false; - float minSize = 0.0f; - float maxSize = 0.0f; - float stepSize = 0.0f; - float fontSize = 0.0f; - string fontSizeType = null; - map.Find(0, "enable")?.Get(out enable); - map.Find(0, "minSize")?.Get(out minSize); - map.Find(0, "maxSize")?.Get(out maxSize); - map.Find(0, "stepSize")?.Get(out stepSize); - map.Find(0, "fontSize")?.Get(out fontSize); - map.Find(0, "fontSizeType")?.Get(out fontSizeType); - - var textFit = new TextFit(); - textFit.Enable = enable; - textFit.MinSize = minSize; - textFit.MaxSize = maxSize; - textFit.StepSize = stepSize; - textFit.FontSize = fontSize; - textFit.FontSizeType = GetFontSizeType(fontSizeType); - - return textFit; - } - - /// - /// This method converts a Placeholder struct to a PropertyMap and returns it. - /// The returned map can be used for set Placeholder PropertyMap in the SetPlaceholder method. - /// The Placeholder struct value. - /// A PropertyMap for Placeholder property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetPlaceholderMap(Placeholder placeholder) - { - var map = new PropertyMap(); - - if (placeholder.Text != null) - map.Add("text", new PropertyValue(placeholder.Text)); - - if (placeholder.TextFocused != null) - map.Add("textFocused", new PropertyValue(placeholder.TextFocused)); - - if (placeholder.Color != null) - map.Add("color", new PropertyValue(placeholder.Color)); - - if (placeholder.FontFamily != null) - map.Add("fontFamily", new PropertyValue(placeholder.FontFamily)); - - if (placeholder.FontStyle != null) - map.Add("fontStyle", new PropertyValue(GetFontStyleMap((FontStyle)placeholder.FontStyle))); - - if (placeholder.PointSize != null && placeholder.PixelSize != null) - map.Add("pointSize", new PropertyValue((float)placeholder.PointSize)); - - else if (placeholder.PointSize != null) - map.Add("pointSize", new PropertyValue((float)placeholder.PointSize)); - - else if (placeholder.PixelSize != null) - map.Add("pixelSize", new PropertyValue((float)placeholder.PixelSize)); - - map.Add("ellipsis", new PropertyValue(placeholder.Ellipsis)); - - return map; - } - - /// - /// This method converts a Placeholder map to a struct and returns it. - /// The returned struct can be returned to the user as a Placeholder in the GetPlaceholder method. - /// The Placeholder PropertyMap. - /// A Placeholder struct. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static Placeholder GetPlaceholderStruct(PropertyMap map) - { - string text = ""; - string textFocused = ""; - Color color = new Color(); - string fontFamily = null; - var fontStyle = new PropertyMap(); - PropertyValue pointSizeValue = null; - PropertyValue pixelSizeValue = null; - bool ellipsis = false; - - map.Find(0)?.Get(out text); - map.Find(1)?.Get(out textFocused); - map.Find(2)?.Get(color); - map.Find(3)?.Get(out fontFamily); - map.Find(4)?.Get(fontStyle); - pointSizeValue = map.Find(5); - pixelSizeValue = map.Find(6); - map.Find(7)?.Get(out ellipsis); - - var placeholder = new Placeholder(); - placeholder.Text = text; - placeholder.TextFocused = textFocused; - placeholder.Color = color; - placeholder.FontFamily = fontFamily; - placeholder.Ellipsis = ellipsis; - placeholder.FontStyle = GetFontStyleStruct(fontStyle); - - if (pointSizeValue != null) - { - pointSizeValue.Get(out float pointSize); - placeholder.PointSize = pointSize; - } - - if (pixelSizeValue != null) - { - pixelSizeValue.Get(out float pixelSize); - placeholder.PixelSize = pixelSize; - } - - return placeholder; - } - - /// - /// This method converts a HiddenInput struct to a PropertyMap and returns it. - /// The returned map can be used for set HiddenInputSettings PropertyMap in the SetHiddenInput method. - /// The HiddenInput struct value. - /// A PropertyMap for HiddenInput property. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetHiddenInputMap(HiddenInput hiddenInput) - { - var map = new PropertyMap(); - - map.Add(0, new PropertyValue((int)hiddenInput.Mode)); - - if (hiddenInput.SubstituteCharacter != null) - map.Add(1, new PropertyValue(Convert.ToInt32(hiddenInput.SubstituteCharacter))); - - if (hiddenInput.SubstituteCount != null) - map.Add(2, new PropertyValue((int)hiddenInput.SubstituteCount)); - - if (hiddenInput.ShowLastCharacterDuration != null) - map.Add(3, new PropertyValue((int)hiddenInput.ShowLastCharacterDuration)); - - return map; - } - - /// - /// This method converts a HiddenInputSettings map to a struct and returns it. - /// The returned struct can be returned to the user as a HiddenInput in the GetHiddenInput method. - /// The HiddenInput PropertyMap. - /// A HiddenInput struct. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static HiddenInput GetHiddenInputStruct(PropertyMap map) - { - PropertyValue value = null; - - var hiddenInput = new HiddenInput(); - - value = map.Find(0); - if (value != null) - { - value.Get(out int mode); - hiddenInput.Mode = (HiddenInputModeType)mode; - } - - value = map.Find(1); - if (value != null) - { - value.Get(out int substituteCharacter); - hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter); - } - - value = map.Find(2); - if (value != null) - { - value.Get(out int substituteCount); - hiddenInput.SubstituteCount = substituteCount; - } - - value = map.Find(3); - if (value != null) - { - value.Get(out int showLastCharacterDuration); - hiddenInput.ShowLastCharacterDuration = showLastCharacterDuration; - } - - return hiddenInput; - } - - /// - /// This method converts a fileName string to a PropertyMap and returns it. - /// The returned map can be used for set SelectionHandleImageLeft, SelectionHandleImageRight PropertyMap in the SetSelectionHandleImage method. - /// The file path string value for SelectionHandleImage. - /// A PropertyMap for SelectionHandleImageLeft, SelectionHandleImageRight properties. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static PropertyMap GetFileNameMap(string fileName) - { - return new PropertyMap().Add("filename", new PropertyValue(fileName)); - } - - /// - /// This method converts a SelectionHandleImageLeft, SelectionHandleImageRight map to a struct and returns it. - /// The returned struct can be returned to the user as a SelectionHandleImage in the GetSelectionHandleImage method. - /// The SelectionHandleImageLeft PropertyMap. - /// The SelectionHandleImageRight PropertyMap. - /// A SelectionHandleImage struct. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static SelectionHandleImage GetSelectionHandleImageStruct(PropertyMap leftImageMap, PropertyMap rightImageMap) - { - string leftImageUrl = null; - string rightImageUrl = null; - - var selectionHandleImage = new SelectionHandleImage(); - - leftImageMap.Find(0, "filename")?.Get(out leftImageUrl); - rightImageMap.Find(0, "filename")?.Get(out rightImageUrl); - - selectionHandleImage.LeftImageUrl = leftImageUrl; - selectionHandleImage.RightImageUrl = rightImageUrl; - - return selectionHandleImage; - } - - /// /// Copy the previously selected text into the clipboard and return the copied value. /// /// The textEditor control from which the text is copied.