Пример #1
0
        /// <summary>
        /// Returns a clone of the current SignalFormatProperties object
        /// </summary>
        /// <returns>Clone of the current SignalFormatProperties object</returns>
        public SignalFormatProperties Get_Clone()
        {
            SignalFormatProperties oClone = new SignalFormatProperties();

            oClone.FormatType = this.FormatType;
            oClone.Decimals   = this.Decimals;

            oClone.Enums = new List <EnumerationValue>();
            foreach (EnumerationValue sEnum in this.Enums)
            {
                oClone.Enums.Add(sEnum);
            }

            if (!(sControlProperties == null))
            {
                SignalControlFormatProperties sCtrlProps = new SignalControlFormatProperties();

                sCtrlProps.Text      = sControlProperties.Value.Text;
                sCtrlProps.On_Value  = sControlProperties.Value.On_Value;
                sCtrlProps.Off_Value = sControlProperties.Value.Off_Value;

                oClone.sControlProperties = sCtrlProps;
            }

            return(oClone);
        }
        public Frm_ParamControlFormatProperties(SignalFormatProperties oFormat, SignalValueFormat SelectedFormat)
        {
            string DefaultText = "";

            InitializeComponent();

            switch (SelectedFormat)
            {
            case SignalValueFormat.Button:

                Lbl_CtrlOnValue.Text  = "Control ON Value (Pressed)";
                Lbl_CtrlOffValue.Text = "Control OFF Value (Released)";

                DefaultText = "Button";

                break;

            case SignalValueFormat.Checkbox:

                Lbl_CtrlOnValue.Text  = "Control ON Value (Checked)";
                Lbl_CtrlOffValue.Text = "Control OFF Value (Unchecked)";

                DefaultText = "Checkbox";

                break;

            default:

                Lbl_CtrlText.Enabled = false;
                Txt_CtrlText.Enabled = false;

                Lbl_CtrlOnValue.Enabled = false;
                Txt_CtrlOnValue.Enabled = false;

                Lbl_CtrlOffValue.Enabled = false;
                Txt_CtrlOffValue.Enabled = false;

                Cmd_OK.Enabled = false;

                break;
            }

            oRefFormat = oFormat;

            FrmClosing = false;

            if (oFormat.sControlProperties.HasValue)
            {
                Txt_CtrlText.Text     = oFormat.sControlProperties.Value.Text;
                Txt_CtrlOnValue.Text  = oFormat.sControlProperties.Value.On_Value.ToString();
                Txt_CtrlOffValue.Text = oFormat.sControlProperties.Value.Off_Value.ToString();
            }
            else
            {
                Txt_CtrlText.Text     = DefaultText;
                Txt_CtrlOnValue.Text  = "1";
                Txt_CtrlOffValue.Text = "0";
            }
        }
        public Frm_ParamEnumerationEdition(SignalFormatProperties oFormat)
        {
            InitializeComponent();

            oRefFormat     = oFormat;
            oCurrentFormat = oRefFormat.Get_Clone();

            NextEnumValue = 0;
            FrmClosing    = false;
            FrmMessageBox = false;

            Show_EnumValues();
        }
Пример #4
0
        /// <summary>
        /// Convert a CANStream SignalFormatProperties class into a Ctrl_GraphWindow GraphSerieValueFormat class
        /// </summary>
        /// <param name="oSigFormat">CANStream SignalFormatProperties object to convert</param>
        /// <returns>Ctrl_GraphWindow GraphSerieValueFormat object</returns>
        public static GraphSerieValueFormat Convert_CSSignalFormatToSerieValueFormat(SignalFormatProperties oSigFormat)
        {
            GraphSerieValueFormat oSerieFormat = new GraphSerieValueFormat();

            switch (oSigFormat.FormatType)
            {
            case SignalValueFormat.Binary:

                oSerieFormat.Format = GraphSerieLegendFormats.Binary;
                break;

            case SignalValueFormat.Decimal:

                oSerieFormat.Format   = GraphSerieLegendFormats.Decimal;
                oSerieFormat.Decimals = oSigFormat.Decimals;
                break;

            case SignalValueFormat.Enum:

                oSerieFormat.Format = GraphSerieLegendFormats.Enum;

                foreach (EnumerationValue sSigEnum in oSigFormat.Enums)
                {
                    GraphSerieEnumValue sSerieEnum = new GraphSerieEnumValue();

                    sSerieEnum.Value = sSigEnum.Value;
                    sSerieEnum.Text  = sSigEnum.Text;

                    oSerieFormat.Enums.Add(sSerieEnum);
                }

                break;

            case SignalValueFormat.Hexadecimal:

                oSerieFormat.Format = GraphSerieLegendFormats.Hexadecimal;
                break;

            default:

                oSerieFormat.Format = GraphSerieLegendFormats.Auto;
                break;
            }

            return(oSerieFormat);
        }
        private bool Set_EnumValues()
        {
            SignalFormatProperties oBackupFormat = oCurrentFormat.Get_Clone();

            oCurrentFormat.Enums.Clear();

            foreach (DataGridViewRow oRow in Grid_Enum.Rows)
            {
                EnumerationValue sEnum = new EnumerationValue();

                int EnumVal;
                if (!(oRow.Cells[0].Value == null))
                {
                    if (int.TryParse(oRow.Cells[0].Value.ToString(), out EnumVal))
                    {
                        if (!(EnumValueExists(EnumVal)))
                        {
                            sEnum.Value = EnumVal;
                        }
                        else
                        {
                            oCurrentFormat = oBackupFormat.Get_Clone();
                            MessageBox.Show("Enumeration value '" + EnumVal.ToString() + "' is defined twice !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return(false);
                        }
                    }
                    else
                    {
                        oCurrentFormat = oBackupFormat.Get_Clone();
                        MessageBox.Show("An enumeration value must be a numerical value !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }
                else
                {
                    oCurrentFormat = oBackupFormat.Get_Clone();
                    MessageBox.Show("An enumeration value cannot be empty !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }


                string EnumTxt;
                if (!(oRow.Cells[1].Value == null))
                {
                    EnumTxt = oRow.Cells[1].Value.ToString();
                    if (!(EnumTextExists(EnumTxt)))
                    {
                        sEnum.Text = EnumTxt;
                    }
                    else
                    {
                        oCurrentFormat = oBackupFormat.Get_Clone();
                        MessageBox.Show("Enumeration text '" + EnumTxt + "' is defined twice !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }
                else
                {
                    oCurrentFormat = oBackupFormat.Get_Clone();
                    MessageBox.Show("An enumeration text cannot be empty !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }

                oCurrentFormat.Enums.Add(sEnum);
            }

            return(true);
        }