Пример #1
0
        /// <summary>
        /// 保存函数
        /// </summary>
        public void SaveData()
        {
            if (this.Tag == null || skillAnalysisData == null)
            {
                return;
            }
            string id = (string)this.Tag;

            Panel[] panels = FlowLayoutPanel_Release_Other.Controls.OfType <Panel>().ToArray();
            foreach (Panel panel in panels)
            {
                ItemStruct itemStruct = panel.Tag as ItemStruct;
                if (itemStruct == null || string.IsNullOrEmpty(itemStruct.Tag))
                {
                    continue;
                }
                //判断条件
                Control control = panel.Controls.Find("ItemControl", false).FirstOrDefault();
                if (control != null)
                {
                    //是否是数组
                    if (itemStruct.IsArray)
                    {
                        IChildControlType iChildControlType = control as IChildControlType;
                        if (iChildControlType != null)
                        {
                            skillAnalysisData.SetValues(id, itemStruct.Tag, iChildControlType.TextValues);
                        }
                    }
                    else
                    {
                        ITextValue iTextValue = control as ITextValue;
                        if (iTextValue != null)
                        {
                            skillAnalysisData.SetValue(id, itemStruct.Tag, iTextValue.TextValue);
                        }
                        else
                        {
                            skillAnalysisData.SetValue(id, itemStruct.Tag, control.Text);
                        }
                    }
                }
            }
        }
Пример #2
0
 public virtual string ConvertValueToString(ITextValue value, RelationalOperators appendWildCardOperators = 0)
 {
     return(GetCheckedTextValueString(AppendWildcard(value.Value, appendWildCardOperators)));
 }
Пример #3
0
        /// <summary>
        /// 更新Item
        /// </summary>
        /// <param name="mustUpdateData">必须更新数据</param>
        public void UpdateItems(bool mustUpdateData = false)
        {
            Panel[] panels    = FlowLayoutPanel_Release_Other.Controls.OfType <Panel>().ToArray();
            int     outHeight = panels.Length * 3 * 2;

            foreach (Panel panel in panels)
            {
                ItemStruct itemStruct = panel.Tag as ItemStruct;
                if (itemStruct == null)
                {
                    FlowLayoutPanel_Release_Other.Controls.Remove(panel);
                }
                else
                {
                    //判断条件
                    if (itemStruct.ControlType != null && !string.IsNullOrEmpty(itemStruct.Label))
                    {
                        int maxHeight = 1;
                        //设置控件的说明
                        Label tempLabelControl = panel.Controls.OfType <Label>().Where(temp => string.Equals(temp.Name, "Label_Show")).FirstOrDefault();
                        if (tempLabelControl == null)
                        {
                            tempLabelControl = new Label();
                            panel.Controls.Add(tempLabelControl);
                            tempLabelControl.Name        = "Label_Show";
                            tempLabelControl.Text        = itemStruct.Label;
                            tempLabelControl.AutoSize    = true;
                            tempLabelControl.MaximumSize = new Size(150, 0);
                            //tempLabelControl.Width = panel.Size.Width / 2;
                            tempLabelControl.Location = new Point(3, 3);
                        }
                        else
                        {
                            tempLabelControl.Text = itemStruct.Label;
                        }
                        maxHeight = tempLabelControl.Height;
                        //设置控件的子控件
                        Control control       = panel.Controls.Find("ItemControl", false).FirstOrDefault();
                        int     controlHeight = 30;
                        if (control == null && itemStruct.ControlType.IsSubclassOf(typeof(Control)))
                        {
                            control = Activator.CreateInstance(itemStruct.ControlType) as Control;
                            panel.Controls.Add(control);
                            control.Name     = "ItemControl";
                            control.Location = new Point(9 + tempLabelControl.Width, 3);
                        }
                        if (control != null)
                        {
                            control.Tag = itemStruct.Tag;
                            ITypeTag iTypeTag = control as ITypeTag;
                            if (iTypeTag != null)
                            {
                                if (!string.Equals(iTypeTag.TypeTag, itemStruct.TypeTag) || mustUpdateData)
                                {
                                    iTypeTag.TypeTag = itemStruct.TypeTag;
                                    //是否不是数组
                                    if (!itemStruct.IsArray)
                                    {
                                        ITextValue iTextValue = control as ITextValue;
                                        if (skillAnalysisData != null && this.Tag != null)
                                        {
                                            string tempValue = skillAnalysisData.GetValue <string>(this.Tag.ToString(), itemStruct.Tag);
                                            if (iTextValue != null)
                                            {
                                                iTextValue.TextValue = tempValue;
                                            }
                                            else
                                            {
                                                control.Text = tempValue;
                                            }
                                            mustUpdateData = false;
                                        }
                                    }
                                }
                            }
                            IChildControlType iChildControlType = control as IChildControlType;
                            if (iChildControlType != null)
                            {
                                controlHeight *= itemStruct.ChildCount;
                                if (!string.Equals(iChildControlType.ChildControlType, itemStruct.ChildControlType) || mustUpdateData)
                                {
                                    iChildControlType.TextValues       = new string[itemStruct.ChildCount];
                                    iChildControlType.ChildControlType = itemStruct.ChildControlType;
                                    //是否是数组
                                    if (itemStruct.IsArray)
                                    {
                                        if (skillAnalysisData != null && this.Tag != null)
                                        {
                                            string[] tempValues = skillAnalysisData.GetValues <string>(this.Tag.ToString(), itemStruct.Tag);
                                            if (tempValues == null)
                                            {
                                                tempValues = new string[0];
                                            }
                                            string[] resultValues = new string[itemStruct.ChildCount];
                                            int      index        = 0;
                                            while (index < tempValues.Length && index < resultValues.Length)
                                            {
                                                resultValues[index] = tempValues[index];
                                                index++;
                                            }
                                            iChildControlType.TextValues = resultValues;
                                            mustUpdateData = false;
                                        }
                                    }
                                }
                                else if (iChildControlType.TextValues.Length != itemStruct.ChildCount || mustUpdateData)
                                {
                                    string[] tempValues = null;
                                    if (this.Tag != null)
                                    {
                                        tempValues = skillAnalysisData.GetValues <string>(this.Tag.ToString(), itemStruct.Tag);
                                    }
                                    if (tempValues == null)
                                    {
                                        tempValues = new string[0];
                                    }
                                    string[] resultValues = new string[itemStruct.ChildCount];
                                    string[] nowValues    = iChildControlType.TextValues;
                                    for (int i = 0; i < itemStruct.ChildCount; i++)
                                    {
                                        if (i < nowValues.Length)
                                        {
                                            resultValues[i] = nowValues[i];
                                            continue;
                                        }
                                        if (i < tempValues.Length)
                                        {
                                            resultValues[i] = tempValues[i];
                                        }
                                    }
                                    iChildControlType.TextValues = resultValues;
                                    mustUpdateData = false;
                                }
                            }
                            maxHeight = maxHeight > controlHeight ? maxHeight : controlHeight;
                        }

                        //设置父控件大小
                        panel.Size = new Size(FlowLayoutPanel_Release_Other.Width - 7, maxHeight + 6);
                        outHeight += maxHeight + 6;
                        //设置自身控件的大小
                        control.Size = new Size(panel.Size.Width - (12 + tempLabelControl.Width), controlHeight);
                    }
                    else
                    {
                        panel.Controls.Clear();
                        panel.Size = new Size(1, 1);
                    }
                }
            }
            FlowLayoutPanel_Release_Other.Size = new Size(FlowLayoutPanel_Release_Other.Size.Width, outHeight);
        }