public override ListViewItem SetupListViewItem(ListViewItem item, XComponent component) { XProp prop = new XProp(ref X, null, Vector3.Zero, Vector3.Zero, Matrix.Identity, Vector3.One); prop.NoCull = true; return(base.SetupListViewItem(item, prop)); }
/// <summary> /// 设置属性窗口值 /// </summary> /// <param name="ent"></param> public void SetPropertyGridEnt(PreWarningRules ent) { if (ent == null) { return; } _srcEnt = ent.DeepClone(); _ruleCodeId.Value = ent.RuleId; _ruleCodeProp.Value = ent.RuleCode; _ruleType.Value = ent.RuleType; _warningType.Value = ent.WarningType; _warningLevel.Value = ent.WarningLevel; _suitableLocation.Value = ent.SuitableLocation; _indicatorType.Value = ent.IndicatorType; _operator.Value = ent.Operator; _dateProp.Value = ent.ModifyDate.ToString(); _remarks.Value = ent.Remarks; //MARK FIELD _multiRulesBindingSingleRule.Value = ent.StrBindingSingleRuleName == null ? "" : ent.StrBindingSingleRuleName; _IsMultiRules.Value = ent.IsMultiRules ? "是" : "否"; var htParams = ent.GetWarningParamsAndValues(); var nParams = 0; if (htParams != null) { nParams = htParams.Count; } _paramCnt.Value = nParams.ToString(); //移除先前的参数 var preCnt = _paramProp.Count; for (var i = 0; i < preCnt; i++) { _props.Remove(_paramProp[i]); } _paramProp.Clear(); //规则参数 if (htParams != null) { foreach (string tmpKey in htParams.Keys) { var prop = new XProp(); prop.Category = CATEGORY_RULE_PARAMS_TITLE; prop.Name = tmpKey; prop.Description = "规则参数" + tmpKey; prop.ReadOnly = false; prop.ProType = typeof(string); prop.Visible = true; prop.Converter = null; prop.Value = htParams[tmpKey].ToString(); _props.Add(prop); _paramProp.Add(prop); } } propertyGridRules.SelectedObject = _props; }
public override void WriteToXML(System.Xml.XmlWriter writer, object obj) { //missing some here XProp prop = (XProp)obj; writer.WriteStartElement("sceneitem"); writer.WriteAttributeString("Type", prop.GetType().ToString()); writer.WriteAttributeString("AutoDraw", prop.AutoDraw.ToString()); writer.WriteAttributeString("ComponentID", prop.ComponentID.ToString()); writer.WriteAttributeString("DrawOrder", prop.DrawOrder.ToString()); writer.WriteAttributeString("model_editor", prop.model_editor.ComponentID.ToString()); writer.WriteAttributeString("ModelOffset_editor", prop.ModelOffset_editor.ToString()); writer.WriteAttributeString("Name", prop.Name); writer.WriteAttributeString("Rotation", prop.Rotation.ToString()); writer.WriteAttributeString("Scale", prop.Scale.ToString()); writer.WriteAttributeString("Translation", prop.Translation.ToString()); writer.WriteEndElement(); }
public override void LoadFromXML(System.Xml.XmlNode node, ListView scene, ref Dictionary <uint, List <uint> > Depends) { XTools tools = new XTools(X); XProp actor = new XProp(ref X, null, tools.ParseXMLVector3(node.Attributes["Translation"].InnerText), tools.ParseXMLVector3(node.Attributes["ModelOffset_editor"].InnerText), Matrix.CreateFromQuaternion(tools.ParseXMLQuaternion(node.Attributes["Rotation"].InnerText)), tools.ParseXMLVector3(node.Attributes["Scale"].InnerText)); actor.NoCull = true; actor.AutoDraw = bool.Parse(node.Attributes["AutoDraw"].InnerText); actor.DrawOrder = int.Parse(node.Attributes["DrawOrder"].InnerText); actor.ComponentID = uint.Parse(node.Attributes["ComponentID"].InnerText); actor.Name = node.Attributes["Name"].InnerText; List <uint> dep = new List <uint>(); dep.Add(uint.Parse(node.Attributes["model_editor"].InnerText)); Depends.Add(actor.ComponentID, dep); X_Editor.Tools.AddXComponentToSceneList(scene, actor, group); }
/// <summary> /// 对于特殊控件的个别用户不可见属性赋值 /// </summary> /// <param name="SpeicalCtrl">控件信息</param> static public void SetUnvisibleFunction(ControlInfo SpeicalCtrl) { if (SpeicalCtrl.CodeInfo[0] == "斜坡控制器") { int TrueStep = 0; //有效段数 int ControlTime = Convert.ToInt32(XProp.GetValue("controlTime", SpeicalCtrl.VisibleFunctionProperty)); //控制时间 int OutNum = Convert.ToInt32(XProp.GetValue("outNum", SpeicalCtrl.VisibleFunctionProperty)); //有效段数 int PreValue = 0; //前一时间值 int NowValue = 0; //当前时间值 foreach (XProp function in SpeicalCtrl.VisibleFunctionProperty) { if (function.VarName.Contains("time")) { if (TrueStep != 0) { PreValue = NowValue; } NowValue = Convert.ToInt32(function.TheValue); if (NowValue < 0 || NowValue < PreValue || NowValue > ControlTime || TrueStep >= OutNum) {//时间值小于0或时间值大于控制时间或当前点时间小于前一点时间 ??点的序号大于控制段数 break; } TrueStep++; } } XProp.SetValue(TrueStep.ToString(), "sectionNum", SpeicalCtrl.UnvisibleFunctionProperty); } else if (SpeicalCtrl.CodeInfo[0] == "通用线性化器") { int TruePoint = 0;//有效点个数 float MinValue = Convert.ToSingle(XProp.GetValue("fInMin", SpeicalCtrl.VisibleFunctionProperty)); float MaxValue = Convert.ToSingle(XProp.GetValue("fInMax", SpeicalCtrl.VisibleFunctionProperty)); float PreValue = 0; //前一输入值 float NowValue = 0; //当前输入值 foreach (XProp function in SpeicalCtrl.VisibleFunctionProperty) { //"第X点输入"取后两字判断 if (function.Name.Length >= 5 && function.Name.Substring(3, 2) == "输入") //为点的输入属性 { if (TruePoint != 0) { PreValue = NowValue; } NowValue = Convert.ToSingle(function.TheValue); if (NowValue <= MinValue || NowValue <= PreValue || NowValue >= MaxValue) {//输入值小于或等于输入最小值或小于或等于前一点的输入值或大于或等于输入最大值 break; } TruePoint++; } } XProp.SetValue(TruePoint.ToString(), "effNum", SpeicalCtrl.UnvisibleFunctionProperty); } else //"三者取中器", "高低选择器" { int index = 0; foreach (string[] Info in SpeicalCtrl.InputInfo) {//遍历输入口信息,非NULL表示有效 if (Info[0] != null) { index++; } } XProp.SetValue(index.ToString(), "ucEffNum", SpeicalCtrl.UnvisibleFunctionProperty); } }
/// <summary> /// Processes user input updates /// </summary> /// <param name="gameTime"></param> public void Update(GameTime gameTime) { if (keyboard.KeyPressed(Keys.OemTilde)) { X.Console.Visible = !X.Console.Visible; } //if console is showing capture all input! if (X.Console.Visible) { X.Console.AcceptInput(keyboard); //return; } // Allows the game to exit //if (gamepad.ButtonDown(Buttons.B)) // parent.Exit(); if (keyboard.KeyPressed(Keys.Escape)) { //toggle physics on/off X.UpdatePhysics = !X.UpdatePhysics; //toggle game menu on/off parent.menus.Toggle(); } if (parent.menus.MenuOpen) { if (keyboard.KeyPressed(Keys.Up)) { parent.menus.SelectPrevious(); } if (keyboard.KeyPressed(Keys.Down)) { parent.menus.SelectNext(); } if (keyboard.KeyPressed(Keys.Enter)) { switch (parent.menus.Current) { case 2: //exit button parent.Exit(); break; default: break; } } return; } //drive car //TODO: Fix the retarded classes here, car is way to many level deep???? or something OMG if (parent.Car != null) { if (keyboard.KeyDown(Keys.Up) || keyboard.KeyDown(Keys.Down)) { if (keyboard.KeyDown(Keys.Up)) { parent.Car.Car.Car.Accelerate = 1.0f; } else { parent.Car.Car.Car.Accelerate = -1.0f; } } else { parent.Car.Car.Car.Accelerate = 0.0f; } if (keyboard.KeyDown(Keys.Left) || keyboard.KeyDown(Keys.Right)) { if (keyboard.KeyDown(Keys.Left)) { parent.Car.Car.Car.Steer = 1.0f; } else { parent.Car.Car.Car.Steer = -1.0f; } } else { parent.Car.Car.Car.Steer = 0.0f; } if (keyboard.KeyDown(Keys.B)) { parent.Car.Car.Car.HBrake = 1.0f; } else { parent.Car.Car.Car.HBrake = 0.0f; } } //Mouse code #if !XBOX parent.freeCamera.Rotate(new Vector3(mouse.Delta.Y * .0016f, mouse.Delta.X * .0016f, 0)); parent.driverCamera.Rotate(new Vector3(mouse.Delta.Y * .0016f, mouse.Delta.X * .0016f, 0)); if (mouse.ButtonPressed(XMouse.Buttons.Left)) { //parent.boxes.Add(new XActor(ref X, parent.model, parent.freeCamera.Position, Vector3.Normalize(parent.freeCamera.Target - parent.freeCamera.Position) * 30, 10)); if (parent.planeActor != null) { parent.planeActor.Disable(); } parent.planeActor = new XActor(ref X, parent.model, parent.freeCamera.Position, Vector3.Normalize(parent.freeCamera.Target - parent.freeCamera.Position) * 30, 10); } if (mouse.ButtonPressed(XMouse.Buttons.Right)) { XProp prop = new XProp(ref X, new XModel(ref X, @"Content\Models\tv"), parent.currentCamera.Position, Vector3.Zero, Matrix.Identity, Vector3.One); prop.Load(X.Content); } #endif //GAME PAD Controls if (gamepad.State(XGamePad.States.Current).IsConnected == true) { parent.freeCamera.Rotate(new Vector3((gamepad.Thumbstick(XGamePad.Thumbsticks.Right).Y * .5f) * (float)gameTime.ElapsedGameTime.TotalSeconds, (-gamepad.Thumbstick(XGamePad.Thumbsticks.Right).X * .5f) * (float)gameTime.ElapsedGameTime.TotalSeconds, 0)); if (gamepad.ButtonPressed(Buttons.A)) { parent.planeActor = new XActor(ref X, parent.model, parent.freeCamera.Position, Vector3.Normalize(parent.freeCamera.Target - parent.freeCamera.Position) * 30, 300); } parent.Car.Car.Car.Accelerate = gamepad.Trigger(XGamePad.Triggers.Left); parent.Car.Car.Car.Steer = gamepad.Thumbstick(XGamePad.Thumbsticks.Left).X * -1; parent.Car.Car.Car.HBrake = gamepad.Trigger(XGamePad.Triggers.Right); //Gamepad driving controls X.Debug.Write("LS: X:" + gamepad.Thumbstick(XGamePad.Thumbsticks.Left).X.ToString() + " Y:" + gamepad.Thumbstick(XGamePad.Thumbsticks.Left).Y.ToString(), false); X.Debug.Write("RS: X:" + gamepad.Thumbstick(XGamePad.Thumbsticks.Right).X.ToString() + " Y:" + gamepad.Thumbstick(XGamePad.Thumbsticks.Right).Y.ToString(), false); X.Debug.Write("LT: " + gamepad.Trigger(XGamePad.Triggers.Left).ToString(), false); X.Debug.Write("RT: " + gamepad.Trigger(XGamePad.Triggers.Right).ToString(), false); } //Camera Movement with KB or Gamepad directional pad float speed = 40f; if (keyboard.KeyDown(Keys.LeftShift)) { speed = 2f; } if (keyboard.KeyDown(Keys.LeftControl)) { speed = 200f; } if (keyboard.KeyDown(Keys.W) || gamepad.ButtonDown(Buttons.DPadUp)) { parent.freeCamera.Translate(Vector3.Forward * speed); } if (keyboard.KeyDown(Keys.S) || gamepad.ButtonDown(Buttons.DPadDown)) { parent.freeCamera.Translate(Vector3.Backward * speed); } if (keyboard.KeyDown(Keys.A) || gamepad.ButtonDown(Buttons.DPadLeft)) { parent.freeCamera.Translate(Vector3.Left * speed); } if (keyboard.KeyDown(Keys.D) || gamepad.ButtonDown(Buttons.DPadRight)) { parent.freeCamera.Translate(Vector3.Right * speed); } //write camera corrds for debug X.Debug.Write("Free Camera: X" + parent.freeCamera.Position.X.ToString() + " Y:" + parent.freeCamera.Position.Y.ToString() + " Z:" + parent.freeCamera.Position.Z.ToString(), false); X.Debug.Write("Driver Camera: X" + parent.driverCamera.Position.X.ToString() + " Y:" + parent.driverCamera.Position.Y.ToString() + " Z:" + parent.driverCamera.Position.Z.ToString(), false); X.Debug.Write("Box Actors in List:" + parent.boxes.Count.ToString(), false); if (keyboard.KeyPressed(Keys.F1)) { } //if (keyboard.KeyDown(Keys.F2)) //parent.sky.Theta -= .5f * (float)gameTime.ElapsedGameTime.TotalSeconds; if (keyboard.KeyPressed(Keys.F3)) { if (parent.water == null) { parent.water = new XWater(ref X, new Vector2(-128, -128), new Vector2(128 * 2, 128 * 2), 3f); parent.water.Load(parent.Content); parent.water.Update(ref gameTime); parent.resources.AddComponent(parent.water); } XWaterFast water = new XWaterFast(ref X, @"Content\XEngine\Textures\Sky\GreenWaterSky"); water.basePosition = new Vector3(0, 1.5f, 0); water.Load(X.Content); } if (keyboard.KeyPressed(Keys.E)) { if (parent.water != null) { parent.water.DoesReflect = !parent.water.DoesReflect; } } if (keyboard.KeyPressed(Keys.R)) { if (parent.water != null) { parent.water.DoesRefract = !parent.water.DoesRefract; } } if (parent.water != null) { //WindDirection if (keyboard.KeyDown(Keys.NumPad4)) { parent.water.WindDirection -= .25f; } if (keyboard.KeyDown(Keys.NumPad6)) { parent.water.WindDirection += .25f; } //WaveHeight if (keyboard.KeyDown(Keys.NumPad2)) { parent.water.WaveHeight -= .01f; } if (keyboard.KeyDown(Keys.NumPad8)) { parent.water.WaveHeight += .01f; } //Wave Length if (keyboard.KeyDown(Keys.NumPad7)) { parent.water.WaveLength -= .01f; } if (keyboard.KeyDown(Keys.NumPad9)) { parent.water.WaveLength += .01f; } //Wind Force if (keyboard.KeyDown(Keys.NumPad1)) { parent.water.WindForce -= .05f; } if (keyboard.KeyDown(Keys.NumPad3)) { parent.water.WindForce += .05f; } } if (keyboard.KeyPressed(Keys.F4)) { for (int x = 0; x < 10; x++) { for (int e = x; e < 10; e++) { parent.boxes.Add(new XActor(ref X, new CapsuleObject(1, 1, Matrix.Identity, new Vector3(20, x * 1.01f + 1, e - 0.5f * x)), parent.model, Vector3.One, Vector3.Zero, 10)); } } } if (keyboard.KeyPressed(Keys.F5)) { List <XActor> chainBoxes = new List <XActor>(); for (int i = 0; i < 25; i++) { XActor actor = new XActor(ref X, new CapsuleObject(1, 1, Matrix.Identity, new Vector3(i + 10, 45 - i, 0)), parent.model, Vector3.One, Vector3.Zero, 10); if (i == 0) { actor.Immovable = true; } chainBoxes.Add(actor); } for (int i = 1; i < 25; i++) { XHingeJoint hinge = new XHingeJoint(ref X, chainBoxes[i - 1], chainBoxes[i], Vector3.Backward, new Vector3(0.5f, -0.5f, 0.0f), 1.0f, 90.0f, 90.0f, 0.2f, 0.2f); } } if (keyboard.KeyPressed(Keys.F6)) { if (parent.currentCamera == parent.chase) { parent.currentCamera = parent.freeCamera; return; } if (parent.currentCamera == parent.freeCamera) { parent.currentCamera = parent.driverCamera; return; } if (parent.currentCamera == parent.driverCamera) { parent.currentCamera = parent.chase; return; } } if (keyboard.KeyPressed(Keys.F7)) { parent.houseactor = new XAnimatedActor(ref X, new BoxObject(new Vector3(5, 5, 1), Matrix.Identity, new Vector3(2, 2, 2)), parent.housemodel, Vector3.One, Vector3.Zero, .1f); parent.houseactor.Load(X.Content); parent.houseactor.Immovable = false; parent.boxes.Add(parent.houseactor); } if (keyboard.KeyPressed(Keys.F8)) { //if (parent.houseactor == null) //{ parent.houseactor = new XAnimatedActor(ref X, new BoxObject(new Vector3(5, 5, 1), Matrix.Identity, new Vector3(2, 2, 2)), parent.housemodel, Vector3.One, Vector3.Zero, .1f); parent.houseactor.Load(X.Content); parent.houseactor.Immovable = false; parent.boxes.Add(parent.houseactor); //} } if (keyboard.KeyPressed(Keys.F9)) { foreach (XActor xa in parent.boxes) { xa.Disable(); } parent.boxes.Clear(); } if (keyboard.KeyPressed(Keys.Add)) { parent.houseactor.AnimationIndex++; } if (keyboard.KeyPressed(Keys.F10)) { XCubeTriggerVolume cv = new XCubeTriggerVolume(ref X, (XPhysicsObject)parent.Car.Car, true, new Vector3(0, 0, 0), new Vector3(10, 10, 10), Vector3.One, Quaternion.Identity, Vector3.One); //XTextureGenerator texGen = new XTextureGenerator(ref X); //texGen.GetMandelBrot(new Vector2(0.25f, 0),3); /* * if (pad.Buttons.A == ButtonState.Pressed) * zoom /= 1.05f; * * if (pad.Buttons.B == ButtonState.Pressed) * zoom *= 1.05f; * * float panSensitivity = 0.01f * (float)Math.Log(zoom + 1); * * pan += new Vector2(pad.ThumbSticks.Left.X, -pad.ThumbSticks.Left.Y) * panSensitivity; */ } if (keyboard.KeyPressed(Keys.PageUp)) { } if (keyboard.KeyPressed(Keys.PageDown)) { } //Example Code /* if (!parent.menus.MenuOpen) * { * X.UpdatePhysics = true; * * if (parent.scene.Ball != null) * { * parent.Camera.TargetPosition = parent.scene.Ball.Position; * * Vector3 ballPos = new Vector3(parent.scene.Ball.Position.X, 0, parent.scene.Ball.Position.Z); * Vector3 camPos = new Vector3(parent.Camera.Position.X, 0, parent.Camera.Position.Z); * Vector3 dir = (ballPos - camPos); * #if XBOX == FALSE * parent.Camera.Rotate(mouse.Delta.X * .008f, mouse.Delta.Y * .008f); * parent.Camera.Zoom(-mouse.ScrollDelta * .015f); * * if (!jumping && keyboard.KeyPressed(Keys.Space)) * { * jumping = true; * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(new Vector3(0, 1200000, 0), Matrix.Invert(parent.scene.Ball.Orientation))); * } * else if (jumping) * { * if (parent.scene.Ball.Actor.Collisions.Count > 0) * jumping = false; * } * * if (parent.scene.Ball.Actor.Collisions.Count > 0) * { * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.W) ? 1 : 0) * 2800, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(-Vector3.Transform(dir * (keyboard.KeyDown(Keys.S) ? 1 : 0) * 4000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.A) ? 1 : 0) * 3300, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(-90))))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.D) ? 1 : 0) * 3300, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(90))))); * } * else * { * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.W) ? 1 : 0) * 1000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(-Vector3.Transform(dir * (keyboard.KeyDown(Keys.S) ? 1 : 0) * 2000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.A) ? 1 : 0) * 1300, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(-90))))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * (keyboard.KeyDown(Keys.D) ? 1 : 0) * 1300, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(90))))); * } #endif * parent.Camera.Rotate(-Gamepad.Thumbstick(XgamePad.Thumbsticks.Right).X * .04f, Gamepad.Thumbstick(XgamePad.Thumbsticks.Right).Y * .04f); * parent.Camera.Zoom((Gamepad.ButtonDown(Buttons.DPadDown) ? 0.15f : 0) + (Gamepad.ButtonDown(Buttons.DPadUp) ? -0.15f : 0)); * * if (!jumping && Gamepad.ButtonPressed(Buttons.A)) * { * jumping = true; * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(new Vector3(0, 1200000, 0), Matrix.Invert(parent.scene.Ball.Orientation))); * } * else if (jumping) * { * if (parent.scene.Ball.Actor.Collisions.Count > 0) * jumping = false; * } * * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * Gamepad.Thumbstick(XgamePad.Thumbsticks.Left).Y * 1000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(-Vector3.Transform(dir * -Gamepad.Thumbstick(XgamePad.Thumbsticks.Left).Y * 1000, Matrix.Invert(parent.scene.Ball.Orientation))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(Vector3.Transform(dir * Gamepad.Thumbstick(XgamePad.Thumbsticks.Left).X * 1000, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(90))))); * parent.scene.Ball.Actor.PhysicsBody.PhysicsBody.ApplyBodyImpulse(-Vector3.Transform(dir * -Gamepad.Thumbstick(XgamePad.Thumbsticks.Left).X * 1000, Matrix.Invert(parent.scene.Ball.Orientation * Matrix.CreateRotationY(MathHelper.ToRadians(90))))); * } * } * else * { * X.UpdatePhysics = false; * * if (keyboard.KeyPressed(Keys.Up)) * parent.menus.SelectPrevious(); * else if (keyboard.KeyPressed(Keys.Down)) * parent.menus.SelectNext(); * } * * if (keyboard.KeyPressed(Keys.Escape)) * parent.menus.Toggle(); */ }
/// <summary> /// 从控件信息中获取提示信息 /// 如果参数index非-1则返回对应序号的参数提示信息 /// 否则返回所有参数的提示信息 /// </summary> /// <param name="ctrl">控件信息</param> /// <param name="index">参数序号</param> /// <returns>提示信息</returns> public void GetTipmessage(ControlInfo ctrl, int index) { List <string> TipMes = new List <string>(); //返回用的信息数组 string tip = null; //提示 if (ctrl.VisibleFunctionProperty.Count == 0 && ctrl.UnvisibleFunctionProperty.Count == 0) {//默认功能属性为空则没有参数提示信息 this.toolTip1.Hide(this); return; } if (index == -1) {//查找全部的参数信息 int paraCount = 0; //foreach (XProp element in ctrl.VisibleFunctionProperty) //{ // tempMes = AddressTable.ConvertShowType(element.ValueType) + " " + element.VarName; // if (TipMes.Count % 4 == 3)//每行3个参数 // { tempMes = "\n" + tempMes; } // TipMes.Add(tempMes); //} foreach (XProp element in ctrl.UnvisibleFunctionProperty) { if (element.TheValue.ToString().Contains("array")) { //tempMes = AddressTable.ConvertShowType(element.ValueType) + " " + element.VarName; //if (TipMes.Count % 4 == 3) //{ tempMes = "\n" + tempMes; } //TipMes.Add(tempMes); paraCount++; } } paraCount += ctrl.VisibleFunctionProperty.Count; if (this.toolTip1.ToolTipTitle != ctrl.SortName) { //控件中文名作标题 this.toolTip1.ToolTipTitle = ctrl.SortName; } if (PLCCodeEditor.CanTipCode.Contains(ctrl.CodeInfo[1])) { tip += "1个参数"; } else if (paraCount == 0) { tip += "无参数"; } else { tip += paraCount + "个参数"; } tip += "\n" + ctrl.OtherProperty[2]; this.toolTip1.Show(tip, this, new Point(Size.Width, 0)); //return TipMes; } else if (ctrl.VisibleFunctionProperty.Count != 0) { //查找制定参数信息 int ParaCount = 0; //数组参数个数 在不可见功能属性遍历中记录所用 XProp tempFun = new XProp(); if (index < ctrl.VisibleFunctionProperty.Count) {//查找序号小于可见功能属性 tempFun = ctrl.VisibleFunctionProperty[index]; } //else //{ for (int x = 0; x < ctrl.UnvisibleFunctionProperty.Count; x++) { if (ctrl.UnvisibleFunctionProperty[x].TheValue.ToString().Contains("array")) { //不可见数组参数 if (index == ParaCount + ctrl.VisibleFunctionProperty.Count) { //序号符合 tempFun = ctrl.UnvisibleFunctionProperty[x]; } ParaCount++; } } //} //string tip = AddressTable.ConvertShowType(tempFun.ValueType) + " " + tempFun.VarName; //if (index <= ParaCount + ctrl.VisibleFunctionProperty.Count - 1) //{ // if (index != ParaCount + ctrl.VisibleFunctionProperty.Count - 1) // {//当不为最后一个参数 // tip = tip + ",..."; // } // if (index != 0) // { //当不为第一个参数 // tip = "...," + tip; // } // //类型后换行加入描述信息 // tip += "\n" + tempFun.Name + ":\n" + tempFun.ValueExplain; // TipMes.Add(tip); //} string title = tempFun.Name + " (" + (index + 1) + "/" + (ParaCount + ctrl.VisibleFunctionProperty.Count) + ")"; tip = AddressTable.ConvertShowType2(tempFun.ValueType) + "\n"; for (int i = 0; i < tempFun.ValueExplain.Length; i++) { if (i % 11 == 0) {//11个字符换行 tip += "\n"; } tip += tempFun.ValueExplain[i]; } if (this.toolTip1.ToolTipTitle != title) { this.toolTip1.ToolTipTitle = title; } this.toolTip1.Show(tip, this, new Point(Size.Width, 0)); } //return TipMes; }