Пример #1
0
        private void btnExpressionSave_Click(object sender, EventArgs e)
        {
            if (this.CurrentProfile.DisplayOptions.Expressions.Any(p => p != SelectedExpression && p.Name == txtExpressionName.Text))
            {
                MessageBox.Show("Duplicate Expression Name");
                return;
            }

            if (this.CurrentProfile.ECUFile.Measurements.Values.Any(m => m.Name == txtExpressionName.Text))
            {
                MessageBox.Show("Invalid Expression Name");
                return;
            }

            if (this.ExpressionEditMode == EditModes.Add)
            {
                this.SelectedExpression = new Session.ExpressionVariable(txtExpressionName.Text, txtExpressionUnit.Text, txtExpressionExpression.Text);
                this.CurrentProfile.DisplayOptions.Expressions.Add(SelectedExpression);
            }
            this.SelectedExpression.Name       = txtExpressionName.Text;
            this.SelectedExpression.Unit       = txtExpressionUnit.Text;
            this.SelectedExpression.Expression = txtExpressionExpression.Text;

            lstExpressions.DataSource   = null;
            lstExpressions.DataSource   = this.CurrentProfile.DisplayOptions.Expressions;
            lstExpressions.SelectedItem = this.SelectedExpression;

            this.ExpressionEditMode = EditModes.View;
            SwitchUI();
        }
Пример #2
0
 private void lstExpressions_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.SelectedExpression           = lstExpressions.SelectedItem as Session.ExpressionVariable;
     this.txtExpressionName.Text       = this.SelectedExpression != null ? this.SelectedExpression.Name : string.Empty;
     this.txtExpressionUnit.Text       = this.SelectedExpression != null ? this.SelectedExpression.Unit : string.Empty;
     this.txtExpressionExpression.Text = this.SelectedExpression != null ? this.SelectedExpression.Expression : string.Empty;
     this.SwitchUI();
 }
Пример #3
0
 private void ReadExpressions(XElement ele)
 {
     foreach (XElement e in ele.Elements())
     {
         Session.ExpressionVariable v = new Session.ExpressionVariable();
         v.Read(e);
         Expressions.Add(v);
     }
 }
Пример #4
0
 private void btnExpressionClone_Click(object sender, EventArgs e)
 {
     Session.ExpressionVariable clone = ((Session.ExpressionVariable)lstExpressions.SelectedItem).Clone();
     clone.Name += " Clone";
     while (true)
     {
         if (this.CurrentProfile.DisplayOptions.Expressions.Any(p => p.Name == clone.Name))
         {
             clone.Name += " Clone";
         }
         else
         {
             break;
         }
     }
     this.CurrentProfile.DisplayOptions.Expressions.Add(clone);
     lstExpressions.DataSource   = null;
     lstExpressions.DataSource   = this.CurrentProfile.DisplayOptions.Expressions;
     lstExpressions.SelectedItem = clone;
 }