123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- namespace GDNXFD.Alert.Config.Views
- {
- using GalaSoft.MvvmLight.Command;
- using GDNXFD.Alert.Config.ViewModel;
- using Data;
- using System.Windows.Controls;
- using System;
- using System.Windows;
- using System.Windows.Input;
- /// <summary>
- /// Interaction logic for TravelRequestForm.xaml
- /// </summary>
- public partial class RuleForm : UserControl
- {
- /// <summary>
- /// Travel Request form
- /// </summary>
- public RuleForm(AlertRule alertRule, FormMode fMode)
- {
- var vm = ViewModelLocator.Instance.RuleForm;// (RuleFormViewModel)this.DataContext;
- vm.InitializeData(alertRule, fMode);
- this.DataContext = vm;
- InitializeComponent();
- }
-
- private void ListBoxDI_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- var obj = sender as ListBox;
- if (obj != null)
- {
- var di = obj.SelectedValue as TestingPointBase;
- if (di != null && di.UniformCode != null)
- {
- string ucode = di.UniformCode;
- if (!ucode.StartsWith("DI"))
- {
- ucode = "DI_" + ucode;
- }
- int curPos = txtExpression.SelectionStart;
- txtExpression.Text = txtExpression.Text.Insert(curPos, ucode);
- txtExpression.SelectionStart = curPos + ucode.Length;
- //if (!txtTag.Text.Contains(di.ModelId))
- //{
- // curPos = txtTag.SelectionStart;
- // txtTag.Text = txtTag.Text.Insert(curPos, di.ModelId + ",");
- // txtTag.SelectionStart = curPos + di.ModelId.Length + 1;
- //}
- if (!txtTag.Text.Contains(di.Name))
- {
- curPos = txtTag.SelectionStart;
- txtTag.Text = txtTag.Text.Insert(curPos, di.Name+",");
- txtTag.SelectionStart = curPos + di.Name.Length +1;
- }
- }
- }
- }
- private void ListBoxAI_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- var obj = sender as ListBox;
- if (obj != null)
- {
- var di = obj.SelectedValue as TestingPointBase;
- if (di != null && di.UniformCode != null)
- {
- string ucode = di.UniformCode;
- if (!ucode.StartsWith("AI"))
- {
- ucode = "AI_" + ucode;
- }
- int curPos = txtExpression.SelectionStart;
- txtExpression.Text = txtExpression.Text.Insert(curPos, ucode);
- txtExpression.SelectionStart = curPos + ucode.Length;
- //if (!txtTag.Text.Contains(di.ModelId))
- //{
- // curPos = txtTag.SelectionStart;
- // txtTag.Text = txtTag.Text.Insert(curPos, di.ModelId + ",");
- // txtTag.SelectionStart = curPos + di.ModelId.Length + 1;
- //}
- if (!txtTag.Text.Contains(di.Name))
- {
- curPos = txtTag.SelectionStart;
- txtTag.Text = txtTag.Text.Insert(curPos, di.Name + ",");
- txtTag.SelectionStart = curPos + di.Name.Length + 1;
- }
- }
- }
- }
- private void ListBoxSymbol_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- var obj = sender as ListBox;
- if (obj != null)
- {
- var item = obj.SelectedValue as ListBoxItem;
- if (item != null && item.Content != null)
- {
- int curPos = txtExpression.SelectionStart;
- string value = item.Content.ToString();
- txtExpression.Text = txtExpression.Text.Insert(curPos, value);
- txtExpression.SelectionStart = curPos + value.Length;
- }
- }
- }
- private void ListBoxMath_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- var obj = sender as ListBox;
- if (obj != null)
- {
- var item = obj.SelectedValue as string;
- if (!string.IsNullOrEmpty(item))
- {
- int curPos = txtExpression.SelectionStart;
- if ("Sustain".Equals(item)
- || "RiseExceed".Equals(item)
- || "MR".Equals(item)
- || "MAR".Equals(item)
- || "LastUpdateTime".Equals(item))
- {
- string value = item + "()";
- txtExpression.Text = txtExpression.Text.Insert(curPos, value);
- txtExpression.SelectionStart = curPos + value.Length - 1;
- }
- else
- {
- string value = string.Format("Math.{0}", item);
- if ("PI".Equals(item)
- || "E".Equals(item))
- {
- txtExpression.Text = txtExpression.Text.Insert(curPos, value);
- }
- else
- {
- value = value + "()";
- txtExpression.Text = txtExpression.Text.Insert(curPos, value);
- txtExpression.SelectionStart = curPos + value.Length - 1;
- }
- }
- }
- }
- }
- }
- }
|