private void RecurseControls(ControlInfo control) { if (control.QfControl is IQuickFormsControlContainer) { IQuickFormsControlContainer container = control.QfControl as IQuickFormsControlContainer; IList<IControlSurface> lst = container.GetControlSurfaces(); if (lst != null) { foreach (IControlSurface surface in lst) { IList<ControlInfo> controls = new List<ControlInfo>(); foreach (ControlInfo childControl in control.Controls) { QuickFormsControlBase qfControl = childControl.QfControl; foreach (var qfe in surface.Controls) { if (qfe.Control == qfControl) { controls.Add(childControl); break; } } } //calculate the layout NewAlgorithmProcessControls(controls, surface.Columns, surface.Rows, control.Width, control.Height); //process child controls foreach (ControlInfo childControl in controls) RecurseControls(childControl); } } } }
private int AdjustOverlappingControlSizes(ControlInfo ctrl1, ControlInfo ctrl2, int MaxRow, int MaxColumn) { Rectangle r1 = new Rectangle(ctrl1.Left, ctrl1.Top, ctrl1.Width, ctrl1.Height); Rectangle r2 = new Rectangle(ctrl2.Left, ctrl2.Top, ctrl2.Width, ctrl2.Height); Rectangle rr = Rectangle.Intersect(r1, r2); if ((rr != null) && (rr.Width > 0) && (rr.Height > 0)) { //yes, the controls do indeed overlap //build a list of all possible changes that make controls non-overlapping List<ControlVariation> list = new List<ControlVariation>(); //ctrl1 - vary Left if ((ctrl1.Left >= rr.Left) && (ctrl1.Left < rr.Left + rr.Width)) { list.Add(new ControlVariation(ctrl1, rr.Left + rr.Width, ctrl1.Top, ctrl1.Width - rr.Width, ctrl1.Height)); //vary left } //ctrl1 - vary Top if ((ctrl1.Top >= rr.Top) && (ctrl1.Top < rr.Top + rr.Height)) { list.Add(new ControlVariation(ctrl1, ctrl1.Left, rr.Top + rr.Height, ctrl1.Width, ctrl1.Height - rr.Height)); //vary top } //ctrl1 - vary Width if ((ctrl1.Left + ctrl1.Width >= rr.Left) && (ctrl1.Left + ctrl1.Width < rr.Left + rr.Width)) { list.Add(new ControlVariation(ctrl1, ctrl1.Left, ctrl1.Top, ctrl1.Width - rr.Width, ctrl1.Height)); //vary width } //ctrl1 - vary Height if ((ctrl1.Top + ctrl1.Height >= rr.Top) && (ctrl1.Top + ctrl1.Height < rr.Top + rr.Height)) { list.Add(new ControlVariation(ctrl1, ctrl1.Left, rr.Top, ctrl1.Width, ctrl1.Height - rr.Height)); //vary height } //ctrl2 - vary Left if ((ctrl2.Left >= rr.Left) && (ctrl2.Left < rr.Left + rr.Width)) { list.Add(new ControlVariation(ctrl2, rr.Left + rr.Width, ctrl2.Top, ctrl2.Width - rr.Width, ctrl2.Height)); //vary left } //ctrl2 - vary Top if ((ctrl2.Top >= rr.Top) && (ctrl2.Top < rr.Top + rr.Height)) { list.Add(new ControlVariation(ctrl2, ctrl2.Left, rr.Top + rr.Height, ctrl2.Width, ctrl2.Height - rr.Height)); //vary top } //ctrl2 - vary Width if ((ctrl2.Left + ctrl2.Width >= rr.Left) && (ctrl2.Left + ctrl2.Width < rr.Left + rr.Width)) { list.Add(new ControlVariation(ctrl2, ctrl2.Left, ctrl2.Top, ctrl2.Width - rr.Width, ctrl2.Height)); //vary width } //ctrl2 - vary Height if ((ctrl2.Top + ctrl2.Height >= rr.Top) && (ctrl2.Top + ctrl2.Height < rr.Top + rr.Height)) { list.Add(new ControlVariation(ctrl2, ctrl2.Left, rr.Top, ctrl2.Width, ctrl2.Height - rr.Height)); //vary height } //now find the smallest change int AreaChange = int.MaxValue; ControlVariation MinVariation = null; foreach (ControlVariation variation in list) { //make sure the control size stays within the form if ((variation.AreaChange() < AreaChange) && (variation.NewLeft >= 0) && (variation.NewTop >= 0) && (variation.NewLeft + variation.NewWidth <= MaxColumn) && (variation.NewTop + variation.NewHeight <= MaxRow)) { AreaChange = variation.AreaChange(); MinVariation = variation; } } if (MinVariation != null) { string ModifiedProperties = ""; if (MinVariation.Control.Column != MinVariation.NewLeft) ModifiedProperties += "Left, "; if (MinVariation.Control.ColumnSpan != MinVariation.NewWidth) ModifiedProperties += "Width, "; if (MinVariation.Control.Row != MinVariation.NewTop) ModifiedProperties += "Top, "; if (MinVariation.Control.RowSpan != MinVariation.NewHeight) ModifiedProperties += "Height, "; if (ModifiedProperties.Length > 0) { ModifiedProperties = ModifiedProperties.Remove(ModifiedProperties.Length - 2); //remove ", " _context.Log.Warn("Control '{0}': the following properties were adjusted: {1}", new object[] { MinVariation.Control.QfControl.ControlId, ModifiedProperties }); } MinVariation.Control.Column = MinVariation.NewLeft; MinVariation.Control.ColumnSpan = MinVariation.NewWidth; MinVariation.Control.Row = MinVariation.NewTop; MinVariation.Control.RowSpan = MinVariation.NewHeight; } return AreaChange; } return 0; }
private ControlInfo[,] GetSurfaceGrid(IList<ControlInfo> controls, IList<ColumnStyle> columns, IList<RowStyle> rows) { ControlInfo[,] points = new ControlInfo[columns.Count + 1, rows.Count + 1]; //it will be populated by nulls foreach (ControlInfo control in controls) { if ((control.QfControl != null) && (control.IsVisible) && (!control.IsExcluded) && (!control.IsTool)) //visible controls only { for (int x = control.Column; x < control.Column + control.ColumnSpan; x++) { for (int y = control.Row; y < control.Row + control.RowSpan; y++) { if ((x >= 0) && (y >= 0) && (x < columns.Count) && (y < rows.Count)) points[x, y] = control; } } } } return points; }
//the beef of the new algorithm - give a list of controls and lists of rows and columns, //modify (Row, Column, RowSpan, ColumnSpan) properties for each control private void NewAlgorithmProcessControls(IList<ControlInfo> controls, IList<ColumnStyle> columns, IList<RowStyle> rows, int MaxX, int MaxY) { columns.Clear(); rows.Clear(); //max coordinates foreach (ControlInfo control in controls) { if (control.Left + control.Width > MaxX) MaxX = control.Left + control.Width; if (control.Top + control.Height > MaxY) MaxY = control.Top + control.Height; } //make columns and rows the same as left/width and top/height foreach (ControlInfo control in controls) { control.Column = control.Left; control.Row = control.Top; control.ColumnSpan = control.Width; control.RowSpan = control.Height; } //report any overlapping controls for (int i = 0; i < controls.Count; i++) { ControlInfo ctrl1 = controls[i]; if ((ctrl1.QfControl != null) && (ctrl1.IsVisible) && (!ctrl1.IsExcluded) && (!ctrl1.IsTool)) { Rectangle r1 = new Rectangle(ctrl1.Left, ctrl1.Top, ctrl1.Width, ctrl1.Height); for (int j = i + 1; j < controls.Count; j++) { ControlInfo ctrl2 = controls[j]; if ((ctrl2.QfControl != null) && (ctrl2.IsVisible) && (!ctrl2.IsExcluded) && (!ctrl2.IsTool)) { Rectangle r2 = new Rectangle(ctrl2.Left, ctrl2.Top, ctrl2.Width, ctrl2.Height); Rectangle rr = Rectangle.Intersect(r1, r2); if ((rr != null) && (rr.Width > 0) && (rr.Height > 0)) { //yep, these two controls overlap. Is that a complete overlap or partial? if ((r1.Left >= r2.Left) && (r1.Top >= r2.Top) && (r1.Left + r1.Width <= r2.Left + r2.Width) && (r1.Top + r1.Height <= r2.Top + r2.Height)) { //ctrl2 completely overlaps ctrl1 _context.Log.Warn("Control '{0}' completely overlaps control '{1}'", new object[] { ctrl2.QfControl.ControlId, ctrl1.QfControl.ControlId }); } else if ((r2.Left >= r1.Left) && (r2.Top >= r1.Top) && (r2.Left + r2.Width <= r1.Left + r1.Width) && (r2.Top + r2.Height <= r1.Top + r1.Height)) { //ctrl1 completely overlaps ctrl2 _context.Log.Warn("Control '{0}' completely overlaps control '{1}'", new object[] { ctrl1.QfControl.ControlId, ctrl2.QfControl.ControlId }); } else { //partical overlap _context.Log.Warn("Control '{0}' partially overlaps control '{1}'", new object[] { ctrl1.QfControl.ControlId, ctrl2.QfControl.ControlId }); //try to fix the partial overlap AdjustOverlappingControlSizes(ctrl1, ctrl2, rows.Count - 1, columns.Count - 1); } } } } } } //initalize Columns and Rows lists for (int x = 0; x < MaxX; x++ ) columns.Add(new ColumnStyle(SizeType.Absolute, 1)); for (int y = 0; y < MaxY; y++) rows.Add(new RowStyle(SizeType.Absolute, 1)); //merge label with their adjucent controls if (_context.Settings.MergeLabels) { MergeAdjacentLabels(controls, columns, rows); } //populate the surface area array ControlInfo[,] points = GetSurfaceGrid(controls, columns, rows); //re-adjust the sizes of the labels with the Autosize property set foreach (ControlInfo control in controls) { if ((control.Builder != null) && (control.Builder is LabelBuilder)) { LabelBuilder labelBuilder = (LabelBuilder)control.Builder; if (labelBuilder != null) { if (labelBuilder.AutoSize) { for (int x = control.Column + control.ColumnSpan; x <= MaxX; x++) { bool overlaps = false; for (int y = control.Row; y < control.Row + control.RowSpan; y++) { if (points[x, y] != null) { overlaps = true; break; } } if (overlaps) break; //from x control.ColumnSpan++; for (int y = control.Row; y < control.Row + control.RowSpan; y++) points[x, y] = control; } } } } } //here is the beauty - remove duplicate rows and columns //Columns for (int x = columns.Count-1; x >= 0; x--) { //the current column ControlInfo[] CurrentColumn = new ControlInfo[rows.Count]; for (int y = 0; y < rows.Count; y++) CurrentColumn[y] = points[x, y]; //now go left and see if the same column repeats itself and how many times int RepeatColumns = 1; //at least the current one for (int x2 = x - 1; x2 >= 0; x2--) { bool ColumnMatches = true; for (int y = 0; y < rows.Count; y++) { if (points[x2, y] != CurrentColumn[y]) { ColumnMatches = false; break; //from y loop } } if (!ColumnMatches) break; //from x2 loop RepeatColumns++; } if (RepeatColumns > 1) { //yes, we had at least 2 repeating columns. //readjust the current column's width columns[x].Width = columns[x].Width + RepeatColumns - 1; //remove the duplicate columns for (int x2 = x - 1; x2 >= x - RepeatColumns + 1; x2--) columns.RemoveAt(x2); //for all controls that span to the right of x, re-asjust the column and, posibly, the column span foreach (ControlInfo control in controls) { if (control.Column >= x) control.Column = control.Column - RepeatColumns + 1; else if ((control.Column + control.ColumnSpan) >= x) control.ColumnSpan = control.ColumnSpan - RepeatColumns + 1; } //re-adjust the counter x = x - RepeatColumns + 1; } } //re-populate the surface area array points = GetSurfaceGrid(controls, columns, rows); //Rows for (int y = rows.Count - 1; y >= 0; y--) { //the current row ControlInfo[] CurrentRow = new ControlInfo[columns.Count]; for (int x = 0; x < columns.Count; x++) CurrentRow[x] = points[x, y]; //now go left and see if the same row repeats itself and how many times int RepeatRows = 1; //at least the current one for (int y2 = y - 1; y2 >= 0; y2--) { bool RowMatches = true; for (int x = 0; x < columns.Count; x++) { if (points[x, y2] != CurrentRow[x]) { RowMatches = false; break; //from y loop } } if (!RowMatches) break; //from y2 loop RepeatRows++; } if (RepeatRows > 1) { //yes, we had at least 2 repeating rows. //readjust the current row's width rows[y].Height = rows[y].Height + RepeatRows - 1; //remove the duplicate rows for (int y2 = y - 1; y2 >= y - RepeatRows + 1; y2--) rows.RemoveAt(y2); //for all controls that span to the right of y, re-asjust the row and, posibly, the row span foreach (ControlInfo control in controls) { if (control.Row >= y) control.Row = control.Row - RepeatRows + 1; else if ((control.Row + control.RowSpan) >= y) control.RowSpan = control.RowSpan - RepeatRows + 1; } //re-adjust the counter y = y - RepeatRows + 1; } } //apply the changes from ControlInfo to QuickFormControlBase (ControlInfo.QfControl) foreach (ControlInfo control in controls) { if (control.QfControl != null) { control.QfControl.Column = control.Column; control.QfControl.ColumnSpan = Math.Max(1, control.ColumnSpan); control.QfControl.Row = control.Row; control.QfControl.RowSpan = Math.Max(1, control.RowSpan); } } }
public void SetValidationRule(Control control, ValidationRule rule) { if (control == null) { throw new ArgumentNullException("control"); } if (rule == null) { throw new ArgumentNullException("rule"); } var info = this.controls.GetValueOrDefault(control); if (info == null) { info = new ControlInfo(EditorAdapterFactory.Create(control)); this.SubscribeValidatingEvent(control); this.controls[control] = info; } info.Rule = rule; }
/// <summary> /// 对三者取中和高低选控件根据指令表中 /// 出现CON null的个数进行修正 /// </summary> /// <param name="specialCtrl"></param> /// <param name="special"></param> private void CodeSetspecialctrl(ControlInfo specialCtrl, ArrayList special) { //需要逆向遍历 且字典不支持序号遍历 List<ArrayList> OrderInfo = new List<ArrayList>(); OrderInfo.AddRange(CodeInfo.Keys); int unConnectNum = specialCtrl.InputInfo.Count; int inputIndex = 0;//所设定到的输入信息序号 int currentNum = 0;//计数遍历到当前何端口 for (int i = OrderInfo.IndexOf(special) - 1; i >= 0; i--) {//逆向遍历 起始行为特殊控件的上一行 string Operator = (string)OrderInfo[i][0]; List<string> Paras = (List<string>)OrderInfo[i][1]; if (Operator == "") {//当前块结束 return; } else { ControlInfo NextCtrl = CtrlPropertys[Operator]; unConnectNum = unConnectNum + NextCtrl.InputInfo.Count - NextCtrl.OutputInfo.Count; if (currentNum > unConnectNum) { currentNum = unConnectNum; if (Paras.Count != 0 && Paras[0].ToUpper() == "NULL") { specialCtrl.InputInfo[inputIndex++][0] = null; } } if (unConnectNum <= 0) {//当前控件所需输入数量满足则返回 return; } } } }
/// <summary> /// Получить информацию об элементах управления из словаря /// </summary> private static Dictionary<string, ControlInfo> GetControlInfoDict(Dict dict) { Dictionary<string, ControlInfo> controlInfoDict = new Dictionary<string, ControlInfo>(); foreach (string phraseKey in dict.Phrases.Keys) { string phraseVal = dict.Phrases[phraseKey]; int dotPos = phraseKey.IndexOf('.'); if (dotPos < 0) { // если точки в ключе фразы нет, то присваивается свойство текст if (controlInfoDict.ContainsKey(phraseKey)) controlInfoDict[phraseKey].Text = phraseVal; else controlInfoDict[phraseKey] = new ControlInfo() { Text = phraseVal }; } else if (0 < dotPos && dotPos < phraseKey.Length - 1) { // если точка в середине ключа фразы, то слева от точки - имя элемента, справа - свойство string ctrlName = phraseKey.Substring(0, dotPos); string ctrlProp = phraseKey.Substring(dotPos + 1); bool propAssigned = true; ControlInfo controlInfo; if (!controlInfoDict.TryGetValue(ctrlName, out controlInfo)) controlInfo = new ControlInfo(); if (ctrlProp == "Text") { controlInfo.Text = phraseVal; } else if (ctrlProp == "ToolTip") { controlInfo.ToolTip = phraseVal; } else if (ctrlProp.StartsWith("Items[")) { int pos = ctrlProp.IndexOf(']'); int ind; if (pos >= 0 && int.TryParse(ctrlProp.Substring(6, pos - 6), out ind)) controlInfo.SetItem(ind, phraseVal); } else { propAssigned = false; } if (propAssigned) controlInfoDict[ctrlName] = controlInfo; } } return controlInfoDict; }
public ControlVariation(ControlInfo ctrl, int newLeft, int newTop, int newWidth, int newHeight) { Control = ctrl; NewTop = newTop; NewLeft = newLeft; NewWidth = newWidth; NewHeight = newHeight; }
//------------------------------------------------------------------------------------- private void ControlGotFocus(ControlInfo ci) { if(followControlFocus == false) return; foreach(DataGridViewRow r in Rows) if(GetControl(r.Index) == ci) { this.CurrentCell = this[0, r.Index]; break; } }
/*/// <summary> * /// Gets the current scale multiplier for the specified control. * /// </summary> * /// <param name="control">The control whose multiplier to return.</param> * public static SizeF GetMultiplier(Control control) { * while (control != null) { * LockHandler.EnterReadLock(); * try { * if (Excluded.Contains(control)) * return One; * } finally { * LockHandler.ExitReadLock(); * } * lock (SyncRoot) { * if (Included.Contains(control)) { * Rectangle originalBounds = PreviousBounds[control].OriginalBounds; * return new SizeF(control.Width / (float) originalBounds.Width, control.Height / (float) originalBounds.Height); * } else * control = control.Parent; * } * } * return One; * }*/ private static void Scale(Control control, float xMult, float yMult, bool isExcludedCheck, bool scaleBounds, bool scaleFont) { if (IsExcluded(control, isExcludedCheck)) { return; } ControlInfo info; float fontSize = control.Font.Size; Rectangle bounds = control.Bounds; if (!PreviousBounds.TryGetValue(control, out info)) { info = new ControlInfo(bounds, fontSize); } if (!scaleBounds) { bool excludeSize; lock (SyncRoot) excludeSize = ExcludeSize.Contains(control); if (bounds != info.LastBounds) { if (bounds.X != 0) { info.OriginalBounds.X *= bounds.X / (float)info.LastBounds.X; } if (bounds.Y != 0) { info.OriginalBounds.Y *= bounds.Y / (float)info.LastBounds.Y; } if (!excludeSize) { if (bounds.Width != 0) { info.OriginalBounds.Width *= bounds.Width / (float)info.LastBounds.Width; } if (bounds.Height != 0) { info.OriginalBounds.Height *= bounds.Height / (float)info.LastBounds.Height; } } info.LastBounds = bounds; } bounds = new Rectangle((int)Math.Round(info.OriginalBounds.X * xMult), (int)Math.Round(info.OriginalBounds.Y * yMult), (int)Math.Round(info.OriginalBounds.Width * xMult), (int)Math.Round(info.OriginalBounds.Height * yMult)); if (excludeSize) { control.Location = bounds.Location; } else { control.Bounds = bounds; } info.LastBounds = bounds; } bool excludeFont; lock (SyncRoot) excludeFont = ExcludeFont.Contains(control); if (!excludeFont) { if (Math.Abs(fontSize - info.LastFontSize) >= 0.01f) { info.OriginalFontSize *= fontSize / info.LastFontSize; } fontSize = info.OriginalFontSize * Math.Min(xMult, yMult); if (fontSize != 0f) { control.Font = new Font(control.Font.Name, fontSize); info.LastFontSize = fontSize; } } PreviousBounds.AddOrUpdate(control, info, (ctrl, sz) => info); foreach (Control child in control.Controls) { Scale(child, xMult, yMult, false, true, true); } }
//------------------------------------------------------------------------------------- private void ControlSizeChanged(ControlInfo ci) { if(ci.Opened == false || ci.Height != 0) return; foreach(DataGridViewRow r in Rows) if(GetControl(r.Index) == ci) { int h = ci.Control.Height > cMaxHeight ? cMaxHeight : ci.Control.Height; r.Height = this.RowTemplate.Height + h; break; } }
//------------------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <param name="e"></param> protected override void OnCellMouseDown(DataGridViewCellMouseEventArgs e) { base.OnCellMouseDown(e); int rowIndex = e.RowIndex; Rectangle r = this.RectangleToScreen(this.GetCellDisplayRectangle(e.ColumnIndex, rowIndex, true)); //r.Y += 3; //r.Height -= 6; Image img = Properties.Resources.TreeBtn_Plus; r.X += Math.Abs(r.Width-img.Width)/2; r.Width = img.Width; r.Y += Math.Abs(this.RowTemplate.Height - img.Height)/2; r.Height = img.Height; if(e.ColumnIndex != -1 || rowIndex == -1 || e.Button != System.Windows.Forms.MouseButtons.Left || r.Contains(Control.MousePosition) == false) return; ControlInfo ci = GetControl(e.RowIndex); object data = Rows[e.RowIndex].GetData(); if(ci == null) { if(IsHasControl(e.RowIndex, data)) { Control c = OnNeedControl(rowIndex, data); if(c == null) { base.OnCellMouseDown(e); return; } ci = new ControlInfo() { Owner = this, Control = c }; index.Add(data, ci); } else { base.OnCellMouseDown(e); return; } } if(ci.Opened) { ci.Opened = false; Rows[rowIndex].MinimumHeight = 2; Rows[rowIndex].Height = this.RowTemplate.Height; Rows[rowIndex].Resizable = DataGridViewTriState.False; OnRowCollapsed(e.RowIndex, data); if(removeControlOnRowCollapce) { this.Controls.Remove(ci.Control); ci.OnDelete(); index.Remove(data); } } else { int h = ci.Height == 0 ? (ci.Control.Height > cMaxHeight ? cMaxHeight : ci.Control.Height) : ci.Height; ci.Opened = true; Rows[rowIndex].Height = this.RowTemplate.Height + h; Rows[rowIndex].Resizable = this.AllowUserToResizeRows ? DataGridViewTriState.True : DataGridViewTriState.False; Rows[rowIndex].MinimumHeight = this.RowTemplate.Height * 2; OnRowExpanded(e.RowIndex, data); } }
// 填充关系列表 int FillRelationList(out string strError) { strError = ""; ClearRelationList(); foreach(Relation relation in this._relationCollection) { foreach (string key in relation.Keys) { ControlInfo info = new ControlInfo(); info.Relation = relation; string strKey = key; if (relation.DbName.StartsWith("DDC") == true) strKey = strKey.Replace("/", ""); else if (relation.DbName.StartsWith("LCC") == true) { //string strSave = strKey; strKey = CanonicalizeLCC(strKey); //if (strSave != strKey) // MessageBox.Show(this, "old=" + strSave + ",new=" + strKey); } RelationControl control = new RelationControl(); control.Tag = info; control.TitleText = relation.DbName; if (string.IsNullOrEmpty(relation.Color) == false) control.TitleBackColor = ColorUtil.String2Color(relation.Color); control.SourceTextOrigin = strKey; control.SourceText = strKey; control.BackColor = SystemColors.Window; AddEvents(control, true); this.flowLayoutPanel_relationList.Controls.Add(control); } } return 0; }
//*************** END new stuff private void RemoveControl(ControlInfo control) { RemoveControlFromList(control, _form.QuickForm.Elements); }
/// <summary> /// �ӿؼ���Ϣ�л�ȡ��ʾ��Ϣ /// �������index��-1�ض�Ӧ��ŵIJ�����ʾ��Ϣ /// �������в�������ʾ��Ϣ /// </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) {//����ȫ���IJ�����Ϣ 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; }
private void RemoveControlFromList(ControlInfo control, IList<QuickFormElement> controls) { foreach (QuickFormElement qfe in controls) { if (qfe.Control == control.QfControl) { int i = controls.IndexOf(qfe); if (i >= 0) { controls.RemoveAt(i); } //controls.Remove(qfe); break; } if (qfe.Control is IQuickFormsControlContainer) { IQuickFormsControlContainer container = qfe.Control as IQuickFormsControlContainer; IList<IControlSurface> lst = container.GetControlSurfaces(); if (lst != null) { foreach (IControlSurface surface in lst) { RemoveControlFromList(control, surface.Controls); } } } } }
/// <summary> /// 从XML文件中获取指令及其参数的描述信息 /// 注:与CASSVIEW的添加控件类似 需要优化或统一 /// </summary> static public void GetInfomation() { SunningCodes.Clear(); CtrlPropertys.Clear(); foreach (XmlNode categoryNode in ToolBoxServiceImpl.toolXML.FirstChild.ChildNodes) { if (categoryNode != null && categoryNode.Attributes[0].InnerText != CassViewGenerator.SpecialCodeNode) { foreach (XmlNode toolItemNode in categoryNode.ChildNodes) { ControlInfo ctrlStruct = new ControlInfo(); ctrlStruct.CodeInfo = new string[3]; if (toolItemNode.FirstChild.Name == "BasicProperty") { foreach (XmlNode property in toolItemNode.FirstChild.ChildNodes) {//基本信息中加入ModuleName和ModuleSort if (property.Attributes["name"].Value == "ModuleName") { //if (property.InnerText == "CALCU" || property.InnerText == "PROCESS") //{//跳过计算器组态和条件动作表控件 // break; //} ctrlStruct.CodeInfo[1] = property.InnerText; } else if (property.Attributes["name"].Value == "ModuleSort") { ctrlStruct.SortName = property.InnerText; ctrlStruct.CodeInfo[0] = property.InnerText; if (CassView.OnlyOneIn.Contains(property.InnerText)) { List<string[]> tempInfo = new List<string[]>(); tempInfo.Add(new string[4] { null, null, null, "0" }); ctrlStruct.InputInfo = tempInfo; ctrlStruct.OutputInfo = CassView.InitializeIOinfo(0); } else if (CassView.OnlyOneOut.Contains(property.InnerText)) { ctrlStruct.OutputInfo = CassView.InitializeIOinfo(1); ctrlStruct.InputInfo = CassView.InitializeIOinfo(0); } } else if (property.Attributes["name"].Value == "OutputName") { //初始化输出口信息 if (property.InnerText != "NULL") { ctrlStruct.OutputInfo = CassView.InitializeIOinfo(property.InnerText.Split(',').Length); } else { ctrlStruct.OutputInfo = new List<string[]>(); } } else if (property.Attributes["name"].Value == "InputName") { if (property.ChildNodes.Count > 1) { List<string[]> Inputinfo = new List<string[]>(); foreach (XmlNode info in property.ChildNodes) { string[] Ininfo = new string[4]; Ininfo[2] = info.Attributes["name"].Value; Ininfo[3] = info.InnerText; Inputinfo.Add(Ininfo); } ctrlStruct.InputInfo = Inputinfo; } else if (property.InnerText != "NULL") { ctrlStruct.InputInfo = CassView.InitializeIOinfo(property.InnerText.Split(',').Length); } else { ctrlStruct.InputInfo = new List<string[]>(); } } } } if (ctrlStruct.CodeInfo[1] == null && GenerateCode.SortCtrlName.Contains(ctrlStruct.SortName)) {//跳过注释控件 ctrlStruct.CodeInfo[1] = GenerateCode.CodeCtrlName[GenerateCode.SortCtrlName.IndexOf(ctrlStruct.SortName)]; } //读入功能属性 if (toolItemNode.FirstChild.NextSibling.Name == "FunctionProperty") { CassView.ReadFunctionProperty(toolItemNode.FirstChild.NextSibling, ref ctrlStruct); } //读入代码信息 if ((toolItemNode.LastChild.Name == "CodeProperty" || toolItemNode.LastChild.Name == "OtherInfo") && toolItemNode.LastChild.ChildNodes.Count > 0) { CassView.ReadOtherProperty(toolItemNode.LastChild, ref ctrlStruct); } if (ctrlStruct.CodeInfo[1] != null && ctrlStruct.SortName != null) { SunningCodes.Add(ctrlStruct.CodeInfo[1], ctrlStruct.SortName); CtrlPropertys.Add(ctrlStruct.CodeInfo[1], ctrlStruct); } } } } }
internal List<ControlInfo> GetControls () { List<ControlInfo> list = new List<ControlInfo>(); foreach (KeyValuePair <object, int> control in columns) { ControlInfo info = new ControlInfo(); info.Control = control.Key; info.Col = GetColumn(control.Key); info.ColSpan = GetColumnSpan (control.Key); info.Row = GetRow (control.Key); info.RowSpan = GetRowSpan (control.Key); list.Add (info); } return list; }
private bool DoValidate(ControlInfo info) { var result = info.Rule.Validate(info.Adapter.EditValue); var errorText = result ? "" : info.Rule.ErrorText; this.ErrorProvider.SetError(info.Adapter.Control, errorText); return result; }