private void Button_DelCustomBind_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (EditorCommon.MessageBox.Show($"即将删除绑定函数{BindFunctionName},删除后不可恢复,是否继续?", EditorCommon.MessageBox.enMessageBoxButton.YesNo) != EditorCommon.MessageBox.enMessageBoxResult.Yes)
            {
                return;
            }
            var bindInsType = BindInstance.GetType();

            if (bindInsType.GetInterface(typeof(IEnumerable).FullName, false) != null)
            {
                foreach (var insObj in (IEnumerable)BindInstance)
                {
                    var uiElement = insObj as EngineNS.UISystem.UIElement;
                    uiElement.PropertyCustomBindRemoveAction?.Invoke(uiElement, BindProperty.Name);
                }
            }
            else
            {
                var uiElement = BindInstance as EngineNS.UISystem.UIElement;
                uiElement.PropertyCustomBindRemoveAction?.Invoke(uiElement, BindProperty.Name);
            }
            BindFunctionOpIsAdd = true;
            Binded           = false;
            BindFunctionName = "";
        }
        private void Button_FindCustomBind_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var bindInsType = BindInstance.GetType();

            if (bindInsType.GetInterface(typeof(IEnumerable).FullName, false) != null)
            {
                foreach (var insObj in (IEnumerable)BindInstance)
                {
                    var uiElement = insObj as EngineNS.UISystem.UIElement;
                    uiElement.PropertyCustomBindFindAction?.Invoke(uiElement, BindProperty.Name);
                }
            }
            else
            {
                var uiElement = BindInstance as EngineNS.UISystem.UIElement;
                uiElement.PropertyCustomBindFindAction?.Invoke(uiElement, BindProperty.Name);
            }
            popup.IsOpen = false;
        }
        private void Button_AddCustomBind_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            BindFunctionOpIsAdd = false;
            Binded = true;
            var bindInsType = BindInstance.GetType();

            if (bindInsType.GetInterface(typeof(IEnumerable).FullName, false) != null)
            {
                foreach (var insObj in (IEnumerable)BindInstance)
                {
                    var uiElement = insObj as EngineNS.UISystem.UIElement;
                    //BindFunctionName = $"UIBindFunc_{uiElement.Initializer.Name}_{BindProperty.Name}";
                    BindFunctionName = $"UIBindFunc_{BindProperty.Name}({uiElement.Initializer.Name})";
                    uiElement.PropertyCustomBindAddAction?.Invoke(uiElement, BindProperty.Name, BindProperty.GetPropertyType(uiElement));
                }
            }
            else
            {
                var uiElement = BindInstance as EngineNS.UISystem.UIElement;
                //BindFunctionName = $"UIBindFunc_{uiElement.Initializer.Name}_{BindProperty.Name}";
                BindFunctionName = $"UIBindFunc_{BindProperty.Name}({uiElement.Initializer.Name})";
                uiElement.PropertyCustomBindAddAction?.Invoke(uiElement, BindProperty.Name, BindProperty.GetPropertyType(uiElement));
            }
        }
