d23004
2023-05-24 fa87a558389d9d425f70afa1c8de54c69875ef2c
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace SA_LTT_UI.Viewer
{
    public partial class RecipeCreateViewer : Form
    {
        public string RecipeName { get; set; }
 
        public float Radius { get; set; }
 
        public float DistancePrimaryFlat { get; set; }
 
        public float EdgeRound { get; set; }
 
        public RecipeCreateViewer()
        {
            InitializeComponent();
            RecipeName = string.Empty;
            Radius = 75;
            DistancePrimaryFlat = 70;
            EdgeRound = 0;
        }
        
        public void SetCopyVersion(float radius, float distancePrimaryFlat, float edgeRound)
        {
            tb_Radius.Text = $"{radius}";
            tb_DistancePrimaryFlat.Text = $"{distancePrimaryFlat}";
            tb_EdgeRound.Text = $"{edgeRound}";
            tb_Radius.Enabled = false;
            tb_DistancePrimaryFlat.Enabled = false;
            tb_EdgeRound.Enabled = false;
        }
 
        private void SettingData_Leave(object sender, EventArgs e)
        {
            SetSettingData(sender);
        }
 
        private void SettingData_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                SetSettingData(sender);
            }
        }
 
        private void SetSettingData(object sender)
        {
            Control control = (Control)sender;
            float floatValue;
 
            switch(control.Name)
            {
                case "tb_Name":
                    {
                        RecipeName = control.Text;
                        break;
                    }
 
                case "tb_Radius":
                    {
                        float.TryParse(tb_Radius.Text, out floatValue);
 
                        if(floatValue < 50)
                        {
                            floatValue = 50;
                        }
 
                        Radius = floatValue;
 
                        if (DistancePrimaryFlat > Radius)
                        {
                            DistancePrimaryFlat = Radius;
                            control.Text = $"{DistancePrimaryFlat}";
                        }
 
                        control.Text = $"{Radius}";
 
                        break;
                    }
                case "tb_DistancePrimaryFlat":
                    {
                        float.TryParse(tb_DistancePrimaryFlat.Text, out floatValue);
 
                        DistancePrimaryFlat = floatValue;
 
                        if(DistancePrimaryFlat > Radius)
                        {
                            DistancePrimaryFlat = Radius;
                        }
 
                        control.Text = $"{DistancePrimaryFlat}";
                        break;
                    }
                case "tb_EdgeRound":
                    {
                        float.TryParse(tb_EdgeRound.Text, out floatValue);
 
                        EdgeRound = floatValue;
 
                        if (EdgeRound > Radius)
                        {
                            EdgeRound = Radius;
                        }
 
                        control.Text = $"{EdgeRound}";
 
                        break;
                    }
            }
        }
 
        private void btn_Create_Click(object sender, EventArgs e)
        {
            if (RecipeName == string.Empty)
            {
                MessageBoxPad messageBox = new MessageBoxPad("이름이 비어있습니다.");
                messageBox.Show();
            }
            else
            {
                char[] nameExceptList = new char[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|' };
 
                foreach(char exceptChar in nameExceptList)
                {
                    if(RecipeName.Contains(exceptChar))
                    {
                        MessageBoxPad messageBox = new MessageBoxPad("파일 이름에는 다음 문자를 사용할 수 없습니다. \r\n \\ / : * ? \" < > | ");
                        messageBox.Show();
                        return;
                    }
                }
 
                DialogResult = DialogResult.OK;
                this.Close();
            }
        }
 
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            RecipeName = string.Empty;
            DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}