| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 | 
							- using Aitex.Core.UI.ControlDataContext;
 
- using MECF.Framework.UI.Core.ExtendedControls;
 
- using System;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Windows.Input;
 
- using System.Windows.Media;
 
- namespace Aitex.Core.UI.Control
 
- {
 
-     /// <summary>
 
-     /// Interaction logic for AnalogControl.xaml
 
-     /// </summary>
 
-     public partial class AnalogControl4Jet : UserControl
 
-     {
 
-         public AnalogControl4Jet()
 
-         {
 
-             InitializeComponent();
 
-         }
 
-         public string ViewName
 
-         {
 
-             get { return (string)this.GetValue(ViewNameProperty); }
 
-             set { this.SetValue(ViewNameProperty, value); }
 
-         }
 
-         // Using a DependencyProperty as the backing store for MenuVisibility.  This enables animation, styling, binding, etc...
 
-         public static readonly DependencyProperty ViewNameProperty =
 
-             DependencyProperty.Register("ViewName", typeof(string), typeof(AnalogControl4Jet),
 
-                 new FrameworkPropertyMetadata(""));
 
-         public bool IsExecute
 
-         {
 
-             get { return (bool)this.GetValue(IsExecuteProperty); }
 
-             set { this.SetValue(IsExecuteProperty, value); }
 
-         }
 
-         // Using a DependencyProperty as the backing store for MenuVisibility.  This enables animation, styling, binding, etc...
 
-         public static readonly DependencyProperty IsExecuteProperty =
 
-             DependencyProperty.Register("IsExecute", typeof(bool), typeof(AnalogControl4Jet),
 
-                 new FrameworkPropertyMetadata(true));
 
-         // define dependency properties
 
-         public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
 
-                         "Command", typeof(ICommand), typeof(AnalogControl4Jet),
 
-                         new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
 
-                         "DeviceData", typeof(AnalogDeviceDataItem), typeof(AnalogControl4Jet),
 
-                         new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender,
 
-                         new PropertyChangedCallback(OnDeviceDataChanged)));
 
