Beispiel #1
0
        /// <summary>
        /// 查找并从字典中将信息移除
        /// </summary>
        /// <param name="obj"></param>
        private void OnDeleteCtrlItem(Control_Item obj)
        {
            var hashCode = obj.dicHash;

            controlItemCreater.RemoveItem(obj);

            using (var enumerator = layerInfo.subResourceDic.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    if (current.Value.GetHashCode() == hashCode)
                    {
                        layerInfo.subResourceDic.Remove(current.Key);
                        return;
                    }
                }
            }

            using (var enumerator = layerInfo.sub_images.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    if (current.GetHashCode() == hashCode)
                    {
                        layerInfo.sub_images.Remove(current);
                        return;
                    }
                }
            }
            using (var enumerator = layerInfo.sub_texts.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    if (current.GetHashCode() == hashCode)
                    {
                        layerInfo.sub_texts.Remove(current);
                        return;
                    }
                }
            }
            using (var enumerator = layerInfo.sub_rawImages.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    if (current.GetHashCode() == hashCode)
                    {
                        layerInfo.sub_rawImages.Remove(current);
                        return;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 创建独立控件
        /// </summary>
        /// <param name="ctrlItem"></param>
        private void OnGenInstenceControl(Control_Item ctrlItem)
        {
            LayerInfo subLayerInfo = new LayerInfo();
            var       typeName     = ctrlItem.layerDefine.type.Name;

            subLayerInfo.name = "new " + typeName;
            subLayerInfo.path = this.layerInfo.path + "/" + subLayerInfo.name;
            subLayerInfo.type = typeName;
            subLayerInfo.rect = this.layerInfo.rect;
            ctrlItem.CopyToDic(subLayerInfo.resourceDic);
            OnDeleteCtrlItem(ctrlItem);
            if (onCreateNewLayerInfo != null)
            {
                onCreateNewLayerInfo.Invoke(this.ID, subLayerInfo);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 初始化CtrlItem
        /// </summary>
        /// <param name="ctrlItem"></param>
        /// <param name="layerDefine"></param>
        /// <param name="dic"></param>
        /// <param name="name"></param>
        private void InitCtrlItem(int index, Control_Item ctrlItem, ILayerDefine layerDefine, ResourceDic dic, string name)
        {
            var mainLayerDefine = controlDic[layerInfo.type];
            var controlName     = name;

            if (index != 0)
            {
                controlName = mainLayerDefine.GetSubControlName(name);
            }
            ctrlItem.onDelete             = OnDeleteCtrlItem;
            ctrlItem.onMainControl        = OnMainCtrlItem;
            ctrlItem.onGenInstenceControl = OnGenInstenceControl;
            ctrlItem.SetIndex(index);
            ctrlItem.SetTitle(controlName);
            UpdateCtrlItemState(index, ctrlItem);
            ctrlItem.SetPropertys(dic, layerDefine);
        }
Beispiel #4
0
        /// <summary>
        /// 置为主控件
        /// </summary>
        /// <param name="ctrlItem"></param>
        private void OnMainCtrlItem(Control_Item ctrlItem)
        {
            var mainLayerDefine = controlDic[layerInfo.type];

            if (ctrlItem.layerDefine != mainLayerDefine)
            {
                var @continue = DialogHelper.ShowDialog("小提示", "注意到与目标类型不一致!", "继续", "取消");
                if (!@continue)
                {
                    return;
                }
            }

            var tempDic = new ResourceDic(layerInfo.resourceDic);

            ctrlItem.CopyToDic(layerInfo.resourceDic);

            var typeName = ctrlItem.layerDefine.type.Name;

            layerInfo.type = typeName;
            var id = controlTypes.IndexOf(typeName);

            if (m_controlTypes.value != id)
            {
                layerInfo.type = controlTypes[id];

                m_controlTypes.onValueChanged.RemoveListener(OnControlTypeChanged);
                m_controlTypes.value = id;
                m_controlTypes.onValueChanged.AddListener(OnControlTypeChanged);
            }

            var keep = tempDic.Count > 0 && DialogHelper.ShowDialog("小提示", "原有主控件信息不为空,是否保留信息继续编辑!", "保留", "删除");

            if (keep)
            {
                ctrlItem.CopyFromDic(tempDic);
            }
            else
            {
                OnDeleteCtrlItem(ctrlItem);
            }
            UpdateListView();
        }
Beispiel #5
0
        private void UpdateCtrlItemState(int index, Control_Item ctrlItem)
        {
            var mainLayerDefine = controlDic[layerInfo.type];

            if (index != 0)//第0个默认为主控件
            {
                if (mainLayerDefine.integrantSubControls == null || !mainLayerDefine.integrantSubControls.Contains(name))
                {
                    ctrlItem.SetDeleteable(true);
                }
                else
                {
                    ctrlItem.SetDeleteable(false);
                }
            }
            else
            {
                ctrlItem.SetDeleteable(false);
            }
        }