EngineNS.UISystem.UIElement CalculateCanAddChildableUIElement(EngineNS.UISystem.UIElement uiElement) { if (uiElement is EngineNS.UISystem.Controls.Containers.Panel) { return(uiElement); } if (uiElement is EngineNS.UISystem.Controls.Containers.Border) { var contentCtrl = uiElement as EngineNS.UISystem.Controls.Containers.Border; if (contentCtrl.Content == null) { return(uiElement); } else { if (uiElement.Parent == null) { return(null); } return(CalculateCanAddChildableUIElement(uiElement.Parent)); } } if (uiElement.Parent == null) { return(null); } return(CalculateCanAddChildableUIElement(uiElement.Parent)); }
internal async Task OnReceiveAddChildren(EngineNS.UISystem.UIElement parent, EngineNS.UISystem.UIElement[] children, int insertIndex) { await EngineNS.Thread.AsyncDummyClass.DummyFunc(); //var rc = EngineNS.CEngine.Instance.RenderContext; //foreach(var child in children) //{ // await AddPanelRectShow(rc, child); //} }
internal async Task FindPropertyCustomBindFunc(EngineNS.UISystem.UIElement uiElement, string propertyName) { string funcName; if (uiElement.PropertyBindFunctions.TryGetValue(propertyName, out funcName)) { Macross.Category category = Macross_Client.GetCategory(MacrossPanel.UIBindFuncCategoryName); var item = category.FindItem(funcName); if (item != null) { await Macross_Client.ShowNodesContainer(item); HostControl.ChangeToLogic(); } } }
internal void SetIsVariable(EngineNS.UISystem.UIElement element, bool setValue) { var category = Macross_Client.GetCategory(MacrossPanel.UIElementVariableCategoryName); var elementType = element.GetType(); var variables = category.Items.ToArray(); for (int i = 0; i < variables.Length; i++) { var pro = variables[i].PropertyShowItem as UIElementVariableCategoryItemPropertys; if (pro == null) { continue; } if (pro.ElementId == element.Id) { if (!setValue) { category.Items.Remove(variables[i]); } return; } } if (setValue) { // 没找到则创建一个 var item = new Macross.CategoryItem(null, category); item.CategoryItemType = Macross.CategoryItem.enCategoryItemType.Unknow; BindingOperations.SetBinding(item, Macross.CategoryItem.NameProperty, new Binding("Name") { Source = element.Initializer, Mode = BindingMode.TwoWay }); item.CanDrag = true; item.InitTypeStr = "UI_UIElement_Variable"; var data = new UIElementVariableCategoryItemInitData(); data.Reset(); data.UIElement = element; data.ElementType = elementType; data.UIElementId = element.Id; data.Deleteable = false; item.Initialize(Macross_Client, data); category.Items.Add(item); } }
internal async Task FindEventFunction(EngineNS.UISystem.UIElement element, string functionName) { var key = new UIResourceInfo.UIEventDicKey(element.Id, functionName); string dicValue; if (HostControl.CurrentResInfo.UIEventsDic.TryGetValue(key, out dicValue)) { var category = Macross_Client.GetCategory(MacrossPanel.UIEventFuncCategoryName); var item = category.FindItem(dicValue); if (item != null) { await Macross_Client.ShowNodesContainer(item); HostControl.ChangeToLogic(); } } }
void RemoveChildPanelRectShow(EngineNS.UISystem.UIElement ui) { var panel = ui as EngineNS.UISystem.Controls.Containers.Panel; if (panel != null) { foreach (var child in panel.ChildrenUIElements) { if (mSelectedUIDatas.ContainsKey(child)) { mSelectedUIDatas.Remove(child); } mPanelRectsShow.Remove(child); RemoveChildPanelRectShow(child); } } }
internal void DelPropertyCustomBindFunc(EngineNS.UISystem.UIElement uiElement, string propertyName) { string funcName; if (uiElement.PropertyBindFunctions.TryGetValue(propertyName, out funcName)) { Macross.Category category = Macross_Client.GetCategory(MacrossPanel.UIBindFuncCategoryName); var item = category.FindItem(funcName); if (item != null) { category.RemoveItem(funcName); Macross_Client.RemoveNodesContainer(item); var fileName = Macross_Client.GetGraphFileName(item.Name); EngineNS.CEngine.Instance.FileManager.DeleteFile(fileName); } uiElement.PropertyBindFunctions.Remove(propertyName); } }
internal void DeleteEventFunction(EngineNS.UISystem.UIElement element, string functionName) { var key = new UIResourceInfo.UIEventDicKey(element.Id, functionName); string dicValue; if (HostControl.CurrentResInfo.UIEventsDic.TryGetValue(key, out dicValue)) { var category = Macross_Client.GetCategory(MacrossPanel.UIEventFuncCategoryName); var item = category.FindItem(dicValue); if (item != null) { Macross_Client.RemoveNodesContainer(item); category.RemoveItem(dicValue); var fileName = Macross_Client.GetGraphFileName(item.Name); EngineNS.CEngine.Instance.FileManager.DeleteFile(fileName); } HostControl.CurrentResInfo.UIEventsDic.Remove(key); } }
public VariableBind(BindButton hostCtrl, EngineNS.UISystem.UIElement uiElement, EngineNS.UISystem.VariableBindInfo bindInfo, Type proType) { InitializeComponent(); mHostControl = hostCtrl; mBindUIElement = uiElement; mBindInfo = bindInfo; mPropertyType = proType; VariableName = mBindInfo.VariableName; BindMode = mBindInfo.BindMode; BindingOperations.SetBinding(this, BindModeProperty, new Binding("BindMode") { Source = mBindInfo, Mode = BindingMode.TwoWay }); UIElementName = uiElement.Initializer.Name; BindingOperations.SetBinding(this, UIElementNameProperty, new Binding("Name") { Source = uiElement.Initializer }); }
internal async Task SetPropertyCustomBindOperation(EngineNS.UISystem.UIElement uiElement, string bindPropertyName, Type bindPropertyType) { Macross.Category category = Macross_Client.GetCategory(MacrossPanel.UIBindFuncCategoryName); var item = new Macross.CategoryItem(null, category); item.CategoryItemType = Macross.CategoryItem.enCategoryItemType.Unknow; item.CanDrag = false; item.InitTypeStr = "UI_UIElement_PropertyCustomBind"; var data = new UIElementPropertyCustomBindCategoryitemInitData(); data.Reset(); data.UIElement = uiElement; data.UIElementId = uiElement.Id; data.PropertyName = bindPropertyName; data.PropertyType = bindPropertyType; data.FunctionName = $"UIBindFunc_{bindPropertyName}_{uiElement.Id.ToString().Replace("-","_")}_{item.Id.ToString().Replace("-", "_")}";// bindFunctionName; item.Initialize(Macross_Client, data); category.Items.Add(item); uiElement.PropertyBindFunctions[bindPropertyName] = data.FunctionName; var varItemPro = item.PropertyShowItem as UIElementPropertyCustomBindCategoryItemPropertys; var nodesContainer = await Macross_Client.CreateNodesContainer(item); var nodeType = typeof(CodeDomNode.MethodCustom); var csParam = new CodeDomNode.MethodCustom.MethodCustomConstructParam() { CSType = Macross_Client.CSType, HostNodesContainer = nodesContainer.NodesControl, ConstructParam = "", MethodInfo = varItemPro.MethodInfo, IsShowProperty = false, }; var node = nodesContainer.NodesControl.AddOrigionNode(nodeType, csParam, 0, 0); node.IsDeleteable = false; node.NodeNameAddShowNodeName = false; nodesContainer.Save(); await Macross_Client.ShowNodesContainer(item); }
public void UpdateBindShow(EngineNS.UISystem.UIElement uiElement) { if (uiElement.VariableBindInfosDic.Count > 0) { TB_AddVariableBind.Visibility = Visibility.Collapsed; } else { TB_AddVariableBind.Visibility = Visibility.Visible; } if (uiElement.PropertyBindFunctions.ContainsKey(BindProperty.Name)) { Binded = true; return; } if (uiElement.VariableBindInfosDic.ContainsKey(BindProperty.Name)) { Binded = true; return; } Binded = false; }
internal async Task AddPanelRectShow(EngineNS.CRenderContext rc, EngineNS.UISystem.UIElement uiCtrl) { var panel = uiCtrl as EngineNS.UISystem.Controls.Containers.Panel; if (panel != null) { var imgInit = new EngineNS.UISystem.Controls.ImageInitializer(); imgInit.ImageBrush.ImageName = EngineNS.RName.GetRName("uieditor/uvanim_dottedline.uvanim", EngineNS.RName.enRNameType.Editor); imgInit.ImageBrush.TileMode = EngineNS.UISystem.Brush.enTileMode.Both; imgInit.ImageBrush.Color = new EngineNS.Color4(0.8f, 1.0f, 1.0f, 1.0f); var show = new EngineNS.UISystem.Controls.Image(); await show.Initialize(rc, imgInit); mPanelRectsShow[panel] = show; if (uiCtrl == HostDesignPanel.CurrentUI || !(uiCtrl is EngineNS.UISystem.Controls.UserControl)) { foreach (var child in panel.ChildrenUIElements) { await AddPanelRectShow(rc, child); } } } }
internal async Task SetEventFunction(EngineNS.UISystem.UIElement element, string functionName, Type eventType) { Macross.Category category = Macross_Client.GetCategory(MacrossPanel.UIEventFuncCategoryName); var item = new Macross.CategoryItem(null, category); item.CategoryItemType = Macross.CategoryItem.enCategoryItemType.Unknow; item.CanDrag = true; item.InitTypeStr = "UI_UIElement_Event"; var data = new UIElementEventCategoryItemInitData(); data.Reset(); data.UIElement = element; data.UIElementId = element.Id; data.FunctionName = functionName; data.EventType = eventType; item.Initialize(Macross_Client, data); category.Items.Add(item); string dicValue; var key = new UIResourceInfo.UIEventDicKey(element.Id, functionName); if (!HostControl.CurrentResInfo.UIEventsDic.TryGetValue(key, out dicValue)) { HostControl.CurrentResInfo.UIEventsDic[key] = item.Name; } // 创建NodesContainer var varItemPro = item.PropertyShowItem as UIElementEventCategoryItemPorpertys; var nodesContainer = await Macross_Client.CreateNodesContainer(item); var nodeType = typeof(CodeDomNode.MethodCustom); var csParam = new CodeDomNode.MethodCustom.MethodCustomConstructParam() { CSType = Macross_Client.CSType, HostNodesContainer = nodesContainer.NodesControl, ConstructParam = "", MethodInfo = varItemPro.MethodInfo, IsShowProperty = false, }; var node = nodesContainer.NodesControl.AddOrigionNode(nodeType, csParam, 0, 0); node.IsDeleteable = false; node.NodeNameAddShowNodeName = false; // 有输出参数时才默认添加return if (varItemPro.MethodInfo.OutParams.Count > 0) { var retNodeType = typeof(CodeDomNode.ReturnCustom); var retParam = new CodeDomNode.ReturnCustom.ReturnCustomConstructParam() { CSType = Macross_Client.CSType, HostNodesContainer = nodesContainer.NodesControl, ConstructParam = "", MethodInfo = varItemPro.MethodInfo, ShowPropertyType = CodeDomNode.ReturnCustom.ReturnCustomConstructParam.enShowPropertyType.ReturnValue, }; var retNode = nodesContainer.NodesControl.AddOrigionNode(retNodeType, retParam, 300, 0) as CodeDomNode.ReturnCustom; retNode.IsDeleteable = false; } nodesContainer.Save(); await Macross_Client.ShowNodesContainer(item); }