-         public static readonly DependencyProperty TagNameProperty = DependencyProperty.Register(
 
-                   "TagName", typeof(string), typeof(AnalogControl4Jet),
 
-                   new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
 
-         public static readonly DependencyProperty OperationNameProperty = DependencyProperty.Register(
 
-                 "OperationName", typeof(string), typeof(AnalogControl4Jet),
 
-                 new FrameworkPropertyMetadata(AnalogDeviceOperation.Ramp, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         public static readonly DependencyProperty BackColorProperty = DependencyProperty.Register(
 
-                         "BackColor", typeof(Brush), typeof(AnalogControl4Jet),
 
-                          new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         public static readonly DependencyProperty HideDialogProperty = DependencyProperty.Register(
 
-                     "HideDialog", typeof(bool), typeof(AnalogControl4Jet),
 
-                     new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         private double oldFeedBack;
 
-         public static readonly DependencyProperty GasPanelStateTypeProperty = DependencyProperty.Register(
 
-         "GasStateType", typeof(GasPanelStateType), typeof(AnalogControl4Jet),
 
-         new FrameworkPropertyMetadata(GasPanelStateType.Manual, FrameworkPropertyMetadataOptions.AffectsRender));
 
-         public GasPanelStateType GasStateType
 
-         {
 
-             get
 
-             {
 
-                 return (GasPanelStateType)this.GetValue(GasPanelStateTypeProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(GasPanelStateTypeProperty, value);
 
-             }
 
-         }
 
-         public static readonly DependencyProperty ShowValueProperty = DependencyProperty.Register(
 
-         "ShowValue", typeof(string), typeof(AnalogControl4Jet),
 
-         new FrameworkPropertyMetadata(0.ToString("f3"), FrameworkPropertyMetadataOptions.AffectsRender));
 
-         public string ShowValue
 
-         {
 
-             get
 
-             {
 
-                 return (string)this.GetValue(ShowValueProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(ShowValueProperty, value);
 
-             }
 
-         }
 
-         public string TagName
 
-         {
 
-             get
 
-             {
 
-                 return (string)this.GetValue(TagNameProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(TagNameProperty, value);
 
-             }
 
-         }
 
-         private static void OnDeviceDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 
-         {
 
-         }
 
-         /// <summary>
 
-         /// 输入值是否百分比,默认否
 
-         /// </summary>
 
-         public bool IsPercent { get; set; }
 
-         public Visibility RampVisibility { get; set; } = Visibility.Collapsed;
 
-         public ICommand Command
 
-         {
 
-             get
 
-             {
 
-                 return (ICommand)this.GetValue(CommandProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(CommandProperty, value);
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// set, get current progress value AnalogDeviceData
 
-         /// </summary>
 
-         public AnalogDeviceDataItem DeviceData
 
-         {
 
-             get
 
-             {
 
-                 var data = (AnalogDeviceDataItem)this.GetValue(DeviceDataProperty);
 
-                 if (data != null)
 
-                 {
 
-                     switch (GasStateType)
 
-                     {
 
-                         case GasPanelStateType.Manual:
 
-                             ShowValue = data.SetPoint.ToString("f3");
 
-                             break;
 
-                         case GasPanelStateType.Monitor:
 
-                             ShowValue = data.FeedBack.ToString("f3");
 
-                             break;
 
-                         case GasPanelStateType.Recipe:
 
-                             ShowValue = data.VirtualFeedBack.ToString("f3");
 
-                             break;
 
-                         default:
 
-                             ShowValue = 0.ToString("f3");
 
-                             break;
 
-                     }
 
-                     oldFeedBack = data.FeedBack;
 
-                 }
 
-                 return data;
 
-                 //return (AnalogDeviceDataItem)this.GetValue(DeviceDataProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(DeviceDataProperty, value);
 
-             }
 
-         }
 
-         public Brush BackColor
 
-         {
 
-             get
 
-             {
 
-                 return (Brush)this.GetValue(BackColorProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(BackColorProperty, value);
 
-             }
 
-         }
 
-         public bool HideDialog
 
-         {
 
-             get
 
-             {
 
-                 return (bool)this.GetValue(HideDialogProperty);
 
-             }
 
-             set
 
-             {
 
-                 this.SetValue(HideDialogProperty, value);
 
-             }
 
-         }
 
-         protected override void OnRender(DrawingContext drawingContext)
 
-         {
 
-             base.OnRender(drawingContext);
 
-             //draw background color
 
-             RefreshMFCData();
 
-         }
 
-         private void RefreshMFCData()
 
-         {
 
-             #region FeedBack
 
-             if (DeviceData == null) return;
 
-             //draw red board if mfc meets a warning
 
-             //draw reading value
 
-             //if (IsPercent)
 
-             //    labelValue.Content = (DeviceData.FeedBack * 100).ToString("F1");
 
-             //else
 
-             //    labelValue.Content = DeviceData.FeedBack.ToString("F1");
 
-             labelValue1.Foreground = DeviceData.IsWarning ? Brushes.Pink : Brushes.Black;
 
-             //if (dialogBox != null)
 
-             //{
 
-             //    if (IsPercent)
 
-             //        dialogBox.RealValue = (DeviceData.FeedBack * 100).ToString("F1") + "%";
 
-             //    else
 
-             //        dialogBox.RealValue = DeviceData.FeedBack.ToString("F1");
 
-             //}
 
-             //draw red board if mfc meets a warning
 
-             //draw reading value
 
-             //if (IsPercent)
 
-             //    labelSetPoint.Content = (DeviceData.SetPoint * 100).ToString("F1");
 
-             //else
 
-             //    labelSetPoint.Content = DeviceData.SetPoint.ToString("F1");
 
-             if (DeviceData.DeviceId.Contains("MFM"))
 
-             {
 
-                 labelSetPoint.Content = DeviceData.DeviceId;
 
-             }
 
-             else
 
-             {
 
-                 labelSetPoint.Content = DeviceData.DeviceId.Replace("MFC", "");
 
-             }
 
-             labelSetPoint.Foreground = DeviceData.IsWarning ? Brushes.Pink : Brushes.Black;
 
-             if (DeviceData != null)
 
-             {
 
-                 BrushConverter brushConverter = new BrushConverter();
 
-                 switch (GasStateType)
 
-                 {
 
-                     case GasPanelStateType.Manual:
 
-                         ShowValue = DeviceData.SetPoint.ToString("f3");
 
-                         if (DeviceData.IsCharge)
 
-                         {
 
-                             topBorder.Background = (Brush)brushConverter.ConvertFromString("#FFFFD2");
 
-                             downBorder.Background = (Brush)brushConverter.ConvertFromString("#FFFFD2");
 
-                         }
 
-                         else
 
-                         {
 
-                             topBorder.Background = (Brush)brushConverter.ConvertFromString("#B0D1F1");
 
-                             downBorder.Background = (Brush)brushConverter.ConvertFromString("#B0D1F1");
 
-                         }
 
-                         break;
 
-                     case GasPanelStateType.Monitor:
 
-                         ShowValue = DeviceData.FeedBack.ToString("f3");
 
-                         topBorder.Background = (Brush)brushConverter.ConvertFromString("#B0D1F1");
 
-                         downBorder.Background = (Brush)brushConverter.ConvertFromString("#B0D1F1");
 
-                         break;
 
-                     case GasPanelStateType.Recipe:
 
-                         ShowValue = DeviceData.VirtualFeedBack.ToString("f3");
 
-                         topBorder.Background = (float.Parse(ShowValue) > 0 && "RecipeView".Equals(ViewName)) ? (Brush)brushConverter.ConvertFromString("#FFFFD2") : (Brush)brushConverter.ConvertFromString("#B0D1F1");
 
-                         downBorder.Background = (float.Parse(ShowValue) > 0 && "RecipeView".Equals(ViewName)) ? (Brush)brushConverter.ConvertFromString("#FFFFD2") : (Brush)brushConverter.ConvertFromString("#B0D1F1");
 
-                         break;
 
-                     default:
 
-                         ShowValue = 0.ToString("f3");
 
-                         break;
 
-                 }
 
-             }
 
-             #endregion
 
-         }
 
-         private void RefreshMFCData(AnalogDeviceDataItem data)
 
-         {
 
-             #region FeedBack
 
-             if (data == null) return;
 
-             //draw red board if mfc meets a warning
 
-             //draw reading value
 
-             //if (IsPercent)
 
-             //    labelValue.Content = (data.FeedBack * 100).ToString("F1");
 
-             //else
 
-             //    labelValue.Content = data.FeedBack.ToString("F1");
 
-             labelValue1.Foreground = data.IsWarning ? Brushes.Pink : Brushes.Black;
 
-             //if (dialogBox != null)
 
-             //{
 
-             //    if (IsPercent)
 
-             //        dialogBox.RealValue = (data.FeedBack * 100).ToString("F1") + "%";
 
-             //    else
 
-             //        dialogBox.RealValue = data.FeedBack.ToString("F1");
 
-             //}
 
-             //draw red board if mfc meets a warning
 
-             //draw reading value
 
-             //if (IsPercent)
 
-             //    labelSetPoint.Content = (DeviceData.SetPoint * 100).ToString("F1");
 
-             //else
 
-             //    labelSetPoint.Content = DeviceData.SetPoint.ToString("F1");
 
-             if (data.DeviceId.Contains("MFM"))
 
-             {
 
-                 labelSetPoint.Content = data.DeviceId.Replace("MFM", "");
 
-             }
 
-             else
 
-             {
 
-                 labelSetPoint.Content = data.DeviceId.Replace("MFC", "");
 
-             }
 
-             if (DeviceData != null)
 
-             {
 
-                 switch (GasStateType)
 
-                 {
 
-                     case GasPanelStateType.Manual:
 
-                     case GasPanelStateType.Monitor:
 
-                         ShowValue = data.FeedBack.ToString("f3");
 
-                         break;
 
-                     case GasPanelStateType.Recipe:
 
-                         ShowValue = data.VirtualFeedBack.ToString("f3");
 
-                         break;
 
-                     default:
 
-                         ShowValue = 0.ToString("f3");
 
-                         break;
 
-                 }
 
-             }
 
-             labelSetPoint.Foreground = data.IsWarning ? Brushes.Pink : Brushes.Black;
 
-             #endregion
 
-         }
 
-         ///// <summary>   
 
-         ///// 设置鼠标的坐标   
 
-         ///// </summary>   
 
-         ///// <param name="x">横坐标</param>   
 
-         ///// <param name="y">纵坐标</param>   
 
-         //[DllImport("User32")]
 
-         //public extern static void SetCursorPos(int x, int y);
 
-         //  private InputDialogBox dialogBox;
 
-         public Window AnalogOwner { get; set; }
 
-         private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 
-         {
 
-             if (e.StylusDevice != null) e.Handled = true;//认为误触
 
-             else Grid_TouchUp(sender, null);
 
-         }
 
-         private void Execute(double value, double? ramp)
 
-         {
 
-             if (!IsExecute)
 
-             {
 
-                 return;
 
-             }
 
-             switch (GasStateType)
 
-             {
 
-                 case GasPanelStateType.Manual:
 
-                     if (ramp != null)
 
-                     {
 
-                         Command.Execute(new object[] { DeviceData.DeviceName, DeviceData.Type.Equals("MFC") ? "SetMfcValue" : "SetMfmValue", value, ramp });
 
-                     }
 
-                     else
 
-                     {
 
-                         Command.Execute(new object[] { DeviceData.DeviceName, DeviceData.Type.Equals("MFC") ? "SetMfcValue" : "SetMfmValue", value });
 
-                     }
 
-                     break;
 
-                 case GasPanelStateType.Monitor:
 
-                     break;
 
-                 case GasPanelStateType.Recipe:
 
-                     Command.Execute(new object[] { DeviceData.DeviceName, DeviceData.Type.Equals("MFC") ? "SetMfcVirtualValue" : "SetMfmValue", value });
 
-                     break;
 
-                 default:
 
-                     break;
 
-             }
 
-         }
 
-         private void Grid_MouseEnter(object sender, MouseEventArgs e)
 
-         {
 
-             if (DeviceData != null)
 
-             {
 
-                 string tooltipValue =
 
-                     string.Format("{0}:{1}\r\n\r\nID:{2}\r\nScale:{3} {4}\r\nSetPoint:{5} {4} \r\nFeedback:{6} {4}\r\nTolerance:{7}%\r\nStatus:{8}",
 
-                         DeviceData.Type,
 
-                         DeviceData.DisplayName,
 
-                         DeviceData.DeviceId,
 
-                         DeviceData.Scale,
 
-                         DeviceData.Unit,
 
-                         IsPercent ? (DeviceData.SetPoint * 100).ToString("F1") + "%" : DeviceData.SetPoint.ToString("F1"),
 
-                         IsPercent ? (DeviceData.FeedBack * 100).ToString("F1") + "%" : DeviceData.FeedBack.ToString("F1"),
 
-                         DeviceData.Scale > 0 ? ((DeviceData.FeedBack - DeviceData.SetPoint) / DeviceData.Scale * 100).ToString("F1") : "0",
 
-                         DeviceData.IsWarning ? "Tolerance Warning" : "Normal");
 
-                 ToolTip = tooltipValue;
 
-             }
 
-         }
 
-         private void Grid_TouchUp(object sender, TouchEventArgs e)
 
-         {
 
-             if (DeviceData == null)
 
-                 return;
 
-             if (GasStateType == GasPanelStateType.Monitor) return;
 
-             if (HideDialog)
 
-                 return;
 
-             BrushConverter brushConverter = new BrushConverter();
 
-             InputDialogBox dialogBox = new InputDialogBox
 
-             {
 
-                 CommandDelegate = Execute,
 
-                 DeviceName = string.Format("{0}: {1}", DeviceData.Type, DeviceData.DisplayName),
 
-                 DeviceId = DeviceData.DeviceId,
 
-                 DefaultValue = DeviceData.DefaultValue,
 
-                 RealValue = DeviceData.FeedBack.ToString("F1"),
 
-                 SetPoint = Math.Round(DeviceData.SetPoint, 1),
 
-                 MaxValue = DeviceData.Scale,
 
-                 Unit = DeviceData.Unit,
 
-                 TagName = TagName,
 
-                 RampValue = DeviceData.RampValue,
 
-                 RampMaxValue = DeviceData.RampMaxValue,
 
-                 RampMinValue = DeviceData.RampMinValue,
 
-                 RampVisibility = (GasStateType == GasPanelStateType.Manual && RampVisibility == Visibility.Visible) ? Visibility.Visible : Visibility.Collapsed
 
-             };
 
-             dialogBox.IsPercent = IsPercent;
 
-             if (IsPercent)
 
-                 dialogBox.SetPoint = Math.Round(DeviceData.SetPoint * 100.0, 1);
 
-             if (AnalogOwner != null)
 
-                 dialogBox.Owner = AnalogOwner;
 
-             dialogBox.Topmost = false;
 
-             dialogBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
 
-             //dialogBox.FocasAll();
 
-             if ((bool)dialogBox.ShowDialog())
 
-             {
 
-                 if (!string.IsNullOrEmpty(dialogBox.inputBox.Text))
 
-                 {
 
-                     ShowValue = dialogBox.inputBox.Text;
 
-                     if (double.Parse(dialogBox.inputBox.Text) != DeviceData.FeedBack)
 
-                     {
 
-                         DeviceData.IsCharge = true;
 
-                     }
 
-                     else
 
-                     {
 
-                         DeviceData.IsCharge = false;
 
-                     }
 
-                     DeviceData.SetValue = double.Parse(dialogBox.inputBox.Text);
 
-                 }
 
-                 if (RampVisibility == Visibility.Visible && GasStateType == GasPanelStateType.Manual)
 
-                 {
 
-                     if (!string.IsNullOrEmpty(dialogBox.inputRampBox.Text))
 
-                     {
 
-                         if (double.Parse(dialogBox.inputRampBox.Text) != DeviceData.RampValue)
 
-                         {
 
-                             DeviceData.IsRampCharge = true;
 
-                         }
 
-                         else
 
-                         {
 
-                             DeviceData.IsRampCharge = false;
 
-                         }
 
-                         DeviceData.SetRampValue = double.Parse(dialogBox.inputRampBox.Text);
 
-                     }
 
-                 }
 
-             }
 
-             //SetCursorPos(0, 0);
 
-             dialogBox.Close();
 
-             dialogBox.Dispose();
 
-         }
 
-     }
 
- }
 
 
  |