public void CloseView(Action <GameObject, Vector2> buttonsMoveAnimationFunc) { ChildButtons.ForEach(b => buttonsMoveAnimationFunc(b, Vector2.zero)); RootButton.SetActive(false); ParentButton.SetActive(false); NodeToButton.Clear(); GameObject rootObj = CreateRootButton(Tree.Root); rootObj.GetComponent <Button>().onClick.AddListener(OpenView); CurrentMiddleNode = Tree.Root; }
/// ------------------------------------------------------------------------------------ private void HandleParentLanguageChange(IEnumerable <ParentButton> buttons, ParentButton selectedButton, CancelEventHandler changeHandler) { foreach (var pb in buttons.Where(x => x != selectedButton)) { pb.SelectedChanged -= HandleParentLanguageSelectedChanged; pb.SelectedChanging -= changeHandler; pb.Selected = false; pb.SelectedChanged += HandleParentLanguageSelectedChanged; pb.SelectedChanging += changeHandler; } }
private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue) { ParentButton.Focus(); Selected = null; } if (_codeEditor.CurrentCodeFile == null) { return; } }
public void ShowRoot(Action <GameObject, Vector2> buttonsMoveAnimationFunc) { ChildButtons.ForEach(b => b.SetActive(false)); RootButton.SetActive(false); ParentButton.SetActive(false); NodeToButton.Clear(); if (useSpringJoints) { ChildButtons.ForEach(b => b.GetComponent <TargetJoint2D>().enabled = false); } ArrangeNodes(Tree.Root.Children, radius, 0, 330, buttonsMoveAnimationFunc); GameObject centerNodeGO = CreateRootButton(Tree.Root); centerNodeGO.GetComponent <Button>().onClick.AddListener(() => OnRootNodeClick(Tree.Root)); CurrentMiddleNode = Tree.Root; }
public void ShowNode(TreeNode <E> centralNode, Action <GameObject, Vector2> buttonsMoveAnimationFunc) { ChildButtons.ForEach(b => b.SetActive(false)); RootButton.SetActive(false); ParentButton.SetActive(false); NodeToButton.Clear(); if (useSpringJoints) { ChildButtons.ForEach(b => b.GetComponent <TargetJoint2D>().enabled = false); } ArrangeNodes(centralNode.Children, radius, 0, 270); GameObject centerNodeGO = CreateRootButton(centralNode); centerNodeGO.GetComponent <Button>().onClick.AddListener(() => OnCenterNodeClick(centralNode)); GameObject parentNodeGO = CreateParentButton(centralNode.Parent); RectTransform parentRectTransf = parentNodeGO.GetComponent <RectTransform>(); parentRectTransf.anchoredPosition = ComputeAnchoredPosition(315, radius + parentRectTransf.sizeDelta.x / 2); parentNodeGO.GetComponent <Button>().onClick.AddListener(() => OnParentNodeClick(centralNode.Parent)); CurrentMiddleNode = centralNode; }
private void InitializeNodesPool(int desiredPoolSize) { ChildButtons = new List <GameObject>(); for (int i = 0; i < desiredPoolSize; i++) { GameObject newChildObj = Instantiate(childPrefab); RectTransform childRectTransf = newChildObj.GetOrAddComponent <RectTransform>(); childRectTransf.SetParent(this.transform, false); newChildObj.name = "ChildNode_" + (i + 1); ChildButtons.Add(newChildObj); newChildObj.SetActive(false); } RootButton = Instantiate(rootPrefab); RectTransform rootRectTransf = RootButton.GetOrAddComponent <RectTransform>(); rootRectTransf.SetParent(this.transform, false); RootButton.name = "RootNode"; RootButton.SetActive(false); ParentButton = Instantiate(rootPrefab); RectTransform parentRectTransf = ParentButton.GetOrAddComponent <RectTransform>(); parentRectTransf.SetParent(this.transform, false); ParentButton.name = "ParentNode"; float scaleFactor = ChildButtons[0].GetComponent <RectTransform>().sizeDelta.x / rootRectTransf.sizeDelta.x; Vector3 newScale = ChildButtons[0].transform.localScale * scaleFactor; ParentButton.transform.localScale = newScale; ParentButton.SetActive(false); }
public GameObject GetParentButton() { ParentButton.GetComponent <Button>().interactable = true; ParentButton.SetActive(true); return(ParentButton); }
/// <summary> /// 分析JArray里包含的微信菜单信息,并保存到菜单数组中 /// </summary> /// <param name="menuButtonArray">JArray微信菜单数据</param> /// <param name="menuButtons">保存解析好的菜单信息</param> private void AnalysisMenuButton(JArray menuButtonArray, List <MenuButton> menuButtons) { if (menuButtonArray == null) { return; } if (menuButtons == null)//先清空下现有的默认菜单信息 { menuButtons = new List <MenuButton>(); } else { menuButtons.Clear(); } foreach (JToken menuButton in menuButtonArray) { JArray subButtonArray = menuButton["sub_button"] as JArray; MenuButton nowMenuButton; if (subButtonArray != null && subButtonArray.Count > 0) { ParentButton parentButton = JsonConvert.DeserializeObject <ParentButton>(menuButton.ToString());//确认为父菜单 AnalysisMenuButton(menuButton["sub_button"] as JArray, parentButton.sub_button); nowMenuButton = parentButton; } else { string buttonType = menuButton["type"]?.ToString();//微信按钮类型 switch (buttonType) { case ClickButton.type: nowMenuButton = JsonConvert.DeserializeObject <ClickButton>(menuButton.ToString()); break; case ViewButton.type: nowMenuButton = JsonConvert.DeserializeObject <ViewButton>(menuButton.ToString()); break; case ScanCodePushButton.type: nowMenuButton = JsonConvert.DeserializeObject <ScanCodePushButton>(menuButton.ToString()); break; case ScanCodeWaitMsgButton.type: nowMenuButton = JsonConvert.DeserializeObject <ScanCodeWaitMsgButton>(menuButton.ToString()); break; case PicSysPhotoButton.type: nowMenuButton = JsonConvert.DeserializeObject <PicSysPhotoButton>(menuButton.ToString()); break; case PicPhotoOrAlbumButton.type: nowMenuButton = JsonConvert.DeserializeObject <PicPhotoOrAlbumButton>(menuButton.ToString()); break; case PicWeixinButton.type: nowMenuButton = JsonConvert.DeserializeObject <PicWeixinButton>(menuButton.ToString()); break; case LocationSelectButton.type: nowMenuButton = JsonConvert.DeserializeObject <LocationSelectButton>(menuButton.ToString()); break; case MediaIdButton.type: nowMenuButton = JsonConvert.DeserializeObject <MediaIdButton>(menuButton.ToString()); break; case ViewLimitedButton.type: nowMenuButton = JsonConvert.DeserializeObject <ViewLimitedButton>(menuButton.ToString()); break; case MiniProgramButton.type: nowMenuButton = JsonConvert.DeserializeObject <MiniProgramButton>(menuButton.ToString()); break; default: nowMenuButton = JsonConvert.DeserializeObject <MenuButton>(menuButton.ToString()); break; } } menuButtons.Add(nowMenuButton);//记录下一个解析好的按钮数据 } }
/// ------------------------------------------------------------------------------------ private string GetParentLanguageName(ParentButton pb) { return(pb == null ? null : ((TextBox)pb.Tag).Text.Trim()); }
public ApiResult SaveAndPublishMenu(string json, UserContext userContext, DomainContext domainContext) { MenuEntity menuEntity = new MenuEntity(); menuEntity.DomainId = userContext.User.Domain; menuEntity.Menu = json; _dataBase.Remove(menuEntity); _dataBase.Insert(menuEntity); ApiResult result = new ApiResult(); //未认证订阅号没有自定义菜单权限 if (domainContext.Authorizer == null || domainContext.Authorizer.AuthorizationType == EnumAuthorizationType.UnauthorizedSubscription) { result.Success = false; result.Message = "未认证订阅号没有自定义菜单权限。"; return(result); } List <ButtonBase> _buttonList = new List <ButtonBase>(); JObject jObject = JObject.Parse(json); #region 解析 JArray buttonArray = (JArray)jObject["button"]; foreach (var button in buttonArray) { if (button["sub_button"] == null || button["sub_button"].Count() == 0) { ButtonBase newButton = null; switch (button["type"].ToString()) { case "wxc_function": newButton = GetWxcFunctionButton(button, domainContext); break; case "click": newButton = GetClickButton(button, domainContext); break; case "view": newButton = JsonHelper.Deserialize <ButtonView>(button.ToString()); break; case "wxc_campaign": newButton = GetWxcCampaignButton(button, domainContext); break; case "wxc_information": newButton = GetWxcInformationButton(button, domainContext); break; case "wxc_customForm": newButton = GetWxcCustomFormButton(button, domainContext); break; case "mediaId": newButton = GetMediaIdButton(button); break; } _buttonList.Add(newButton); } else { ParentButton parentButton = JsonHelper.Deserialize <ParentButton>(button.ToString()); parentButton.SubButton = new List <ButtonBase>(); JArray subButtonArray = (JArray)button["sub_button"]; foreach (var subButton in subButtonArray) { ButtonBase newSubButton = null; switch (subButton["type"].ToString()) { case "wxc_function": newSubButton = GetWxcFunctionButton(subButton, domainContext); break; case "click": newSubButton = GetClickButton(subButton, domainContext); break; case "view": newSubButton = JsonHelper.Deserialize <ButtonView>(subButton.ToString()); break; case "wxc_campaign": newSubButton = GetWxcCampaignButton(subButton, domainContext); break; case "wxc_information": newSubButton = GetWxcInformationButton(subButton, domainContext); break; case "wxc_customForm": newSubButton = GetWxcCustomFormButton(subButton, domainContext); break; case "mediaId": newSubButton = GetMediaIdButton(subButton); break; } parentButton.SubButton.Add(newSubButton); } _buttonList.Add(parentButton); } } #endregion ButtonWrapper menu = new ButtonWrapper(); menu.Button = _buttonList; RequestApiResult apiResult = MenuApi.Create(menu, domainContext.AccessToken); result.Success = apiResult.Success; result.Message = apiResult.Message; return(result); }