Ejemplo n.º 1
0
        private TextBox CreateTextBox(Camera.ParamDesc paramDesc, int currentRow)
        {
            TextBox textBoxValue = new TextBox();

            textBoxValue.Name   = paramDesc.Name + VALUE_SUFFIX;
            textBoxValue.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            textBoxValue.Height = LabelFont.Height;
            textBoxValue.Font   = LabelFont;
            if (paramDesc.IsReadable)
            {
                try
                {
                    textBoxValue.Text = paramDesc.Value.ToString();
                }
                catch (Exception ex)
                {
                    CreateWarningLabel(paramDesc, ex, currentRow);
                }
            }
            if (!paramDesc.IsWritable)
            {
                textBoxValue.Enabled = false;
            }

            return(textBoxValue);
        }
Ejemplo n.º 2
0
        private CheckBox CreateCheckBox(Camera.ParamDesc <bool> paramDesc, int currentRow)
        {
            CheckBox checkBoxValue = new CheckBox();

            checkBoxValue.Name   = paramDesc.Name + VALUE_SUFFIX;
            checkBoxValue.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            checkBoxValue.Height = (int)(LabelFont.Height * 2f);
            checkBoxValue.Text   = paramDesc.Description;

            if (paramDesc.IsReadable)
            {
                try
                {
                    checkBoxValue.Checked = (bool)paramDesc.Value;
                }
                catch (Exception ex)
                {
                    CreateWarningLabel(paramDesc, ex, currentRow);
                }
            }
            if (!paramDesc.IsWritable)
            {
                checkBoxValue.Enabled = false;
            }

            return(checkBoxValue);
        }
Ejemplo n.º 3
0
        private Label CreateNameLabel(Camera.ParamDesc paramDesc)
        {
            Label labelName = new Label();

            labelName.Font      = LabelFont;
            labelName.Name      = paramDesc.Name + "_label";
            labelName.Text      = SeperateString(paramDesc.Name) + ":";
            labelName.ForeColor = TextColor;
            labelName.AutoSize  = true;
            labelName.Anchor    = AnchorStyles.Right;
            labelName.Enabled   = paramDesc.IsWritable;

            return(labelName);
        }
Ejemplo n.º 4
0
        private ComboBox CreateComboBox(Camera.IListParamDesc listParamDesc, int currentRow)
        {
            Camera.ParamDesc paramDesc     = (Camera.ParamDesc)listParamDesc;
            ComboBox         comboBoxValue = new ComboBox();

            comboBoxValue.Name   = paramDesc.Name + VALUE_SUFFIX;
            comboBoxValue.Height = LabelFont.Height;
            comboBoxValue.Font   = LabelFont;
            comboBoxValue.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            if (paramDesc.IsReadable)
            {
                for (int i = 0; i < listParamDesc.AllowedValues.Count; i++)
                {
                    var item = listParamDesc.AllowedValues[i];
                    comboBoxValue.Items.Add(item.ToString(CultureInfo.InvariantCulture));
                    if (paramDesc.Type.IsEnum)
                    {
                        if (paramDesc.Value.ToString() == item)
                        {
                            comboBoxValue.SelectedIndex = i;
                        }
                    }
                    else
                    {
                        object tmpVal;

                        if (paramDesc is Camera.ListParamDesc <Point2i> )
                        {
                            tmpVal = ResolutionToPoint2i(item);
                        }
                        else
                        {
                            tmpVal = Convert.ChangeType(item, paramDesc.Type, CultureInfo.InvariantCulture);
                        }

                        if (null != tmpVal && paramDesc.Value.Equals(tmpVal))
                        {
                            comboBoxValue.SelectedIndex = i;
                        }
                    }
                }
            }
            if (!paramDesc.IsWritable)
            {
                comboBoxValue.Enabled = false;
            }

            return(comboBoxValue);
        }
Ejemplo n.º 5
0
        private void CreateWarningLabel(Camera.ParamDesc paramDesc, Exception ex, int currentRow)
        {
            //WarningControl wc = new WarningControl();
            Label warningLabel = new Label();

            warningLabel.Name      = paramDesc.Name + "_warn";
            warningLabel.Size      = new System.Drawing.Size(20, 20);
            warningLabel.Visible   = true;
            warningLabel.Text      = "!";
            warningLabel.BackColor = Color.Orange;
            if (ex.InnerException != null)
            {
                warningLabel.Text = ex.InnerException.Message;
            }

            tableLayoutPanel1.Controls.Add(warningLabel, 0, currentRow);
        }
Ejemplo n.º 6
0
        private Label CreateUnitLabel(Camera.ParamDesc paramDesc)
        {
            string unitText = "";

            if (null != paramDesc && null != paramDesc.Unit)
            {
                unitText = paramDesc.Unit.ToString(CultureInfo.InvariantCulture);
            }

            Label labelUnit = new Label();

            labelUnit.Font      = LabelFont;
            labelUnit.Name      = paramDesc.Name + "_unit";
            labelUnit.Text      = unitText;
            labelUnit.ForeColor = TextColor;
            labelUnit.AutoSize  = true;
            labelUnit.Anchor    = AnchorStyles.Left;
            labelUnit.Enabled   = paramDesc.IsWritable;

            return(labelUnit);
        }