Пример #1
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);
            }
        }
Пример #2
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();
        }