| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 | 
							- using Aitex.Core.RT.SCCore;
 
- using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
 
- using MECF.Framework.UI.Client.CenterViews.Dialogs;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- using System.Windows.Controls;
 
- using System.Text.RegularExpressions;
 
- using System.Windows.Media;
 
- using MECF.Framework.UI.Client.ClientBase;
 
- namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
 
- {
 
-     public class RecipeStepTimeViewModel : ModuleUiViewModelBase
 
-     {
 
-         public Dictionary<string, string> RecipeStepTime = new Dictionary<string, string>();
 
-         public bool IsSave { get; set; } = false;
 
-         private string _selectTime;
 
-         public string SelectTime
 
-         {
 
-             get => _selectTime;
 
-             set
 
-             {
 
-                 _selectTime = value;
 
-                 if (!string.IsNullOrEmpty(value) && !value.Contains(" ") && value.Contains(":"))
 
-                 {
 
-                     SelectValueTime = value;
 
-                     SelectValueTimeH = value.Split(':')[0];
 
-                     SelectValueTimeM = value.Split(':')[1];
 
-                     SelectValueTimeS = value.Split(':')[2];
 
-                 }
 
-                 else if (!string.IsNullOrEmpty(value) && RecipeStepTime.ContainsKey(value))
 
-                 {
 
-                     SelectValueTime = RecipeStepTime[value];
 
-                     SelectValueTimeH = SelectValueTime.Split(':')[0];
 
-                     SelectValueTimeM = SelectValueTime.Split(':')[1];
 
-                     SelectValueTimeS = SelectValueTime.Split(':')[2];
 
-                 }
 
-             }
 
-         }
 
-         private string _selectValueTime = "00:00:10.0";
 
-         public string SelectValueTime
 
-         {
 
-             get
 
-             {
 
-                 return _selectValueTime;
 
-             }
 
-             set
 
-             {
 
-                 _selectValueTime = value;
 
-                 NotifyOfPropertyChange(SelectValueTime);
 
-             }
 
-         }
 
-         private string _selectValueTimeH = "00";
 
-         public string SelectValueTimeH
 
-         {
 
-             get
 
-             {
 
-                 return _selectValueTimeH;
 
-             }
 
-             set
 
-             {
 
-                 _selectValueTimeH = value;
 
-                 NotifyOfPropertyChange(SelectValueTimeH);
 
-             }
 
-         }
 
-         private string _selectValueTimeM = "00";
 
-         public string SelectValueTimeM
 
-         {
 
-             get
 
-             {
 
-                 return _selectValueTimeM;
 
-             }
 
-             set
 
-             {
 
-                 _selectValueTimeM = value;
 
-                 NotifyOfPropertyChange(SelectValueTimeM);
 
-             }
 
-         }
 
-         private string _selectValueTimeS = "10";
 
-         public string SelectValueTimeS
 
-         {
 
-             get
 
-             {
 
-                 return _selectValueTimeS;
 
-             }
 
-             set
 
-             {
 
-                 _selectValueTimeS = value;
 
-                 NotifyOfPropertyChange(SelectValueTimeS);
 
-             }
 
-         }
 
-         private string _TimeModel;
 
-         public string TimeModel { get { return _TimeModel; } set { _TimeModel = value; NotifyOfPropertyChange(nameof(TimeModel)); } }
 
-         public string TimeParam { get; set; }
 
-         public bool IsEnable => CGlobal.RecipeProcessEditViewEnable;//是否是View模式
 
-         private void GetDataOfConfigItems()
 
-         {
 
-             if (SelectTime != null && SelectTime.Length > 1 && SelectTime.Split(':').Length > 2)
 
-             {
 
-                 SelectValueTimeH = SelectTime.Split(':')[0];
 
-                 SelectValueTimeM = SelectTime.Split(':')[1];
 
-                 SelectValueTimeS = SelectTime.Split(':')[2];
 
-             }
 
-             var temp = generate();
 
-             foreach (var item in temp)
 
-             {
 
-                 RecipeStepTime[item] = SystemConfigProvider.Instance.GetValueByName($"PM1.RecipeEditParameter.{TimeParam}.{item}");
 
-             }
 
-         }
 
-         public RecipeStepTimeViewModel(string timeParam)
 
-         {
 
-             TimeParam = timeParam;
 
-             Initialize();
 
-         }
 
-         protected override void OnInitialize()
 
-         {
 
-             base.OnInitialize();
 
-             InitTime();
 
-         }
 
-         protected override void OnViewLoaded(object view)
 
-         {
 
-             GetDataOfConfigItems();
 
-             base.OnViewLoaded(view);
 
-             foreach (var item in RecipeStepTime.Keys)
 
-             {
 
-                 object Txt = ((RecipeStepTimeView)(((Window)GetView()).Content)).FindName("Txt" + item);
 
-                 if (Txt is TextBlock)
 
-                 {
 
-                     ((TextBlock)Txt).Text = RecipeStepTime[item];
 
-                 }
 
-             }
 
-         }
 
-         public void SetValue(object sender, string isFullKeyboard = "")
 
-         {
 
-             string value = ((TextBox)sender).Text;
 
-             if (!string.IsNullOrEmpty(isFullKeyboard))
 
-             {
 
-                 FullKeyboard fullKeyboard1 = new FullKeyboard("", value);
 
-                 if ((bool)fullKeyboard1.ShowDialog())
 
-                 {
 
-                     ((TextBox)sender).Text = fullKeyboard1.ValueString;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 NumberKeyboard fullKeyboard = new NumberKeyboard("", value);
 
-                 if ((bool)fullKeyboard.ShowDialog())
 
-                 {
 
-                     ((TextBox)sender).Text = fullKeyboard.ValueString;
 
-                 }
 
-             }
 
-         }
 
-         public void InitTime()
 
-         {
 
-             if (string.IsNullOrEmpty(SelectValueTime))
 
-             {
 
-                 return;
 
-             }
 
-             var timeList = SelectValueTime.Split(':').ToList();
 
-             var first = timeList[0];
 
-             string pattern = "^[0-9]*$";
 
-             Regex rex = new Regex(pattern);
 
-             if (!rex.IsMatch(first))
 
-             {
 
-                 timeList.Remove(first);
 
-             }
 
-             SelectValueTimeH = timeList.FirstOrDefault();
 
-             SelectValueTimeM = timeList.Skip(1).Take(1).FirstOrDefault();
 
-             SelectValueTimeS = timeList.LastOrDefault();
 
-             SetTimeValue("Value");
 
-         }
 
-         public void Initialize()
 
-         {
 
-             var temp = generate();
 
-             foreach (var item in temp)
 
-             {
 
-                 RecipeStepTime.Add(item, "00:00:00");
 
-             }
 
-         }
 
-         IEnumerable<string> generate()
 
-         {
 
-             for (char c = 'A'; c <= 'Z'; c++)
 
-                 yield return new string(c, 1);
 
-         }
 
-         public void SetTimeValue(string nameCmd)
 
-         {
 
-             SelectTime = nameCmd;
 
-             TimeModel = nameCmd;
 
-             if (TimeModel != "Value")
 
-             {
 
-                 object Txt = ((RecipeStepTimeView)(((Window)GetView()).Content)).FindName("TxtTime");
 
-                 if (Txt is TextBox)
 
-                 {
 
-                     ((TextBox)Txt).Foreground = new SolidColorBrush(Colors.Black);
 
-                 }
 
-             }
 
-         }
 
-         public void SetTimeCmd(string nameCmd)
 
-         {
 
-             SelectValueTime = SelectValueTimeH + ":" + SelectValueTimeM + ":" + SelectValueTimeS;
 
-             switch (nameCmd)
 
-             {
 
-                 case "Save":
 
-                     if (!CheckTimeFormat(SelectValueTimeH, SelectValueTimeM, SelectValueTimeS)) return;
 
-                     IsSave = true;
 
-                     break;
 
-                 case "Close":
 
-                     IsSave = false;
 
-                     break;
 
-                 default:
 
-                     break;
 
-             }
 
-             ((Window)GetView()).Close();
 
-         }
 
-         private bool CheckTimeFormat(string strTimeH, string strTimeM, string strTimeS)
 
-         {
 
-             bool bResult = true, bTimeH = true, bTimeM = true, bTimeS = true;
 
-             string pattern = "^[0-9]*$";
 
-             Regex rex = new Regex(pattern);
 
-             //秒需要设置小数
 
-             Regex reg = new Regex(@"^\d+(\.\d+)?$");
 
-             object TxtH = ((RecipeStepTimeView)(((Window)GetView()).Content)).FindName("TxtTimeH");
 
-             object TxtM = ((RecipeStepTimeView)(((Window)GetView()).Content)).FindName("TxtTimeM");
 
-             object TxtS = ((RecipeStepTimeView)(((Window)GetView()).Content)).FindName("TxtTimeS");
 
-             if (!rex.IsMatch(strTimeH))
 
-             {
 
-                 bTimeH = false;
 
-             }
 
-             if (!bTimeH)
 
-             {
 
-                 if (TxtH is TextBox)((TextBox)TxtH).Foreground = new SolidColorBrush(Colors.Red);
 
-             }
 
-             else
 
-             {
 
-                 if (TxtH is TextBox) ((TextBox)TxtH).Foreground = new SolidColorBrush(Colors.Black);
 
-             }
 
-             if (!rex.IsMatch(strTimeM)|| double.Parse(strTimeM) > 59)
 
-             {
 
-                 bTimeM = false;
 
-             }
 
-             if (!bTimeM)
 
-             {
 
-                 if (TxtM is TextBox)((TextBox)TxtM).Foreground = new SolidColorBrush(Colors.Red);
 
-             }
 
-             else
 
-             {
 
-                 if (TxtM is TextBox) ((TextBox)TxtM).Foreground = new SolidColorBrush(Colors.Black);
 
-             }
 
-             double value;
 
-             if (!double.TryParse(strTimeS, out value))
 
-             {
 
-                 bTimeS = false;
 
-             }
 
-             //if (Convert.ToDouble(value) < 0)
 
-             //{
 
-             //    bTimeS = false;
 
-             //}
 
-             if (!reg.IsMatch(strTimeS) || double.Parse(strTimeS) >= 60)
 
-             {
 
-                 bTimeS = false;
 
-             }
 
-             if (!bTimeS)
 
-             {
 
-                 if (TxtS is TextBox) ((TextBox)TxtS).Foreground = new SolidColorBrush(Colors.Red);
 
-             }
 
-             else
 
-             {
 
-                 if (TxtS is TextBox)  ((TextBox)TxtS).Foreground = new SolidColorBrush(Colors.Black);
 
-             }
 
-             bResult = bTimeH && bTimeM && bTimeS;
 
-             return bResult;
 
-         }
 
-     }
 
- }
 
 
  |