Ver Fonte

fix asset location

ChingYi há 2 anos atrás
pai
commit
44ee0ded6b

+ 36 - 0
CMSCollection/Data/ViewerEventBarSettingResponse.cs

@@ -49,9 +49,27 @@ namespace KdanCommon.CMSCollection.Data
 
         [JsonProperty("event_bar_icon_image")]
         public string EventBarIconImage { get; set; }
+        public string EventBarIconImageUrlStr
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(EventBarIconImage))
+                    return null;
+                return $"{CMSCollection.CMSDomain}/assets/{EventBarIconImage}";
+            }
+        }
 
         [JsonProperty("event_bar_close_button_image")]
         public string EventBarCloseButtonImage { get; set; }
+        public string EventBarCloseButtonImageUrlStr
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(EventBarCloseButtonImage))
+                    return null;
+                return $"{CMSCollection.CMSDomain}/assets/{EventBarCloseButtonImage}";
+            }
+        }
 
         [JsonProperty("event_bar_icon_visible")]
         public bool EventBarIconVisible { get; set; }
@@ -67,9 +85,27 @@ namespace KdanCommon.CMSCollection.Data
 
         [JsonProperty("dialog_image")]
         public string DialogImage { get; set; }
+        public string DialogImageUrlStr
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(DialogImage))
+                    return null;
+                return $"{CMSCollection.CMSDomain}/assets/{DialogImage}";
+            }
+        }
 
         [JsonProperty("dialog_close_icon_image")]
         public string DialogCloseIconImage { get; set; }
+        public string DialogCloseIconImageUrlStr
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(DialogCloseIconImage))
+                    return null;
+                return $"{CMSCollection.CMSDomain}/assets/{DialogCloseIconImage}";
+            }
+        }
 
         [JsonProperty("dialog_close_button_visible")]
         public bool DialogCloseButtonVisible { get; set; }

+ 38 - 0
Helpers/ColorCodeExtension.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Windows.UI;
+
+namespace KdanCommon.Helpers
+{
+    public static class ColorCodeExtension
+    {
+        public static Color ToColor(this string hex)
+        {
+            byte a = 255;
+            byte r = 0;
+            byte g = 0;
+            byte b = 0;
+            if (hex.StartsWith("#"))
+            {
+                hex = hex.Replace("#", string.Empty);
+                if (hex.Length == 8)
+                {
+                    a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
+                    r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
+                    g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
+                    b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16));
+                }
+                else if (hex.Length == 6)
+                {
+                    r = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
+                    g = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
+                    b = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
+                }
+            }
+            return Color.FromArgb(a, r, g, b);
+        }
+    }
+}

+ 1 - 0
KdanCommon.csproj

@@ -125,6 +125,7 @@
     <Compile Include="CMSCollection\Data\JsonSetting.cs" />
     <Compile Include="CMSCollection\Data\ViewerEventBarSettingResponse.cs" />
     <Compile Include="CMSCollection\Data\WindowsCardsResponse.cs" />
+    <Compile Include="Helpers\ColorCodeExtension.cs" />
     <Compile Include="Helpers\DynamicJsonHelper.cs" />
     <Compile Include="Helpers\HttpClientHelper.cs" />
     <Compile Include="Helpers\JsonTool.cs" />