Beispiel #1
0
        private void OnKeyChanged(PropertyItem item, string lastKey, string key)
        {
            if (!string.IsNullOrEmpty(lastKey) && propertyDic.ContainsKey(lastKey))
            {
                if (!string.IsNullOrEmpty(propertyDic[lastKey]))
                {
                    propertyCatchedDic[lastKey] = propertyDic[lastKey];
                }
                propertyDic.Remove(lastKey);
            }

            if (!string.IsNullOrEmpty(key))
            {
                if (propertyDic.ContainsKey(key))//不支持重复
                {
                    OnDeleteItem(item);
                }
                else
                {
                    if (propertyCatchedDic.ContainsKey(key))//从缓存加载
                    {
                        propertyDic[key] = propertyCatchedDic[key];
                    }
                    else
                    {
                        propertyDic.Add(key, "");
                    }

                    item.UpdateInfo(key, propertyDic[key]);
                }
                SetAcitveKey(propertyDic, key);
            }
        }
Beispiel #2
0
        public static void AnalysisLayerInfo(PsdLayer layer, LayerInfo layerInfo)
        {
            ResourceDic dic        = new ResourceDic();
            Rect        parentRect = layerInfo.rect;
            Rect        innerRect  = GetSubRectFromLayer(layer, parentRect);

            dic.Add("name", layer.Name);
            switch (layer.LayerType)
            {
            case LayerType.Normal:
            case LayerType.Color:
                layerInfo.sub_images.Add(dic);
                dic.Add("sprite", layer.Name + ".png");
                dic.Add("rect", ParamAnalysisTool.RectToString(innerRect));
                CreatePNGFile(layer);
                break;

            case LayerType.Text:
                layerInfo.sub_texts.Add(dic);
                var textInfo = layer.Records.TextInfo;
                var color    = new Color(textInfo.color[0], textInfo.color[1], textInfo.color[2], textInfo.color[3]);
                dic.Add("rect", ParamAnalysisTool.RectToString(GetMarginRect(innerRect, 1.2f)));
                dic.Add("color", ParamAnalysisTool.ColorToString(color));
                dic.Add("text", textInfo.text);
                if (!string.IsNullOrEmpty(textInfo.fontName))
                {
                    dic.Add("font", textInfo.fontName);
                }
                dic.Add("fontSize", textInfo.fontSize.ToString());
                break;

            case LayerType.Complex:
                Debug.Log("目标层解析能正常,请修改为智能对象! layer --> " + layer.Name);
                layerInfo.sub_images.Add(dic);
                dic.Add("sprite", layer.Name + ".png");
                dic.Add("rect", ParamAnalysisTool.RectToString(innerRect));
                CreatePNGFile(layer);
                break;

            default:
                break;
            }
        }