Пример #1
0
 public void Set( ParameterSearchValue param )
 {
     labelGroup.Text = param.group;
     labelParameterName.Text = param.parameterName;
     switch( param.valueType )
     {
         case ParameterSearchValue.TYPE_INT:
             labelType.Text = ParameterSearchValue.STRING_TYPE_INT;
             labelValue.Text = Convert.ToString(param.value1_int);
             if (param.range)
             {
                 labelValue2.Text = Convert.ToString(param.value2_int);
             }
             break;
         case ParameterSearchValue.TYPE_BOOL:
             labelType.Text = ParameterSearchValue.STRING_TYPE_BOOL;
             labelValue.Text = Convert.ToString(param.value_bool);
             break;
         case ParameterSearchValue.TYPE_DOUBLE:
             labelType.Text = ParameterSearchValue.STRING_TYPE_DOUBLE;
             labelValue.Text = Convert.ToString(param.value1_double);
             if (param.range)
             {
                 labelValue2.Text = Convert.ToString(param.value2_double);
             }
             break;
         case ParameterSearchValue.TYPE_TEXT:
             labelType.Text = ParameterSearchValue.STRING_TYPE_TEXT;
             labelValue.Text = Convert.ToString(param.value_string);
             break;
     }
 }
Пример #2
0
 public void AddParameterView(ParameterSearchValue param)
 {
     ParameterView parameterView = new ParameterView(this, param);
     this.panel1.Controls.Add(parameterView);
     if (this.panel1.Controls.Count * 17 + 18 > this.Size.Height)
     {
         this.tableLayoutPanel1.ColumnStyles[5].Width = 20F;
     }
     parameterViewsList.Add(parameterView);
 }
Пример #3
0
 public ParameterView(ParameterViewList _owner, ParameterSearchValue param)
 {
     InitializeComponent();
     owner = _owner;
     this.Size = new System.Drawing.Size(this.Size.Width, 17);
     this.Dock = DockStyle.Top;
     this.BackColor = System.Drawing.Color.White;
     parameter = param;
     Set(param);
 }
Пример #4
0
        public bool CompareToParameterSearchValue(ParameterSearchValue param)
        {
            XmlDocument doc = new XmlDocument();
            doc.InnerXml = Content;
            XmlNodeList xmlList = doc.DocumentElement.GetElementsByTagName("GROUP");

            foreach (XmlNode node in xmlList)
            {
                string groupName = ((XmlElement)node).GetAttribute("NAME");

                if (groupName == null || !groupName.Contains(param.group))
                {
                    continue;
                }

                XmlNodeList paramList = ((XmlElement)node).GetElementsByTagName("PARAM");
                foreach (XmlNode parameter in paramList)
                {
                    string parameterName = ((XmlElement)parameter).GetAttribute("NAME");

                    if (parameterName == null || !parameterName.Contains(param.parameterName))
                    {
                        continue;
                    }

                    string value = ((XmlElement)parameter).GetAttribute("VALUE");

                    if (value == null)
                    {
                        continue;
                    }

                    switch (param.valueType)
                    {
                        case (ParameterSearchValue.TYPE_INT):
                            int value_int;
                            try
                            {
                                value_int = Convert.ToInt32(value);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                            if (param.range)
                            {
                                if (value_int > param.value1_int && value_int < param.value2_int)
                                {
                                    return true;
                                }
                            }
                            else if (value_int == param.value1_int)
                            {
                                return true;
                            }
                            break;
                        case (ParameterSearchValue.TYPE_DOUBLE):
                            double value_double;
                            try
                            {
                                value_double = Convert.ToDouble(value.Replace(".", ","));
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                            if (param.range)
                            {
                                if (value_double > param.value1_double && value_double < param.value2_double)
                                {
                                    return true;
                                }
                            }
                            else if (value_double == param.value1_double)
                            {
                                return true;
                            }
                            break;
                        case (ParameterSearchValue.TYPE_BOOL):
                            bool value_bool;
                            try
                            {
                                value_bool = Convert.ToBoolean(value);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                            if (value_bool == param.value_bool)
                            {
                                return true;
                            }
                            break;
                        case (ParameterSearchValue.TYPE_TEXT):
                            if (value == param.value_string)
                            {
                                return true;
                            }
                            break;
                    }
                }
            }
            return false;
        }
Пример #5
0
 public void RemoveParameter(ParameterSearchValue param)
 {
     parameters.Remove(param);
 }
Пример #6
0
 public void AddParameter(ParameterSearchValue param)
 {
     parameters.Add( param );
 }
Пример #7
0
        private void buttonSearchAddParameter_Click(object sender, EventArgs e)
        {
            ParameterSearchValue param = new ParameterSearchValue();
            param.group = comboBoxSearchParameterGroup.Text;
            param.parameterName = comboBoxSearchParameterName.Text;
            param.range = radioButtonSearchParameterRange.Checked;

            string selectedType = (string)labelSearchParameterType.Text;
            if ((string)selectedType == ParameterSearchValue.STRING_TYPE_INT)
            {
                param.valueType = ParameterSearchValue.TYPE_INT;
                try
                {
                    param.value1_int = Convert.ToInt32(textBoxSearchParameterValue1.Text);
                    if (radioButtonSearchParameterRange.Checked)
                    {
                        param.value2_int = Convert.ToInt32(textBoxSearchParameterValue2.Text);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("One or both values are not integers", "Error", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
            }
            else if ((string)selectedType == ParameterSearchValue.STRING_TYPE_DOUBLE)
            {
                param.valueType = ParameterSearchValue.TYPE_DOUBLE;
                try
                {
                    param.value1_double = Convert.ToDouble(textBoxSearchParameterValue1.Text);
                    if (radioButtonSearchParameterRange.Checked)
                    {
                        param.value2_double = Convert.ToDouble(textBoxSearchParameterValue2.Text);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("One or both values are not floating point numbers", "Error", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
            }
            else if ((string)selectedType == ParameterSearchValue.STRING_TYPE_BOOL)
            {
                param.valueType = ParameterSearchValue.TYPE_BOOL;
                try
                {
                    param.value_bool = Convert.ToBoolean(textBoxSearchParameterValue1.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Value is not of boolean type", "Error", MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }
            }
            else if ((string)selectedType == ParameterSearchValue.STRING_TYPE_TEXT)
            {
                param.valueType = ParameterSearchValue.TYPE_TEXT;
                param.value_string = textBoxSearchParameterValue1.Text;
            }

            ClearSearchParameterTextBoxes();

            this.parameterViewList.AddParameterView(param);
            searchingParameters.AddParameter(param);
        }