RecipesHistoryCompareViewModel.cs 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073
  1. using Aitex.Core.RT.Log;
  2. using Caliburn.Micro;
  3. using MECF.Framework.Common.CommonData;
  4. using MECF.Framework.Common.DataCenter;
  5. using MECF.Framework.UI.Client.CenterViews.Editors;
  6. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  7. using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
  8. using MECF.Framework.UI.Client.ClientBase;
  9. using OpenSEMI.ClientBase;
  10. using RecipeEditorLib.RecipeModel.Params;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Collections.ObjectModel;
  14. using System.Text.RegularExpressions;
  15. using System.Windows;
  16. using System.Xml;
  17. using System.Linq;
  18. using System.Windows.Controls;
  19. using System.IO;
  20. using FurnaceUI.Views.Editors;
  21. using System.Threading.Tasks;
  22. namespace FurnaceUI.Views.Recipes
  23. {
  24. public class RecipesHistoryCompareViewModel : ModuleUiViewModelBase
  25. {
  26. private string _module = "PM1";
  27. public ObservableCollection<ProcessTypeFileItem> ProcessTypeFileList { get; set; }
  28. public ObservableCollection<string> ChamberType { get; set; }
  29. public ObservableCollection<string> RecipeProcessType { get; set; }
  30. public int ChamberTypeIndexSelection { get; set; }
  31. public int _processTypeIndexSelection;
  32. public int ProcessTypeIndexSelection
  33. {
  34. get { return _processTypeIndexSelection; }
  35. set { _processTypeIndexSelection = value; NotifyOfPropertyChange("ProcessTypeIndexSelection"); }
  36. }
  37. public string CurrentChamberType
  38. {
  39. get
  40. {
  41. return ChamberType[ChamberTypeIndexSelection];
  42. }
  43. }
  44. private string _currentProcessType;
  45. public string CurrentProcessType
  46. {
  47. get
  48. {
  49. if (ProcessTypeIndexSelection < 0)
  50. ProcessTypeIndexSelection = 0;
  51. if (ProcessTypeFileList.Count == 0)
  52. return "Process";
  53. return ProcessTypeFileList[ProcessTypeIndexSelection].ProcessType;
  54. }
  55. set { _currentProcessType = CurrentProcessType; NotifyOfPropertyChange("CurrentProcessType"); }
  56. }
  57. //-------------------------A Properties
  58. public ObservableCollection<StepDataItem> StepListA { get; set; }
  59. public ObservableCollection<ParamDataItem> ParamListA { get; set; }
  60. public ObservableCollection<LineDataItem> WholeListA { get; set; }
  61. public string RecipeA { get; set; }
  62. public string TimeA
  63. {
  64. get { return _timeA; }
  65. set
  66. {
  67. _timeA = value;
  68. NotifyOfPropertyChange("TimeA");
  69. }
  70. }
  71. private string _timeA = string.Empty;
  72. private XmlDocument _domA = new XmlDocument();
  73. private string _pathPrefixA;
  74. private Dictionary<string, ObservableCollection<ParamDataItem>> _mapStepParamA = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  75. private Dictionary<string, LineDataItem> _mapLineTextA = new Dictionary<string, LineDataItem>();
  76. private List<string> BackInnerXmlTextA = new List<string>();
  77. private bool _isChangedA { get; set; }
  78. public bool EnableButtonRemoveA
  79. {
  80. get { return !string.IsNullOrEmpty(RecipeA); }
  81. }
  82. public bool EnableButtonUndoA
  83. {
  84. get { return false; }
  85. }
  86. public bool EnableButtonSaveA
  87. {
  88. get { return false; }
  89. }
  90. private StepDataItem _stepSelectionA;
  91. public StepDataItem StepSelectionA
  92. {
  93. get
  94. {
  95. return _stepSelectionA;
  96. }
  97. set
  98. {
  99. SyncStepSelection(value, false);
  100. _stepSelectionA = value;
  101. }
  102. }
  103. private ParamDataItem _paramSelectionA;
  104. public ParamDataItem ParamSelectionA
  105. {
  106. get
  107. {
  108. return _paramSelectionA;
  109. }
  110. set
  111. {
  112. SyncParamSelection(value, false);
  113. _paramSelectionA = value;
  114. }
  115. }
  116. private LineDataItem _lineSelectionA;
  117. public LineDataItem LineSelectionA
  118. {
  119. get
  120. {
  121. return _lineSelectionA;
  122. }
  123. set
  124. {
  125. SyncLineSelection(value, false);
  126. _lineSelectionA = value;
  127. }
  128. }
  129. //-------------------------B Properties-------------------------------------------------------------
  130. public ObservableCollection<StepDataItem> StepListB { get; set; }
  131. public ObservableCollection<ParamDataItem> ParamListB { get; set; }
  132. public ObservableCollection<LineDataItem> WholeListB { get; set; }
  133. public string RecipeB { get; set; }
  134. public string TimeB
  135. {
  136. get { return _timeB; }
  137. set
  138. {
  139. _timeB = value;
  140. NotifyOfPropertyChange("TimeB");
  141. }
  142. }
  143. private string _timeB = string.Empty;
  144. private XmlDocument _domB = new XmlDocument();
  145. private string _pathPrefixB;
  146. private Dictionary<string, ObservableCollection<ParamDataItem>> _mapStepParamB = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  147. private Dictionary<string, LineDataItem> _mapLineTextB = new Dictionary<string, LineDataItem>();
  148. private List<string> BackInnerXmlTextB = new List<string>();
  149. private string BaseTextB = "";
  150. private bool _isChangedB { get; set; }
  151. public bool EnableButtonRemoveB
  152. {
  153. get { return !string.IsNullOrEmpty(RecipeB); }
  154. }
  155. public bool EnableButtonUndoB
  156. {
  157. get { return false; }
  158. }
  159. public bool EnableButtonSaveB
  160. {
  161. get { return false; }
  162. }
  163. private StepDataItem _stepSelectionB;
  164. public StepDataItem StepSelectionB
  165. {
  166. get
  167. {
  168. return _stepSelectionB;
  169. }
  170. set
  171. {
  172. SyncStepSelection(value, true);
  173. _stepSelectionB = value;
  174. }
  175. }
  176. private ParamDataItem _paramSelectionB;
  177. public ParamDataItem ParamSelectionB
  178. {
  179. get
  180. {
  181. return _paramSelectionB;
  182. }
  183. set
  184. {
  185. SyncParamSelection(value, true);
  186. _paramSelectionB = value;
  187. }
  188. }
  189. private LineDataItem _lineSelectionB;
  190. public LineDataItem LineSelectionB
  191. {
  192. get
  193. {
  194. return _lineSelectionB;
  195. }
  196. set
  197. {
  198. SyncLineSelection(value, true);
  199. _lineSelectionB = value;
  200. }
  201. }
  202. private ShowRecipeHistory recipeHistory;
  203. public ShowRecipeHistory RecipeHistory
  204. {
  205. get => recipeHistory;
  206. set
  207. {
  208. recipeHistory = value;
  209. if (recipeHistory != null)
  210. {
  211. RecipeB = recipeHistory.Recipe_Name;
  212. TimeB = recipeHistory.LastRevisionTime.ToString("yyyy-MM-dd HH:mm:ss");
  213. }
  214. NotifyOfPropertyChange("RecipeHistory");
  215. }
  216. }
  217. private RecipeDataBase currentRecipe;
  218. public RecipeDataBase CurrentRecipe
  219. {
  220. get => currentRecipe;
  221. set
  222. {
  223. currentRecipe = value;
  224. if (currentRecipe!=null)
  225. {
  226. RecipeA = currentRecipe.Name;
  227. TimeA = currentRecipe.ReviseTime.ToString("yyyy-MM-dd HH:mm:ss");
  228. }
  229. NotifyOfPropertyChange("CurrentRecipe");
  230. }
  231. }
  232. public bool CurrentRecipeIsHistoty { get; set; }
  233. private ShowRecipeHistory _currentRecipeHistory;
  234. public ShowRecipeHistory CurrentRecipeHistory
  235. {
  236. get => _currentRecipeHistory;
  237. set
  238. {
  239. _currentRecipeHistory = value;
  240. if (_currentRecipeHistory != null)
  241. {
  242. RecipeA = _currentRecipeHistory.Recipe_Name;
  243. TimeA = _currentRecipeHistory.LastRevisionTime.ToString("yyyy-MM-dd HH:mm:ss");
  244. }
  245. NotifyOfPropertyChange("CurrentRecipeHistory");
  246. }
  247. }
  248. public RecipesHistoryCompareViewModel()
  249. {
  250. StepListA = new ObservableCollection<StepDataItem>();
  251. ParamListA = new ObservableCollection<ParamDataItem>();
  252. WholeListA = new ObservableCollection<LineDataItem>();
  253. StepListB = new ObservableCollection<StepDataItem>();
  254. ParamListB = new ObservableCollection<ParamDataItem>();
  255. WholeListB = new ObservableCollection<LineDataItem>();
  256. }
  257. protected override void OnInitialize()
  258. {
  259. base.OnInitialize();
  260. var chamberType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedChamberType");
  261. if (chamberType == null)
  262. {
  263. ChamberType = new ObservableCollection<string>() { "Default" };
  264. }
  265. else
  266. {
  267. ChamberType = new ObservableCollection<string>(((string)(chamberType)).Split(','));
  268. }
  269. ChamberTypeIndexSelection = 0;
  270. //Etch:Process,Clean,Chuck,Dechuck;CVD:Process,Clean;
  271. var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  272. if (processType == null)
  273. {
  274. RecipeProcessType = new ObservableCollection<string>() { "Process" };
  275. }
  276. else
  277. {
  278. RecipeProcessType = new ObservableCollection<string>(((string)processType).Split(','));
  279. }
  280. ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  281. var chamber = QueryDataClient.Instance.Service.GetConfig("System.Recipe.ChamberModules");
  282. UpdateProcessTypeFileList();
  283. }
  284. protected override void OnActivate()
  285. {
  286. base.OnActivate();
  287. SelectRecipe();
  288. Recompare();
  289. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  290. }
  291. protected override void OnDeactivate(bool close)
  292. {
  293. base.OnDeactivate(close);
  294. }
  295. public void UpdateProcessTypeFileList()
  296. {
  297. ProcessTypeFileList.Clear();
  298. for (int i = 0; i < RecipeProcessType.Count; i++)
  299. {
  300. var type = new ProcessTypeFileItem();
  301. type.ProcessType = RecipeProcessType[i];
  302. var prefix = $"{ChamberType[ChamberTypeIndexSelection]}\\{RecipeProcessType[i]}";
  303. ProcessTypeFileList.Add(type);
  304. }
  305. while (ProcessTypeFileList.Count > RecipeProcessType.Count)
  306. {
  307. ProcessTypeFileList.RemoveAt(0);
  308. }
  309. }
  310. private void SelectRecipe()
  311. {
  312. try
  313. {
  314. var recipeProvider = new RecipeProvider();
  315. string suffix = $".{_module}";
  316. if (RecipeHistory != null)
  317. {
  318. LoadContentData(RecipeHistory);
  319. }
  320. if (CurrentRecipeIsHistoty)
  321. {
  322. if (CurrentRecipeHistory != null)
  323. {
  324. LoadCurrentHistoryContentData(CurrentRecipeHistory);
  325. }
  326. }
  327. else
  328. {
  329. if (CurrentRecipe != null)
  330. {
  331. LoadData(CurrentRecipe);
  332. }
  333. }
  334. Recompare();
  335. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  336. }
  337. catch (Exception ex)
  338. {
  339. throw;
  340. }
  341. }
  342. /// <summary>
  343. /// 当前版本显示在左边
  344. /// </summary>
  345. /// <param name="selectedRecipePath"></param>
  346. public void LoadData(RecipeDataBase Recipe)
  347. {
  348. string recipeName = Recipe.Name;
  349. string prefixPath = Recipe.PrefixPath;
  350. var _recipeProvider = new RecipeProvider();
  351. var recipeContent = _recipeProvider.LoadRecipe(prefixPath, recipeName, false);//_recipeProvider.LoadRecipeByFullPath(selectedRecipePath);//
  352. if (string.IsNullOrEmpty(recipeContent))
  353. {
  354. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  355. return;
  356. }
  357. BackInnerXmlTextA.Clear();
  358. if (BackInnerXmlTextB.Count > 0)
  359. {
  360. string dataXml = BackInnerXmlTextB[0];
  361. BackInnerXmlTextB.Clear();
  362. BackInnerXmlTextB.Add(dataXml);
  363. }
  364. _pathPrefixA = prefixPath;
  365. _mapLineTextA = new Dictionary<string, LineDataItem>();
  366. BackInnerXmlTextA.Add(recipeContent);
  367. LoadrecipeContentData(recipeContent, true);
  368. }
  369. /// <summary>
  370. /// 当前历史版本显示在左边
  371. /// </summary>
  372. /// <param name="recipeHistory"></param>
  373. public void LoadCurrentHistoryContentData(ShowRecipeHistory recipeHistory)
  374. {
  375. string recipeName = recipeHistory.Recipe_Name;
  376. string prefixPath = recipeHistory.Recipe_Type;
  377. var _recipeProvider = new RecipeProvider();
  378. var recipeContent = recipeHistory.Recipe_Content;//_recipeProvider.LoadRecipe(prefixPath, recipeName, false);// _recipeProvider.LoadRecipeByFullPath(selectedRecipePath);//
  379. if (string.IsNullOrEmpty(recipeContent))
  380. {
  381. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  382. return;
  383. }
  384. BackInnerXmlTextA.Clear();
  385. if (BackInnerXmlTextB.Count > 0)
  386. {
  387. string dataXml = BackInnerXmlTextB[0];
  388. BackInnerXmlTextB.Clear();
  389. BackInnerXmlTextB.Add(dataXml);
  390. }
  391. _pathPrefixA = prefixPath;
  392. _mapLineTextA = new Dictionary<string, LineDataItem>();
  393. BackInnerXmlTextA.Add(recipeContent);
  394. LoadrecipeContentData(recipeContent, true);
  395. }
  396. /// <summary>
  397. /// 历史版本显示在右边
  398. /// </summary>
  399. /// <param name="recipeHistory"></param>
  400. public void LoadContentData(ShowRecipeHistory recipeHistory)
  401. {
  402. XmlDocument doc = _domB;
  403. string recipeName = recipeHistory.Recipe_Name;
  404. string prefixPath = recipeHistory.Recipe_Type;
  405. var _recipeProvider = new RecipeProvider();
  406. var recipeContent = recipeHistory.Recipe_Content;//_recipeProvider.LoadRecipe(prefixPath, recipeName, false);// _recipeProvider.LoadRecipeByFullPath(selectedRecipePath);//
  407. if (string.IsNullOrEmpty(recipeContent))
  408. {
  409. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  410. return;
  411. }
  412. BackInnerXmlTextB.Clear();
  413. if (BackInnerXmlTextA.Count > 0)
  414. {
  415. string dataXml = BackInnerXmlTextA[0];
  416. BackInnerXmlTextA.Clear();
  417. BackInnerXmlTextA.Add(dataXml);
  418. }
  419. _pathPrefixB = prefixPath;
  420. _mapLineTextB = new Dictionary<string, LineDataItem>();
  421. BackInnerXmlTextB.Add(recipeContent);
  422. LoadrecipeContentData(recipeContent, false);
  423. // LoadrecipeContentDataB(recipeContent);
  424. }
  425. //private void SelectRecipe(bool isSelectA)
  426. //{
  427. // try
  428. // {
  429. // RecipeCompareSelectDialogViewModel dialog = new RecipeCompareSelectDialogViewModel();
  430. // dialog.DisplayName = "Select Recipe";
  431. // SystemName = _module;
  432. // var recipeProvider = new RecipeProvider();
  433. // var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  434. // if (processType == null)
  435. // {
  436. // processType = "Process";
  437. // }
  438. // var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  439. // string[] recipeProcessType = ((string)processType).Split(',');
  440. // string[] partsType1 = new string[] { };
  441. // string[] partsType2 = new string[] { };
  442. // for (int i = 0; i < recipeProcessType.Length; i++)
  443. // {
  444. // var type = new ProcessTypeFileItem();
  445. // type.ProcessType = recipeProcessType[i];
  446. // var prefix = $"ISSET\\{recipeProcessType[i]}";
  447. // var recipes = recipeProvider.GetXmlRecipeList(prefix);
  448. // string[] parts = Regex.Split(recipes, "<");
  449. // if (i == 0)
  450. // {
  451. // partsType1 = parts;
  452. // }
  453. // else if (i == 1)
  454. // {
  455. // partsType2 = parts;
  456. // }
  457. // string recipeChamber;
  458. // recipeChamber = "<" + parts[1];
  459. // foreach (string part in parts)
  460. // {
  461. // if (part.Contains($".{SystemName}"))
  462. // {
  463. // string temp = part.Replace($".{SystemName}", string.Empty);
  464. // recipeChamber += "<" + temp;
  465. // }
  466. // }
  467. // if (parts.Length > 2)
  468. // {
  469. // recipeChamber += "<" + parts[parts.Length - 1];
  470. // }
  471. // type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipeChamber)[0].Files;
  472. // ProcessTypeFileList.Add(type);
  473. // }
  474. // dialog.ProcessTypeFileList = ProcessTypeFileList;
  475. // WindowManager wm = new WindowManager();
  476. // bool? bret = wm.ShowDialog(dialog);
  477. // if (!(bool)bret)
  478. // return;
  479. // _module = dialog.SelectedChamber;
  480. // string suffix = $".{_module}";
  481. // string dialogResult = dialog.DialogResult;
  482. // bool isFullPath = false;
  483. // if (dialogResult.Contains(".rcp"))
  484. // isFullPath = true;
  485. // string recipeName = dialogResult;
  486. // if (isSelectA)
  487. // {
  488. // RecipeA = recipeName;
  489. // NotifyOfPropertyChange(nameof(RecipeA));
  490. // NotifyOfPropertyChange(nameof(EnableButtonRemoveA));
  491. // }
  492. // else
  493. // {
  494. // RecipeB = recipeName;
  495. // NotifyOfPropertyChange(nameof(RecipeB));
  496. // NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  497. // }
  498. // if (!string.IsNullOrEmpty(RecipeA) && !string.IsNullOrEmpty(RecipeB))
  499. // {
  500. // string[] recipe1 = RecipeA.Split('\\'); string r1 = recipe1[0];
  501. // string[] recipe2 = RecipeB.Split('\\'); string r2 = recipe2[0];
  502. // if (r1 != r2)
  503. // {
  504. // if (MessageBoxResult.Yes != MessageBox.Show($"腔体类型不一致! \n 是否继续比较 ?", "", MessageBoxButton.YesNo, MessageBoxImage.Information))
  505. // {
  506. // RemoveSelectB();
  507. // return;
  508. // }
  509. // }
  510. // }
  511. // LoadData(recipeName, isSelectA, isFullPath);
  512. // Recompare();
  513. // SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  514. // }
  515. // catch (Exception ex)
  516. // {
  517. // throw;
  518. // }
  519. //}
  520. public void LoadData(string selectedRecipePath, bool isSelectA, bool isFullPath)
  521. {
  522. var array = selectedRecipePath.Split(new char[] { '\\' });
  523. string recipeName = array[array.Length - 1];
  524. XmlDocument doc = isSelectA ? _domA : _domB;
  525. string prefixPath = (isSelectA ? RecipeA : RecipeB).Replace(recipeName, "");
  526. var _recipeProvider = new RecipeProvider();
  527. var recipeContent = isFullPath ? _recipeProvider.LoadRecipeByFullPath(selectedRecipePath) : _recipeProvider.LoadRecipe(prefixPath, recipeName, false);
  528. if (string.IsNullOrEmpty(recipeContent))
  529. {
  530. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  531. return;
  532. }
  533. if (isSelectA)
  534. {
  535. BackInnerXmlTextA.Clear();
  536. if (BackInnerXmlTextB.Count > 0)
  537. {
  538. string dataXml = BackInnerXmlTextB[0];
  539. BackInnerXmlTextB.Clear();
  540. BackInnerXmlTextB.Add(dataXml);
  541. }
  542. }
  543. else
  544. {
  545. BackInnerXmlTextB.Clear();
  546. if (BackInnerXmlTextA.Count > 0)
  547. {
  548. string dataXml = BackInnerXmlTextA[0];
  549. BackInnerXmlTextA.Clear();
  550. BackInnerXmlTextA.Add(dataXml);
  551. }
  552. }
  553. if (isSelectA)
  554. {
  555. _pathPrefixA = prefixPath;
  556. _mapLineTextA = new Dictionary<string, LineDataItem>();
  557. BackInnerXmlTextA.Add(recipeContent);
  558. }
  559. else
  560. {
  561. _pathPrefixB = prefixPath;
  562. _mapLineTextB = new Dictionary<string, LineDataItem>();
  563. BackInnerXmlTextB.Add(recipeContent);
  564. }
  565. LoadrecipeContentData(recipeContent, isSelectA);
  566. }
  567. public void StepGridSelectionChangedA()
  568. {
  569. if (StepSelectionA == null)
  570. {
  571. ParamListA.Clear();
  572. NotifyOfPropertyChange(nameof(ParamListA));
  573. return;
  574. }
  575. Task.Run(() =>
  576. {
  577. if (_mapStepParamA.ContainsKey(StepSelectionA.StepNumber))
  578. {
  579. // ParamListA = _mapStepParamA[StepSelectionA.StepNumber];
  580. var tempParamListA = _mapStepParamA[StepSelectionA.StepNumber];
  581. foreach (ParamDataItem item in tempParamListA)
  582. {
  583. item.IsHidden = (!item.IsDiff && !item.IsExtra && IsShowDiffParams) ? true : false;
  584. }
  585. Application.Current.Dispatcher.Invoke(new System.Action(() =>
  586. {
  587. ParamListA.Clear();
  588. tempParamListA.ToList().ForEach(x => ParamListA.Add(x));
  589. }));
  590. NotifyOfPropertyChange(nameof(ParamListA));
  591. NotifyOfPropertyChange(nameof(StepSelectionA));
  592. //StepSelectionA.InvokePropertyChanged();
  593. }
  594. });
  595. }
  596. public void LoadDataByRecipeContent(string recipeContent, bool isSelectA)
  597. {
  598. LoadrecipeContentData(recipeContent, isSelectA);
  599. }
  600. private void LoadrecipeContentData(string recipeContent, bool isSelectA)
  601. {
  602. XmlDocument doc = isSelectA ? _domA : _domB;
  603. if (isSelectA)
  604. {
  605. _mapLineTextA = new Dictionary<string, LineDataItem>();
  606. //BackInnerXmlTextA.Add(recipeContent);
  607. }
  608. else
  609. {
  610. _mapLineTextB = new Dictionary<string, LineDataItem>();
  611. //BackInnerXmlTextB.Add(recipeContent);
  612. }
  613. if (!isSelectA)
  614. {
  615. doc.LoadXml(recipeContent);
  616. StringWriter stringWriter = new StringWriter();
  617. XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
  618. xmlTextWriter.Formatting = Formatting.Indented;
  619. doc.WriteTo(xmlTextWriter);
  620. recipeContent = stringWriter.ToString();
  621. }
  622. string[] allText = recipeContent.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  623. int number = 0;
  624. ObservableCollection<LineDataItem> lineData = new ObservableCollection<LineDataItem>();
  625. foreach (string lineText in allText)
  626. {
  627. LineDataItem line = new LineDataItem();
  628. line.LineNumber = (++number).ToString();
  629. line.LineText = lineText;
  630. if (!string.IsNullOrEmpty(lineText))
  631. {
  632. lineData.Add(line);
  633. if (isSelectA)
  634. {
  635. _mapLineTextA[line.LineNumber] = line;
  636. }
  637. else
  638. {
  639. _mapLineTextB[line.LineNumber] = line;
  640. }
  641. }
  642. }
  643. doc.LoadXml(recipeContent);
  644. ObservableCollection<StepDataItem> stepData = new ObservableCollection<StepDataItem>();
  645. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{_module}']/Step");
  646. if (nodeSteps == null)
  647. nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Step");
  648. foreach (XmlNode nodeStep in nodeSteps)
  649. {
  650. ObservableCollection<ParamDataItem> paramData = new ObservableCollection<ParamDataItem>();
  651. StepDataItem step = new StepDataItem();
  652. foreach (XmlAttribute attr in nodeStep.Attributes)
  653. {
  654. if (attr.Name == "StepNo")
  655. step.StepNumber = attr.Value;
  656. else if (attr.Name == "Name")
  657. step.StepName = attr.Value;
  658. else
  659. {
  660. ParamDataItem param = new ParamDataItem();
  661. param.ParamName = attr.Name;
  662. param.ParamValue = attr.Value;
  663. paramData.Add(param);
  664. }
  665. }
  666. stepData.Add(step);
  667. if (isSelectA)
  668. {
  669. _mapStepParamA[step.StepNumber] = paramData;
  670. }
  671. else
  672. {
  673. _mapStepParamB[step.StepNumber] = paramData;
  674. }
  675. }
  676. if (isSelectA)
  677. {
  678. StepListA = stepData;
  679. NotifyOfPropertyChange(nameof(StepListA));
  680. WholeListA = lineData;
  681. NotifyOfPropertyChange(nameof(WholeListA));
  682. }
  683. else
  684. {
  685. StepListB = stepData;
  686. NotifyOfPropertyChange(nameof(StepListB));
  687. WholeListB = lineData;
  688. NotifyOfPropertyChange(nameof(WholeListB));
  689. }
  690. }
  691. public void StepGridSelectionChangedB()
  692. {
  693. if (StepSelectionB == null)
  694. {
  695. ParamListB.Clear();
  696. NotifyOfPropertyChange(nameof(ParamListB));
  697. return;
  698. }
  699. if (_mapStepParamB.ContainsKey(StepSelectionB.StepNumber))
  700. {
  701. // ParamListB = _mapStepParamB[StepSelectionB.StepNumber];
  702. var tempParamListB = _mapStepParamB[StepSelectionB.StepNumber];
  703. foreach (ParamDataItem item in tempParamListB)
  704. {
  705. item.IsHidden = (!item.IsDiff && !item.IsExtra && IsShowDiffParams) ? true : false;
  706. }
  707. Application.Current.Dispatcher.Invoke(new System.Action(() =>
  708. {
  709. ParamListB.Clear();
  710. tempParamListB.ToList().ForEach(x => ParamListB.Add(x));
  711. }
  712. ));
  713. NotifyOfPropertyChange(nameof(ParamListB));
  714. NotifyOfPropertyChange(nameof(StepSelectionB));
  715. // StepSelectionB.InvokePropertyChanged();
  716. }
  717. }
  718. public void ParamGridSelectionChangedA()
  719. {
  720. if (ParamSelectionA == null)
  721. {
  722. return;
  723. }
  724. NotifyOfPropertyChange(nameof(ParamSelectionA));
  725. ParamSelectionA.InvokePropertyChanged();
  726. }
  727. public void ParamGridSelectionChangedB()
  728. {
  729. if (ParamSelectionB == null)
  730. {
  731. return;
  732. }
  733. NotifyOfPropertyChange(nameof(ParamSelectionB));
  734. ParamSelectionB.InvokePropertyChanged();
  735. }
  736. public void WholeGridSelectionChangedA()
  737. {
  738. if (LineSelectionA == null)
  739. {
  740. return;
  741. }
  742. NotifyOfPropertyChange(nameof(LineSelectionA));
  743. LineSelectionA.InvokePropertyChanged();
  744. }
  745. public void WholeGridSelectionChangedB()
  746. {
  747. if (LineSelectionB == null)
  748. {
  749. return;
  750. }
  751. NotifyOfPropertyChange(nameof(LineSelectionB));
  752. LineSelectionB.InvokePropertyChanged();
  753. }
  754. public void SaveLineA()
  755. {
  756. if (LineSelectionA == null)
  757. return;
  758. foreach (LineDataItem lineDataItem in WholeListA)
  759. {
  760. if (lineDataItem.LineNumber == LineSelectionA.LineNumber)
  761. {
  762. lineDataItem.LineText = LineSelectionA.LineText;
  763. break;
  764. }
  765. }
  766. string recipeContent = "";
  767. for (int i = 0; i < WholeListA.Count; i++)
  768. {
  769. recipeContent += WholeListA[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  770. }
  771. CopyToInnerXml(recipeContent, true);
  772. LoadDataByRecipeContent(recipeContent, true);
  773. Recompare();
  774. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  775. }
  776. public void SaveLineB()
  777. {
  778. if (LineSelectionB == null)
  779. return;
  780. foreach (LineDataItem lineDataItem in WholeListB)
  781. {
  782. if (lineDataItem.LineNumber == LineSelectionB.LineNumber)
  783. {
  784. lineDataItem.LineText = LineSelectionB.LineText;
  785. break;
  786. }
  787. }
  788. string recipeContent = "";
  789. for (int i = 0; i < WholeListB.Count; i++)
  790. {
  791. recipeContent += WholeListB[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  792. }
  793. CopyToInnerXml(recipeContent, false);
  794. LoadDataByRecipeContent(recipeContent, false);
  795. Recompare();
  796. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  797. }
  798. private void Recompare()
  799. {
  800. RecompareStep();
  801. RecompareWhole();
  802. }
  803. private void RecompareStep()
  804. {
  805. if (StepListA == null || StepListB == null)
  806. return;
  807. int i = 0;
  808. for (i = 0; i < StepListA.Count && i < StepListB.Count; i++)
  809. {
  810. if (StepListA[i].StepName == StepListB[i].StepName)
  811. StepListA[i].IsDiffName = StepListB[i].IsDiffName = false;
  812. else
  813. StepListA[i].IsDiffName = StepListB[i].IsDiffName = true;
  814. ObservableCollection<ParamDataItem> paramA = _mapStepParamA[StepListA[i].StepNumber];
  815. ObservableCollection<ParamDataItem> paramB = _mapStepParamB[StepListB[i].StepNumber];
  816. bool isDiff = false;
  817. bool IsExtra = true;
  818. foreach (var pa in paramA)
  819. {
  820. pa.IsExtra = true;
  821. }
  822. foreach (var pb in paramB)
  823. {
  824. pb.IsExtra = true;
  825. }
  826. foreach (var pa in paramA)
  827. {
  828. foreach (var pb in paramB)
  829. {
  830. if (pb.ParamName == pa.ParamName)
  831. {
  832. pb.IsExtra = false;
  833. pa.IsExtra = false;
  834. pb.IsDiff = pa.IsDiff = (pa.ParamValue != pb.ParamValue);
  835. if (pa.IsDiff)
  836. isDiff = true;
  837. break;
  838. }
  839. }
  840. }
  841. foreach (var pa in paramA)
  842. {
  843. pa.InvokePropertyChanged();
  844. }
  845. foreach (var pb in paramB)
  846. {
  847. pb.InvokePropertyChanged();
  848. }
  849. StepListA[i].IsDiff = StepListB[i].IsDiff = isDiff;
  850. StepListA[i].IsExtra = StepListB[i].IsExtra = false;
  851. StepListA[i].IsHidden = StepListB[i].IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  852. StepListA[i].InvokePropertyChanged();
  853. StepListB[i].InvokePropertyChanged();
  854. }
  855. for (int j = i; j < StepListA.Count; j++)
  856. {
  857. StepListA[j].IsDiff = false;
  858. StepListA[j].IsExtra = true;
  859. StepListA[j].InvokePropertyChanged();
  860. foreach (var pa in _mapStepParamA[StepListA[j].StepNumber])
  861. {
  862. pa.InvokePropertyChanged();
  863. }
  864. }
  865. for (int k = i; k < StepListB.Count; k++)
  866. {
  867. StepListB[k].IsDiff = false;
  868. StepListB[k].IsExtra = true;
  869. WholeListB[k].InvokePropertyChanged();
  870. _mapLineTextB[WholeListB[k].LineNumber].InvokePropertyChanged();
  871. foreach (var pb in _mapStepParamB[StepListB[k].StepNumber])
  872. {
  873. pb.InvokePropertyChanged();
  874. }
  875. }
  876. NotifyOfPropertyChange(nameof(StepListA));
  877. NotifyOfPropertyChange(nameof(StepListB));
  878. }
  879. private void RecompareWhole()
  880. {
  881. if (WholeListA == null || WholeListB == null)
  882. return;
  883. int i = 0;
  884. for (i = 0; i < WholeListA.Count && i < WholeListB.Count; i++)
  885. {
  886. LineDataItem lineA = _mapLineTextA[WholeListA[i].LineNumber];
  887. LineDataItem lineB = _mapLineTextB[WholeListB[i].LineNumber];
  888. bool isDiff = false;
  889. lineB.IsDiff = lineA.IsDiff = (lineA.LineText != lineB.LineText);
  890. if (lineA.IsDiff)
  891. isDiff = true;
  892. WholeListA[i].IsDiff = WholeListB[i].IsDiff = isDiff;
  893. WholeListA[i].IsExtra = WholeListB[i].IsExtra = false;
  894. _mapLineTextA[WholeListA[i].LineNumber].IsDiff = _mapLineTextB[WholeListB[i].LineNumber].IsDiff = isDiff;
  895. _mapLineTextA[WholeListA[i].LineNumber].IsExtra = _mapLineTextB[WholeListB[i].LineNumber].IsExtra = false;
  896. lineA.InvokePropertyChanged();
  897. lineB.InvokePropertyChanged();
  898. WholeListA[i].InvokePropertyChanged();
  899. WholeListB[i].InvokePropertyChanged();
  900. }
  901. for (int j = i; j < WholeListA.Count; j++)
  902. {
  903. WholeListA[j].IsDiff = false;
  904. WholeListA[j].IsExtra = true;
  905. _mapLineTextA[WholeListA[j].LineNumber].IsDiff = false;
  906. _mapLineTextA[WholeListA[j].LineNumber].IsExtra = true;
  907. if (!(_mapLineTextA[WholeListA[j].LineNumber].LineText.Contains("<Step StepNo") || _mapLineTextA[WholeListA[j].LineNumber].LineText.Contains("<Moudule Name")))
  908. {
  909. WholeListA[j].IsDiff = false;
  910. WholeListA[j].IsExtra = false;
  911. }
  912. WholeListA[j].InvokePropertyChanged();
  913. _mapLineTextA[WholeListA[j].LineNumber].InvokePropertyChanged();
  914. }
  915. for (int k = i; k < WholeListB.Count; k++)
  916. {
  917. WholeListB[k].IsDiff = false;
  918. WholeListB[k].IsExtra = true;
  919. _mapLineTextB[WholeListB[k].LineNumber].IsDiff = false;
  920. _mapLineTextB[WholeListB[k].LineNumber].IsExtra = true;
  921. if (!(_mapLineTextB[WholeListB[k].LineNumber].LineText.Contains("<Step StepNo") || _mapLineTextB[WholeListB[k].LineNumber].LineText.Contains("<Moudule Name")))
  922. {
  923. WholeListB[k].IsDiff = false;
  924. WholeListB[k].IsExtra = false;
  925. }
  926. WholeListB[k].InvokePropertyChanged();
  927. _mapLineTextB[WholeListB[k].LineNumber].InvokePropertyChanged();
  928. }
  929. NotifyOfPropertyChange(nameof(WholeListA));
  930. NotifyOfPropertyChange(nameof(WholeListB));
  931. }
  932. private void SyncStepSelection(StepDataItem stepData, bool isSelectA)
  933. {
  934. if (stepData == null)
  935. return;
  936. if (isSelectA)
  937. {
  938. var findStepA = StepListA.FirstOrDefault(x => x.StepNumber == stepData.StepNumber);
  939. if (findStepA != null)
  940. {
  941. _stepSelectionA = findStepA;
  942. NotifyOfPropertyChange(nameof(StepSelectionA));
  943. StepSelectionA.InvokePropertyChanged();
  944. }
  945. }
  946. else
  947. {
  948. var findStepB = StepListB.FirstOrDefault(x => x.StepNumber == stepData.StepNumber);
  949. if (findStepB != null)
  950. {
  951. _stepSelectionB = findStepB;
  952. NotifyOfPropertyChange(nameof(StepSelectionB));
  953. StepSelectionB.InvokePropertyChanged();
  954. }
  955. }
  956. }
  957. private void SyncParamSelection(ParamDataItem paramData, bool isSelectA)
  958. {
  959. try
  960. {
  961. if (paramData == null)
  962. return;
  963. if (isSelectA)
  964. {
  965. if (_mapStepParamA.ContainsKey(StepSelectionB.StepNumber))
  966. {
  967. ParamListA = _mapStepParamA[StepSelectionB.StepNumber];
  968. NotifyOfPropertyChange(nameof(ParamListA));
  969. }
  970. else
  971. return;
  972. foreach (var item in ParamListA)
  973. {
  974. if (item.ParamName == paramData.ParamName)
  975. {
  976. _paramSelectionA = item;
  977. NotifyOfPropertyChange(nameof(ParamSelectionA));
  978. ParamSelectionA.InvokePropertyChanged();
  979. }
  980. }
  981. }
  982. else
  983. {
  984. if (ParamListB == null)
  985. {
  986. if (_mapStepParamB.ContainsKey(StepSelectionA.StepNumber))
  987. {
  988. ParamListB = _mapStepParamB[StepSelectionA.StepNumber];
  989. NotifyOfPropertyChange(nameof(ParamListB));
  990. }
  991. else
  992. return;
  993. }
  994. foreach (var item in ParamListB)
  995. {
  996. if (item.ParamName == paramData.ParamName)
  997. {
  998. _paramSelectionB = item;
  999. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1000. ParamSelectionB.InvokePropertyChanged();
  1001. }
  1002. }
  1003. }
  1004. }
  1005. catch (Exception ex)
  1006. {
  1007. LOG.Write(ex.Message);
  1008. }
  1009. }
  1010. private void SyncLineSelection(LineDataItem lineData, bool isSelectA)
  1011. {
  1012. if (lineData == null)
  1013. return;
  1014. if (isSelectA)
  1015. {
  1016. foreach (var item in WholeListA)
  1017. {
  1018. if (item.LineNumber == lineData.LineNumber)
  1019. {
  1020. _lineSelectionA = item;
  1021. NotifyOfPropertyChange(nameof(LineSelectionA));
  1022. LineSelectionA.InvokePropertyChanged();
  1023. }
  1024. }
  1025. }
  1026. else
  1027. {
  1028. foreach (var item in WholeListB)
  1029. {
  1030. if (item.LineNumber == lineData.LineNumber)
  1031. {
  1032. _lineSelectionB = item;
  1033. NotifyOfPropertyChange(nameof(LineSelectionB));
  1034. LineSelectionB.InvokePropertyChanged();
  1035. }
  1036. }
  1037. }
  1038. }
  1039. public void RemoveA()
  1040. {
  1041. RemoveRecipe(true);
  1042. }
  1043. public void RemoveB()
  1044. {
  1045. RemoveRecipe(false);
  1046. }
  1047. private void RemoveSelectB()
  1048. {
  1049. StepListB?.Clear();
  1050. ParamListB?.Clear();
  1051. WholeListB?.Clear();
  1052. RecipeB = string.Empty;
  1053. _mapStepParamB?.Clear();
  1054. _stepSelectionB = null;
  1055. _paramSelectionB = null;
  1056. NotifyOfPropertyChange(nameof(StepListB));
  1057. NotifyOfPropertyChange(nameof(ParamListB));
  1058. NotifyOfPropertyChange(nameof(RecipeB));
  1059. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  1060. NotifyOfPropertyChange(nameof(StepSelectionB));
  1061. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1062. }
  1063. private void RemoveRecipe(bool isSelectA)
  1064. {
  1065. if (!DialogBox.Confirm($"Are you sure you want to remove the recipe? \r\n{RecipeB}"))
  1066. return;
  1067. if (isSelectA)
  1068. {
  1069. StepListA?.Clear();
  1070. ParamListA?.Clear();
  1071. WholeListA?.Clear();
  1072. RecipeA = string.Empty;
  1073. TimeA = string.Empty;
  1074. _mapStepParamA?.Clear();
  1075. _stepSelectionA = null;
  1076. _paramSelectionA = null;
  1077. NotifyOfPropertyChange(nameof(StepListA));
  1078. NotifyOfPropertyChange(nameof(ParamListA));
  1079. NotifyOfPropertyChange(nameof(RecipeA));
  1080. NotifyOfPropertyChange(nameof(EnableButtonRemoveA));
  1081. NotifyOfPropertyChange(nameof(StepSelectionA));
  1082. NotifyOfPropertyChange(nameof(ParamSelectionA));
  1083. }
  1084. else
  1085. {
  1086. StepListB?.Clear();
  1087. ParamListB?.Clear();
  1088. WholeListB?.Clear();
  1089. RecipeB = string.Empty;
  1090. TimeB = string.Empty;
  1091. _mapStepParamB?.Clear();
  1092. _stepSelectionB = null;
  1093. _paramSelectionB = null;
  1094. NotifyOfPropertyChange(nameof(StepListB));
  1095. NotifyOfPropertyChange(nameof(ParamListB));
  1096. NotifyOfPropertyChange(nameof(RecipeB));
  1097. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  1098. NotifyOfPropertyChange(nameof(StepSelectionB));
  1099. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1100. }
  1101. }
  1102. public void StepCopyToRight(StepDataItem stepA)
  1103. {
  1104. string temp = "";
  1105. if (StepSelectionA != null)
  1106. temp = StepSelectionA.StepNumber;
  1107. StepCopy(stepA, true);
  1108. if (!string.IsNullOrEmpty(temp))
  1109. {
  1110. foreach (StepDataItem tempStep in StepListA)
  1111. {
  1112. if (tempStep.StepNumber == temp)
  1113. {
  1114. StepSelectionA = tempStep;
  1115. break;
  1116. }
  1117. }
  1118. }
  1119. }
  1120. public void StepCopyToLeft(StepDataItem stepB)
  1121. {
  1122. string temp = "";
  1123. if (StepSelectionB != null)
  1124. temp = StepSelectionB.StepNumber;
  1125. StepCopy(stepB, false);
  1126. if (!string.IsNullOrEmpty(temp))
  1127. {
  1128. foreach (StepDataItem tempStep in StepListB)
  1129. {
  1130. if (tempStep.StepNumber == temp)
  1131. {
  1132. StepSelectionB = tempStep;
  1133. break;
  1134. }
  1135. }
  1136. }
  1137. }
  1138. public void LeftDelete(StepDataItem step)
  1139. {
  1140. StepDelete(step, true);
  1141. }
  1142. public void RightDelete(StepDataItem step)
  1143. {
  1144. StepDelete(step, false);
  1145. }
  1146. private void StepDelete(StepDataItem step, bool isSelectA)
  1147. {
  1148. ObservableCollection<StepDataItem> stepList = isSelectA ? StepListA : StepListB;
  1149. Dictionary<string, ObservableCollection<ParamDataItem>> _mapStepParam = isSelectA ? _mapStepParamA : _mapStepParamB;
  1150. foreach (var stepTemp in stepList)
  1151. {
  1152. if (step.StepNumber != stepTemp.StepNumber)
  1153. continue;
  1154. stepList.Remove(stepTemp);
  1155. break;
  1156. }
  1157. for (int i = 0; i < stepList.Count; i++)
  1158. {
  1159. if (stepList[i].StepNumber != (i + 1).ToString())
  1160. {
  1161. if (_mapStepParam.ContainsKey((i + 1).ToString()))
  1162. {
  1163. _mapStepParam[(i + 1).ToString()] = _mapStepParam[stepList[i].StepNumber];
  1164. }
  1165. stepList[i].StepNumber = (i + 1).ToString();
  1166. }
  1167. }
  1168. DeleteInnerXml(isSelectA);
  1169. Recompare();
  1170. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  1171. }
  1172. private void DeleteInnerXml(bool isSelectA)
  1173. {
  1174. try
  1175. {
  1176. XmlDocument docTo = isSelectA ? _domA : _domB;
  1177. //XmlNode nodeModule = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{_module}']");
  1178. XmlNodeList nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{_module}']/Step");
  1179. if (nodeSteps == null)
  1180. nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Step");
  1181. List<XmlNode> oldNodeSteps = new List<XmlNode>();
  1182. foreach (XmlNode nodeTemp in nodeSteps)
  1183. {
  1184. oldNodeSteps.Add(nodeTemp.Clone());
  1185. }
  1186. XmlNodeList backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{_module}']/BakeStep");
  1187. if (backSteps == null)
  1188. backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/BakeStep");
  1189. List<XmlNode> oldBackNodeSteps = new List<XmlNode>();
  1190. foreach (XmlNode nodeTemp in backSteps)
  1191. {
  1192. oldBackNodeSteps.Add(nodeTemp.Clone());
  1193. }
  1194. XmlNode stepsNode = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{_module}']/Step").ParentNode;
  1195. stepsNode.RemoveAll();
  1196. (stepsNode as XmlElement).SetAttribute("Name", _module);
  1197. ObservableCollection<StepDataItem> stepListTo = isSelectA ? StepListA : StepListB;
  1198. if (stepsNode == null)
  1199. {
  1200. return;
  1201. }
  1202. int stepNoCount = 1;
  1203. foreach (StepDataItem item in stepListTo)
  1204. {
  1205. XmlElement DeviceTree = docTo.CreateElement("Step");
  1206. DeviceTree.SetAttribute("StepNo", (stepNoCount++).ToString());
  1207. DeviceTree.SetAttribute("Name", item.StepName);
  1208. stepsNode.AppendChild(DeviceTree);
  1209. }
  1210. foreach (XmlNode nodeStep in stepsNode)
  1211. {
  1212. string stepNumber = nodeStep.Attributes["StepNo"].Value;
  1213. ObservableCollection<ParamDataItem> paramList =
  1214. isSelectA ? _mapStepParamA[stepNumber] : _mapStepParamB[stepNumber];
  1215. foreach (var param in paramList)
  1216. {
  1217. (nodeStep as XmlElement).SetAttribute(param.ParamName, param.ParamValue);
  1218. }
  1219. }
  1220. foreach (XmlNode nodeStep in backSteps)
  1221. {
  1222. stepsNode.AppendChild(nodeStep);
  1223. }
  1224. string backText = getXmlText(isSelectA ? _domA : _domB);
  1225. LoadDataByRecipeContent(backText, isSelectA);
  1226. Recompare();
  1227. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  1228. if (isSelectA)
  1229. {
  1230. BackInnerXmlTextA.Add(backText);
  1231. }
  1232. else
  1233. {
  1234. BackInnerXmlTextB.Add(backText);
  1235. }
  1236. }
  1237. catch (Exception ex)
  1238. {
  1239. LOG.Write(ex.Message);
  1240. }
  1241. }
  1242. private void StepCopy(StepDataItem stepData, bool isFromA)
  1243. {
  1244. StepDataItem stepFrom = stepData;
  1245. ObservableCollection<StepDataItem> stepListTo = isFromA ? StepListB : StepListA;
  1246. Dictionary<string, ObservableCollection<ParamDataItem>> mapFrom = isFromA ? _mapStepParamA : _mapStepParamB;
  1247. Dictionary<string, ObservableCollection<ParamDataItem>> mapTo = isFromA ? _mapStepParamB : _mapStepParamA;
  1248. bool isNotOverOf = false;
  1249. foreach (var stepTo in stepListTo)
  1250. {
  1251. if (stepTo.StepNumber != stepFrom.StepNumber)
  1252. continue;
  1253. isNotOverOf = true;
  1254. stepTo.StepName = stepFrom.StepName;
  1255. //stepTo.IsDiff = stepFrom.IsDiff = false;
  1256. //stepTo.IsExtra = stepFrom.IsExtra = false;
  1257. if (mapFrom.ContainsKey(stepFrom.StepNumber) &&
  1258. mapTo.ContainsKey(stepTo.StepNumber))
  1259. {
  1260. foreach (var paramFrom in mapFrom[stepFrom.StepNumber])
  1261. {
  1262. foreach (var paramTo in mapTo[stepFrom.StepNumber])
  1263. {
  1264. if (paramTo.ParamName != paramFrom.ParamName)
  1265. continue;
  1266. paramTo.ParamValue = paramFrom.ParamValue;
  1267. break;
  1268. }
  1269. }
  1270. }
  1271. break;
  1272. }
  1273. if (!isNotOverOf)
  1274. {
  1275. StepDataItem stepDataItem = new StepDataItem();
  1276. stepDataItem.StepName = stepFrom.StepName;
  1277. stepDataItem.StepNumber = (stepListTo.Count + 1).ToString();
  1278. stepListTo.Add(stepDataItem);
  1279. ObservableCollection<ParamDataItem> paramDataItems = new ObservableCollection<ParamDataItem>();
  1280. foreach (var paramFrom in mapFrom[stepFrom.StepNumber])
  1281. {
  1282. ParamDataItem paramDataItem = new ParamDataItem();
  1283. paramDataItem.ParamName = paramFrom.ParamName;
  1284. paramDataItem.ParamValue = paramFrom.ParamValue;
  1285. paramDataItems.Add(paramDataItem);
  1286. }
  1287. if (mapTo.ContainsKey(stepDataItem.StepNumber))
  1288. mapTo[stepDataItem.StepNumber] = paramDataItems;
  1289. else
  1290. mapTo.Add(stepDataItem.StepNumber, paramDataItems);
  1291. }
  1292. CopyToInnerXml(!isFromA);
  1293. Recompare();
  1294. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  1295. SyncStepSelection(stepFrom, !isFromA);
  1296. }
  1297. private void CopyToInnerXml(bool isSelectA)
  1298. {
  1299. try
  1300. {
  1301. XmlDocument docTo = isSelectA ? _domA : _domB;
  1302. XmlNode nodeModule = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{_module}']");
  1303. XmlNodeList nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{_module}']/Step");
  1304. if (nodeSteps == null)
  1305. nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Step");
  1306. List<XmlNode> oldNodeSteps = new List<XmlNode>();
  1307. foreach (XmlNode nodeTemp in nodeSteps)
  1308. {
  1309. oldNodeSteps.Add(nodeTemp.Clone());
  1310. }
  1311. XmlNodeList backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{_module}']/BakeStep");
  1312. if (backSteps == null)
  1313. backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/BakeStep");
  1314. List<XmlNode> oldBackNodeSteps = new List<XmlNode>();
  1315. foreach (XmlNode nodeTemp in backSteps)
  1316. {
  1317. oldBackNodeSteps.Add(nodeTemp.Clone());
  1318. }
  1319. ObservableCollection<StepDataItem> stepListTo = isSelectA ? StepListA : StepListB;
  1320. if (nodeModule == null)
  1321. {
  1322. return;
  1323. }
  1324. foreach (StepDataItem item in stepListTo)
  1325. {
  1326. bool isOverOf = true;
  1327. foreach (XmlNode xmlNode in oldNodeSteps)
  1328. {
  1329. string stepNumber = xmlNode.Attributes["StepNo"].Value;
  1330. if (item.StepNumber == stepNumber)
  1331. {
  1332. isOverOf = false;
  1333. break;
  1334. }
  1335. }
  1336. if (isOverOf)
  1337. {
  1338. XmlElement DeviceTree = docTo.CreateElement("Step");
  1339. DeviceTree.SetAttribute("StepNo", (oldNodeSteps.Count + 1).ToString());
  1340. DeviceTree.SetAttribute("Name", item.StepName);
  1341. nodeModule.AppendChild(DeviceTree);
  1342. }
  1343. }
  1344. nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{_module}']/Step");
  1345. foreach (XmlNode nodeStep in nodeSteps)
  1346. {
  1347. string stepNumber = nodeStep.Attributes["StepNo"].Value;
  1348. ObservableCollection<ParamDataItem> paramList =
  1349. isSelectA ? _mapStepParamA[stepNumber] : _mapStepParamB[stepNumber];
  1350. foreach (var param in paramList)
  1351. {
  1352. (nodeStep as XmlElement).SetAttribute(param.ParamName, param.ParamValue);
  1353. }
  1354. }
  1355. foreach (XmlNode nodeStep in backSteps)
  1356. {
  1357. nodeModule.AppendChild(nodeStep);
  1358. }
  1359. string backText = getXmlText(isSelectA ? _domA : _domB);
  1360. LoadDataByRecipeContent(backText, isSelectA);
  1361. Recompare();
  1362. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  1363. if (isSelectA)
  1364. {
  1365. BackInnerXmlTextA.Add(backText);
  1366. }
  1367. else
  1368. {
  1369. BackInnerXmlTextB.Add(backText);
  1370. }
  1371. }
  1372. catch (Exception ex)
  1373. {
  1374. LOG.Write(ex.Message);
  1375. }
  1376. }
  1377. private string getXmlText(XmlDocument xmlDocument)
  1378. {
  1379. (new RecipeProvider()).SaveRecipe("", "RecipeTemp", xmlDocument.InnerXml);
  1380. var _recipeProvider = new RecipeProvider();
  1381. var recipeContent = _recipeProvider.LoadRecipe("", "RecipeTemp", false);
  1382. return recipeContent;
  1383. }
  1384. public void ParamCopyToRight(ParamDataItem paramData)
  1385. {
  1386. string temp = "";
  1387. if (StepSelectionA != null)
  1388. temp = StepSelectionA.StepNumber;
  1389. ParamCopy(paramData, true);
  1390. if (!string.IsNullOrEmpty(temp))
  1391. {
  1392. foreach (StepDataItem tempStep in StepListA)
  1393. {
  1394. if (tempStep.StepNumber == temp)
  1395. {
  1396. StepSelectionA = tempStep;
  1397. break;
  1398. }
  1399. }
  1400. }
  1401. }
  1402. public void ParamCopyToLeft(ParamDataItem paramData)
  1403. {
  1404. string temp = "";
  1405. if (StepSelectionB != null)
  1406. temp = StepSelectionB.StepNumber;
  1407. ParamCopy(paramData, false);
  1408. if (!string.IsNullOrEmpty(temp))
  1409. {
  1410. foreach (StepDataItem tempStep in StepListB)
  1411. {
  1412. if (tempStep.StepNumber == temp)
  1413. {
  1414. StepSelectionB = tempStep;
  1415. break;
  1416. }
  1417. }
  1418. }
  1419. }
  1420. private void ParamCopy(ParamDataItem paramData, bool isFromA)
  1421. {
  1422. ParamDataItem paramFrom = paramData;
  1423. StepDataItem stepFrom = isFromA ? StepSelectionA : StepSelectionB;
  1424. Dictionary<string, ObservableCollection<ParamDataItem>> mapFrom = isFromA ? _mapStepParamA : _mapStepParamB;
  1425. Dictionary<string, ObservableCollection<ParamDataItem>> mapTo = isFromA ? _mapStepParamB : _mapStepParamA;
  1426. if (mapTo.ContainsKey(stepFrom.StepNumber))
  1427. {
  1428. foreach (var paramTo in mapTo[stepFrom.StepNumber])
  1429. {
  1430. if (paramTo.ParamName != paramFrom.ParamName)
  1431. continue;
  1432. paramTo.ParamValue = paramFrom.ParamValue;
  1433. paramTo.IsDiff = paramFrom.IsDiff = false;
  1434. paramTo.IsExtra = paramFrom.IsExtra = false;
  1435. paramFrom.InvokePropertyChanged();
  1436. paramTo.InvokePropertyChanged();
  1437. break;
  1438. }
  1439. }
  1440. bool isDiff = false;
  1441. foreach (var paramListFrom in mapFrom[stepFrom.StepNumber])
  1442. {
  1443. if (paramListFrom.IsDiff)
  1444. {
  1445. isDiff = true;
  1446. break;
  1447. }
  1448. }
  1449. stepFrom.IsDiff = isDiff;
  1450. stepFrom.InvokePropertyChanged();
  1451. ObservableCollection<StepDataItem> stepListTo = isFromA ? StepListB : StepListA;
  1452. foreach (var stepTo in stepListTo)
  1453. {
  1454. if (stepTo.StepNumber == stepFrom.StepNumber)
  1455. {
  1456. isDiff = false;
  1457. foreach (var paramListTo in mapTo[stepTo.StepNumber])
  1458. {
  1459. if (paramListTo.IsDiff)
  1460. {
  1461. isDiff = true;
  1462. break;
  1463. }
  1464. }
  1465. stepTo.IsDiff = isDiff;
  1466. stepTo.InvokePropertyChanged();
  1467. break;
  1468. }
  1469. }
  1470. CopyToInnerXml(!isFromA);
  1471. }
  1472. public void LineCopyToLeft(LineDataItem lineData)
  1473. {
  1474. LineCopy(lineData, false);
  1475. }
  1476. public void LineCopyToRight(LineDataItem lineData)
  1477. {
  1478. LineCopy(lineData, true);
  1479. }
  1480. public void LineCopy(LineDataItem lineData, bool isFromA)
  1481. {
  1482. try
  1483. {
  1484. LineDataItem lineFrom = lineData;
  1485. ObservableCollection<LineDataItem> lineListTo = isFromA ? WholeListB : WholeListA;
  1486. Dictionary<string, LineDataItem> mapFrom = isFromA ? _mapLineTextA : _mapLineTextB;
  1487. Dictionary<string, LineDataItem> mapTo = isFromA ? _mapLineTextB : _mapLineTextA;
  1488. foreach (var lineTo in lineListTo)
  1489. {
  1490. if (lineTo.LineNumber != lineFrom.LineNumber)
  1491. continue;
  1492. lineTo.LineText = lineFrom.LineText;
  1493. lineTo.IsDiff = lineFrom.IsDiff = false;
  1494. lineTo.IsExtra = lineFrom.IsExtra = false;
  1495. break;
  1496. }
  1497. string recipeContent = "";
  1498. if (isFromA)
  1499. {
  1500. for (int i = 0; i < WholeListB.Count; i++)
  1501. {
  1502. recipeContent += WholeListB[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  1503. }
  1504. }
  1505. else
  1506. {
  1507. for (int i = 0; i < WholeListA.Count; i++)
  1508. {
  1509. recipeContent += WholeListA[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  1510. }
  1511. }
  1512. CopyToInnerXml(recipeContent, !isFromA);
  1513. LoadDataByRecipeContent(recipeContent, !isFromA);
  1514. Recompare();
  1515. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  1516. }
  1517. catch (Exception ex)
  1518. {
  1519. LOG.Write(ex.Message);
  1520. }
  1521. }
  1522. private void CopyToInnerXml(string recipeContent, bool isSelectA)
  1523. {
  1524. XmlDocument doc = isSelectA ? _domA : _domB;
  1525. doc.InnerXml = recipeContent;
  1526. if (isSelectA)
  1527. {
  1528. BackInnerXmlTextA.Add(recipeContent);
  1529. }
  1530. else
  1531. {
  1532. BackInnerXmlTextB.Add(recipeContent);
  1533. }
  1534. }
  1535. public void SaveA()
  1536. {
  1537. Save(true);
  1538. }
  1539. public void SaveB()
  1540. {
  1541. Save(false);
  1542. }
  1543. private void Save(bool isSelectA)
  1544. {
  1545. XmlDocument doc = isSelectA ? _domA : _domB;
  1546. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='{_module}']/Step");
  1547. if (nodeSteps == null)
  1548. nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Step");
  1549. if (isSelectA)
  1550. {
  1551. (new RecipeProvider()).SaveRecipe("", RecipeA, doc.InnerXml);
  1552. }
  1553. else
  1554. {
  1555. (new RecipeProvider()).SaveRecipe("", RecipeB, doc.InnerXml);
  1556. }
  1557. }
  1558. public void UndoA()
  1559. {
  1560. string xmlData = "";
  1561. string temp = "";
  1562. if (StepSelectionB != null)
  1563. temp = StepSelectionB.StepNumber;
  1564. for (var i = BackInnerXmlTextA.Count - 1; i >= 0;)
  1565. {
  1566. if (i > 0)
  1567. {
  1568. xmlData = BackInnerXmlTextA[i - 1];
  1569. BackInnerXmlTextA.RemoveAt(i);
  1570. }
  1571. else
  1572. xmlData = BackInnerXmlTextA[0];
  1573. break;
  1574. }
  1575. //_domA.InnerXml = xmlData;
  1576. LoadDataByRecipeContent(xmlData, true);
  1577. Recompare();
  1578. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  1579. if (!string.IsNullOrEmpty(temp))
  1580. {
  1581. foreach (StepDataItem tempStep in StepListB)
  1582. {
  1583. if (tempStep.StepNumber == temp)
  1584. {
  1585. StepSelectionB = tempStep;
  1586. break;
  1587. }
  1588. }
  1589. }
  1590. }
  1591. public void UndoB()
  1592. {
  1593. string xmlData = "";
  1594. string temp = "";
  1595. if (StepSelectionA != null)
  1596. temp = StepSelectionA.StepNumber;
  1597. for (var i = (BackInnerXmlTextB.Count - 1); i >= 0;)
  1598. {
  1599. if (i > 0)
  1600. {
  1601. xmlData = BackInnerXmlTextB[i - 1];
  1602. BackInnerXmlTextB.RemoveAt(i);
  1603. }
  1604. else
  1605. xmlData = BackInnerXmlTextB[0];
  1606. break;
  1607. }
  1608. //_domB.InnerXml = xmlData;
  1609. LoadDataByRecipeContent(xmlData, false);
  1610. Recompare();
  1611. SyncShowDiffSteps(IsShowDiffSteps, IsCompareBySName);
  1612. if (!string.IsNullOrEmpty(temp))
  1613. {
  1614. foreach (StepDataItem tempStep in StepListA)
  1615. {
  1616. if (tempStep.StepNumber == temp)
  1617. {
  1618. StepSelectionA = tempStep;
  1619. break;
  1620. }
  1621. }
  1622. }
  1623. }
  1624. private bool _isStepModel = true;
  1625. public bool IsStepModel
  1626. {
  1627. get { return _isStepModel; }
  1628. set
  1629. {
  1630. _isStepModel = value;
  1631. _isWholeModel = !_isStepModel;
  1632. StepVisibility = _isStepModel ? Visibility.Visible : Visibility.Hidden;
  1633. WholeVisibility = _isWholeModel ? Visibility.Visible : Visibility.Hidden;
  1634. InvokePropertyChanged(nameof(IsStepModel));
  1635. InvokePropertyChanged(nameof(IsWholeModel));
  1636. InvokePropertyChanged(nameof(StepVisibility));
  1637. InvokePropertyChanged(nameof(WholeVisibility));
  1638. }
  1639. }
  1640. private bool _isWholeModel;
  1641. public bool IsWholeModel
  1642. {
  1643. get { return _isWholeModel; }
  1644. set
  1645. {
  1646. _isWholeModel = value;
  1647. _isStepModel = !_isWholeModel;
  1648. StepVisibility = _isStepModel ? Visibility.Visible : Visibility.Hidden;
  1649. WholeVisibility = _isWholeModel ? Visibility.Visible : Visibility.Hidden;
  1650. InvokePropertyChanged(nameof(IsWholeModel));
  1651. InvokePropertyChanged(nameof(IsStepModel));
  1652. InvokePropertyChanged(nameof(StepVisibility));
  1653. InvokePropertyChanged(nameof(WholeVisibility));
  1654. }
  1655. }
  1656. public Visibility StepVisibility
  1657. {
  1658. get; set;
  1659. }
  1660. public Visibility WholeVisibility
  1661. {
  1662. get; set;
  1663. }
  1664. private bool _isShowDiffSteps;
  1665. public bool IsShowDiffSteps
  1666. {
  1667. get { return _isShowDiffSteps; }
  1668. set
  1669. {
  1670. _isShowDiffSteps = value;
  1671. _isShowAllSteps = !_isShowDiffSteps;
  1672. SyncShowDiffSteps(_isShowDiffSteps, _isCompareBySName);
  1673. InvokePropertyChanged(nameof(IsShowDiffSteps));
  1674. InvokePropertyChanged(nameof(IsShowAllSteps));
  1675. }
  1676. }
  1677. private bool _isShowAllSteps = true;
  1678. public bool IsShowAllSteps
  1679. {
  1680. get { return _isShowAllSteps; }
  1681. set
  1682. {
  1683. _isShowAllSteps = value;
  1684. _isShowDiffSteps = !_isShowAllSteps;
  1685. SyncShowDiffSteps(_isShowDiffSteps, _isCompareBySName);
  1686. InvokePropertyChanged(nameof(IsShowAllSteps));
  1687. InvokePropertyChanged(nameof(IsShowDiffSteps));
  1688. }
  1689. }
  1690. private bool _isShowDiffParams;
  1691. public bool IsShowDiffParams
  1692. {
  1693. get { return _isShowDiffParams; }
  1694. set
  1695. {
  1696. _isShowDiffParams = value;
  1697. SyncShowDiffParams(_isShowDiffParams);
  1698. _isShowAllParams = !_isShowDiffParams;
  1699. InvokePropertyChanged(nameof(IsShowDiffParams));
  1700. InvokePropertyChanged(nameof(IsShowAllParams));
  1701. }
  1702. }
  1703. private bool _isShowAllParams = true;
  1704. public bool IsShowAllParams
  1705. {
  1706. get { return _isShowAllParams; }
  1707. set
  1708. {
  1709. _isShowAllParams = value;
  1710. _isShowDiffParams = !_isShowAllParams;
  1711. SyncShowDiffParams(_isShowDiffParams);
  1712. InvokePropertyChanged(nameof(IsShowDiffParams));
  1713. InvokePropertyChanged(nameof(IsShowAllParams));
  1714. }
  1715. }
  1716. private bool _isCompareByStep = true;
  1717. public bool IsCompareByStep
  1718. {
  1719. get { return _isCompareByStep; }
  1720. set
  1721. {
  1722. _isCompareByStep = value;
  1723. _isCompareBySName = !_isCompareByStep;
  1724. SyncShowDiffSteps(_isShowDiffSteps, _isCompareBySName);
  1725. InvokePropertyChanged(nameof(IsCompareByStep));
  1726. InvokePropertyChanged(nameof(IsCompareBySName));
  1727. }
  1728. }
  1729. private bool _isCompareBySName;
  1730. public bool IsCompareBySName
  1731. {
  1732. get { return _isCompareBySName; }
  1733. set
  1734. {
  1735. _isCompareBySName = value;
  1736. _isCompareByStep = !_isCompareBySName;
  1737. SyncShowDiffSteps(_isShowDiffSteps, _isCompareBySName);
  1738. InvokePropertyChanged(nameof(IsCompareByStep));
  1739. InvokePropertyChanged(nameof(IsCompareBySName));
  1740. }
  1741. }
  1742. private void SyncShowDiffSteps(bool isShowDiffSteps, bool isCompareBySName)
  1743. {
  1744. if (StepListA == null || StepListB == null)
  1745. return;
  1746. foreach (var item in StepListA)
  1747. {
  1748. item.IsHidden = (IsShowDiffSteps ? (item.IsDiff == false && item.IsExtra == false) : false) || (isCompareBySName ? (item.IsDiffName || item.IsExtra == true) : false);
  1749. item.InvokePropertyChanged();
  1750. }
  1751. foreach (var item in StepListB)
  1752. {
  1753. item.IsHidden = (IsShowDiffSteps ? (item.IsDiff == false && item.IsExtra == false) : false) || (isCompareBySName ? (item.IsDiffName || item.IsExtra == true) : false);
  1754. item.InvokePropertyChanged();
  1755. }
  1756. NotifyOfPropertyChange(nameof(StepListA));
  1757. NotifyOfPropertyChange(nameof(StepListB));
  1758. }
  1759. private void SyncShowDiffParams(bool isShowDiffParams)
  1760. {
  1761. if (ParamListA == null || ParamListB == null)
  1762. return;
  1763. if (isShowDiffParams)
  1764. {
  1765. foreach (var item in ParamListA)
  1766. {
  1767. if (item.IsDiff == false && item.IsExtra == false)
  1768. {
  1769. item.IsHidden = isShowDiffParams;
  1770. item.InvokePropertyChanged();
  1771. }
  1772. }
  1773. foreach (var item in ParamListB)
  1774. {
  1775. if (item.IsDiff == false && item.IsExtra == false)
  1776. {
  1777. item.IsHidden = isShowDiffParams;
  1778. item.InvokePropertyChanged();
  1779. }
  1780. }
  1781. }
  1782. else
  1783. {
  1784. foreach (var item in ParamListA)
  1785. {
  1786. item.IsHidden = isShowDiffParams;
  1787. item.InvokePropertyChanged();
  1788. }
  1789. foreach (var item in ParamListB)
  1790. {
  1791. item.IsHidden = isShowDiffParams;
  1792. item.InvokePropertyChanged();
  1793. }
  1794. }
  1795. NotifyOfPropertyChange(nameof(ParamListA));
  1796. NotifyOfPropertyChange(nameof(ParamListB));
  1797. }
  1798. }
  1799. }