private void btnLimit_Click(object sender, EventArgs e)
 {
     var form = new LimitForm();
     form.Limit = _limit;
     if (DialogResult.OK == form.ShowDialog())
     {
         Limit = form.Limit;
     }
 }
Esempio n. 2
0
 public LimitForm( Limit limit )
 {
     InitializeComponent();
     this.Limit = limit;
 }
Esempio n. 3
0
 public void CopyTo( Limit copy )
 {
     copy.@operator = @operator;
     copy.Description = Description;
     copy.Extension = Extension;
     copy.Item = Item;
     copy.name = name;
     copy.operatorSpecified = operatorSpecified;
 }
 private void AddLimitToListView(Limit limit)
 {
     if (limit != null)
     {
         var lvi = new ListViewItem(limit.Item.GetType().Name);
         lvi.SubItems.Add(limit.ToString());
         lvi.Tag = limit;
         limitListControl.Items.Add(lvi);
     }
 }
 private void UpdateLimitInListView(ListViewItem lvi, Limit limit)
 {
     lvi.SubItems[0].Text = limit.Item.GetType().Name;
     lvi.SubItems[1].Text = limit.ToString();
     lvi.Tag = limit;
 }
 /// <summary>
 /// Deserializes xml markup from file into an Limit object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output Limit object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out Limit obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Limit);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool LoadFromFile(string fileName, out Limit obj)
 {
     System.Exception exception;
     return LoadFromFile(fileName, out obj, out exception);
 }
 public static bool Deserialize(string input, out Limit obj)
 {
     System.Exception exception;
     return Deserialize(input, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an Limit object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output Limit object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string input, out Limit obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Limit);
     try
     {
         obj = Deserialize(input);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
Esempio n. 10
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            string input1 = edtQuickEntry.Text;
            string input2 = null;
            int idx = input1.IndexOf(" to ", System.StringComparison.Ordinal);
            if (idx != -1)
            {
                input2 = input1.Substring(idx + " to ".Length );
                input1 = input1.Substring(0, idx);
            }

            bool useLimitPair = false;
            List<Value> values1 = ElectricalUtils.ParseExpression(input1);
            List<Value> values2 = null;
            if (input2 != null)
            {
                values2 = ElectricalUtils.ParseExpression(input2);
                useLimitPair = true;
            }

            if (values1.Count > 0)
            {
                Value value1 = values1[0];
                ErrorLimit errorLimit1 = value1.errorLimit;
                Value resolution1 = value1.resoluion;
                string unit1 = value1.unit;
                string val1 = value1.value;
                @double datum1 = value1.@double;
                _limit = new Limit();
                if (!useLimitPair)
                {
                    cmbLimitType.SelectedIndex = LIMIT_EXPECTED;
                    var le = new LimitExpected { Item = datum1 };
                    _limit.Item = le;
                    //20msV errlmt 0.01% res 1mV range 50mV to 10V  range 100mV to 20V
                }
                else
                {
                    cmbLimitType.SelectedIndex = LIMIT_PAIR;
                    SingleLimit limit1 = new SingleLimit();
                    SingleLimit limit2 = new SingleLimit();
                    limit1.comparator = ComparisonOperator.GE;
                    limit2.comparator = ComparisonOperator.LE;
                    var lp = new LimitPair {Limit = new List<SingleLimit> {limit1, limit2}};
                    limit1.Item = datum1;
                    if ( values2.Count > 0)
                    {
                        Value value2 = values2[0];
                        ErrorLimit errorLimit2 = value2.errorLimit;
                        Value resolution2 = value2.resoluion;
                        string unit2 = value2.unit;
                        string val2 = value2.value;
                        @double datum2 = value2.@double;
                        limit2.Item = datum2;
                        //20mV errlmt 0.01% res 1mV range 50mV to 10V  range 100mV to 20V
                    }
                    _limit.Item = lp;
                }
                DataToControls();
            }
        }
Esempio n. 11
0
        protected virtual void DataToControls()
        {
            if (_limit == null)
                _limit = new Limit();

            InitLimitTypeCombo();
            SetControlStates();
            edtLimitName.Text = _limit.name;
            edtLimitDescription.Text = _limit.Description;

            if (_limit.operatorSpecified)
                cmbOperator.SelectedValue = _limit.@operator;

            if (_limit.Item is LimitMask)
                ((LimitMaskControl) _limitTypeControl).LimitMask = (LimitMask) _limit.Item;
            else if (_limit.Item is LimitExpected)
                ((ExpectedLimitSimpleControl) _limitTypeControl).LimitExpected = (LimitExpected) _limit.Item;
            else if (_limit.Item is LimitPair)
                ((LimitPairControl) _limitTypeControl).LimitPair = (LimitPair) _limit.Item;
            else if (_limit.Item is SingleLimit)
                ((SingleLimitSimpleControl) _limitTypeControl).SingleLimit = (SingleLimit) _limit.Item;
        }
Esempio n. 12
0
        protected virtual void ControlsToData()
        {
            if (_limit == null)
                _limit = new Limit();
            _limit.Description = edtLimitDescription.GetValue<string>();
            _limit.name = edtLimitName.GetValue<string>();
            _limit.operatorSpecified = cmbOperator.SelectedIndex != -1;
            if (_limit.operatorSpecified)
                _limit.@operator =
                    (LogicalOperator) Enum.Parse(typeof (LogicalOperator), (String) cmbOperator.SelectedValue);

            //TODO: Add Limit Extension if needed

            switch (cmbLimitType.SelectedIndex)
            {
                case LIMIT_EXPECTED:
                    _limit.Item = ((ExpectedLimitSimpleControl) _limitTypeControl).LimitExpected;
                    break;
                case LIMIT_MASK:
                    _limit.Item = ((LimitMaskControl) _limitTypeControl).LimitMask;
                    break;
                case LIMIT_PAIR:
                    _limit.Item = ((LimitPairControl) _limitTypeControl).LimitPair;
                    break;
                case LIMIT_SINGLE:
                    _limit.Item = ((SingleLimitSimpleControl) _limitTypeControl).SingleLimit;
                    break;
                case NO_VALUE:
                    _limit = null;
                    break;
            }
        }