private void CheckGText() { GText gt = GetComponent <GText>(); if (gt) { gt.FormatBoard(); } }
public static void CreateTopRFTTxt(GCanvas gCanvas, GeometryEngine GeometryEngineRFT, double scale) { TopRFTTxt = new GText[SpanVals.Length + 1]; //Top Support RFT/*------------------*/ //Case Of Cantilever Start Span if (GeometryEditorVM.GeometryEditor.RestraintsCollection[0].SelectedRestraint != Restraints.NoRestraints) { if (nRebarTopSupport[0] > 0) { TopRFTTxt[0] = new GText(gCanvas, new Point(RFTCanvas.TopRFTLines[0].EndPoint.X /*+ 0.30 * SpanVals[0] * scale*/ , RFTCanvas.TopRFTLines[0].EndPoint.Y + 0.07 * scale), $"{nRebarTopSupport[0]}T{TopChosenDiameterArr[0]}"); GeometryEngineRFT.Shapes["Text"].Add(TopRFTTxt[0]); } else { TopRFTTxt[0] = new GText(gCanvas, new Point(RFTCanvas.TopRFTLines[0].EndPoint.X /*+ 0.30 * SpanVals[0] * scale*/ , RFTCanvas.TopRFTLines[0].EndPoint.Y + 0.07 * scale), $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(TopRFTTxt[0]); } } for (int i = 1; i < TopRFTTxt.Length - 1; i++) { if (nRebarTopSupport[i] > 0) { TopRFTTxt[i] = new GText(gCanvas, new Point(RFTCanvas.TopRFTLines[i].EndPoint.X /*+ 0.30 * SpanVals[i] * scale*/ , RFTCanvas.TopRFTLines[i].EndPoint.Y + 0.07 * scale), $"{nRebarTopSupport[i]}T{TopChosenDiameterArr[i]}"); GeometryEngineRFT.Shapes["Text"].Add(TopRFTTxt[i]); } else { TopRFTTxt[i] = new GText(gCanvas, new Point(RFTCanvas.TopRFTLines[i].EndPoint.X /*+ 0.30 * SpanVals[i] * scale*/ , RFTCanvas.TopRFTLines[i].EndPoint.Y + 0.07 * scale), $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(TopRFTTxt[i]); } } //Case of Cantilever end Span if (GeometryEditorVM.GeometryEditor.RestraintsCollection[SpanVals.Length].SelectedRestraint != Restraints.NoRestraints) { if (nRebarTopSupport[TopRFTTxt.Length - 1] > 0) { TopRFTTxt[TopRFTTxt.Length - 1] = new GText(gCanvas, new Point(RFTCanvas.TopRFTLines[TopRFTTxt.Length - 1].EndPoint.X /*+ 0.30 * SpanVals[TopRFTTxt.Length - 1] * scale*/ , RFTCanvas.TopRFTLines[TopRFTTxt.Length - 1].EndPoint.Y + 0.07 * scale), $"{nRebarTopSupport[TopRFTTxt.Length - 1]}T{TopChosenDiameterArr[TopRFTTxt.Length - 1]}"); GeometryEngineRFT.Shapes["Text"].Add(TopRFTTxt[TopRFTTxt.Length - 1]); } else { TopRFTTxt[TopRFTTxt.Length - 1] = new GText(gCanvas, new Point(RFTCanvas.TopRFTLines[TopRFTTxt.Length - 1].EndPoint.X /*+ 0.30 * SpanVals[TopRFTTxt.Length - 1] * scale*/ , RFTCanvas.TopRFTLines[TopRFTTxt.Length - 1].EndPoint.Y + 0.07 * scale), $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(TopRFTTxt[TopRFTTxt.Length - 1]); } } }
protected override void OnEnable() { base.OnEnable(); gText = (GText)target; // gText.font = ProjectDefaultConfig.defaultTextFont; // gText.raycastTarget = false; // gText.alignment = TextAnchor.MiddleCenter; // gText.color = ProjectDefaultConfig.defaultTextColor; // gText.text = "text"; // gText.supportRichText = false; }
public static void CreateBottomRFTTxt(GCanvas gCanvas, GeometryEngine GeometryEngineRFT, double scale) { BotRFTTxt = new GText[SpanVals.Length]; //Case of Cantilever at start if (GeometryEditorVM.GeometryEditor.RestraintsCollection[0].SelectedRestraint != Restraints.NoRestraints) { if (nRebarBot[0] > 0) { BotRFTTxt[0] = new GText(gCanvas, new Point(RFTCanvas.StartPointBotArr[0].X + 0.30 * SpanVals[0] * scale , RFTCanvas.StartPointBotArr[0].Y - 0.30 * scale), $"{nRebarBot[0]}T{BotChosenDiameterArr[0]}"); GeometryEngineRFT.Shapes["Text"].Add(BotRFTTxt[0]); } else { BotRFTTxt[0] = new GText(gCanvas, new Point(RFTCanvas.StartPointBotArr[0].X + 0.30 * SpanVals[0] * scale , RFTCanvas.StartPointBotArr[0].Y - 0.30 * scale), $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(BotRFTTxt[0]); } } //Bottom Rft Text/*------------------*/ for (int i = 1; i < BotRFTTxt.Length - 1; i++) { if (nRebarBot[i] > 0) { BotRFTTxt[i] = new GText(gCanvas, new Point(RFTCanvas.StartPointBotArr[i].X + 0.30 * SpanVals[i] * scale , RFTCanvas.StartPointBotArr[i].Y - 0.30 * scale), $"{nRebarBot[i]}T{BotChosenDiameterArr[i]}"); GeometryEngineRFT.Shapes["Text"].Add(BotRFTTxt[i]); } else { BotRFTTxt[i] = new GText(gCanvas, new Point(RFTCanvas.StartPointBotArr[i].X + 0.30 * SpanVals[i] * scale , RFTCanvas.StartPointBotArr[i].Y - 0.30 * scale), $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(BotRFTTxt[i]); } } //Case of Cantilever End if (GeometryEditorVM.GeometryEditor.RestraintsCollection[SpanVals.Length].SelectedRestraint != Restraints.NoRestraints) { if (nRebarBot[BotRFTTxt.Length - 1] > 0) { BotRFTTxt[BotRFTTxt.Length - 1] = new GText(gCanvas, new Point(RFTCanvas.StartPointBotArr[BotRFTTxt.Length - 1].X + 0.30 * SpanVals[BotRFTTxt.Length - 1] * scale , RFTCanvas.StartPointBotArr[BotRFTTxt.Length - 1].Y - 0.30 * scale), $"{nRebarBot[BotRFTTxt.Length - 1]}T{BotChosenDiameterArr[BotRFTTxt.Length - 1]}"); GeometryEngineRFT.Shapes["Text"].Add(BotRFTTxt[BotRFTTxt.Length - 1]); } else { BotRFTTxt[BotRFTTxt.Length - 1] = new GText(gCanvas, new Point(RFTCanvas.StartPointBotArr[BotRFTTxt.Length - 1].X + 0.30 * SpanVals[BotRFTTxt.Length - 1] * scale , RFTCanvas.StartPointBotArr[BotRFTTxt.Length - 1].Y - 0.30 * scale), $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(BotRFTTxt[BotRFTTxt.Length - 1]); } } }
private void Btn_DrawLine_Click(object sender, RoutedEventArgs e) { // GeometryEngine.Remove("Supports"); // var traingle = new GTriangle(GeometryEngine.GCanvas, new Point(60, 60), 20); l = new GLine(GeometryEngine.GCanvas, new Point(60, 60), new Point(100, 200)); c = new GCircle(GeometryEngine.GCanvas, new Point(200, 200), 50); c.Fill = Brushes.Green; hinged = new Hinged(GeometryEngine.GCanvas, new Point(500, 500)); hinged.Fill = Brushes.Transparent; hinged.Stroke = Brushes.Red; hinged.StrokeThickness = 2; roller = new Roller(GeometryEngine.GCanvas, new Point(160, 60)); roller.Fill = Brushes.Transparent; roller.StrokeThickness = 2; //var rectangle = new GRectangle(GeometryEngine.GCanvas, 30, 15, new Point(140, 60+15)); fixd = new Fixed(GeometryEngine.GCanvas, new Point(100, 60), 20); fixd.Fill = Brushes.Orange; fixd.StrokeThickness = 2; arrow = new Arrow(GeometryEngine.GCanvas, new Point(220, 60), 20); arrow.Stroke = Brushes.Yellow; arrow.StrokeThickness = 4; arrowLoad = new ArrowLoad(GeometryEngine.GCanvas, new Point(100, 120), new Point(200, 120), 20); arrowLoad.Stroke = Brushes.Blue; arrowLoad.StrokeThickness = 2; gText = new GText(GeometryEngine.GCanvas, new Point(500, 500), "Hello Text!"); gText.Text = "Hello Text!"; gText.Render(); //arrow.Rotate(45); //render on Screen //GeometryEngine.RenderAll(); // GeometryEngine.Render(new List<GShape>() { roller, hinged, fixd }); GeometryEngine.Shapes["Beams"].Add(c); GeometryEngine.Shapes["Beams"].Add(arrow); GeometryEngine.Shapes["Supports"].Add(arrowLoad); GeometryEngine.Shapes["Supports"].Add(roller); GeometryEngine.Shapes["Supports"].Add(fixd); GeometryEngine.Shapes["Supports"].Add(l); GeometryEngine.Shapes["Supports"].Add(hinged); // GeometryEngine.Shapes["Supports"].Add(gText); // GeometryEngine.Render("Beams"); // GeometryEngine.Render("Supports"); l.Stroke = Brushes.Red; l.StrokeThickness = 4; GeometryEngine.RenderAll(); }
public static int SetText(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; if ((count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(string)))) { var labelObj = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); if (labelObj == null) { HobaDebuger.LogWarning("SetText: param 1 must be GameObject"); LuaScriptMgr.Instance.CallOnTraceBack(); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } var textComp = labelObj.GetComponent <Text>(); GText gtextComp = null; if (textComp == null) { gtextComp = labelObj.GetComponent <GText>(); } if (textComp == null && gtextComp == null) { HobaDebuger.LogWarning("SetText: param 1 must have text component"); LuaScriptMgr.Instance.CallOnTraceBack(); return(GameUtilWrap.CheckReturnNum(L, count, nRet)); } var content = LuaScriptMgr.GetString(L, 2); if (null != textComp) { textComp.text = content; } else { gtextComp.text = content; } } else { //Debug.LogError(LuaStatic.GetTraceBackInfo(L)); GameUtilWrap.LogParamError("SetText", count); LuaScriptMgr.Instance.CallOnTraceBack(); } return(GameUtilWrap.CheckReturnNum(L, count, nRet)); }
public sealed override void Redraw() { if (!MatchUtils.IsEmpty(this.Target) && !MatchUtils.IsEmpty(this.Target.Netmap) && !MatchUtils.IsEmpty(this.Facade) && this.Target.Enable && this.Enable) { bool hide = this.Matte || !this.Viewble(this.Arise); { if (!MatchUtils.IsEmpty(this.Handle)) { if (!(this.Handle.Matte = hide)) { GText v_text = this.Handle as GText; { } } // 重绘图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { this.Handle.Paint(); } })); } else { if (!((this.Handle = this.Target.Sketch.CreateText()).Matte = hide)) { GText v_text = this.Handle as GText; { } // 绘制图形 this.Facade.Dispatcher.BeginInvoke(new Action(() => { if (!MatchUtils.IsEmpty(this.Handle)) { v_text.Paint(); } })); } } } } }
static void Create() { GameObject select = Selection.activeGameObject; if (select == null) { return; } RectTransform transform = select.GetComponent <RectTransform>(); if (transform == null) { return; } GameObject obj = new GameObject("GText"); obj.transform.SetParent(transform); RectTransform rect = obj.AddComponent <RectTransform>(); rect.anchoredPosition = Vector2.zero; rect.sizeDelta = new Vector2(160, 30); obj.AddComponent <CanvasRenderer>(); GText text = obj.AddComponent <GText>(); text.text = "New GText"; Material material = AssetDatabase.LoadAssetAtPath <Material>(emojiMat); text.material = material; Selection.activeGameObject = obj; /* * Canvas[] canvas = rect.GetComponentsInParent<Canvas>(); * foreach (var cv in canvas) * { * cv.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord1; * } */ }
static int set_TextID(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GText obj = (GText)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name TextID"); } else { LuaDLL.luaL_error(L, "attempt to index TextID on a nil value"); } } obj.TextID = (int)LuaScriptMgr.GetNumber(L, 3); return(0); }
public static void StirrupRightTxt(GCanvas gCanvas, GeometryEngine GeometryEngineRFT, double scale) { stirRightTxt = new GText[SpanVals.Length]; //Stirrups Text Left/*------------------*/ double fystr = -1; for (int i = 0; i < stirRightTxt.Length - 1; i++) { if (indexesRight[i] != -2) { if (indexesRight[i] < stirDiaArr240.Length) { fystr = 240; stirRightTxt[i] = new GText(gCanvas , new Point(RFTCanvas.StirrupsRightSec[i, 2].StartPoint.X - 0.7 * scale, RFTCanvas.StirrupsRightSec[i, 2].StartPoint.Y - 0.30 * scale) , $"Y{stirDiaArr240[indexesRight[i]]}@{spacingRightSec[i]}"); GeometryEngineRFT.Shapes["Text"].Add(stirRightTxt[i]); } else if (indexesRight[i] < stirDiaArr240.Length + stirDiaArr360.Length) { fystr = 360; stirRightTxt[i] = new GText(gCanvas , new Point(RFTCanvas.StirrupsRightSec[i, 2].StartPoint.X - 0.70 * scale, RFTCanvas.StirrupsRightSec[i, 2].StartPoint.Y - 0.30 * scale) , $"T{stirDiaArr360[indexesRight[i] - stirDiaArr240.Length]}@{spacingRightSec[i]}"); GeometryEngineRFT.Shapes["Text"].Add(stirRightTxt[i]); } else if (indexesRight[i] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length) { fystr = 400; stirRightTxt[i] = new GText(gCanvas , new Point(RFTCanvas.StirrupsRightSec[i, 2].StartPoint.X - 0.70 * scale, RFTCanvas.StirrupsRightSec[i, 2].StartPoint.Y - 0.30 * scale) , $"T{stirDiaArr400[indexesRight[i] - stirDiaArr360.Length - stirDiaArr240.Length]}"); GeometryEngineRFT.Shapes["Text"].Add(stirRightTxt[i]); } } else { stirRightTxt[i] = new GText(gCanvas , new Point(RFTCanvas.StirrupsRightSec[i, 2].StartPoint.X - 0.70 * scale, RFTCanvas.StirrupsRightSec[i, 2].StartPoint.Y - 0.30 * scale) , $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(stirRightTxt[i]); } } //Case Of Cantilever at right End #region Case of Cantilever at right end if (GeometryEditorVM.GeometryEditor.RestraintsCollection[SpanVals.Length].SelectedRestraint != Restraints.NoRestraints) { if (indexesRight[stirRightTxt.Length - 1] != -2) { if (indexesRight[stirRightTxt.Length - 1] < stirDiaArr240.Length) { fystr = 240; stirRightTxt[stirRightTxt.Length - 1] = new GText(gCanvas , new Point(RFTCanvas.StirrupsRightSec[stirRightTxt.Length - 1, 2].StartPoint.X - 0.70 * scale, RFTCanvas.StirrupsRightSec[stirRightTxt.Length - 1, 2].StartPoint.Y - 0.30 * scale) , $"Y{stirDiaArr240[indexesRight[stirRightTxt.Length - 1]]}@{spacingRightSec[stirRightTxt.Length - 1]}"); GeometryEngineRFT.Shapes["Text"].Add(stirRightTxt[stirRightTxt.Length - 1]); } else if (indexesRight[stirRightTxt.Length - 1] < stirDiaArr240.Length + stirDiaArr360.Length) { fystr = 360; stirRightTxt[stirRightTxt.Length - 1] = new GText(gCanvas , new Point(RFTCanvas.StirrupsRightSec[stirRightTxt.Length - 1, 2].StartPoint.X - 0.70 * scale, RFTCanvas.StirrupsRightSec[stirRightTxt.Length - 1, 2].StartPoint.Y - 0.30 * scale) , $"T{stirDiaArr360[indexesRight[stirRightTxt.Length - 1] - stirDiaArr240.Length]}@{spacingRightSec[stirRightTxt.Length - 1]}"); GeometryEngineRFT.Shapes["Text"].Add(stirRightTxt[stirRightTxt.Length - 1]); } else if (indexesRight[stirRightTxt.Length - 1] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length) { fystr = 400; stirRightTxt[stirRightTxt.Length - 1] = new GText(gCanvas , new Point(RFTCanvas.StirrupsRightSec[stirRightTxt.Length - 1, 2].StartPoint.X - 0.70 * scale, RFTCanvas.StirrupsRightSec[stirRightTxt.Length - 1, 2].StartPoint.Y - 0.30 * scale) , $"T{stirDiaArr400[indexesRight[stirRightTxt.Length - 1] - stirDiaArr360.Length - stirDiaArr240.Length]}"); GeometryEngineRFT.Shapes["Text"].Add(stirRightTxt[stirRightTxt.Length - 1]); } } else { stirRightTxt[stirRightTxt.Length - 1] = new GText(gCanvas , new Point(RFTCanvas.StirrupsRightSec[stirRightTxt.Length - 1, 2].StartPoint.X - 0.70 * scale, RFTCanvas.StirrupsRightSec[stirRightTxt.Length - 1, 2].StartPoint.Y - 0.30 * scale) , $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(stirRightTxt[stirRightTxt.Length - 1]); } } #endregion }
public static void StirrupLeftTxt(GCanvas gCanvas, GeometryEngine GeometryEngineRFT, double scale) { stirLeftTxt = new GText[SpanVals.Length]; //Stirrups Text Left/*------------------*/ double fystr = -1; /*Case Of Cantilever at left End*/ #region Case of Cantilever at start if (GeometryEditorVM.GeometryEditor.RestraintsCollection[0].SelectedRestraint != Restraints.NoRestraints) { if (indexesLeft[0] != -2) { if (indexesLeft[0] < stirDiaArr240.Length) { fystr = 240; stirLeftTxt[0] = new GText(gCanvas , new Point(RFTCanvas.StirrupsLeftSec[0, 2].StartPoint.X, RFTCanvas.StirrupsLeftSec[0, 2].StartPoint.Y - 0.40 * scale) , $"Y{stirDiaArr240[indexesLeft[0]]}@{spacingLeftSec[0]}"); GeometryEngineRFT.Shapes["Text"].Add(stirLeftTxt[0]); } else if (indexesLeft[0] < stirDiaArr240.Length + stirDiaArr360.Length) { fystr = 360; stirLeftTxt[0] = new GText(gCanvas , new Point(RFTCanvas.StirrupsLeftSec[0, 2].StartPoint.X, RFTCanvas.StirrupsLeftSec[0, 2].StartPoint.Y - 0.40 * scale) , $"T{stirDiaArr360[indexesLeft[0] - stirDiaArr240.Length]}@{spacingLeftSec[0]}"); GeometryEngineRFT.Shapes["Text"].Add(stirLeftTxt[0]); } else if (indexesLeft[0] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length) { fystr = 400; stirLeftTxt[0] = new GText(gCanvas , new Point(RFTCanvas.StirrupsLeftSec[0, 2].StartPoint.X, RFTCanvas.StirrupsLeftSec[0, 2].StartPoint.Y - 0.40 * scale) , $"T{stirDiaArr400[indexesLeft[0] - stirDiaArr360.Length - stirDiaArr240.Length]}@{spacingLeftSec[0]}"); GeometryEngineRFT.Shapes["Text"].Add(stirLeftTxt[0]); } } else { stirLeftTxt[0] = new GText(gCanvas , new Point(RFTCanvas.StirrupsLeftSec[0, 2].StartPoint.X, RFTCanvas.StirrupsLeftSec[0, 2].StartPoint.Y - 0.40 * scale) , $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(stirLeftTxt[0]); } } #endregion for (int i = 1; i < stirLeftTxt.Length; i++) { if (indexesLeft[i] != -2) { if (indexesLeft[i] < stirDiaArr240.Length) { fystr = 240; stirLeftTxt[i] = new GText(gCanvas , new Point(RFTCanvas.StirrupsLeftSec[i, 2].StartPoint.X, RFTCanvas.StirrupsLeftSec[i, 2].StartPoint.Y - 0.40 * scale) , $"Y{stirDiaArr240[indexesLeft[i]]}@{spacingLeftSec[i]}"); GeometryEngineRFT.Shapes["Text"].Add(stirLeftTxt[i]); } else if (indexesLeft[i] < stirDiaArr240.Length + stirDiaArr360.Length) { fystr = 360; stirLeftTxt[i] = new GText(gCanvas , new Point(RFTCanvas.StirrupsLeftSec[i, 2].StartPoint.X, RFTCanvas.StirrupsLeftSec[i, 2].StartPoint.Y - 0.40 * scale) , $"T{stirDiaArr360[indexesLeft[i] - stirDiaArr240.Length]}@{spacingLeftSec[i]}"); GeometryEngineRFT.Shapes["Text"].Add(stirLeftTxt[i]); } else if (indexesLeft[i] < stirDiaArr240.Length + stirDiaArr360.Length + stirDiaArr400.Length) { fystr = 400; stirLeftTxt[i] = new GText(gCanvas , new Point(RFTCanvas.StirrupsLeftSec[i, 2].StartPoint.X, RFTCanvas.StirrupsLeftSec[i, 2].StartPoint.Y - 0.40 * scale) , $"T{stirDiaArr400[indexesLeft[i] - stirDiaArr360.Length - stirDiaArr240.Length]}@{spacingLeftSec[i]}"); GeometryEngineRFT.Shapes["Text"].Add(stirLeftTxt[i]); } } else { stirLeftTxt[i] = new GText(gCanvas , new Point(RFTCanvas.StirrupsLeftSec[i, 2].StartPoint.X, RFTCanvas.StirrupsLeftSec[i, 2].StartPoint.Y - 0.40 * scale) , $"Increase Dims"); GeometryEngineRFT.Shapes["Text"].Add(stirLeftTxt[i]); } } }
//This overrides the callback of a UI Component to a single call public void RegisterSingleObjHandler(GameObject control, int class_type, bool recursion) { if (control == null) { Debug.LogError("Cannot register event since the control object is null!"); return; } System.Type type = WrapClassID.GetClassType(class_type); if (type == typeof(UnityEngine.UI.Button) || type == typeof(GButton)) { GButton gbtn = control.GetComponent <GButton>(); if (gbtn != null) { gbtn.OnClick = OnClick; return; } Button btn = control.GetComponent <Button>(); if (btn != null) { btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(delegate() { OnClick(btn.gameObject); }); } if (recursion) { GButton[] btns = control.GetComponentsInChildren <GButton>(true); for (int i = 0; i < btns.Length; i++) { if (btns[i] != null) { btns[i].OnClick = OnClick; } } } } else if (type == typeof(Toggle)) { if (recursion) { Toggle[] toggles = control.GetComponentsInChildren <Toggle>(true); for (int i = 0; i < toggles.Length; i++) { if (toggles[i] != null) { toggles[i].onValueChanged.RemoveAllListeners(); GameObject go = toggles[i].gameObject; toggles[i].onValueChanged.AddListener(delegate(bool ischeck) { OnToggle(go, ischeck); }); } } } else { Toggle toggle = control.GetComponent <Toggle>(); if (toggle != null) { toggle.onValueChanged.RemoveAllListeners(); toggle.onValueChanged.AddListener(delegate(bool ischeck) { OnToggle(toggle.gameObject, ischeck); }); } } } else if (type == typeof(GNewIOSToggle)) { GNewIOSToggle gTgl = control.GetComponent <GNewIOSToggle>(); if (gTgl != null) { gTgl.OnClick = OnClick; //gTgl.OnValueChanged = OnToggleSpecial; } if (recursion) { GNewIOSToggle[] gToggles = control.GetComponentsInChildren <GNewIOSToggle>(true); for (int i = 0; i < gToggles.Length; i++) { if (gToggles[i] != null) { gToggles[i].OnClick = OnClick; //gToggles[i].OnValueChanged = OnToggleSpecial; } } } } else if (type == typeof(GText)) { // 现在需求中GText不在root上,所以这么处理;其实不太好 GText gtext = control.GetComponentInChildren <GText>(); if (gtext != null) { gtext.OnClick = OnGTextClick; } if (recursion) { GText[] gts = control.GetComponentsInChildren <GText>(true); for (int i = 0; i < gts.Length; i++) { if (gts[i] != null) { gts[i].OnClick = OnGTextClick; } } } } else if (type == typeof(GImageModel)) { GImageModel gim = control.GetComponent <GImageModel>(); if (gim != null) { gim.OnModelClick = OnClick; } if (recursion) { GImageModel[] gims = control.GetComponentsInChildren <GImageModel>(true); for (int i = 0; i < gims.Length; i++) { if (gims[i] != null) { gims[i].OnModelClick = OnClick; } } } } else if (type == typeof(Slider)) { Slider sld = control.GetComponent <Slider>(); if (sld != null) { sld.onValueChanged.AddListener(delegate(float value) { OnSliderChanged(sld.gameObject, value); }); } if (recursion) { Slider[] sliders = control.GetComponentsInChildren <Slider>(true); for (int i = 0; i < sliders.Length; i++) { if (sliders[i] != null) { sliders[i].onValueChanged.AddListener(delegate(float value) { OnSliderChanged(sliders[i].gameObject, value); }); } } } } else if (type == typeof(GScaleScroll)) { GScaleScroll gss = control.GetComponent <GScaleScroll>(); if (gss != null) { gss.onScaleChanged = OnScaleChanged; } if (recursion) { GScaleScroll[] gsss = control.GetComponentsInChildren <GScaleScroll>(true); for (int i = 0; i < gsss.Length; i++) { if (gsss[i] != null) { gsss[i].onScaleChanged = OnScaleChanged; } } } } else if (type == typeof(GBlood)) { GBlood gwv = control.GetComponent <GBlood>(); if (gwv != null) { gwv.OnTweenFinishCallBack = this.OnDOTComplete; } if (recursion) { GBlood[] gwvs = control.GetComponentsInChildren <GBlood>(true); for (int i = 0; i < gwvs.Length; i++) { gwvs[i].OnTweenFinishCallBack = this.OnDOTComplete; } } } else if (type == typeof(GWebView)) { GWebView gwv = control.GetComponent <GWebView>(); if (gwv != null) { gwv.OnReceiveMessage = this.OnReceiveWebViewMessage; } if (recursion) { GWebView[] gwvs = control.GetComponentsInChildren <GWebView>(true); for (int i = 0; i < gwvs.Length; i++) { gwvs[i].OnReceiveMessage = OnReceiveWebViewMessage; } } } else if (type == typeof(GNewListBase)) { GNewListBase list = control.GetComponent <GNewListBase>(); if (list != null) { list.ClickItemCallBack = this.OnSelectItem; //list.PressItemCallBack = this.OnPressItem; //list.ReleaseItemCallBack = this.OnReleaseItem; list.LongPressCallBack = this.OnLongPressItem; list.InitItemCallBack = this.OnInitItem; if (list.HasChildButton) { list.ClickItemButtonCallBack = this.OnSelectItemButton; } } if (recursion) { GNewListBase[] lists = control.GetComponentsInChildren <GNewListBase>(true); for (int i = 0; i < lists.Length; i++) { lists[i].ClickItemCallBack = this.OnSelectItem; lists[i].LongPressCallBack = this.OnLongPressItem; lists[i].InitItemCallBack = this.OnInitItem; if (lists[i].HasChildButton) { lists[i].ClickItemButtonCallBack = this.OnSelectItemButton; } } } } else { // TODO: 将来根据需要自行扩展 HobaDebuger.LogError("<RegisterUIEventHandler>WrapClassID not supported!" + class_type); } }
public void InitFilter() { int left = 20; int top = 15; foreach (FilterInfo f in FilterInfos) { switch (f.controltype) { case "dropdown": GDropDown controldrop = new GDropDown(); controldrop.Caption = f.caption; controldrop.Location = new Point(left, top); controldrop.Name = "dropdown_" + f.fieldname; controldrop.Width = 200; if (f.SearchForm != null) { controldrop.CustomerDropDownForm = f.SearchForm; } G.Controls.Base.Initialize.InitDropDown(controldrop, f.controldata, f.searchLogic, true); if (!f.defaultvalue.IsNullOrEmpty()) { controldrop.SetValue(f.defaultvalue); } this.tabPage1.Controls.Add(controldrop); top += controldrop.Height + 10; f.control = controldrop.Name; break; case "combox": GCombo2 controlcombox = new GCombo2(); controlcombox.Caption = f.caption; controlcombox.Data = f.controldata; controlcombox.Name = "combox_" + f.fieldname; controlcombox.Location = new Point(left, top); controlcombox.Width = 200; if (!f.defaultvalue.IsNullOrEmpty()) { controlcombox.SetValue(f.defaultvalue); } this.tabPage1.Controls.Add(controlcombox); top += controlcombox.Height + 10; f.control = controlcombox.Name; break; case "checkbox": GCheckBox controlcheckbox = new GCheckBox(); controlcheckbox.Caption = f.caption; controlcheckbox.Name = "checkbox_" + f.fieldname; controlcheckbox.Location = new Point(left, top); controlcheckbox.Width = 200; if (!f.defaultvalue.IsNullOrEmpty()) { controlcheckbox.SetValue(f.defaultvalue); } this.tabPage1.Controls.Add(controlcheckbox); top += controlcheckbox.Height + 10; f.control = controlcheckbox.Name; break; case "date": case "datetime": GDate controldate = new GDate(); controldate.Caption = f.caption; controldate.Name = "date_" + f.fieldname; DefaultDate(f); controldate.Width = 200; controldate.Location = new Point(left, top); if (!f.defaultvalue.IsNullOrEmpty()) { controldate.SetValue(f.defaultvalue); } this.tabPage1.Controls.Add(controldate); f.control = controldate.Name; if (f.isdouble) { GDate controldate2 = new GDate(); controldate2.Caption = "一一"; controldate2.Name = "date2_" + f.fieldname; controldate2.Location = new Point(left + controldate.Width + 20, top); if (!f.defaultvalue2.IsNullOrEmpty()) { controldate2.SetValue(f.defaultvalue2); } this.tabPage1.Controls.Add(controldate2); f.control2 = controldate2.Name; } top += controldate.Height + 10; break; default: GText controltext = new GText(); controltext.Caption = f.caption; controltext.Name = "text_" + f.fieldname; controltext.Location = new Point(left, top); controltext.Width = 200; if (!f.defaultvalue.IsNullOrEmpty()) { controltext.SetValue(f.defaultvalue); } this.tabPage1.Controls.Add(controltext); top += controltext.Height + 10; f.control = controltext.Name; break; } } }
public Condition GetCondition() { Condition c = DefaultCondition; foreach (FilterInfo f in FilterInfos) { string v = "", v2 = ""; switch (f.controltype) { case "dropdown": GDropDown cd = this.tabPage1.Controls[f.control] as GDropDown; v = G.Core.GConvert.ToString(cd.GetValue()); if (!v.IsNullOrEmpty()) { if (f.islike) { c &= CK.K[f.fieldname].Like(v); } else { c &= CK.K[f.fieldname].Eq(v); } } break; case "combox": GCombo2 cc = this.tabPage1.Controls[f.control] as GCombo2; v = G.Core.GConvert.ToString(cc.GetValue()); if (!v.IsNullOrEmpty()) { if (f.islike) { c &= CK.K[f.fieldname].Like(v); } else { c &= CK.K[f.fieldname].Eq(v); } } break; case "datetime": GDate gdt = this.tabPage1.Controls[f.control] as GDate; GDate gdt2 = this.tabPage1.Controls[f.control2] as GDate; v = gdt.GetValue().ToShortDateTime(); if (!v.IsNullOrEmpty()) { if (f.islike) { c &= CK.K[f.fieldname].Like(v); } else if (f.isdouble) { v2 = ""; object obj2 = gdt2.GetValue(); if (!obj2.Equals(DBNull.Value)) { v2 = obj2.ToDateTime().AddDays(1).ToShortDateString(); } c &= CK.K[f.fieldname].Ge(v); c &= CK.K[f.fieldname].Le(v2); } else { string v3 = gdt.GetValue().ToDateTime().AddDays(1).ToShortDateString(); c &= CK.K[f.fieldname].Ge(v); c &= CK.K[f.fieldname].Le(v3); } } break; case "date": GDate gd = this.tabPage1.Controls[f.control] as GDate; v = gd.GetValue().ToShortDateTime(); GDate gd2 = this.tabPage1.Controls[f.control2] as GDate; v2 = gd2.GetValue().ToShortDateTime(); if (!v.IsNullOrEmpty()) { if (f.islike) { c &= CK.K[f.fieldname].Like(v); } else if (f.isdouble) { c &= CK.K[f.fieldname].Ge(v); c &= CK.K[f.fieldname].Le(v2); } else { c &= CK.K[f.fieldname].Eq(v); } } break; case "checkbox": GCheckBox ccb = this.tabPage1.Controls[f.control] as GCheckBox; v = G.Core.GConvert.ToString(ccb.GetValue()); if (!v.IsNullOrEmpty()) { c &= CK.K[f.fieldname].Eq(v); } break; default: GText gt = this.tabPage1.Controls[f.control] as GText; v = G.Core.GConvert.ToString(gt.GetValue()); if (!v.IsNullOrEmpty()) { if (f.islike) { c &= CK.K[f.fieldname].Like(v); } else { c &= CK.K[f.fieldname].Eq(v); } } break; } } if (c == null) { c = Condition.Empty; } return(c); }