RecipesCompareViewModel.cs 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637
  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.Linq;
  15. using System.Text.RegularExpressions;
  16. using System.Windows;
  17. using System.Xml;
  18. namespace FurnaceUI.Views.Recipes
  19. {
  20. public class CompareItem : NotifiableItem
  21. {
  22. private bool _isDiff;
  23. public bool IsDiff
  24. {
  25. get => _isDiff;
  26. set
  27. {
  28. _isDiff = value;
  29. InvokePropertyChanged("IsDiff");
  30. InvokePropertyChanged("Background");
  31. }
  32. }
  33. public bool IsDiffName { get; set; }
  34. private bool _isExtra;
  35. public bool IsExtra
  36. {
  37. get => _isExtra;
  38. set
  39. {
  40. _isExtra = value;
  41. InvokePropertyChanged("IsExtra");
  42. InvokePropertyChanged("Background");
  43. }
  44. }
  45. private bool _isHidden;
  46. public bool IsHidden
  47. {
  48. get=> _isHidden;
  49. set
  50. {
  51. _isHidden = value;
  52. InvokePropertyChanged("IsHidden");
  53. }
  54. }
  55. public string Background
  56. {
  57. get
  58. {
  59. if (IsDiff)
  60. return "Tomato";
  61. if (IsExtra)
  62. return "Gold";
  63. return "White";
  64. }
  65. }
  66. public Visibility CopyVisibility
  67. {
  68. get
  69. {
  70. return IsDiff || IsExtra ? Visibility.Visible : Visibility.Hidden;
  71. }
  72. }
  73. }
  74. public class StepDataItem : CompareItem
  75. {
  76. public string StepNumber { get; set; }
  77. public string StepName { get; set; }
  78. }
  79. public class ParamDataItem : CompareItem
  80. {
  81. public string ParamName { get; set; }
  82. public string ParamValue { get; set; }
  83. }
  84. public class LineDataItem : CompareItem
  85. {
  86. public string LineNumber { get; set; }
  87. public string LineText { get; set; }
  88. }
  89. public class RecipesCompareViewModel : ModuleUiViewModelBase
  90. {
  91. private string _module = "PM1";
  92. public ObservableCollection<ProcessTypeFileItem> ProcessTypeFileList { get; set; }
  93. public ObservableCollection<string> ChamberType { get; set; }
  94. public ObservableCollection<string> RecipeProcessType { get; set; }
  95. public int ChamberTypeIndexSelection { get; set; }
  96. public int _processTypeIndexSelection;
  97. public int ProcessTypeIndexSelection
  98. {
  99. get { return _processTypeIndexSelection; }
  100. set { _processTypeIndexSelection = value; NotifyOfPropertyChange("ProcessTypeIndexSelection"); }
  101. }
  102. public string CurrentChamberType
  103. {
  104. get
  105. {
  106. return ChamberType[ChamberTypeIndexSelection];
  107. }
  108. }
  109. private string _currentProcessType;
  110. public string CurrentProcessType
  111. {
  112. get
  113. {
  114. if (ProcessTypeIndexSelection < 0)
  115. ProcessTypeIndexSelection = 0;
  116. if (ProcessTypeFileList.Count == 0)
  117. return "Process";
  118. return ProcessTypeFileList[ProcessTypeIndexSelection].ProcessType;
  119. }
  120. set { _currentProcessType = CurrentProcessType; NotifyOfPropertyChange("CurrentProcessType"); }
  121. }
  122. //-------------------------A Properties
  123. public ObservableCollection<StepDataItem> StepListA { get; set; }
  124. public ObservableCollection<ParamDataItem> ParamListA { get; set; }
  125. public ObservableCollection<LineDataItem> WholeListA { get; set; }
  126. public string RecipeA { get; set; }
  127. private XmlDocument _domA = new XmlDocument();
  128. private string _pathPrefixA;
  129. private Dictionary<string, ObservableCollection<ParamDataItem>> _mapStepParamA = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  130. private Dictionary<string, LineDataItem> _mapLineTextA = new Dictionary<string, LineDataItem>();
  131. private List<string> BackInnerXmlTextA = new List<string>();
  132. private bool _isChangedA { get; set; }
  133. public bool EnableButtonRemoveA
  134. {
  135. get { return !string.IsNullOrEmpty(RecipeA); }
  136. }
  137. public bool EnableButtonUndoA
  138. {
  139. get { return false; }
  140. }
  141. public bool EnableButtonSaveA
  142. {
  143. get { return false; }
  144. }
  145. private StepDataItem _stepSelectionA;
  146. public StepDataItem StepSelectionA
  147. {
  148. get
  149. {
  150. return _stepSelectionA;
  151. }
  152. set
  153. {
  154. SyncStepSelection(value, false);
  155. _stepSelectionA = value;
  156. }
  157. }
  158. private ParamDataItem _paramSelectionA;
  159. public ParamDataItem ParamSelectionA
  160. {
  161. get
  162. {
  163. return _paramSelectionA;
  164. }
  165. set
  166. {
  167. SyncParamSelection(value, false);
  168. _paramSelectionA = value;
  169. }
  170. }
  171. private LineDataItem _lineSelectionA;
  172. public LineDataItem LineSelectionA
  173. {
  174. get
  175. {
  176. return _lineSelectionA;
  177. }
  178. set
  179. {
  180. SyncLineSelection(value, false);
  181. _lineSelectionA = value;
  182. }
  183. }
  184. //-------------------------B Properties-------------------------------------------------------------
  185. public ObservableCollection<StepDataItem> StepListB { get; set; }
  186. public ObservableCollection<ParamDataItem> ParamListB { get; set; }
  187. public ObservableCollection<LineDataItem> WholeListB { get; set; }
  188. public string RecipeB { get; set; }
  189. private XmlDocument _domB = new XmlDocument();
  190. private string _pathPrefixB;
  191. private Dictionary<string, ObservableCollection<ParamDataItem>> _mapStepParamB = new Dictionary<string, ObservableCollection<ParamDataItem>>();
  192. private Dictionary<string, LineDataItem> _mapLineTextB = new Dictionary<string, LineDataItem>();
  193. private List<string> BackInnerXmlTextB = new List<string>();
  194. private string BaseTextB = "";
  195. private bool _isChangedB { get; set; }
  196. public bool EnableButtonRemoveB
  197. {
  198. get { return !string.IsNullOrEmpty(RecipeB); }
  199. }
  200. public bool EnableButtonUndoB
  201. {
  202. get { return false; }
  203. }
  204. public bool EnableButtonSaveB
  205. {
  206. get { return false; }
  207. }
  208. private StepDataItem _stepSelectionB;
  209. public StepDataItem StepSelectionB
  210. {
  211. get
  212. {
  213. return _stepSelectionB;
  214. }
  215. set
  216. {
  217. SyncStepSelection(value, true);
  218. _stepSelectionB = value;
  219. }
  220. }
  221. private ParamDataItem _paramSelectionB;
  222. public ParamDataItem ParamSelectionB
  223. {
  224. get
  225. {
  226. return _paramSelectionB;
  227. }
  228. set
  229. {
  230. SyncParamSelection(value, true);
  231. _paramSelectionB = value;
  232. }
  233. }
  234. private LineDataItem _lineSelectionB;
  235. public LineDataItem LineSelectionB
  236. {
  237. get
  238. {
  239. return _lineSelectionB;
  240. }
  241. set
  242. {
  243. SyncLineSelection(value, true);
  244. _lineSelectionB = value;
  245. }
  246. }
  247. private bool _isCurrentSelected = true;
  248. public bool IsCurrentSelected
  249. {
  250. get => _isCurrentSelected;
  251. set
  252. {
  253. _isCurrentSelected = value;
  254. NotifyOfPropertyChange(nameof(IsCurrentSelected));
  255. NotifyOfPropertyChange(nameof(ChkboxString));
  256. }
  257. }
  258. public string ChkboxString
  259. {
  260. get
  261. {
  262. if (_isCurrentSelected)
  263. {
  264. return "Current";
  265. }
  266. else
  267. {
  268. return "History";
  269. }
  270. }
  271. }
  272. public RecipesCompareViewModel()
  273. {
  274. StepListA = new ObservableCollection<StepDataItem>();
  275. ParamListA = new ObservableCollection<ParamDataItem>();
  276. WholeListA = new ObservableCollection<LineDataItem>();
  277. StepListB = new ObservableCollection<StepDataItem>();
  278. ParamListB = new ObservableCollection<ParamDataItem>();
  279. WholeListB = new ObservableCollection<LineDataItem>();
  280. }
  281. protected override void OnInitialize()
  282. {
  283. base.OnInitialize();
  284. var chamberType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedChamberType");
  285. if (chamberType == null)
  286. {
  287. ChamberType = new ObservableCollection<string>() { "Default" };
  288. }
  289. else
  290. {
  291. ChamberType = new ObservableCollection<string>(((string)(chamberType)).Split(','));
  292. }
  293. ChamberTypeIndexSelection = 0;
  294. //Etch:Process,Clean,Chuck,Dechuck;CVD:Process,Clean;
  295. var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  296. if (processType == null)
  297. {
  298. RecipeProcessType = new ObservableCollection<string>() { "Process" };
  299. }
  300. else
  301. {
  302. RecipeProcessType = new ObservableCollection<string>(((string)processType).Split(','));
  303. }
  304. ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  305. //var chamber = QueryDataClient.Instance.Service.GetConfig("System.Recipe.ChamberModules");
  306. UpdateProcessTypeFileList();
  307. }
  308. protected override void OnActivate()
  309. {
  310. base.OnActivate();
  311. }
  312. protected override void OnDeactivate(bool close)
  313. {
  314. base.OnDeactivate(close);
  315. }
  316. public void UpdateProcessTypeFileList()
  317. {
  318. ProcessTypeFileList.Clear();
  319. for (int i = 0; i < RecipeProcessType.Count; i++)
  320. {
  321. var type = new ProcessTypeFileItem();
  322. type.ProcessType = RecipeProcessType[i];
  323. var prefix = $"{ChamberType[ChamberTypeIndexSelection]}\\{RecipeProcessType[i]}";
  324. ProcessTypeFileList.Add(type);
  325. }
  326. while (ProcessTypeFileList.Count > RecipeProcessType.Count)
  327. {
  328. ProcessTypeFileList.RemoveAt(0);
  329. }
  330. }
  331. public void SelectA()
  332. {
  333. SelectRecipe(true);
  334. }
  335. public void SelectB()
  336. {
  337. //if (IsCurrentSelected)
  338. //{
  339. SelectBCurrent();
  340. //}
  341. //else
  342. //{
  343. // SelectBHistory();
  344. //}
  345. }
  346. public void SelectBHistory()
  347. {
  348. // SelectRecipe(false);
  349. try
  350. {
  351. RecipeCompareSelectDialogViewModel dialog = new RecipeCompareSelectDialogViewModel();
  352. dialog.DisplayName = "Select Recipe";
  353. SystemName = _module;
  354. dialog.IsSelectedA = false;
  355. var recipeProvider = new RecipeProvider();
  356. dialog.Chambers.Clear();
  357. recipeProvider.RestoreRecipeFolderList().ForEach(x => dialog.Chambers.Add(x));
  358. var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  359. if (processType == null)
  360. {
  361. processType = "Process";
  362. }
  363. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  364. string[] recipeProcessType = ((string)processType).Split(',');
  365. string[] partsType1 = new string[] { };
  366. string[] partsType2 = new string[] { };
  367. for (int i = 0; i < recipeProcessType.Length; i++)
  368. {
  369. var type = new ProcessTypeFileItem();
  370. type.ProcessType = recipeProcessType[i];
  371. var prefix = $"Furnace\\{recipeProcessType[i]}";
  372. var recipes = recipeProvider.GetXmlRecipeList(prefix, false);
  373. string[] parts = Regex.Split(recipes, "<");
  374. if (i == 0)
  375. {
  376. partsType1 = parts;
  377. }
  378. else if (i == 1)
  379. {
  380. partsType2 = parts;
  381. }
  382. string recipeChamber;
  383. recipeChamber = "<" + parts[1];
  384. foreach (string part in parts)
  385. {
  386. if (part.Contains($".{SystemName}"))
  387. {
  388. string temp = part.Replace($".{SystemName}", string.Empty);
  389. recipeChamber += "<" + temp;
  390. }
  391. }
  392. if (parts.Length > 2)
  393. {
  394. recipeChamber += "<" + parts[parts.Length - 1];
  395. }
  396. type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipeChamber)[0].Files;
  397. ProcessTypeFileList.Add(type);
  398. }
  399. dialog.ProcessTypeFileList = ProcessTypeFileList;
  400. WindowManager wm = new WindowManager();
  401. bool? bret = wm.ShowDialog(dialog);
  402. if (!(bool)bret)
  403. return;
  404. _module = dialog.SelectedChamber;
  405. string suffix = $".{_module}";
  406. string dialogResult = dialog.DialogResult;
  407. bool isFullPath = false;
  408. if (dialogResult.Contains(".rcp"))
  409. isFullPath = true;
  410. string recipeName = dialogResult;
  411. RecipeB = recipeName;
  412. NotifyOfPropertyChange(nameof(RecipeB));
  413. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  414. if (string.IsNullOrEmpty(RecipeB))
  415. {
  416. string[] recipe2 = RecipeB.Split('\\'); string r2 = recipe2[0];
  417. }
  418. LoadData(recipeName, false, false, isFullPath);
  419. Recompare();
  420. SyncShowDiffSteps(IsShowDiffSteps);
  421. }
  422. catch (Exception ex)
  423. {
  424. throw;
  425. }
  426. }
  427. public void SelectBCurrent()
  428. {
  429. try
  430. {
  431. RecipeCompareSelectDialogViewModel dialog = new RecipeCompareSelectDialogViewModel();
  432. dialog.DisplayName = "Select Recipe";
  433. SystemName = _module;
  434. var recipeProvider = new RecipeProvider();
  435. var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  436. if (processType == null)
  437. {
  438. processType = "Process";
  439. }
  440. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  441. string[] recipeProcessType = ((string)processType).Split(',');
  442. string[] partsType1 = new string[] { };
  443. string[] partsType2 = new string[] { };
  444. for (int i = 0; i < recipeProcessType.Length; i++)
  445. {
  446. var type = new ProcessTypeFileItem();
  447. type.ProcessType = recipeProcessType[i];
  448. var prefix = $"Furnace\\{recipeProcessType[i]}";
  449. //var recipes = recipeProvider.GetXmlRecipeList(prefix, false);
  450. //string[] parts = Regex.Split(recipes, "<");
  451. //if (i == 0)
  452. //{
  453. // partsType1 = parts;
  454. //}
  455. //else if (i == 1)
  456. //{
  457. // partsType2 = parts;
  458. //}
  459. //string recipeChamber;
  460. //recipeChamber = "<" + parts[1];
  461. //foreach (string part in parts)
  462. //{
  463. // if (part.Contains($".{SystemName}"))
  464. // {
  465. // string temp = part.Replace($".{SystemName}", string.Empty);
  466. // recipeChamber += "<" + temp;
  467. // }
  468. //}
  469. //if (parts.Length > 2)
  470. //{
  471. // recipeChamber += "<" + parts[parts.Length - 1];
  472. //}
  473. //type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipeChamber)[0].Files;
  474. type.FileListByProcessType = RecipeSequenceTreeBuilder.GetFileNodeParameterList(prefix);
  475. ProcessTypeFileList.Add(type);
  476. }
  477. dialog.ProcessTypeFileList = ProcessTypeFileList;
  478. WindowManager wm = new WindowManager();
  479. bool? bret = wm.ShowDialog(dialog);
  480. if (!(bool)bret)
  481. return;
  482. _module = dialog.SelectedChamber;
  483. string suffix = $".{_module}";
  484. string dialogResult = dialog.DialogResult;
  485. bool isFullPath = false;
  486. if (dialogResult.Contains(".rcp"))
  487. isFullPath = true;
  488. string recipeName = dialogResult;
  489. RecipeB = recipeName;
  490. NotifyOfPropertyChange(nameof(RecipeB));
  491. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  492. if (!string.IsNullOrEmpty(RecipeA) && !string.IsNullOrEmpty(RecipeB))
  493. {
  494. string[] recipe1 = RecipeA.Split('\\'); string r1 = recipe1[0];
  495. string[] recipe2 = RecipeB.Split('\\'); string r2 = recipe2[0];
  496. if (r1 != r2)
  497. {
  498. if (MessageBoxResult.Yes != MessageBox.Show($"腔体类型不一致! \n 是否继续比较 ?", "", MessageBoxButton.YesNo, MessageBoxImage.Information))
  499. {
  500. RemoveSelectB();
  501. return;
  502. }
  503. }
  504. }
  505. LoadData(recipeName, false, true, isFullPath);
  506. Recompare();
  507. SyncShowDiffSteps(IsShowDiffSteps);
  508. }
  509. catch (Exception ex)
  510. {
  511. LOG.Error(ex.Message);
  512. }
  513. }
  514. private void SelectRecipe(bool isSelectA)
  515. {
  516. try
  517. {
  518. RecipeCompareSelectDialogViewModel dialog = new RecipeCompareSelectDialogViewModel();
  519. dialog.DisplayName = "Select Recipe";
  520. SystemName = _module;
  521. var recipeProvider = new RecipeProvider();
  522. var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");
  523. if (processType == null)
  524. {
  525. processType = "Process";
  526. }
  527. var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItem>();
  528. string[] recipeProcessType = ((string)processType).Split(',');
  529. string[] partsType1 = new string[] { };
  530. string[] partsType2 = new string[] { };
  531. for (int i = 0; i < recipeProcessType.Length; i++)
  532. {
  533. var type = new ProcessTypeFileItem();
  534. type.ProcessType = recipeProcessType[i];
  535. var prefix = $"Furnace\\{recipeProcessType[i]}";
  536. var recipes = recipeProvider.GetXmlRecipeList(prefix, false);
  537. //string[] parts = Regex.Split(recipes, "<");
  538. //if (i == 0)
  539. //{
  540. // partsType1 = parts;
  541. //}
  542. //else if (i == 1)
  543. //{
  544. // partsType2 = parts;
  545. //}
  546. //string recipeChamber;
  547. //recipeChamber = "<" + parts[1];
  548. //foreach (string part in parts)
  549. //{
  550. // if (part.Contains($".{SystemName}"))
  551. // {
  552. // string temp = part.Replace($".{SystemName}", string.Empty);
  553. // recipeChamber += "<" + temp;
  554. // }
  555. //}
  556. //if (parts.Length > 2)
  557. //{
  558. // recipeChamber += "<" + parts[parts.Length - 1];
  559. //}
  560. // type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipeChamber)[0].Files;
  561. type.FileListByProcessType = RecipeSequenceTreeBuilder.GetFileNodeParameterList(prefix);
  562. ProcessTypeFileList.Add(type);
  563. }
  564. dialog.ProcessTypeFileList = ProcessTypeFileList;
  565. WindowManager wm = new WindowManager();
  566. bool? bret = wm.ShowDialog(dialog);
  567. if (!(bool)bret)
  568. return;
  569. _module = dialog.SelectedChamber;
  570. string suffix = $".{_module}";
  571. string dialogResult = dialog.DialogResult;
  572. bool isFullPath = false;
  573. if (dialogResult.Contains(".rcp"))
  574. isFullPath = true;
  575. string recipeName = dialogResult;
  576. if (isSelectA)
  577. {
  578. RecipeA = recipeName;
  579. NotifyOfPropertyChange(nameof(RecipeA));
  580. NotifyOfPropertyChange(nameof(EnableButtonRemoveA));
  581. }
  582. else
  583. {
  584. RecipeB = recipeName;
  585. NotifyOfPropertyChange(nameof(RecipeB));
  586. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  587. }
  588. if (!string.IsNullOrEmpty(RecipeA) && !string.IsNullOrEmpty(RecipeB))
  589. {
  590. string[] recipe1 = RecipeA.Split('\\'); string r1 = recipe1[0];
  591. string[] recipe2 = RecipeB.Split('\\'); string r2 = recipe2[0];
  592. if (r1 != r2)
  593. {
  594. if (MessageBoxResult.Yes != MessageBox.Show($"腔体类型不一致! \n 是否继续比较 ?", "", MessageBoxButton.YesNo, MessageBoxImage.Information))
  595. {
  596. RemoveSelectB();
  597. return;
  598. }
  599. }
  600. }
  601. LoadData(recipeName, isSelectA, true, isFullPath);
  602. Recompare();
  603. SyncShowDiffSteps(IsShowDiffSteps);
  604. }
  605. catch (Exception ex)
  606. {
  607. throw;
  608. }
  609. }
  610. public void LoadData(string selectedRecipePath, bool isSelectA, bool isCurrent, bool isFullPath)
  611. {
  612. var array = selectedRecipePath.Split(new char[] { '\\' });
  613. string recipeName = array[array.Length - 1];
  614. XmlDocument doc = isSelectA ? _domA : _domB;
  615. string prefixPath = (isSelectA ? RecipeA : RecipeB).Replace(recipeName, "");
  616. var _recipeProvider = new RecipeProvider();
  617. string recipeContent;
  618. if (isSelectA)
  619. {
  620. recipeContent = isFullPath ? _recipeProvider.LoadRecipeByFullPath(selectedRecipePath) : _recipeProvider.LoadRecipe(prefixPath, recipeName, false);
  621. }
  622. else
  623. {
  624. if (isCurrent)
  625. {
  626. recipeContent = _recipeProvider.LoadRecipe(prefixPath, recipeName);
  627. }
  628. else
  629. {
  630. recipeContent = _recipeProvider.LoadRestoreRecipe(prefixPath, recipeName);
  631. }
  632. }
  633. if (string.IsNullOrEmpty(recipeContent))
  634. {
  635. MessageBox.Show($"{prefixPath}\\{recipeName} is empty, please confirm the file is valid.");
  636. return;
  637. }
  638. if (isSelectA)
  639. {
  640. BackInnerXmlTextA.Clear();
  641. if (BackInnerXmlTextB.Count > 0)
  642. {
  643. string dataXml = BackInnerXmlTextB[0];
  644. BackInnerXmlTextB.Clear();
  645. BackInnerXmlTextB.Add(dataXml);
  646. }
  647. }
  648. else
  649. {
  650. BackInnerXmlTextB.Clear();
  651. if (BackInnerXmlTextA.Count > 0)
  652. {
  653. string dataXml = BackInnerXmlTextA[0];
  654. BackInnerXmlTextA.Clear();
  655. BackInnerXmlTextA.Add(dataXml);
  656. }
  657. }
  658. if (isSelectA)
  659. {
  660. _pathPrefixA = prefixPath;
  661. _mapLineTextA = new Dictionary<string, LineDataItem>();
  662. BackInnerXmlTextA.Add(recipeContent);
  663. }
  664. else
  665. {
  666. _pathPrefixB = prefixPath;
  667. _mapLineTextB = new Dictionary<string, LineDataItem>();
  668. BackInnerXmlTextB.Add(recipeContent);
  669. }
  670. LoadrecipeContentData(recipeContent, isSelectA);
  671. }
  672. public void StepGridSelectionChangedA()
  673. {
  674. if (StepSelectionA == null)
  675. {
  676. ParamListA.Clear();
  677. NotifyOfPropertyChange(nameof(ParamListA));
  678. return;
  679. }
  680. if (_mapStepParamA.ContainsKey(StepSelectionA.StepNumber))
  681. {
  682. ParamListA = _mapStepParamA[StepSelectionA.StepNumber];
  683. foreach (ParamDataItem item in ParamListA)
  684. {
  685. item.IsHidden = (!item.IsDiff && !item.IsExtra && IsShowDiffParams) ? true : false;
  686. }
  687. NotifyOfPropertyChange(nameof(ParamListA));
  688. NotifyOfPropertyChange(nameof(StepSelectionA));
  689. StepSelectionA.InvokePropertyChanged();
  690. }
  691. }
  692. public void LoadDataByRecipeContent(string recipeContent, bool isSelectA)
  693. {
  694. LoadrecipeContentData(recipeContent, isSelectA);
  695. }
  696. private void LoadrecipeContentData(string recipeContent, bool isSelectA)
  697. {
  698. XmlDocument doc = isSelectA ? _domA : _domB;
  699. if (isSelectA)
  700. {
  701. _mapLineTextA = new Dictionary<string, LineDataItem>();
  702. //BackInnerXmlTextA.Add(recipeContent);
  703. }
  704. else
  705. {
  706. _mapLineTextB = new Dictionary<string, LineDataItem>();
  707. //BackInnerXmlTextB.Add(recipeContent);
  708. }
  709. string[] allText = recipeContent.Split(new string[] { "\r\n" }, StringSplitOptions.None);
  710. int number = 0;
  711. ObservableCollection<LineDataItem> lineData = new ObservableCollection<LineDataItem>();
  712. foreach (string lineText in allText)
  713. {
  714. LineDataItem line = new LineDataItem();
  715. line.LineNumber = (++number).ToString();
  716. line.LineText = lineText;
  717. if (!string.IsNullOrEmpty(lineText))
  718. {
  719. lineData.Add(line);
  720. if (isSelectA)
  721. {
  722. _mapLineTextA[line.LineNumber] = line;
  723. }
  724. else
  725. {
  726. _mapLineTextB[line.LineNumber] = line;
  727. }
  728. }
  729. }
  730. doc.LoadXml(recipeContent);
  731. ObservableCollection<StepDataItem> stepData = new ObservableCollection<StepDataItem>();
  732. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  733. if (nodeSteps == null)
  734. nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Step");
  735. foreach (XmlNode nodeStep in nodeSteps)
  736. {
  737. ObservableCollection<ParamDataItem> paramData = new ObservableCollection<ParamDataItem>();
  738. StepDataItem step = new StepDataItem();
  739. foreach (XmlAttribute attr in nodeStep.Attributes)
  740. {
  741. if (attr.Name == "StepNo")
  742. step.StepNumber = attr.Value;
  743. else if (attr.Name == "Name")
  744. step.StepName = attr.Value;
  745. else
  746. {
  747. if (!attr.Name.Contains("IsSaved"))
  748. {
  749. ParamDataItem param = new ParamDataItem();
  750. param.ParamName = attr.Name;
  751. param.ParamValue = attr.Value;
  752. paramData.Add(param);
  753. }
  754. }
  755. }
  756. stepData.Add(step);
  757. if (isSelectA)
  758. {
  759. _mapStepParamA[step.StepNumber] = paramData;
  760. }
  761. else
  762. {
  763. _mapStepParamB[step.StepNumber] = paramData;
  764. }
  765. }
  766. if (isSelectA)
  767. {
  768. StepListA = new ObservableCollection<StepDataItem>(stepData.OrderBy(x => int.Parse(x.StepNumber)));
  769. NotifyOfPropertyChange(nameof(StepListA));
  770. WholeListA = new ObservableCollection<LineDataItem>(lineData.OrderBy(x => int.Parse(x.LineNumber)));
  771. NotifyOfPropertyChange(nameof(WholeListA));
  772. }
  773. else
  774. {
  775. StepListB = new ObservableCollection<StepDataItem>(stepData.OrderBy(x => int.Parse(x.StepNumber)));
  776. NotifyOfPropertyChange(nameof(StepListB));
  777. WholeListB = new ObservableCollection<LineDataItem>(lineData.OrderBy(x => int.Parse(x.LineNumber)));
  778. NotifyOfPropertyChange(nameof(WholeListB));
  779. }
  780. }
  781. public void StepGridSelectionChangedB()
  782. {
  783. if (StepSelectionB == null)
  784. {
  785. ParamListB.Clear();
  786. NotifyOfPropertyChange(nameof(ParamListB));
  787. return;
  788. }
  789. if (_mapStepParamB.ContainsKey(StepSelectionB.StepNumber))
  790. {
  791. ParamListB = _mapStepParamB[StepSelectionB.StepNumber];
  792. foreach (ParamDataItem item in ParamListB)
  793. {
  794. item.IsHidden = (!item.IsDiff && !item.IsExtra && IsShowDiffParams) ? true : false;
  795. }
  796. NotifyOfPropertyChange(nameof(ParamListB));
  797. NotifyOfPropertyChange(nameof(StepSelectionB));
  798. StepSelectionB.InvokePropertyChanged();
  799. }
  800. }
  801. public void ParamGridSelectionChangedA()
  802. {
  803. if (ParamSelectionA == null)
  804. {
  805. return;
  806. }
  807. NotifyOfPropertyChange(nameof(ParamSelectionA));
  808. ParamSelectionA.InvokePropertyChanged();
  809. }
  810. public void ParamGridSelectionChangedB()
  811. {
  812. if (ParamSelectionB == null)
  813. {
  814. return;
  815. }
  816. NotifyOfPropertyChange(nameof(ParamSelectionB));
  817. ParamSelectionB.InvokePropertyChanged();
  818. }
  819. public void WholeGridSelectionChangedA()
  820. {
  821. if (LineSelectionA == null)
  822. {
  823. return;
  824. }
  825. NotifyOfPropertyChange(nameof(LineSelectionA));
  826. LineSelectionA.InvokePropertyChanged();
  827. }
  828. public void WholeGridSelectionChangedB()
  829. {
  830. if (LineSelectionB == null)
  831. {
  832. return;
  833. }
  834. NotifyOfPropertyChange(nameof(LineSelectionB));
  835. LineSelectionB.InvokePropertyChanged();
  836. }
  837. public void SaveLineA()
  838. {
  839. if (LineSelectionA == null)
  840. return;
  841. foreach (LineDataItem lineDataItem in WholeListA)
  842. {
  843. if (lineDataItem.LineNumber == LineSelectionA.LineNumber)
  844. {
  845. lineDataItem.LineText = LineSelectionA.LineText;
  846. break;
  847. }
  848. }
  849. string recipeContent = "";
  850. for (int i = 0; i < WholeListA.Count; i++)
  851. {
  852. recipeContent += WholeListA[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  853. }
  854. CopyToInnerXml(recipeContent, true);
  855. LoadDataByRecipeContent(recipeContent, true);
  856. Recompare();
  857. SyncShowDiffSteps(IsShowDiffSteps);
  858. }
  859. public void SaveLineB()
  860. {
  861. if (LineSelectionB == null)
  862. return;
  863. foreach (LineDataItem lineDataItem in WholeListB)
  864. {
  865. if (lineDataItem.LineNumber == LineSelectionB.LineNumber)
  866. {
  867. lineDataItem.LineText = LineSelectionB.LineText;
  868. break;
  869. }
  870. }
  871. string recipeContent = "";
  872. for (int i = 0; i < WholeListB.Count; i++)
  873. {
  874. recipeContent += WholeListB[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  875. }
  876. CopyToInnerXml(recipeContent, false);
  877. LoadDataByRecipeContent(recipeContent, false);
  878. Recompare();
  879. SyncShowDiffSteps(IsShowDiffSteps);
  880. }
  881. private void Recompare()
  882. {
  883. if (IsCompareByStep)
  884. {
  885. RecompareStepByStep();
  886. }
  887. if (IsCompareBySName)
  888. {
  889. RecompareStepByName();
  890. }
  891. RecompareWhole();
  892. }
  893. private void RecompareStepByStep()
  894. {
  895. if (StepListA == null || StepListB == null)
  896. return;
  897. var stepAMaxNumber = (StepListA == null || StepListA.Count() == 0) ? 0 : StepListA.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  898. var stepBMaxNumber = (StepListB == null || StepListB.Count() == 0) ? 0 : StepListB.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  899. int stepMaxNumber = stepAMaxNumber > stepBMaxNumber ? stepAMaxNumber : stepBMaxNumber;
  900. for (int i = 0; i < stepMaxNumber + 1; i++)
  901. {
  902. StepDataItem getStepA = (StepListA == null || StepListA.Count() == 0) ? null : (StepListA.Where(x => x.StepNumber == i.ToString()) == null ? null : StepListA.Where(x => x.StepNumber == i.ToString()).FirstOrDefault());
  903. StepDataItem getStepB = (StepListB == null || StepListB.Count() == 0) ? null : (StepListB.Where(x => x.StepNumber == i.ToString()) == null ? null : StepListB.Where(x => x.StepNumber == i.ToString()).FirstOrDefault());
  904. if (getStepA != null && getStepB != null)
  905. {
  906. if (getStepA.StepName == getStepB.StepName)
  907. getStepA.IsDiffName = getStepB.IsDiffName = false;
  908. else
  909. getStepA.IsDiffName = getStepB.IsDiffName = true;
  910. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(i.ToString()) ? _mapStepParamA[i.ToString()] : null;
  911. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(i.ToString()) ? _mapStepParamB[i.ToString()] : null;
  912. bool isDiff = false;
  913. bool IsExtra = true;
  914. if (paramA != null && paramB == null)
  915. {
  916. foreach (var pa in paramA)
  917. {
  918. pa.IsExtra = true;
  919. pa.IsDiff = false;
  920. }
  921. }
  922. else if (paramA == null && paramB != null)
  923. {
  924. foreach (var pb in paramB)
  925. {
  926. pb.IsExtra = true;
  927. pb.IsDiff = false;
  928. }
  929. }
  930. else if (paramA != null && paramB != null)
  931. {
  932. foreach (var pa in paramA)
  933. {
  934. var getParam = paramB.Where(pb => pb.ParamName == pa.ParamName).FirstOrDefault();
  935. if (getParam != null)
  936. {
  937. pa.IsExtra = false;
  938. getParam.IsExtra = false;
  939. getParam.IsDiff = pa.IsDiff = (pa.ParamValue != getParam.ParamValue);
  940. if (pa.ParamValue != getParam.ParamValue)
  941. {
  942. isDiff = true;
  943. }
  944. }
  945. }
  946. getStepA.IsExtra = getStepB.IsExtra = false;
  947. }
  948. if (paramA != null)
  949. {
  950. foreach (var pa in paramA)
  951. {
  952. pa.InvokePropertyChanged();
  953. }
  954. }
  955. if (paramB != null)
  956. {
  957. foreach (var pb in paramB)
  958. {
  959. pb.InvokePropertyChanged();
  960. }
  961. }
  962. getStepA.IsDiff = getStepB.IsDiff = isDiff;
  963. getStepA.IsHidden = getStepB.IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  964. getStepA.InvokePropertyChanged();
  965. getStepB.InvokePropertyChanged();
  966. }
  967. else if (getStepA == null && getStepB != null)
  968. {
  969. getStepB.IsExtra = true;
  970. getStepB.IsDiff = false;
  971. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  972. foreach (var pb in paramB)
  973. {
  974. pb.IsExtra = false;
  975. pb.IsDiff = false;
  976. pb.InvokePropertyChanged();
  977. }
  978. getStepB.InvokePropertyChanged();
  979. continue;
  980. }
  981. else if (getStepA != null && getStepB == null)
  982. {
  983. getStepA.IsExtra = true;
  984. getStepA.IsDiff = false;
  985. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(getStepA.StepNumber) ? _mapStepParamA[getStepA.StepNumber] : null;
  986. foreach (var pa in paramA)
  987. {
  988. pa.IsExtra = false;
  989. pa.IsDiff = false;
  990. pa.InvokePropertyChanged();
  991. }
  992. getStepA.InvokePropertyChanged();
  993. continue;
  994. }
  995. else
  996. {
  997. continue;
  998. }
  999. }
  1000. NotifyOfPropertyChange(nameof(StepListA));
  1001. NotifyOfPropertyChange(nameof(StepListB));
  1002. }
  1003. private void RecompareStepByName()
  1004. {
  1005. if (StepListA == null || StepListB == null)
  1006. return;
  1007. var stepAMaxNumber = (StepListA == null || StepListA.Count() == 0) ? 0 : StepListA.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1008. var stepBMaxNumber = (StepListB == null || StepListB.Count() == 0) ? 0 : StepListB.Select(stepItem => int.Parse(stepItem.StepNumber)).Max();
  1009. int stepMaxNumber = stepAMaxNumber > stepBMaxNumber ? stepAMaxNumber : stepBMaxNumber;
  1010. foreach (var getStepA in StepListA)
  1011. {
  1012. StepDataItem getStepB = (StepListB.Where(x => x.StepName == getStepA.StepName) == null ? null : StepListB.Where(x => x.StepName == getStepA.StepName).FirstOrDefault());
  1013. if (getStepB == null)
  1014. {
  1015. getStepA.IsDiff = false;
  1016. getStepA.IsExtra = true;
  1017. continue;
  1018. }
  1019. getStepA.IsDiffName = getStepB.IsDiffName = true;
  1020. ObservableCollection<ParamDataItem> paramA = _mapStepParamA.ContainsKey(getStepA.StepNumber) ? _mapStepParamA[getStepA.StepNumber] : null;
  1021. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  1022. bool isDiff = false;
  1023. bool IsExtra = true;
  1024. if (paramA != null && paramB == null)
  1025. {
  1026. foreach (var pa in paramA)
  1027. {
  1028. pa.IsExtra = true;
  1029. pa.IsDiff = false;
  1030. }
  1031. }
  1032. else if (paramA == null && paramB != null)
  1033. {
  1034. foreach (var pb in paramB)
  1035. {
  1036. pb.IsExtra = true;
  1037. pb.IsDiff = false;
  1038. }
  1039. }
  1040. else if (paramA != null && paramB != null)
  1041. {
  1042. foreach (var pa in paramA)
  1043. {
  1044. var getParam = paramB.Where(pb => pb.ParamName == pa.ParamName).FirstOrDefault();
  1045. if (getParam != null)
  1046. {
  1047. pa.IsExtra = false;
  1048. getParam.IsExtra = false;
  1049. getParam.IsDiff = pa.IsDiff = (pa.ParamValue != getParam.ParamValue);
  1050. if (pa.ParamValue != getParam.ParamValue)
  1051. {
  1052. isDiff = true;
  1053. }
  1054. }
  1055. }
  1056. getStepA.IsExtra = getStepB.IsExtra = false;
  1057. }
  1058. if (paramA != null)
  1059. {
  1060. foreach (var pa in paramA)
  1061. {
  1062. pa.InvokePropertyChanged();
  1063. }
  1064. }
  1065. if (paramB != null)
  1066. {
  1067. foreach (var pb in paramB)
  1068. {
  1069. pb.InvokePropertyChanged();
  1070. }
  1071. }
  1072. getStepA.IsDiff = getStepB.IsDiff = isDiff;
  1073. getStepA.IsHidden = getStepB.IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1074. getStepA.InvokePropertyChanged();
  1075. getStepB.InvokePropertyChanged();
  1076. }
  1077. foreach (var getStepB in StepListB)
  1078. {
  1079. StepDataItem getStepA = (StepListA.Where(x => x.StepName == getStepB.StepName) == null ? null : StepListA.Where(x => x.StepName == getStepB.StepName).FirstOrDefault());
  1080. if (getStepA != null)
  1081. { continue; }
  1082. getStepB.IsExtra = true;
  1083. getStepB.IsDiff = false;
  1084. ObservableCollection<ParamDataItem> paramB = _mapStepParamB.ContainsKey(getStepB.StepNumber) ? _mapStepParamB[getStepB.StepNumber] : null;
  1085. foreach (var pb in paramB)
  1086. {
  1087. pb.IsExtra = false;
  1088. pb.IsDiff = false;
  1089. pb.InvokePropertyChanged();
  1090. }
  1091. getStepB.InvokePropertyChanged();
  1092. }
  1093. NotifyOfPropertyChange(nameof(StepListA));
  1094. NotifyOfPropertyChange(nameof(StepListB));
  1095. }
  1096. //private void RecompareStep()
  1097. //{
  1098. // if (StepListA == null || StepListB == null)
  1099. // return;
  1100. // int i = 0;
  1101. // for (i = 0; i < StepListA.Count && i < StepListB.Count; i++)
  1102. // {
  1103. // if (StepListA[i].StepName == StepListB[i].StepName)
  1104. // StepListA[i].IsDiffName = StepListB[i].IsDiffName = false;
  1105. // else
  1106. // StepListA[i].IsDiffName = StepListB[i].IsDiffName = true;
  1107. // ObservableCollection<ParamDataItem> paramA = _mapStepParamA[StepListA[i].StepNumber];
  1108. // ObservableCollection<ParamDataItem> paramB = _mapStepParamB[StepListB[i].StepNumber];
  1109. // bool isDiff = false;
  1110. // bool IsExtra = true;
  1111. // foreach (var pa in paramA)
  1112. // {
  1113. // pa.IsExtra = true;
  1114. // }
  1115. // foreach (var pb in paramB)
  1116. // {
  1117. // pb.IsExtra = true;
  1118. // }
  1119. // foreach (var pa in paramA)
  1120. // {
  1121. // foreach (var pb in paramB)
  1122. // {
  1123. // if (pb.ParamName == pa.ParamName)
  1124. // {
  1125. // pb.IsExtra = false;
  1126. // pa.IsExtra = false;
  1127. // pb.IsDiff = pa.IsDiff = (pa.ParamValue != pb.ParamValue);
  1128. // if (pa.IsDiff)
  1129. // isDiff = true;
  1130. // break;
  1131. // }
  1132. // }
  1133. // }
  1134. // foreach (var pa in paramA)
  1135. // {
  1136. // pa.InvokePropertyChanged();
  1137. // }
  1138. // foreach (var pb in paramB)
  1139. // {
  1140. // pb.InvokePropertyChanged();
  1141. // }
  1142. // StepListA[i].IsDiff = StepListB[i].IsDiff = isDiff;
  1143. // StepListA[i].IsExtra = StepListB[i].IsExtra = false;
  1144. // StepListA[i].IsHidden = StepListB[i].IsHidden = !isDiff && IsShowDiffSteps ? true : false;
  1145. // StepListA[i].InvokePropertyChanged();
  1146. // StepListB[i].InvokePropertyChanged();
  1147. // }
  1148. // for (int j = i; j < StepListA.Count; j++)
  1149. // {
  1150. // StepListA[j].IsDiff = false;
  1151. // StepListA[j].IsExtra = true;
  1152. // StepListA[j].InvokePropertyChanged();
  1153. // foreach (var pa in _mapStepParamA[StepListA[j].StepNumber])
  1154. // {
  1155. // pa.InvokePropertyChanged();
  1156. // }
  1157. // }
  1158. // for (int k = i; k < StepListB.Count; k++)
  1159. // {
  1160. // StepListB[k].IsDiff = false;
  1161. // StepListB[k].IsExtra = true;
  1162. // WholeListB[k].InvokePropertyChanged();
  1163. // _mapLineTextB[WholeListB[k].LineNumber].InvokePropertyChanged();
  1164. // foreach (var pb in _mapStepParamB[StepListB[k].StepNumber])
  1165. // {
  1166. // pb.InvokePropertyChanged();
  1167. // }
  1168. // }
  1169. // NotifyOfPropertyChange(nameof(StepListA));
  1170. // NotifyOfPropertyChange(nameof(StepListB));
  1171. //}
  1172. private void RecompareWhole()
  1173. {
  1174. if (WholeListA == null || WholeListB == null)
  1175. return;
  1176. int i = 0;
  1177. for (i = 0; i < WholeListA.Count && i < WholeListB.Count; i++)
  1178. {
  1179. LineDataItem lineA = _mapLineTextA[WholeListA[i].LineNumber];
  1180. LineDataItem lineB = _mapLineTextB[WholeListB[i].LineNumber];
  1181. bool isDiff = false;
  1182. lineB.IsDiff = lineA.IsDiff = (lineA.LineText != lineB.LineText);
  1183. if (lineA.IsDiff)
  1184. isDiff = true;
  1185. WholeListA[i].IsDiff = WholeListB[i].IsDiff = isDiff;
  1186. WholeListA[i].IsExtra = WholeListB[i].IsExtra = false;
  1187. _mapLineTextA[WholeListA[i].LineNumber].IsDiff = _mapLineTextB[WholeListB[i].LineNumber].IsDiff = isDiff;
  1188. _mapLineTextA[WholeListA[i].LineNumber].IsExtra = _mapLineTextB[WholeListB[i].LineNumber].IsExtra = false;
  1189. lineA.InvokePropertyChanged();
  1190. lineB.InvokePropertyChanged();
  1191. WholeListA[i].InvokePropertyChanged();
  1192. WholeListB[i].InvokePropertyChanged();
  1193. }
  1194. for (int j = i; j < WholeListA.Count; j++)
  1195. {
  1196. WholeListA[j].IsDiff = false;
  1197. WholeListA[j].IsExtra = true;
  1198. _mapLineTextA[WholeListA[j].LineNumber].IsDiff = false;
  1199. _mapLineTextA[WholeListA[j].LineNumber].IsExtra = true;
  1200. if (!(_mapLineTextA[WholeListA[j].LineNumber].LineText.Contains("<Step StepNo") || _mapLineTextA[WholeListA[j].LineNumber].LineText.Contains("<Moudule Name")))
  1201. {
  1202. WholeListA[j].IsDiff = false;
  1203. WholeListA[j].IsExtra = false;
  1204. }
  1205. WholeListA[j].InvokePropertyChanged();
  1206. _mapLineTextA[WholeListA[j].LineNumber].InvokePropertyChanged();
  1207. }
  1208. for (int k = i; k < WholeListB.Count; k++)
  1209. {
  1210. WholeListB[k].IsDiff = false;
  1211. WholeListB[k].IsExtra = true;
  1212. _mapLineTextB[WholeListB[k].LineNumber].IsDiff = false;
  1213. _mapLineTextB[WholeListB[k].LineNumber].IsExtra = true;
  1214. if (!(_mapLineTextB[WholeListB[k].LineNumber].LineText.Contains("<Step StepNo") || _mapLineTextB[WholeListB[k].LineNumber].LineText.Contains("<Moudule Name")))
  1215. {
  1216. WholeListB[k].IsDiff = false;
  1217. WholeListB[k].IsExtra = false;
  1218. }
  1219. WholeListB[k].InvokePropertyChanged();
  1220. _mapLineTextB[WholeListB[k].LineNumber].InvokePropertyChanged();
  1221. }
  1222. NotifyOfPropertyChange(nameof(WholeListA));
  1223. NotifyOfPropertyChange(nameof(WholeListB));
  1224. }
  1225. private void SyncStepSelection(StepDataItem stepData, bool isSelectA)
  1226. {
  1227. if (stepData == null)
  1228. return;
  1229. if (isSelectA)
  1230. {
  1231. if (IsCompareByStep)
  1232. {
  1233. var getStepA = StepListA.Where(x => x.StepNumber == stepData.StepNumber).FirstOrDefault();
  1234. if (getStepA == null)
  1235. {
  1236. ParamListA.Clear();
  1237. }
  1238. else
  1239. {
  1240. _stepSelectionA = getStepA;
  1241. NotifyOfPropertyChange(nameof(StepSelectionA));
  1242. StepSelectionA.InvokePropertyChanged();
  1243. }
  1244. }
  1245. if (IsCompareBySName)
  1246. {
  1247. var getStepA = StepListA.Where(x => x.StepName == stepData.StepName).FirstOrDefault();
  1248. if (getStepA == null)
  1249. {
  1250. ParamListA.Clear();
  1251. }
  1252. else
  1253. {
  1254. _stepSelectionA = getStepA;
  1255. NotifyOfPropertyChange(nameof(StepSelectionA));
  1256. StepSelectionA.InvokePropertyChanged();
  1257. }
  1258. }
  1259. }
  1260. else
  1261. {
  1262. if (IsCompareByStep)
  1263. {
  1264. var getStepB = StepListB.Where(x => x.StepNumber == stepData.StepNumber).FirstOrDefault();
  1265. if (getStepB == null)
  1266. {
  1267. ParamListB.Clear();
  1268. }
  1269. else
  1270. {
  1271. _stepSelectionB = getStepB;
  1272. NotifyOfPropertyChange(nameof(StepSelectionB));
  1273. StepSelectionB.InvokePropertyChanged();
  1274. }
  1275. }
  1276. if (IsCompareBySName)
  1277. {
  1278. var getStepB = StepListB.Where(x => x.StepName == stepData.StepName).FirstOrDefault();
  1279. if (getStepB == null)
  1280. {
  1281. ParamListB.Clear();
  1282. }
  1283. else
  1284. {
  1285. _stepSelectionB = getStepB;
  1286. NotifyOfPropertyChange(nameof(StepSelectionB));
  1287. StepSelectionB.InvokePropertyChanged();
  1288. }
  1289. }
  1290. }
  1291. }
  1292. private void SyncParamSelection(ParamDataItem paramData, bool isSelectA)
  1293. {
  1294. try
  1295. {
  1296. if (paramData == null)
  1297. return;
  1298. if (isSelectA)
  1299. {
  1300. if (IsCompareByStep)
  1301. {
  1302. if (_mapStepParamA.ContainsKey(StepSelectionB.StepNumber))
  1303. {
  1304. ParamListA = _mapStepParamA[StepSelectionB.StepNumber];
  1305. NotifyOfPropertyChange(nameof(ParamListA));
  1306. }
  1307. else
  1308. return;
  1309. foreach (var item in ParamListA)
  1310. {
  1311. if (item.ParamName == paramData.ParamName)
  1312. {
  1313. _paramSelectionA = item;
  1314. NotifyOfPropertyChange(nameof(ParamSelectionA));
  1315. ParamSelectionA.InvokePropertyChanged();
  1316. }
  1317. }
  1318. }
  1319. if (IsCompareBySName)
  1320. {
  1321. var getSameStepName = StepListA.Where(x => x.StepName == StepSelectionB.StepName).FirstOrDefault();
  1322. if (getSameStepName == null) return;
  1323. if (_mapStepParamA.ContainsKey(getSameStepName.StepNumber))
  1324. {
  1325. ParamListA = _mapStepParamA[getSameStepName.StepNumber];
  1326. NotifyOfPropertyChange(nameof(ParamListA));
  1327. }
  1328. else
  1329. return;
  1330. foreach (var item in ParamListA)
  1331. {
  1332. if (item.ParamName == paramData.ParamName)
  1333. {
  1334. _paramSelectionA = item;
  1335. NotifyOfPropertyChange(nameof(ParamSelectionA));
  1336. ParamSelectionA.InvokePropertyChanged();
  1337. }
  1338. }
  1339. }
  1340. }
  1341. else
  1342. {
  1343. if (IsCompareByStep)
  1344. {
  1345. if (ParamListB == null)
  1346. {
  1347. if (_mapStepParamB.ContainsKey(StepSelectionA.StepNumber))
  1348. {
  1349. ParamListB = _mapStepParamB[StepSelectionA.StepNumber];
  1350. NotifyOfPropertyChange(nameof(ParamListB));
  1351. }
  1352. else
  1353. return;
  1354. }
  1355. foreach (var item in ParamListB)
  1356. {
  1357. if (item.ParamName == paramData.ParamName)
  1358. {
  1359. _paramSelectionB = item;
  1360. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1361. ParamSelectionB.InvokePropertyChanged();
  1362. }
  1363. }
  1364. }
  1365. if (IsCompareBySName)
  1366. {
  1367. if (ParamListB == null)
  1368. {
  1369. var getSameStepName = StepListB.Where(x => x.StepName == StepSelectionA.StepName).FirstOrDefault();
  1370. if (_mapStepParamB.ContainsKey(getSameStepName.StepNumber))
  1371. {
  1372. ParamListB = _mapStepParamB[getSameStepName.StepNumber];
  1373. NotifyOfPropertyChange(nameof(ParamListB));
  1374. }
  1375. else
  1376. return;
  1377. }
  1378. foreach (var item in ParamListB)
  1379. {
  1380. if (item.ParamName == paramData.ParamName)
  1381. {
  1382. _paramSelectionB = item;
  1383. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1384. ParamSelectionB.InvokePropertyChanged();
  1385. }
  1386. }
  1387. }
  1388. }
  1389. }
  1390. catch (Exception ex)
  1391. {
  1392. LOG.Write(ex.Message);
  1393. }
  1394. }
  1395. private void SyncLineSelection(LineDataItem lineData, bool isSelectA)
  1396. {
  1397. if (lineData == null)
  1398. return;
  1399. if (isSelectA)
  1400. {
  1401. foreach (var item in WholeListA)
  1402. {
  1403. if (item.LineNumber == lineData.LineNumber)
  1404. {
  1405. _lineSelectionA = item;
  1406. NotifyOfPropertyChange(nameof(LineSelectionA));
  1407. LineSelectionA.InvokePropertyChanged();
  1408. }
  1409. }
  1410. }
  1411. else
  1412. {
  1413. foreach (var item in WholeListB)
  1414. {
  1415. if (item.LineNumber == lineData.LineNumber)
  1416. {
  1417. _lineSelectionB = item;
  1418. NotifyOfPropertyChange(nameof(LineSelectionB));
  1419. LineSelectionB.InvokePropertyChanged();
  1420. }
  1421. }
  1422. }
  1423. }
  1424. public void RemoveA()
  1425. {
  1426. RemoveRecipe(true);
  1427. }
  1428. public void RemoveB()
  1429. {
  1430. RemoveRecipe(false);
  1431. }
  1432. private void RemoveSelectB()
  1433. {
  1434. StepListB?.Clear();
  1435. ParamListB?.Clear();
  1436. WholeListB?.Clear();
  1437. RecipeB = string.Empty;
  1438. _mapStepParamB?.Clear();
  1439. _stepSelectionB = null;
  1440. _paramSelectionB = null;
  1441. NotifyOfPropertyChange(nameof(StepListB));
  1442. NotifyOfPropertyChange(nameof(ParamListB));
  1443. NotifyOfPropertyChange(nameof(RecipeB));
  1444. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  1445. NotifyOfPropertyChange(nameof(StepSelectionB));
  1446. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1447. }
  1448. private void RemoveRecipe(bool isSelectA)
  1449. {
  1450. if (!DialogBox.Confirm($"Are you sure you want to remove the recipe? \r\n{RecipeB}"))
  1451. return;
  1452. if (isSelectA)
  1453. {
  1454. StepListA?.Clear();
  1455. ParamListA?.Clear();
  1456. WholeListA?.Clear();
  1457. RecipeA = string.Empty;
  1458. _mapStepParamA?.Clear();
  1459. _stepSelectionA = null;
  1460. _paramSelectionA = null;
  1461. NotifyOfPropertyChange(nameof(StepListA));
  1462. NotifyOfPropertyChange(nameof(ParamListA));
  1463. NotifyOfPropertyChange(nameof(RecipeA));
  1464. NotifyOfPropertyChange(nameof(EnableButtonRemoveA));
  1465. NotifyOfPropertyChange(nameof(StepSelectionA));
  1466. NotifyOfPropertyChange(nameof(ParamSelectionA));
  1467. }
  1468. else
  1469. {
  1470. StepListB?.Clear();
  1471. ParamListB?.Clear();
  1472. WholeListB?.Clear();
  1473. RecipeB = string.Empty;
  1474. _mapStepParamB?.Clear();
  1475. _stepSelectionB = null;
  1476. _paramSelectionB = null;
  1477. NotifyOfPropertyChange(nameof(StepListB));
  1478. NotifyOfPropertyChange(nameof(ParamListB));
  1479. NotifyOfPropertyChange(nameof(RecipeB));
  1480. NotifyOfPropertyChange(nameof(EnableButtonRemoveB));
  1481. NotifyOfPropertyChange(nameof(StepSelectionB));
  1482. NotifyOfPropertyChange(nameof(ParamSelectionB));
  1483. }
  1484. }
  1485. public void StepCopyToRight(StepDataItem stepA)
  1486. {
  1487. string temp = "";
  1488. if (StepSelectionA != null)
  1489. temp = StepSelectionA.StepNumber;
  1490. if (IsCompareByStep)
  1491. {
  1492. StepCopyByStepNo(stepA, true);
  1493. }
  1494. if (IsCompareBySName)
  1495. {
  1496. StepCopyByName(stepA, true);
  1497. }
  1498. if (!string.IsNullOrEmpty(temp))
  1499. {
  1500. foreach (StepDataItem tempStep in StepListA)
  1501. {
  1502. if (tempStep.StepNumber == temp)
  1503. {
  1504. StepSelectionA = tempStep;
  1505. break;
  1506. }
  1507. }
  1508. }
  1509. }
  1510. public void StepCopyToLeft(StepDataItem stepB)
  1511. {
  1512. string temp = "";
  1513. if (StepSelectionB != null)
  1514. temp = StepSelectionB.StepNumber;
  1515. if (IsCompareByStep)
  1516. {
  1517. StepCopyByStepNo(stepB, false);
  1518. }
  1519. if (IsCompareBySName)
  1520. {
  1521. StepCopyByName(stepB, false);
  1522. }
  1523. if (!string.IsNullOrEmpty(temp))
  1524. {
  1525. foreach (StepDataItem tempStep in StepListB)
  1526. {
  1527. if (tempStep.StepNumber == temp)
  1528. {
  1529. StepSelectionB = tempStep;
  1530. break;
  1531. }
  1532. }
  1533. }
  1534. }
  1535. public void LeftDelete(StepDataItem step)
  1536. {
  1537. StepDelete(step, true);
  1538. Recompare();
  1539. SyncShowDiffSteps(IsShowDiffSteps);
  1540. }
  1541. public void RightDelete(StepDataItem step)
  1542. {
  1543. StepDelete(step, false);
  1544. Recompare();
  1545. SyncShowDiffSteps(IsShowDiffSteps);
  1546. }
  1547. private void StepDelete(StepDataItem step, bool isSelectA)
  1548. {
  1549. ObservableCollection<StepDataItem> stepList = isSelectA ? StepListA : StepListB;
  1550. Dictionary<string, ObservableCollection<ParamDataItem>> _mapStepParam = isSelectA ? _mapStepParamA : _mapStepParamB;
  1551. foreach (var stepTemp in stepList)
  1552. {
  1553. if (step.StepNumber != stepTemp.StepNumber)
  1554. continue;
  1555. stepList.Remove(stepTemp);
  1556. break;
  1557. }
  1558. //for (int i = 0; i < stepList.Count; i++)
  1559. //{
  1560. // if (stepList[i].StepNumber != (i + 1).ToString())
  1561. // {
  1562. // if (_mapStepParam.ContainsKey((i + 1).ToString()))
  1563. // {
  1564. // _mapStepParam[(i + 1).ToString()] = _mapStepParam[stepList[i].StepNumber];
  1565. // }
  1566. // stepList[i].StepNumber = (i + 1).ToString();
  1567. // }
  1568. //}
  1569. DeleteInnerXml(isSelectA);
  1570. Recompare();
  1571. SyncShowDiffSteps(IsShowDiffSteps);
  1572. }
  1573. private void DeleteInnerXml(bool isSelectA)
  1574. {
  1575. try
  1576. {
  1577. XmlDocument docTo = isSelectA ? _domA : _domB;
  1578. //XmlNode nodeModule = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='PM1']");{_module}
  1579. // doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  1580. XmlNodeList nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  1581. if (nodeSteps == null)
  1582. nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Step");
  1583. List<XmlNode> oldNodeSteps = new List<XmlNode>();
  1584. foreach (XmlNode nodeTemp in nodeSteps)
  1585. {
  1586. oldNodeSteps.Add(nodeTemp.Clone());
  1587. }
  1588. XmlNodeList backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/BakeStep");
  1589. if (backSteps == null)
  1590. backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/BakeStep");
  1591. List<XmlNode> oldBackNodeSteps = new List<XmlNode>();
  1592. foreach (XmlNode nodeTemp in backSteps)
  1593. {
  1594. oldBackNodeSteps.Add(nodeTemp.Clone());
  1595. }
  1596. XmlNode stepsNode = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='PM1']/Step").ParentNode;
  1597. stepsNode.RemoveAll();
  1598. (stepsNode as XmlElement).SetAttribute("Name", "PM1"); //微釜的recipe为什么都是PM1?,如果recipe改了,此处要改回(stepsNode as XmlElement).SetAttribute("Name", _module);
  1599. ObservableCollection<StepDataItem> stepListTo = isSelectA ? StepListA : StepListB;
  1600. if (stepsNode == null)
  1601. {
  1602. return;
  1603. }
  1604. foreach (StepDataItem item in stepListTo)
  1605. {
  1606. XmlElement DeviceTree = docTo.CreateElement("Step");
  1607. DeviceTree.SetAttribute("StepNo", item.StepNumber.ToString());
  1608. DeviceTree.SetAttribute("Name", item.StepName);
  1609. stepsNode.AppendChild(DeviceTree);
  1610. }
  1611. foreach (XmlNode nodeStep in stepsNode)
  1612. {
  1613. string stepNumber = nodeStep.Attributes["StepNo"].Value;
  1614. ObservableCollection<ParamDataItem> paramList =
  1615. isSelectA ? _mapStepParamA[stepNumber] : _mapStepParamB[stepNumber];
  1616. foreach (var param in paramList)
  1617. {
  1618. (nodeStep as XmlElement).SetAttribute(param.ParamName, param.ParamValue);
  1619. }
  1620. }
  1621. foreach (XmlNode nodeStep in backSteps)
  1622. {
  1623. stepsNode.AppendChild(nodeStep);
  1624. }
  1625. string backText = getXmlText(isSelectA ? _domA : _domB);
  1626. LoadDataByRecipeContent(backText, isSelectA);
  1627. Recompare();
  1628. SyncShowDiffSteps(IsShowDiffSteps);
  1629. if (isSelectA)
  1630. {
  1631. BackInnerXmlTextA.Add(backText);
  1632. }
  1633. else
  1634. {
  1635. BackInnerXmlTextB.Add(backText);
  1636. }
  1637. }
  1638. catch (Exception ex)
  1639. {
  1640. LOG.Write(ex.Message);
  1641. }
  1642. }
  1643. private void StepCopyByStepNo(StepDataItem stepData, bool isFromA)
  1644. {
  1645. StepDataItem stepFrom = stepData;
  1646. ObservableCollection<StepDataItem> stepListTo = isFromA ? StepListB : StepListA;
  1647. Dictionary<string, ObservableCollection<ParamDataItem>> mapFrom = isFromA ? _mapStepParamA : _mapStepParamB;
  1648. Dictionary<string, ObservableCollection<ParamDataItem>> mapTo = isFromA ? _mapStepParamB : _mapStepParamA;
  1649. var stepTo = stepListTo.Where(x => x.StepNumber == stepFrom.StepNumber).FirstOrDefault();
  1650. if (stepTo != null)
  1651. {
  1652. stepTo.StepName = stepFrom.StepName;
  1653. //stepTo.IsDiff = stepFrom.IsDiff = false;
  1654. //stepTo.IsExtra = stepFrom.IsExtra = false;
  1655. if (mapFrom.ContainsKey(stepFrom.StepNumber) &&
  1656. mapTo.ContainsKey(stepTo.StepNumber))
  1657. {
  1658. foreach (var paramFrom in mapFrom[stepFrom.StepNumber])
  1659. {
  1660. foreach (var paramTo in mapTo[stepFrom.StepNumber])
  1661. {
  1662. if (paramTo.ParamName != paramFrom.ParamName)
  1663. continue;
  1664. paramTo.ParamValue = paramFrom.ParamValue;
  1665. break;
  1666. }
  1667. }
  1668. }
  1669. }
  1670. else
  1671. {
  1672. StepDataItem stepDataItem = new StepDataItem();
  1673. stepDataItem.StepName = stepFrom.StepName;
  1674. stepDataItem.StepNumber = stepFrom.StepNumber;
  1675. ObservableCollection<ParamDataItem> paramDataItems = new ObservableCollection<ParamDataItem>();
  1676. foreach (var paramFrom in mapFrom[stepFrom.StepNumber])
  1677. {
  1678. ParamDataItem paramDataItem = new ParamDataItem();
  1679. paramDataItem.ParamName = paramFrom.ParamName;
  1680. paramDataItem.ParamValue = paramFrom.ParamValue;
  1681. paramDataItems.Add(paramDataItem);
  1682. }
  1683. if (mapTo.ContainsKey(stepDataItem.StepNumber))
  1684. mapTo[stepDataItem.StepNumber] = paramDataItems;
  1685. else
  1686. mapTo.Add(stepDataItem.StepNumber, paramDataItems);
  1687. var stepNumber = int.Parse(stepFrom.StepNumber);
  1688. var findBigStep = stepListTo.Where(x => int.Parse(x.StepNumber) > stepNumber).FirstOrDefault();
  1689. if (findBigStep == null)
  1690. {
  1691. stepListTo.Add(stepDataItem);
  1692. }
  1693. else
  1694. {
  1695. int index = stepListTo.IndexOf(findBigStep);
  1696. index = index > -1 ? index : 0;
  1697. stepListTo.Insert(index, stepDataItem);
  1698. }
  1699. }
  1700. CopyToInnerXml(!isFromA);
  1701. Recompare();
  1702. SyncShowDiffSteps(IsShowDiffSteps);
  1703. SyncStepSelection(stepFrom, !isFromA);
  1704. }
  1705. private void StepCopyByName(StepDataItem stepData, bool isFromA)
  1706. {
  1707. StepDataItem stepFrom = stepData;
  1708. ObservableCollection<StepDataItem> stepListTo = isFromA ? StepListB : StepListA;
  1709. Dictionary<string, ObservableCollection<ParamDataItem>> mapFrom = isFromA ? _mapStepParamA : _mapStepParamB;
  1710. Dictionary<string, ObservableCollection<ParamDataItem>> mapTo = isFromA ? _mapStepParamB : _mapStepParamA;
  1711. var stepTo = stepListTo.Where(x => x.StepName == stepFrom.StepName).FirstOrDefault();
  1712. if (stepTo != null)
  1713. {
  1714. if (mapFrom.ContainsKey(stepFrom.StepNumber) &&
  1715. mapTo.ContainsKey(stepTo.StepNumber))
  1716. {
  1717. foreach (var paramFrom in mapFrom[stepFrom.StepNumber])
  1718. {
  1719. foreach (var paramTo in mapTo[stepTo.StepNumber])
  1720. {
  1721. if (paramTo.ParamName != paramFrom.ParamName)
  1722. continue;
  1723. paramTo.ParamValue = paramFrom.ParamValue;
  1724. break;
  1725. }
  1726. }
  1727. }
  1728. stepTo.IsDiff = stepFrom.IsDiff = false;
  1729. stepTo.IsExtra = stepFrom.IsExtra = false;
  1730. }
  1731. else
  1732. {
  1733. StepDataItem stepDataItem = new StepDataItem();
  1734. stepDataItem.StepName = stepFrom.StepName;
  1735. //stepDataItem.StepNumber = stepFrom.StepNumber;
  1736. ObservableCollection<ParamDataItem> paramDataItems = new ObservableCollection<ParamDataItem>();
  1737. foreach (var paramFrom in mapFrom[stepFrom.StepNumber])
  1738. {
  1739. ParamDataItem paramDataItem = new ParamDataItem();
  1740. paramDataItem.ParamName = paramFrom.ParamName;
  1741. paramDataItem.ParamValue = paramFrom.ParamValue;
  1742. paramDataItems.Add(paramDataItem);
  1743. }
  1744. var findBigStepNo = stepListTo.Select(x => int.Parse(x.StepNumber)).Max() + 1;
  1745. stepDataItem.StepNumber = findBigStepNo.ToString();
  1746. if (mapTo.ContainsKey(findBigStepNo.ToString()))
  1747. mapTo[stepDataItem.StepNumber] = paramDataItems;
  1748. else
  1749. mapTo.Add(findBigStepNo.ToString(), paramDataItems);
  1750. stepListTo.Add(stepDataItem);
  1751. }
  1752. CopyToInnerXml(!isFromA);
  1753. Recompare();
  1754. SyncShowDiffSteps(IsShowDiffSteps);
  1755. SyncStepSelection(stepFrom, !isFromA);
  1756. }
  1757. private void CopyToInnerXml(bool isSelectA)
  1758. {
  1759. try
  1760. {
  1761. XmlDocument docTo = isSelectA ? _domA : _domB;
  1762. XmlNode nodeModule = docTo.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='PM1']");
  1763. XmlNodeList nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  1764. if (nodeSteps == null)
  1765. nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Step");
  1766. List<XmlNode> oldNodeSteps = new List<XmlNode>();
  1767. foreach (XmlNode nodeTemp in nodeSteps)
  1768. {
  1769. oldNodeSteps.Add(nodeTemp.Clone());
  1770. }
  1771. XmlNodeList backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/BakeStep");
  1772. if (backSteps == null)
  1773. backSteps = docTo.SelectNodes($"Aitex/TableRecipeData/BakeStep");
  1774. List<XmlNode> oldBackNodeSteps = new List<XmlNode>();
  1775. foreach (XmlNode nodeTemp in backSteps)
  1776. {
  1777. oldBackNodeSteps.Add(nodeTemp.Clone());
  1778. }
  1779. ObservableCollection<StepDataItem> stepListTo = isSelectA ? StepListA : StepListB;
  1780. if (nodeModule == null)
  1781. {
  1782. return;
  1783. }
  1784. foreach (StepDataItem item in stepListTo)
  1785. {
  1786. bool isOverOf = true;
  1787. foreach (XmlNode xmlNode in oldNodeSteps)
  1788. {
  1789. string stepNumber = xmlNode.Attributes["StepNo"].Value;
  1790. if (item.StepNumber == stepNumber)
  1791. {
  1792. isOverOf = false;
  1793. break;
  1794. }
  1795. }
  1796. if (isOverOf)
  1797. {
  1798. XmlElement DeviceTree = docTo.CreateElement("Step");
  1799. DeviceTree.SetAttribute("StepNo", item.StepNumber);
  1800. DeviceTree.SetAttribute("Name", item.StepName);
  1801. nodeModule.AppendChild(DeviceTree);
  1802. }
  1803. }
  1804. nodeSteps = docTo.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  1805. foreach (XmlNode nodeStep in nodeSteps)
  1806. {
  1807. string stepNumber = nodeStep.Attributes["StepNo"].Value;
  1808. ObservableCollection<ParamDataItem> paramList =
  1809. isSelectA ? _mapStepParamA[stepNumber] : _mapStepParamB[stepNumber];
  1810. foreach (var param in paramList)
  1811. {
  1812. (nodeStep as XmlElement).SetAttribute(param.ParamName, param.ParamValue);
  1813. }
  1814. }
  1815. foreach (XmlNode nodeStep in backSteps)
  1816. {
  1817. nodeModule.AppendChild(nodeStep);
  1818. }
  1819. string backText = getXmlText(isSelectA ? _domA : _domB);
  1820. LoadDataByRecipeContent(backText, isSelectA);
  1821. Recompare();
  1822. SyncShowDiffSteps(IsShowDiffSteps);
  1823. if (isSelectA)
  1824. {
  1825. BackInnerXmlTextA.Add(backText);
  1826. }
  1827. else
  1828. {
  1829. BackInnerXmlTextB.Add(backText);
  1830. }
  1831. }
  1832. catch (Exception ex)
  1833. {
  1834. LOG.Write(ex.Message);
  1835. }
  1836. }
  1837. private string getXmlText(XmlDocument xmlDocument)
  1838. {
  1839. (new RecipeProvider()).SaveRecipe("", "RecipeTemp", xmlDocument.InnerXml);
  1840. var _recipeProvider = new RecipeProvider();
  1841. var recipeContent = _recipeProvider.LoadRecipe("", "RecipeTemp", false);
  1842. return recipeContent;
  1843. }
  1844. public void ParamCopyToRight(ParamDataItem paramData)
  1845. {
  1846. string temp = "";
  1847. if (StepSelectionA != null)
  1848. temp = StepSelectionA.StepNumber;
  1849. if (IsCompareByStep)
  1850. {
  1851. ParamCopyByStepNo(paramData, true);
  1852. }
  1853. if (IsCompareBySName)
  1854. {
  1855. ParamCopyByStepName(paramData, true);
  1856. }
  1857. if (!string.IsNullOrEmpty(temp))
  1858. {
  1859. foreach (StepDataItem tempStep in StepListA)
  1860. {
  1861. if (tempStep.StepNumber == temp)
  1862. {
  1863. StepSelectionA = tempStep;
  1864. break;
  1865. }
  1866. }
  1867. }
  1868. }
  1869. public void ParamCopyToLeft(ParamDataItem paramData)
  1870. {
  1871. string temp = "";
  1872. if (StepSelectionB != null)
  1873. temp = StepSelectionB.StepNumber;
  1874. if (IsCompareByStep)
  1875. {
  1876. ParamCopyByStepNo(paramData, false);
  1877. }
  1878. if (IsCompareBySName)
  1879. {
  1880. ParamCopyByStepName(paramData, false);
  1881. }
  1882. if (!string.IsNullOrEmpty(temp))
  1883. {
  1884. foreach (StepDataItem tempStep in StepListB)
  1885. {
  1886. if (tempStep.StepNumber == temp)
  1887. {
  1888. StepSelectionB = tempStep;
  1889. break;
  1890. }
  1891. }
  1892. }
  1893. }
  1894. private void ParamCopyByStepNo(ParamDataItem paramData, bool isFromA)
  1895. {
  1896. ParamDataItem paramFrom = paramData;
  1897. StepDataItem stepFrom = isFromA ? StepSelectionA : StepSelectionB;
  1898. Dictionary<string, ObservableCollection<ParamDataItem>> mapFrom = isFromA ? _mapStepParamA : _mapStepParamB;
  1899. Dictionary<string, ObservableCollection<ParamDataItem>> mapTo = isFromA ? _mapStepParamB : _mapStepParamA;
  1900. if (mapTo.ContainsKey(stepFrom.StepNumber))
  1901. {
  1902. foreach (var paramTo in mapTo[stepFrom.StepNumber])
  1903. {
  1904. if (paramTo.ParamName != paramFrom.ParamName)
  1905. continue;
  1906. paramTo.ParamValue = paramFrom.ParamValue;
  1907. paramTo.IsDiff = paramFrom.IsDiff = false;
  1908. paramTo.IsExtra = paramFrom.IsExtra = false;
  1909. paramFrom.InvokePropertyChanged();
  1910. paramTo.InvokePropertyChanged();
  1911. break;
  1912. }
  1913. }
  1914. bool isDiff = false;
  1915. foreach (var paramListFrom in mapFrom[stepFrom.StepNumber])
  1916. {
  1917. if (paramListFrom.IsDiff)
  1918. {
  1919. isDiff = true;
  1920. break;
  1921. }
  1922. }
  1923. stepFrom.IsDiff = isDiff;
  1924. stepFrom.InvokePropertyChanged();
  1925. ObservableCollection<StepDataItem> stepListTo = isFromA ? StepListB : StepListA;
  1926. foreach (var stepTo in stepListTo)
  1927. {
  1928. if (stepTo.StepNumber == stepFrom.StepNumber)
  1929. {
  1930. isDiff = false;
  1931. foreach (var paramListTo in mapTo[stepTo.StepNumber])
  1932. {
  1933. if (paramListTo.IsDiff)
  1934. {
  1935. isDiff = true;
  1936. break;
  1937. }
  1938. }
  1939. stepTo.IsDiff = isDiff;
  1940. stepTo.InvokePropertyChanged();
  1941. break;
  1942. }
  1943. }
  1944. CopyToInnerXml(!isFromA);
  1945. }
  1946. private void ParamCopyByStepName(ParamDataItem paramData, bool isFromA)
  1947. {
  1948. ParamDataItem paramFrom = paramData;
  1949. StepDataItem stepFrom = isFromA ? StepSelectionA : StepSelectionB;
  1950. StepDataItem stepTo = isFromA ? StepSelectionB : StepSelectionA;
  1951. Dictionary<string, ObservableCollection<ParamDataItem>> mapFrom = isFromA ? _mapStepParamA : _mapStepParamB;
  1952. Dictionary<string, ObservableCollection<ParamDataItem>> mapTo = isFromA ? _mapStepParamB : _mapStepParamA;
  1953. if (mapTo.ContainsKey(stepTo.StepNumber))
  1954. {
  1955. foreach (var paramTo in mapTo[stepTo.StepNumber])
  1956. {
  1957. if (paramTo.ParamName != paramFrom.ParamName)
  1958. continue;
  1959. paramTo.ParamValue = paramFrom.ParamValue;
  1960. paramTo.IsDiff = paramFrom.IsDiff = false;
  1961. paramTo.IsExtra = paramFrom.IsExtra = false;
  1962. paramFrom.InvokePropertyChanged();
  1963. paramTo.InvokePropertyChanged();
  1964. break;
  1965. }
  1966. }
  1967. bool isDiff = false;
  1968. foreach (var paramListFrom in mapFrom[stepFrom.StepNumber])
  1969. {
  1970. if (paramListFrom.IsDiff)
  1971. {
  1972. isDiff = true;
  1973. break;
  1974. }
  1975. }
  1976. stepFrom.IsDiff = isDiff;
  1977. stepFrom.InvokePropertyChanged();
  1978. ObservableCollection<StepDataItem> stepListTo = isFromA ? StepListB : StepListA;
  1979. foreach (var step in stepListTo)
  1980. {
  1981. if (step.StepNumber == stepTo.StepNumber)
  1982. {
  1983. isDiff = false;
  1984. foreach (var paramListTo in mapTo[step.StepNumber])
  1985. {
  1986. if (paramListTo.IsDiff)
  1987. {
  1988. isDiff = true;
  1989. break;
  1990. }
  1991. }
  1992. step.IsDiff = isDiff;
  1993. step.InvokePropertyChanged();
  1994. break;
  1995. }
  1996. }
  1997. CopyToInnerXml(!isFromA);
  1998. }
  1999. public void LineCopyToLeft(LineDataItem lineData)
  2000. {
  2001. LineCopy(lineData, false);
  2002. }
  2003. public void LineCopyToRight(LineDataItem lineData)
  2004. {
  2005. LineCopy(lineData, true);
  2006. }
  2007. public void LineCopy(LineDataItem lineData, bool isFromA)
  2008. {
  2009. try
  2010. {
  2011. LineDataItem lineFrom = lineData;
  2012. ObservableCollection<LineDataItem> lineListTo = isFromA ? WholeListB : WholeListA;
  2013. Dictionary<string, LineDataItem> mapFrom = isFromA ? _mapLineTextA : _mapLineTextB;
  2014. Dictionary<string, LineDataItem> mapTo = isFromA ? _mapLineTextB : _mapLineTextA;
  2015. var tempLine = lineListTo.Where(x => x.LineNumber == lineFrom.LineNumber).FirstOrDefault();
  2016. if (tempLine != null)
  2017. {
  2018. tempLine.LineText = lineFrom.LineText;
  2019. tempLine.IsDiff = lineFrom.IsDiff = false;
  2020. tempLine.IsExtra = lineFrom.IsExtra = false;
  2021. }
  2022. string recipeContent = "";
  2023. if (isFromA)
  2024. {
  2025. for (int i = 0; i < WholeListB.Count; i++)
  2026. {
  2027. recipeContent += WholeListB[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  2028. }
  2029. }
  2030. else
  2031. {
  2032. for (int i = 0; i < WholeListA.Count; i++)
  2033. {
  2034. recipeContent += WholeListA[i].LineText + ((i == WholeListB.Count - 1) ? "" : "\r\n");
  2035. }
  2036. }
  2037. CopyToInnerXml(recipeContent, !isFromA);
  2038. LoadDataByRecipeContent(recipeContent, !isFromA);
  2039. Recompare();
  2040. SyncShowDiffSteps(IsShowDiffSteps);
  2041. }
  2042. catch (Exception ex)
  2043. {
  2044. LOG.Write(ex.Message);
  2045. }
  2046. }
  2047. private void CopyToInnerXml(string recipeContent, bool isSelectA)
  2048. {
  2049. XmlDocument doc = isSelectA ? _domA : _domB;
  2050. doc.InnerXml = recipeContent;
  2051. if (isSelectA)
  2052. {
  2053. BackInnerXmlTextA.Add(recipeContent);
  2054. }
  2055. else
  2056. {
  2057. BackInnerXmlTextB.Add(recipeContent);
  2058. }
  2059. }
  2060. public void SaveA()
  2061. {
  2062. Save(true);
  2063. }
  2064. public void SaveB()
  2065. {
  2066. Save(false);
  2067. }
  2068. private void Save(bool isSelectA)
  2069. {
  2070. XmlDocument doc = isSelectA ? _domA : _domB;
  2071. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Module[@Name='PM1']/Step");
  2072. if (nodeSteps == null)
  2073. nodeSteps = doc.SelectNodes($"Aitex/TableRecipeData/Step");
  2074. if (isSelectA)
  2075. {
  2076. (new RecipeProvider()).SaveRecipe("", RecipeA, doc.InnerXml);
  2077. }
  2078. else
  2079. {
  2080. (new RecipeProvider()).SaveRecipe("", RecipeB, doc.InnerXml);
  2081. }
  2082. }
  2083. public void UndoA()
  2084. {
  2085. string xmlData = "";
  2086. string temp = "";
  2087. if (StepSelectionB != null)
  2088. temp = StepSelectionB.StepNumber;
  2089. for (var i = BackInnerXmlTextA.Count - 1; i >= 0;)
  2090. {
  2091. if (i > 0)
  2092. {
  2093. xmlData = BackInnerXmlTextA[i - 1];
  2094. BackInnerXmlTextA.RemoveAt(i);
  2095. }
  2096. else
  2097. xmlData = BackInnerXmlTextA[0];
  2098. break;
  2099. }
  2100. //_domA.InnerXml = xmlData;
  2101. LoadDataByRecipeContent(xmlData, true);
  2102. Recompare();
  2103. SyncShowDiffSteps(IsShowDiffSteps);
  2104. if (!string.IsNullOrEmpty(temp))
  2105. {
  2106. foreach (StepDataItem tempStep in StepListB)
  2107. {
  2108. if (tempStep.StepNumber == temp)
  2109. {
  2110. StepSelectionB = tempStep;
  2111. break;
  2112. }
  2113. }
  2114. }
  2115. //ParamListA = _mapStepParamA[temp];
  2116. }
  2117. public void UndoB()
  2118. {
  2119. string xmlData = "";
  2120. string temp = "";
  2121. if (StepSelectionA != null)
  2122. temp = StepSelectionA.StepNumber;
  2123. for (var i = (BackInnerXmlTextB.Count - 1); i >= 0;)
  2124. {
  2125. if (i > 0)
  2126. {
  2127. xmlData = BackInnerXmlTextB[i - 1];
  2128. BackInnerXmlTextB.RemoveAt(i);
  2129. }
  2130. else
  2131. xmlData = BackInnerXmlTextB[0];
  2132. break;
  2133. }
  2134. //_domB.InnerXml = xmlData;
  2135. LoadDataByRecipeContent(xmlData, false);
  2136. Recompare();
  2137. SyncShowDiffSteps(IsShowDiffSteps);
  2138. if (!string.IsNullOrEmpty(temp))
  2139. {
  2140. foreach (StepDataItem tempStep in StepListA)
  2141. {
  2142. if (tempStep.StepNumber == temp)
  2143. {
  2144. StepSelectionA = tempStep;
  2145. break;
  2146. }
  2147. }
  2148. }
  2149. }
  2150. private bool _isStepModel = true;
  2151. public bool IsStepModel
  2152. {
  2153. get { return _isStepModel; }
  2154. set
  2155. {
  2156. _isStepModel = value;
  2157. _isWholeModel = !_isStepModel;
  2158. StepVisibility = _isStepModel ? Visibility.Visible : Visibility.Hidden;
  2159. WholeVisibility = _isWholeModel ? Visibility.Visible : Visibility.Hidden;
  2160. InvokePropertyChanged(nameof(IsStepModel));
  2161. InvokePropertyChanged(nameof(IsWholeModel));
  2162. InvokePropertyChanged(nameof(StepVisibility));
  2163. InvokePropertyChanged(nameof(WholeVisibility));
  2164. }
  2165. }
  2166. private bool _isWholeModel;
  2167. public bool IsWholeModel
  2168. {
  2169. get { return _isWholeModel; }
  2170. set
  2171. {
  2172. _isWholeModel = value;
  2173. _isStepModel = !_isWholeModel;
  2174. StepVisibility = _isStepModel ? Visibility.Visible : Visibility.Hidden;
  2175. WholeVisibility = _isWholeModel ? Visibility.Visible : Visibility.Hidden;
  2176. InvokePropertyChanged(nameof(IsWholeModel));
  2177. InvokePropertyChanged(nameof(IsStepModel));
  2178. InvokePropertyChanged(nameof(StepVisibility));
  2179. InvokePropertyChanged(nameof(WholeVisibility));
  2180. }
  2181. }
  2182. public Visibility StepVisibility
  2183. {
  2184. get; set;
  2185. }
  2186. public Visibility WholeVisibility
  2187. {
  2188. get; set;
  2189. }
  2190. private bool _isShowDiffSteps;
  2191. public bool IsShowDiffSteps
  2192. {
  2193. get { return _isShowDiffSteps; }
  2194. set
  2195. {
  2196. _isShowDiffSteps = value;
  2197. _isShowAllSteps = !_isShowDiffSteps;
  2198. SyncShowDiffSteps(_isShowDiffSteps);
  2199. InvokePropertyChanged(nameof(IsShowDiffSteps));
  2200. InvokePropertyChanged(nameof(IsShowAllSteps));
  2201. }
  2202. }
  2203. private bool _isShowAllSteps = true;
  2204. public bool IsShowAllSteps
  2205. {
  2206. get { return _isShowAllSteps; }
  2207. set
  2208. {
  2209. _isShowAllSteps = value;
  2210. _isShowDiffSteps = !_isShowAllSteps;
  2211. SyncShowDiffSteps(_isShowDiffSteps);
  2212. InvokePropertyChanged(nameof(IsShowAllSteps));
  2213. InvokePropertyChanged(nameof(IsShowDiffSteps));
  2214. }
  2215. }
  2216. private bool _isShowDiffParams;
  2217. public bool IsShowDiffParams
  2218. {
  2219. get { return _isShowDiffParams; }
  2220. set
  2221. {
  2222. _isShowDiffParams = value;
  2223. SyncShowDiffParams(_isShowDiffParams);
  2224. _isShowAllParams = !_isShowDiffParams;
  2225. InvokePropertyChanged(nameof(IsShowDiffParams));
  2226. InvokePropertyChanged(nameof(IsShowAllParams));
  2227. }
  2228. }
  2229. private bool _isShowAllParams = true;
  2230. public bool IsShowAllParams
  2231. {
  2232. get { return _isShowAllParams; }
  2233. set
  2234. {
  2235. _isShowAllParams = value;
  2236. _isShowDiffParams = !_isShowAllParams;
  2237. SyncShowDiffParams(_isShowDiffParams);
  2238. InvokePropertyChanged(nameof(IsShowDiffParams));
  2239. InvokePropertyChanged(nameof(IsShowAllParams));
  2240. }
  2241. }
  2242. private bool _isCompareByStep = true;
  2243. public bool IsCompareByStep
  2244. {
  2245. get { return _isCompareByStep; }
  2246. set
  2247. {
  2248. _isCompareByStep = value;
  2249. _isCompareBySName = !_isCompareByStep;
  2250. Recompare();
  2251. SyncShowDiffSteps(_isShowDiffSteps);
  2252. InvokePropertyChanged(nameof(IsCompareByStep));
  2253. InvokePropertyChanged(nameof(IsCompareBySName));
  2254. }
  2255. }
  2256. private bool _isCompareBySName;
  2257. public bool IsCompareBySName
  2258. {
  2259. get { return _isCompareBySName; }
  2260. set
  2261. {
  2262. _isCompareBySName = value;
  2263. _isCompareByStep = !_isCompareBySName;
  2264. Recompare();
  2265. SyncShowDiffSteps(_isShowDiffSteps);
  2266. InvokePropertyChanged(nameof(IsCompareByStep));
  2267. InvokePropertyChanged(nameof(IsCompareBySName));
  2268. }
  2269. }
  2270. private void SyncShowDiffSteps(bool isShowDiffSteps)
  2271. {
  2272. if (StepListA == null || StepListB == null)
  2273. return;
  2274. foreach (var item in StepListA)
  2275. {
  2276. item.IsHidden = (IsShowDiffSteps ? (item.IsDiff == false && item.IsExtra == false) : false);
  2277. item.InvokePropertyChanged();
  2278. }
  2279. foreach (var item in StepListB)
  2280. {
  2281. item.IsHidden = (IsShowDiffSteps ? (item.IsDiff == false && item.IsExtra == false) : false);
  2282. item.InvokePropertyChanged();
  2283. }
  2284. NotifyOfPropertyChange(nameof(StepListA));
  2285. NotifyOfPropertyChange(nameof(StepListB));
  2286. }
  2287. private void SyncShowDiffParams(bool isShowDiffParams)
  2288. {
  2289. if (ParamListA == null || ParamListB == null)
  2290. return;
  2291. if (isShowDiffParams)
  2292. {
  2293. foreach (var item in ParamListA)
  2294. {
  2295. if (item.IsDiff == false && item.IsExtra == false)
  2296. {
  2297. item.IsHidden = isShowDiffParams;
  2298. item.InvokePropertyChanged();
  2299. }
  2300. }
  2301. foreach (var item in ParamListB)
  2302. {
  2303. if (item.IsDiff == false && item.IsExtra == false)
  2304. {
  2305. item.IsHidden = isShowDiffParams;
  2306. item.InvokePropertyChanged();
  2307. }
  2308. }
  2309. }
  2310. else
  2311. {
  2312. foreach (var item in ParamListA)
  2313. {
  2314. item.IsHidden = isShowDiffParams;
  2315. item.InvokePropertyChanged();
  2316. }
  2317. foreach (var item in ParamListB)
  2318. {
  2319. item.IsHidden = isShowDiffParams;
  2320. item.InvokePropertyChanged();
  2321. }
  2322. }
  2323. NotifyOfPropertyChange(nameof(ParamListA));
  2324. NotifyOfPropertyChange(nameof(ParamListB));
  2325. }
  2326. }
  2327. }