/// <summary> /// ��������������ڵ� /// </summary> /// <param name="curCas">�ؼ�����CASSVIEW����</param> /// <param name="curCtrl">�ؼ�</param> /// <returns>�ڵ�</returns> private XmlNode CreateProcess(CassView curCas, Control curCtrl) { PropertyDescriptor configurationProperty = TypeDescriptor.GetProperties(curCtrl)["Configuration"]; ControlTactic.SpecialControl.Process ConvertTool = new ControlTactic.SpecialControl.Process(); ControlTactic.SpecialControl.ProcessStruct tempStruct = ConvertTool.ListToStruct((List<string>)configurationProperty.GetValue(curCtrl)); tempStruct = AddID(tempStruct); XmlElement Process = document.CreateElement("ConditionAction"); ControlInfo currentCtrl = curCas.FindControlInfo(curCtrl); Process.SetAttribute("name", currentCtrl.CodeInfo[2]); if (tempStruct.IsOnlyStart) { for (int i = 0; i < tempStruct.NumOfConditions; i++) {//�������������Ϣ���������� if (tempStruct.Conditions[i] == "") { continue; } XmlElement newItem = document.CreateElement("item"); XmlElement newCondition = document.CreateElement("condition"); newCondition.InnerText = tempStruct.Conditions[i]; newItem.AppendChild(newCondition); XmlElement newExpression = document.CreateElement("expression"); newExpression.InnerText = "condition[" + i.ToString() + "] = 1"; newItem.AppendChild(newExpression); Process.AppendChild(newItem); } } for (int Aindex = 0; Aindex < tempStruct.NumOfActions; Aindex++) { XmlElement newItem = document.CreateElement("item"); if (tempStruct.Actions[Aindex][0] == "" || (tempStruct.Actions[Aindex][1] == "" && tempStruct.Actions[Aindex][2] == "")) {//����Ϊ�ջ������ı��ʽΪ�� continue; } for (int Cindex = 0; Cindex < tempStruct.NumOfConditions; Cindex++) { string Condition = null; if (tempStruct.OrderBox[Cindex, Aindex] == "" || tempStruct.Conditions[Cindex] == "") {//���˳����ϵΪ�� ���Ӧ������Ϊ�������� continue; } else if (tempStruct.OrderBox[Aindex, Cindex] == "N") {//�ǹ�ϵ���ϣ� Condition = "!"; } if (tempStruct.IsOnlyStart) {//�������������趨�ж���ʾ�������黹�DZ��ʽ Condition += "condition[" + Cindex.ToString() + "]"; } else { Condition += "(" + tempStruct.Conditions[Cindex] + ")"; } XmlElement newCondition = document.CreateElement("condition"); newCondition.InnerText = Condition; newItem.AppendChild(newCondition); } if (newItem.ChildNodes.Count == 0) {//���û��������Ĭ��Ϊ1 �������"1"�����ӽڵ� XmlElement newCondition = document.CreateElement("condition"); newCondition.InnerText = "1"; newItem.AppendChild(newCondition); } XmlElement newExpression = document.CreateElement("expression"); if (tempStruct.Actions[Aindex][0] == "Evaluate") { newExpression = document.CreateElement("expression"); newExpression.InnerText = tempStruct.Actions[Aindex][1] + "=" + tempStruct.Actions[Aindex][2]; } else if (tempStruct.Actions[Aindex][0] == "Transfer") { newExpression = document.CreateElement("function"); newExpression.InnerText = Mid + tempStruct.Actions[Aindex][1] + Sid; } newItem.AppendChild(newExpression); Process.AppendChild(newItem); } return Process; }
/// <summary> /// 调用SetActionInformation函数判断当前的对象是否需要进行动作设置 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">时间数据</param> private void controlfilteredPropertyGrid_SelectedObjectsChanged(object sender, EventArgs e) { if (tabControlView.SelectedIndex >= 0 //&& tabList.Count == tabControlView.TabCount//有指令表页面 删除该条件20090619 && controlfilteredPropertyGrid.SelectedObject != null) { if (!controlfilteredPropertyGrid.SelectedObject.GetType().ToString().Equals(PublicVariable.viewName)) //不为CassView { bringToFrontToolStripButton.Enabled = true; sendToBackStripButton.Enabled = true; CassView cassView = (CassView)(currentTabPage.Controls[0].GetNextControl(currentTabPage.Controls[0], false)); Control control = (Control)(this.controlfilteredPropertyGrid.SelectedObject); PropertyDescriptor moduleSortProperty = TypeDescriptor.GetProperties(control)["ModuleSort"]; if (moduleSortProperty != null) { string sortName = moduleSortProperty.GetValue(control).ToString(); if (sortName == "输入变量" || sortName == "输出变量") { SetPortnameList(control);//设置控件点名列表 SetPropertyList(control);//设置选定控件的属性列表 } else if (sortName == "跳转") { PropertyDescriptor serialNumberProperty = TypeDescriptor.GetProperties(control)["SerialNumberNames"]; if (serialNumberProperty != null) { if (currentTabPage != null && currentTabPage.Controls[0] != null && currentTabPage.Controls[0].GetNextControl(currentTabPage.Controls[0], false) != null) { //修改列表 模块序号 如果是已经串联的 则为Bl:1,2,3 List<string> ControlTarget = new List<string>(); new GenerateCode(null).PackOrderCtrl(cassView, new string[] { currentTabPage.Text, null }); //{//是否要排除包含自身的控件序列选项????????? foreach (string[] element in GenerateCode.PackInfos) { ControlTarget.Add("Bl:" + element[1]); } serialNumberProperty.SetValue(control, ControlTarget); }//end if (currentTabPage != null) }//end if(serialNumberProperty != null) }//end else if (sortName == "跳转") else if (sortName == "调用") { PropertyDescriptor serialNumberProperty = TypeDescriptor.GetProperties(control)["SerialNumberNames"]; if (serialNumberProperty != null) { if (currentTabPage != null && currentTabPage.Controls[0] != null && currentTabPage.Controls[0].GetNextControl(currentTabPage.Controls[0], false) != null) { serialNumberProperty.SetValue(control, GetTacticList()); } } } else if (sortName == "条件动作表") { PropertyDescriptor configurationProperty = TypeDescriptor.GetProperties(control)["Configuration"]; ControlTactic.SpecialControl.Process ConvertTool = new ControlTactic.SpecialControl.Process(); ControlTactic.SpecialControl.ProcessStruct tempStruct = ConvertTool.ListToStruct((List<string>)configurationProperty.GetValue(control)); tempStruct.Tactic = GetTacticList(); tempStruct.ControlAttribute = GetControlValue(); configurationProperty.SetValue(control, ConvertTool.StructToList(tempStruct)); } }//end if (moduleSortProperty != null) }//end if (!controlfilteredPropertyGrid.SelectedObject.GetType().ToString().Equals(PublicVariable.viewName)) else //为CassView { bringToFrontToolStripButton.Enabled = false; sendToBackStripButton.Enabled = false; }//end else if (controlfilteredPropertyGrid.SelectedObject.GetType().ToString().Equals(PublicVariable.viewName)) }//end if (tabControlView.SelectedIndex >= 0) else if (controlfilteredPropertyGrid.SelectedObject == null) { bringToFrontToolStripButton.Enabled = false; sendToBackStripButton.Enabled = false; }//end else if (controlfilteredPropertyGrid.SelectedObject == null) }