Exemple #4
0
        private void IconTextBtn_SubmenuOpened(object sender, RoutedEventArgs e)
        {
            BoneList.Clear();
            var enumrableInterface = BindInstance.GetType().GetInterface(typeof(System.Collections.IEnumerable).FullName, false);

            if (enumrableInterface != null)
            {
                // 显示多个对象
                int count = 0;
                foreach (var objIns in (System.Collections.IEnumerable)BindInstance)
                {
                    if (objIns == null)
                    {
                        continue;
                    }
                    count++;
                }
                if (count == 0)
                {
                }
                else if (count == 1)
                {
                    foreach (var objIns in (System.Collections.IEnumerable)BindInstance)
                    {
                        if (objIns == null)
                        {
                            continue;
                        }
                        RefreshBoneList(objIns);
                    }
                }
                else
                {
                    string skeletonName     = null;
                    bool   haveSameSkeleton = true;
                    foreach (var objIns in (System.Collections.IEnumerable)BindInstance)
                    {
                        if (objIns == null)
                        {
                            continue;
                        }
                        var comp = objIns as EngineNS.GamePlay.Component.GComponent;
                        if (comp == null)
                        {
                            continue;
                        }
                        var hostMesh = comp.HostContainer as EngineNS.GamePlay.Component.GMeshComponent;
                        if (hostMesh != null)
                        {
                            var modifier = hostMesh.SceneMesh.MdfQueue.FindModifier <EngineNS.Graphics.Mesh.CGfxSkinModifier>();
                            if (modifier != null)
                            {
                                if (skeletonName == null)
                                {
                                    skeletonName = modifier.SkeletonAsset;
                                }
                                if (skeletonName != modifier.SkeletonAsset)
                                {
                                    haveSameSkeleton = false;
                                    return;
                                }
                            }
                        }
                    }
                    if (haveSameSkeleton && !string.IsNullOrEmpty(skeletonName))
                    {
                        var skeleton     = EngineNS.CEngine.Instance.SkeletonAssetManager.GetSkeleton(EngineNS.CEngine.Instance.RenderContext, EngineNS.RName.GetRName(skeletonName));
                        var skeletonPose = skeleton.CreateSkeletonPose();
                        BoneList.Add("None");
                        for (uint i = 0; i < skeletonPose.BoneNumber; ++i)
                        {
                            BoneList.Add(skeletonPose.GetBonePose(i).ReferenceBone.BoneDesc.Name);
                        }
                    }
                }
            }
            else
            {
                RefreshBoneList(BindInstance);
            }
            SearchBoxCtrl.FocusInput();
        }
        //bool mBindInitialized = false;
        private void UpdateBindShow()
        {
            //if (mBindInitialized)
            //    return;

            //////ListBox_ClassBind.Items.Clear();
            //////ListBox_ControlBind.Items.Clear();

            //////UISystem.WinBase win = BindInstance as UISystem.WinBase;
            //////if (win != null)
            //////{
            //////    var bindInfos = win.GetPropertyBinds(BindProperty.Name);
            //////    if (bindInfos != null)
            //////    {
            //////        // 新的UI逻辑图,绑定不一样了,这里先注掉
            //////        //////foreach (UISystem.Bind.ClassPropertyBindInfo bindInfo in (from bind in bindInfos where bind is UISystem.Bind.ClassPropertyBindInfo select bind))
            //////        //////{
            //////        //////    ClassPropertyBindControl ctrl = new ClassPropertyBindControl(BindInstance, BindProperty, bindInfo);

            //////        //////    ListBox_ClassBind.Items.Add(ctrl);
            //////        //////}
            //////        //////foreach (UISystem.Bind.ControlPropertyBindInfo bindInfo in (from bind in bindInfos where bind is UISystem.Bind.ControlPropertyBindInfo select bind))
            //////        //////{
            //////        //////    ControlPropertyBindControl ctrl = new ControlPropertyBindControl(BindInstance, BindProperty, bindInfo);

            //////        //////    ListBox_ControlBind.Items.Add(ctrl);
            //////        //////}
            //////        //foreach (var bindInfo in bindInfos)
            //////        //{
            //////        //    if (bindInfo is UISystem.Bind.ClassPropertyBindInfo)
            //////        //    {
            //////        //        ClassPropertyBindControl ctrl = new ClassPropertyBindControl(BindInstance, BindProperty, (UISystem.Bind.ClassPropertyBindInfo)bindInfo);
            //////        //        //ctrl.BindInstance = BindInstance;
            //////        //        //ctrl.BindProperty = BindProperty;
            //////        //        ListBox_ClassBind.Items.Add(ctrl);
            //////        //    }
            //////        //    else if (bindInfo is UISystem.Bind.ControlPropertyBindInfo)
            //////        //    {
            //////        //        ControlPropertyBindControl ctrl = new ControlPropertyBindControl(BindInstance, BindProperty, (UISystem.Bind.ControlPropertyBindInfo)bindInfo);
            //////        //        ListBox_ControlBind.Items.Add(ctrl);
            //////        //    }
            //////        //}
            //////    }
            //////}

            //////if (ListBox_ClassBind.Items.Count > 0 || ListBox_ControlBind.Items.Count > 0)
            //////    Binded = true;
            //////else
            //////    Binded = false;
            IsEnabled = true;
            var bindInsType = BindInstance.GetType();

            if (bindInsType.GetInterface(typeof(IEnumerable).FullName, false) != null)
            {
                // 多选
                int count = 0;
                foreach (var objIns in (IEnumerable)BindInstance)
                {
                    count++;
                }
                if (count > 1)
                {
                    BindFunctionName = "无法同时操作多个控件";
                    IsEnabled        = false;
                }
                foreach (var objIns in (IEnumerable)BindInstance)
                {
                    if (objIns == null)
                    {
                        continue;
                    }

                    var uiElement = objIns as EngineNS.UISystem.UIElement;
                    if (uiElement == null)
                    {
                        continue;
                    }
                    string bindFunctionName;
                    if (uiElement.PropertyBindFunctions.TryGetValue(BindProperty.Name, out bindFunctionName))
                    {
                        BindFunctionName    = $"UIBindFunc_{BindProperty.Name}({uiElement.Initializer.Name})";// bindFunctionName;
                        BindFunctionOpIsAdd = false;
                    }
                    else
                    {
                        BindFunctionOpIsAdd = true;
                    }

                    List <EngineNS.UISystem.VariableBindInfo> varBindInfos;
                    if (uiElement.VariableBindInfosDic.TryGetValue(BindProperty.Name, out varBindInfos))
                    {
                        ListBox_VariableBind.Items.Clear();
                        foreach (var info in varBindInfos)
                        {
                            var ctrl = new EditorCommon.Bind.VariableBind(this, uiElement, info, BindProperty.GetPropertyType(uiElement));
                            ListBox_VariableBind.Items.Add(ctrl);
                        }
                    }

                    UpdateBindShow(uiElement);
                }
            }
            else
            {
                var uiElement = BindInstance as EngineNS.UISystem.UIElement;
                if (uiElement != null)
                {
                    string bindFunctionName;
                    if (uiElement.PropertyBindFunctions.TryGetValue(BindProperty.Name, out bindFunctionName))
                    {
                        BindFunctionName    = $"UIBindFunc_{BindProperty.Name}({uiElement.Initializer.Name})";// bindFunctionName;
                        BindFunctionOpIsAdd = false;
                    }
                    else
                    {
                        BindFunctionOpIsAdd = true;
                    }

                    List <EngineNS.UISystem.VariableBindInfo> varBindInfos;
                    if (uiElement.VariableBindInfosDic.TryGetValue(BindProperty.Name, out varBindInfos))
                    {
                        foreach (var info in varBindInfos)
                        {
                            var ctrl = new EditorCommon.Bind.VariableBind(this, uiElement, info, BindProperty.GetPropertyType(uiElement));
                            ListBox_VariableBind.Items.Add(ctrl);
                        }
                    }

                    UpdateBindShow(uiElement);
                }
            }

            //mBindInitialized = true;
        }