BOOK-IQ4TD9B9LB\DIT-930
2023-05-15 f5120e92b525474f6b4e50130797946986c28eed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SA_LTT.Info.RecipeInfo;
using SA_LTT_UI.Viewer;
using SA_LTT;
 
namespace SA_LTT_UI.Screen
{
    public partial class ScreenRecipe : UserControl
    {
        private MainFrame _mainFrame;
 
        private Recipe currentRecipe;
        private FoupRecipe currentFoupRecipe;
 
        private WaferProcessPointView _waferProcessPointView;
 
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams MyCp = base.CreateParams;
                MyCp.ExStyle |= 0x02000000;
 
                return MyCp;
            }
        }
 
        public ScreenRecipe(MainFrame mainFrame)
        {
            InitializeComponent();
            _mainFrame = mainFrame;
            _waferProcessPointView = new WaferProcessPointView();
            el_CurrentWaferProcess.Child = _waferProcessPointView;
 
            _waferProcessPointView.PointClicked += _waferProcessPointView_PointClicked; ;
            RefreshRecipes();
            RefreshFoupRecipes();
        }
 
        private void _waferProcessPointView_PointClicked(System.Windows.Point clickedPoint, double width, double height)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new WaferProcessPointView.PointClickedEvent(_waferProcessPointView_PointClicked), clickedPoint);
            }
            else
            {
                tb_StartX.Text = $"{clickedPoint.X}";
                tb_StartY.Text = $"{clickedPoint.Y}";
                tb_Width.Text = $"{width}";
                tb_Height.Text = $"{height}";
            }
        }
 
        private void Recipe_Leaves(object sender, EventArgs e)
        {
            SetSettingData(sender);
        }
 
        private void Recipe_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                SetSettingData(sender);
            }
        }
        
        public void SetSettingData(object sender)
        {
            if (currentRecipe == null)
            {
                RefreshRecipeData();
                return;
            }
 
            Control control = (Control)sender;
            float floatValue;
 
            switch (control.Name)
            {
                case "tb_BeamWidth":
                    {
                        float.TryParse(control.Text, out floatValue);
 
                        if(floatValue < 0.1)
                        {
                            floatValue = 0.1f;
                        }
 
                        if (currentRecipe.BeamWidth != floatValue)
                        {
                            currentRecipe.ProcessInfoList.Clear();
                        }
 
                        currentRecipe.BeamWidth = floatValue;
                        control.Text = $"{floatValue}";
                        break;
                    }
                case "tb_BeamHeight":
                    {
                        float.TryParse(control.Text, out floatValue);
 
                        if (floatValue < 0.1)
                        {
                            floatValue = 0.1f;
                        }
                        
                        if(currentRecipe.BeamHeight != floatValue)
                        {
                            currentRecipe.ProcessInfoList.Clear();
                        }
 
                        currentRecipe.BeamHeight = floatValue;
                        control.Text = $"{floatValue}";
                        break;
                    }
            }
 
            RefreshRecipeData();
        }
        
        public void RefreshRecipeData()
        {
            if (currentRecipe == null)
            {
                tb_Name.Text = "";
                tb_Radius.Text = "";
                tb_DistancePrimaryFlat.Text = "";
                tb_EdgeRound.Text = "";
                
                tb_BeamWidth.Text = "";
                tb_BeamHeight.Text = "";
 
                lv_ProcessList.Items.Clear();
 
                tb_StartX.Text = "";
                tb_StartY.Text = "";
                tb_Width.Text = "";
                tb_Height.Text = "";
 
                tb_HeightOverlap.Text = "";
                tb_WidthOverlap.Text = "";
                tb_AttenuaotrStep.Text = "";
 
                _waferProcessPointView.ClearProcessArea();
                _waferProcessPointView.Radius = 75;
                _waferProcessPointView.PrimaryFlat = 70;
 
                btn_Save.BackColor = Color.Gainsboro;
            }
            else
            {
                tb_Name.Text = currentRecipe.Name;
                tb_Radius.Text = $"{currentRecipe.Radius}";
                tb_DistancePrimaryFlat.Text = $"{currentRecipe.DistanceFromCenterToPrimaryFlat}";
                tb_EdgeRound.Text = $"{currentRecipe.EdgeRound}";
 
                tb_BeamWidth.Text = $"{currentRecipe.BeamWidth}";
                tb_BeamHeight.Text = $"{currentRecipe.BeamHeight}";
 
                lv_ProcessList.Items.Clear();
 
                tb_StartX.Text = "";
                tb_StartY.Text = "";
                tb_Width.Text = "";
                tb_Height.Text = "";
                
                tb_HeightOverlap.Text = "";
                tb_WidthOverlap.Text = "";
                tb_AttenuaotrStep.Text = "";
 
                _waferProcessPointView.ClearProcessArea();
                _waferProcessPointView.Radius = currentRecipe.Radius;
                _waferProcessPointView.PrimaryFlat = currentRecipe.DistanceFromCenterToPrimaryFlat;
 
                foreach (ProcessInfo processInfo in currentRecipe.ProcessInfoList)
                {
                    ListViewItem lvi = new ListViewItem($"{processInfo.StartX}");
                    lvi.SubItems.Add($"{processInfo.StartY}");
                    lvi.SubItems.Add($"{processInfo.Width}");
                    lvi.SubItems.Add($"{processInfo.Height}");
 
                    lvi.SubItems.Add($"{processInfo.BeamHeightOverlap}");
                    lvi.SubItems.Add($"{processInfo.BeamWidthOverlap}");
                    lvi.SubItems.Add($"{processInfo.Energy}");
 
                    processInfo.SetProcessData();
                    _waferProcessPointView.AddProcessArea(processInfo.ProcessStartY, processInfo.ProcessEndY, processInfo.ProcessList.ToArray());
                    lv_ProcessList.Items.Add(lvi);
                }
 
                Recipe originalRecipe = _mainFrame.equipment.recipeManager.GetRecipe(currentRecipe.Name);
 
                if (Recipe.IsEquals(currentRecipe, originalRecipe))
                {
                    tb_BeamWidth.BackColor = Color.White;
                    tb_BeamHeight.BackColor = Color.White;
 
                    btn_Save.BackColor = Color.Gainsboro;
                }
                else
                {
                    tb_BeamWidth.BackColor = currentRecipe.BeamWidth != originalRecipe.BeamWidth ? Color.Red : Color.White;
                    tb_BeamHeight.BackColor = currentRecipe.BeamHeight != originalRecipe.BeamHeight ? Color.Red : Color.White;
 
                    btn_Save.BackColor = Color.Red;
                }
            }
        }
        
        public void RefreshRecipes()
        {
            _mainFrame.equipment.recipeManager.RefreshRecipes();
 
            lv_RecipeList.Items.Clear();
 
            Recipe[] recipes = _mainFrame.equipment.recipeManager.GetRecipeList();
 
            foreach(Recipe recipe in recipes)
            {
                lv_RecipeList.Items.Add(recipe.Name);
            }
 
            currentRecipe = null;
            RefreshRecipeData();
        }
 
        public void RefreshFoupRecipes()
        {
            _mainFrame.equipment.foupRecipeManager.RefreshRecipes();
 
            lv_FoupRecipe.Items.Clear();
 
            FoupRecipe[] recipes = _mainFrame.equipment.foupRecipeManager.GetRecipeList();
 
            foreach (FoupRecipe recipe in recipes)
            {
                lv_FoupRecipe.Items.Add(recipe.Name);
            }
        }
 
        public void RefreshFoupRecipeData()
        {
            lv_Recipes.Items.Clear();
 
            if(currentFoupRecipe != null)
            {
                FoupRecipe originalRecipe = _mainFrame.equipment.foupRecipeManager.GetRecipe(currentFoupRecipe.Name);
 
                for (int i = 24; i >= 0; i--)
                {
                    ListViewItem lvi = new ListViewItem($"{i + 1}");
 
                    if(currentFoupRecipe.RecipeNames[i] != originalRecipe.RecipeNames[i])
                    {
                        lvi.BackColor = Color.Red;
                    }
 
                    if (currentFoupRecipe.RecipeNames[i] == null)
                    {
                        lvi.SubItems.Add("Empty");
                    }
                    else
                    {
                        lvi.SubItems.Add(currentFoupRecipe.RecipeNames[i]);
                    }
 
                    lv_Recipes.Items.Add(lvi);
                }
            }
        }
 
        private void btn_Refresh_Click(object sender, EventArgs e)
        {
            RefreshRecipes();
        }
 
        private void btn_Create_Click(object sender, EventArgs e)
        {
            RecipeCreateViewer recipeCreateViewer = new RecipeCreateViewer();
 
            if(recipeCreateViewer.ShowDialog() == DialogResult.OK)
            {
                Recipe recipe = new Recipe();
                recipe.Name = recipeCreateViewer.RecipeName;
                recipe.Radius = recipeCreateViewer.Radius;
                recipe.DistanceFromCenterToPrimaryFlat = recipeCreateViewer.DistancePrimaryFlat;
                recipe.EdgeRound = recipeCreateViewer.EdgeRound;
 
                if (_mainFrame.equipment.recipeManager.ExistsRecipe(recipe.Name) == false)
                {
                    EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Create Recipe {recipe.Name}");
                    _mainFrame.equipment.recipeManager.SaveOrCreate(recipe);
                    RefreshRecipes();
                }
                else
                {
                    Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("같은 이름의 Recipe가 있습니다.");
                    mbPad.Show();
                }
            }
        }
 
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            if(currentRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            string strMsg = $"\"{currentRecipe.Name}\" 레시피를 제거 하시겠습니까?";
            if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Delete Recipe {currentRecipe.Name}");
                _mainFrame.equipment.recipeManager.Delete(currentRecipe.Name);
                currentRecipe = null;
                RefreshRecipes();
            }
        }
 
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (currentRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            string strMsg = $"\"{currentRecipe.Name}\" 레시피를 저장 하시겠습니까 ?";
            if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Save Recipe {currentRecipe.Name}");
                _mainFrame.equipment.recipeManager.SaveOrCreate(currentRecipe);
                RefreshRecipeData();
            }
        }
 
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            if (currentRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            string strMsg = $"취소 하시겠습니까 ?";
            if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Cancel Recipe {currentRecipe.Name}");
                currentRecipe = _mainFrame.equipment.recipeManager.GetRecipe(currentRecipe.Name);
                RefreshRecipeData();
            }
        }
 
        private void btn_Copy_Click(object sender, EventArgs e)
        {
            if (currentRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            RecipeCreateViewer recipeCreateViewer = new RecipeCreateViewer();
            recipeCreateViewer.SetCopyVersion(currentRecipe.Radius, currentRecipe.DistanceFromCenterToPrimaryFlat, currentRecipe.EdgeRound);
 
            if (recipeCreateViewer.ShowDialog() == DialogResult.OK)
            {
                Recipe recipe = _mainFrame.equipment.recipeManager.GetRecipe(currentRecipe.Name);
                recipe.EdgeRound = recipeCreateViewer.EdgeRound;
                recipe.Name = recipeCreateViewer.RecipeName;
 
                if (_mainFrame.equipment.recipeManager.ExistsRecipe(recipe.Name) == false)
                {
                    EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Copy Recipe {currentRecipe} -> {recipe.Name}");
                    _mainFrame.equipment.recipeManager.SaveOrCreate(recipe);
                    RefreshRecipes();
                }
                else
                {
                    Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("같은 이름의 Recipe가 있습니다.");
                    mbPad.Show();
                }
            }
        }
 
        private void lv_RecipeList_Click(object sender, EventArgs e)
        {
            if (lv_RecipeList.SelectedItems.Count == 0)
                return;
 
            string recipeName = lv_RecipeList.SelectedItems[0].Text;
 
            currentRecipe = _mainFrame.equipment.recipeManager.GetRecipe(recipeName);
 
            //레시피 정보 Refresh 값.
            RefreshRecipeData();
        }
 
        private void lv_ProcessList_Click(object sender, EventArgs e)
        {
            if (lv_ProcessList.SelectedItems.Count == 0)
                return;
 
            int selectedIndex = lv_ProcessList.SelectedItems[0].Index;
 
            ProcessInfo processInfo = currentRecipe.ProcessInfoList[selectedIndex];
 
            tb_StartX.Text = $"{processInfo.StartX}";
            tb_StartY.Text = $"{processInfo.StartY}";
            tb_Width.Text = $"{processInfo.Width}";
            tb_Height.Text = $"{processInfo.Height}";
            
            tb_HeightOverlap.Text = $"{processInfo.BeamHeightOverlap}";
            tb_WidthOverlap.Text = $"{processInfo.BeamWidthOverlap}";
            tb_AttenuaotrStep.Text = $"{processInfo.Energy}";
 
            _waferProcessPointView.SetClickedLocationPosition(processInfo.StartX, processInfo.StartY, processInfo.Width, processInfo.Height);
            _waferProcessPointView.HighlightClear();
 
            for (int i = 0; i < lv_ProcessList.SelectedItems.Count; i++)
            {
                _waferProcessPointView.HighlightProcessAreas(lv_ProcessList.SelectedItems[i].Index);
            }
 
            //_waferProcessPointView.HighlightProcessAreas(selectedIndex);
        }
 
        private void btn_ProcessDataClear_Click(object sender, EventArgs e)
        {
            if (currentRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            string strMsg = $"Process Data를 제거 하시겠습니까?";
            if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }
 
            EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Process Data Clear");
            currentRecipe.ProcessInfoList.Clear();
            _waferProcessPointView.ClearProcessArea();
            RefreshRecipeData();
        }
 
        private void btn_FullShot_Click(object sender, EventArgs e)
        {
            if(currentRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            float scanRange = 0;
            float beamWidthOverlap = 0;
            float beamHeightOverlap = 0;
            float overlapOffset = 0;
            double energy = 0;
 
            double doubleValue;
            float floatValue;
 
            float.TryParse(tb_FullShotBeamHeightOverlap.Text, out floatValue);
            beamHeightOverlap = floatValue;
 
            float.TryParse(tb_FullShotBeamWidthOverlap.Text, out floatValue);
            beamWidthOverlap = floatValue;
 
            double.TryParse(tb_FullShotAttenuator.Text, out doubleValue);
            energy = doubleValue;
 
            float.TryParse(tb_FullShotScanRange.Text, out floatValue);
            scanRange = floatValue;
 
            float.TryParse(tb_FullShotOverlapOffset.Text, out floatValue);
            overlapOffset = floatValue;
 
            //인터락.
            if (currentRecipe.BeamWidth - beamWidthOverlap <= 0)
            {
                MessageBox.Show("BeamWidth - BeamWidthOverlap은 0보다 커야 합니다.", "확인", MessageBoxButtons.OK);
                return;
            }
 
            if (currentRecipe.BeamHeight - beamHeightOverlap <= 0)
            {
                MessageBox.Show("BeamHeight - BeamHeightOverlap은 0보다 커야 합니다.", "확인", MessageBoxButtons.OK);
                return;
            }
            
            if (scanRange <= 0)
            {
                MessageBox.Show("Scan Range는 1 보다 커야 합니다.", "확인", MessageBoxButtons.OK);
                return;
            }
 
            float beamheightdistance = currentRecipe.BeamHeight - beamHeightOverlap;
 
            float remainderBeamHeight = scanRange % beamheightdistance; //나머지 구하기
 
            if (remainderBeamHeight != 0)
            {
                int beamCount = (int)(scanRange / beamheightdistance);
 
                if (remainderBeamHeight > beamheightdistance / 2) // BeamHeight의 반보다 작거나 같으면 올림.
                {
                    scanRange = (beamCount + 1) * beamheightdistance;
                }
                else
                {
                    scanRange = beamCount * beamheightdistance;
                }
            }
 
            scanRange = float.Parse($"{scanRange:F4}");
            currentRecipe.ProcessInfoList.Clear();
 
            for (double i = currentRecipe.Radius; i > -currentRecipe.Radius; i -= (scanRange - overlapOffset - beamHeightOverlap))
            {
                ProcessInfo processInfo = new ProcessInfo();
                processInfo.SetRecipeData(currentRecipe.Clone());
 
                processInfo.StartX = -currentRecipe.Radius;
                processInfo.StartY = float.Parse($"{i:F4}");
                processInfo.Width = currentRecipe.Radius * 2;
                processInfo.Height = scanRange;
 
                processInfo.BeamHeightOverlap = beamHeightOverlap;
                processInfo.BeamWidthOverlap = beamWidthOverlap;
                processInfo.Energy = energy;
 
                processInfo.SetProcessData();
                if (processInfo.IsProcessEnable)
                {
                    currentRecipe.AddProcessInfo(processInfo.Clone());
                }
            }
 
            EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Full shot");
            RefreshRecipeData();
        }
 
        private void btn_AddProcessInfo_Click(object sender, EventArgs e)
        {
            if (currentRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            ProcessInfo processInfo = new ProcessInfo();
            int intValue;
            float floatValue;
            double doubleValue;
 
            processInfo.SetRecipeData(currentRecipe.Clone());
 
            float.TryParse(tb_StartX.Text, out floatValue);
            processInfo.StartX = floatValue;
 
            float.TryParse(tb_StartY.Text, out floatValue);
            processInfo.StartY = floatValue;
 
            float.TryParse(tb_Width.Text, out floatValue);
            processInfo.Width = floatValue;
 
            float.TryParse(tb_Height.Text, out floatValue);
            processInfo.Height = floatValue;
 
            float.TryParse(tb_HeightOverlap.Text, out floatValue);
            processInfo.BeamHeightOverlap = floatValue;
 
            float.TryParse(tb_WidthOverlap.Text, out floatValue);
            processInfo.BeamWidthOverlap = floatValue;
 
            double.TryParse(tb_AttenuaotrStep.Text, out doubleValue);
            processInfo.Energy = doubleValue;
 
            //==================== Beam 크기에 따른 가공 높이 설정. ======================
            //double remainderBeamHeight = processInfo.Height % currentRecipe.BeamHeight;
 
            //if (remainderBeamHeight != 0)
            //{
            //    if (remainderBeamHeight <= currentRecipe.BeamHeight - processInfo.BeamHeightOverlap / 2) // BeamHeight의 반보다 작거나 같으면 올림.
            //    {
            //        processInfo.Height = currentRecipe.BeamHeight * Math.Ceiling(processInfo.Height / currentRecipe.BeamHeight);
            //    }
            //    else
            //    {
            //        processInfo.Height = currentRecipe.BeamHeight * Math.Floor(processInfo.Height / currentRecipe.BeamHeight);
            //    }
            //}
            //=============================================================================
 
            //인터락.
            if (processInfo.Width <= 0 || processInfo.Height <= 0)
            {
                MessageBox.Show("Width, Height값을 확인해 주세요.", "확인", MessageBoxButtons.OK);
                return;
            }
 
            if (processInfo.Energy < 0)
            {
                MessageBox.Show("Energy 값을 확인해 주세요.", "확인", MessageBoxButtons.OK);
                return;
            }
 
            if (processInfo.BeamWidth - processInfo.BeamWidthOverlap <= 0)
            {
                MessageBox.Show("BeamWidth - BeamWidthOverlap은 0보다 커야 합니다..", "확인", MessageBoxButtons.OK);
                return;
            }
 
            if (processInfo.BeamHeight - processInfo.BeamHeightOverlap <= 0)
            {
                MessageBox.Show("BeamHeight - BeamHeightOverlap은 0보다 커야 합니다..", "확인", MessageBoxButtons.OK);
                return;
            }
 
 
            processInfo.SetProcessData();
            
            if (processInfo.IsProcessEnable == false)
            {
                MessageBox.Show("가공 불가능한 Process 입니다.", "확인", MessageBoxButtons.OK);
                return;
            }
 
            EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Add process data {currentRecipe}");
            currentRecipe.AddProcessInfo(processInfo.Clone());
            RefreshRecipeData();
        }
 
        private void btn_ProcessDataDelete_Click(object sender, EventArgs e)
        {
            if (currentRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            if (lv_ProcessList.SelectedItems.Count == 0)
            {
                return;
            }
            
            string strMsg = $"Process Data를 제거 하시겠습니까?";
            if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }
 
            List<ProcessInfo> deleteList = new List<ProcessInfo>();
            List<System.Windows.Shapes.Polygon> deleteProcessList = new List<System.Windows.Shapes.Polygon>();
 
            for(int i = 0; i < lv_ProcessList.SelectedItems.Count; i++)
            {
                deleteList.Add(currentRecipe.ProcessInfoList[lv_ProcessList.SelectedItems[i].Index]);
                deleteProcessList.Add(_waferProcessPointView.ProcessAreas[i]);
            }
 
            for(int i = 0; i < deleteList.Count; i++)
            {
                _waferProcessPointView.DeleteProcessArea(deleteProcessList[i]);
                currentRecipe.ProcessInfoList.Remove(deleteList[i]);
            }
 
            EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Process Data Delete");
            RefreshRecipeData();
        }
 
        private void btn_CreateFoupRecipe_Click(object sender, EventArgs e)
        {
            FoupRecipeCreateViewer recipeCreateViewer = new FoupRecipeCreateViewer();
 
            if (recipeCreateViewer.ShowDialog() == DialogResult.OK)
            {
                FoupRecipe recipe = new FoupRecipe();
                recipe.Name = recipeCreateViewer.RecipeName;
 
                if (_mainFrame.equipment.foupRecipeManager.ExistsRecipe(recipe.Name) == false)
                {
                    _mainFrame.equipment.foupRecipeManager.SaveOrCreate(recipe);
 
                    EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Foup Recipe Create Foup Recipe {recipe.Name}");
                    RefreshFoupRecipes();
                }
                else
                {
                    Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("같은 이름의 FoupRecipe가 있습니다.");
                    mbPad.Show();
                }
            }
        }
 
        private void btn_CancelFoupRecipe_Click(object sender, EventArgs e)
        {
            if (currentFoupRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            string strMsg = $"취소 하시겠습니까 ?";
            if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Foup Recipe Cancel Foup Recipe {currentFoupRecipe.Name}");
                currentFoupRecipe = _mainFrame.equipment.foupRecipeManager.GetRecipe(currentFoupRecipe.Name);
                RefreshFoupRecipeData();
            }
        }
 
        private void btn_DeleteFoupRecipe_Click(object sender, EventArgs e)
        {
            if (currentFoupRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            string strMsg = $"\"{currentFoupRecipe.Name}\" 레시피를 제거 하시겠습니까?";
            if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Foup Recipe Delete Foup Recipe {currentFoupRecipe.Name}");
                _mainFrame.equipment.foupRecipeManager.Delete(currentFoupRecipe.Name);
                currentFoupRecipe = null;
                RefreshFoupRecipes();
            }
        }
 
        private void btn_SaveFoupRecipe_Click(object sender, EventArgs e)
        {
            if (currentFoupRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            string strMsg = $"\"{currentFoupRecipe.Name}\" 레시피를 저장 하시겠습니까 ?";
            if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Foup Recipe Save Foup Recipe {currentFoupRecipe.Name}");
                _mainFrame.equipment.foupRecipeManager.SaveOrCreate(currentFoupRecipe);
                RefreshFoupRecipeData();
            }
        }
 
        private void lv_FoupRecipe_Click(object sender, EventArgs e)
        {
            if (lv_FoupRecipe.SelectedItems.Count == 0)
                return;
 
            string recipeName = lv_FoupRecipe.SelectedItems[0].Text;
 
            currentFoupRecipe = _mainFrame.equipment.foupRecipeManager.GetRecipe(recipeName);
 
            //레시피 정보 Refresh 값.
            RefreshFoupRecipeData();
        }
 
        private void lv_Recipes_DoubleClick(object sender, EventArgs e)
        {
            if (currentFoupRecipe == null)
            {
                string strMsg = $"선택된 Recipe가 없습니다.";
                if (MessageBox.Show(strMsg, "확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                }
                return;
            }
 
            if(lv_Recipes.SelectedItems.Count != 0)
            {
                currentFoupRecipe.RecipeNames[currentFoupRecipe.RecipeNames.Length - lv_Recipes.SelectedItems[0].Index - 1] = null;
            }
 
            RefreshFoupRecipeData();
        }
 
        private void btn_AddFoupRecipe_Click(object sender, EventArgs e)
        {
            if (currentRecipe == null || currentFoupRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            if(lv_Recipes.CheckedItems.Count != 0)
            {
                for (int i = 0; i < lv_Recipes.CheckedItems.Count; i++)
                {
                    currentFoupRecipe.RecipeNames[24 - lv_Recipes.CheckedItems[i].Index] = currentRecipe.Name;
                }
 
                EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Foup Recipe Add Foup Recipe {currentFoupRecipe.Name}, Recipe {currentRecipe.Name}");
                RefreshFoupRecipeData();
            }
        }
 
        private void btn_FoupRecipeClear_Click(object sender, EventArgs e)
        {
            if (currentFoupRecipe == null)
            {
                Viewer.MessageBoxPad mbPad = new Viewer.MessageBoxPad("선택된 Recipe가 없습니다.");
                mbPad.Show();
                return;
            }
 
            for (int i = 0; i < 25; i++)
            {
                currentFoupRecipe.RecipeNames[i] = null;
            }
 
            EquipmentLogManager.Instance.WriteButtonLog($"ScreenRecipe : Foup Recipe Clear Foup Recipe {currentFoupRecipe.Name}");
            RefreshFoupRecipeData();
        }
 
        private void SetProcessLocationPosition()
        {
            double startX;
            double startY;
            double width;
            double height;
 
            if (double.TryParse(tb_StartX.Text, out startX))
            {
                startX = double.Parse($"{startX:F3}");
            }
 
            tb_StartX.Text = $"{startX}";
 
            if (double.TryParse(tb_StartY.Text, out startY))
            {
                startY = double.Parse($"{startY:F3}");
            }
 
            tb_StartY.Text = $"{startY}";
 
            if (double.TryParse(tb_Width.Text, out width))
            {
                width = double.Parse($"{width:F3}");
            }
            if(width < 0)
            {
                width = 0;
            }
            tb_Width.Text = $"{width}";
 
            if (double.TryParse(tb_Height.Text, out height))
            {
                height = double.Parse($"{height:F3}");
            }
            if (height < 0)
            {
                height = 0;
            }
            tb_Height.Text = $"{height}";
 
            if (width < 1)
            {
                width = 1;
            }
 
            if (height < 1)
            {
                height = 1;
            }
            _waferProcessPointView.SetClickedLocationPosition(startX, startY, width, height);
        }
 
        private void tb_ProcessData_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                SetProcessLocationPosition();
            }
        }
 
        private void tb_ProcessData_Leave(object sender, EventArgs e)
        {
            SetProcessLocationPosition();
        }
 
    }
}