관리자페이지 개발
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -12,31 +13,106 @@ namespace ControlServer
|
||||
{
|
||||
public TerminalInfo TerminalData { get; private set; } = new TerminalInfo();
|
||||
|
||||
// 둥근 모서리 반지름 설정
|
||||
private const int CornerRadius = 15;
|
||||
|
||||
public Form2()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 1. 버튼 테두리 없애고 Flat 스타일로 변경
|
||||
ConfigureModernButtons();
|
||||
btnRegister.BackColor = Color.FromArgb(160, 180, 240); // 연해진 블루
|
||||
btnRegister.Enabled = false; // 저장버튼 비활성화
|
||||
|
||||
// 모든 텍스트박스의 값이 변할 때마다 실행될 이벤트 연결
|
||||
txtBoxName.TextChanged += ValidateInputs;
|
||||
txtBoxIP.TextChanged += ValidateInputs;
|
||||
txtBoxPort.TextChanged += ValidateInputs;
|
||||
txtBoxMac.TextChanged += ValidateInputs;
|
||||
|
||||
// 2. 둥근 모서리를 그리기 위한 Paint 이벤트 연결
|
||||
if (lblBox != null) lblBox.Paint += lblBox_Paint;
|
||||
btnRegister.Paint += Button_Paint;
|
||||
btnCancel.Paint += Button_Paint;
|
||||
}
|
||||
|
||||
private void ConfigureModernButtons()
|
||||
{
|
||||
// 등록 버튼 스타일 설정
|
||||
btnRegister.FlatStyle = FlatStyle.Flat;
|
||||
btnRegister.FlatAppearance.BorderSize = 0; // 보더라인 삭제
|
||||
|
||||
// 취소 버튼 스타일 설정
|
||||
btnCancel.BackColor = Color.FromArgb(230, 235, 240);
|
||||
btnCancel.FlatStyle = FlatStyle.Flat;
|
||||
btnCancel.FlatAppearance.BorderSize = 0; // 보더라인 삭제
|
||||
}
|
||||
|
||||
// 컨트롤을 둥글게 만들기 위한 공통 경로 생성 메서드
|
||||
private GraphicsPath GetRoundPath(Rectangle bounds, int radius)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
int diameter = radius * 2;
|
||||
|
||||
path.AddArc(bounds.X, bounds.Y, diameter, diameter, 180, 90);
|
||||
path.AddArc(bounds.Right - diameter, bounds.Y, diameter, diameter, 270, 90);
|
||||
path.AddArc(bounds.Right - diameter, bounds.Bottom - diameter, diameter, diameter, 0, 90);
|
||||
path.AddArc(bounds.X, bounds.Bottom - diameter, diameter, diameter, 90, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
// 흰색 배경 박스 둥글게 자르기
|
||||
private void lblBox_Paint(object? sender, PaintEventArgs e)
|
||||
{
|
||||
if (sender is Panel panel)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
using (GraphicsPath path = GetRoundPath(new Rectangle(0, 0, panel.Width, panel.Height), CornerRadius))
|
||||
{
|
||||
panel.Region = new Region(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 버튼 둥글게 자르기
|
||||
private void Button_Paint(object? sender, PaintEventArgs e)
|
||||
{
|
||||
if (sender is Button button)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
// 버튼은 박스보다 조금 더 작으므로 반지름을 10 정도로 주면 예쁩니다
|
||||
using (GraphicsPath path = GetRoundPath(new Rectangle(0, 0, button.Width, button.Height), 10))
|
||||
{
|
||||
button.Region = new Region(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateInputs(object? sender, EventArgs e)
|
||||
{
|
||||
// 모든 텍스트박스가 공백이 아닐 때만 true
|
||||
bool isValid = !string.IsNullOrWhiteSpace(txtBoxName.Text) &&
|
||||
!string.IsNullOrWhiteSpace(txtBoxIP.Text) &&
|
||||
!string.IsNullOrWhiteSpace(txtBoxPort.Text);
|
||||
!string.IsNullOrWhiteSpace(txtBoxPort.Text) &&
|
||||
!string.IsNullOrWhiteSpace(txtBoxMac.Text);
|
||||
|
||||
// 저장 버튼 활성화 상태 조절
|
||||
btnRegister.Enabled = isValid;
|
||||
|
||||
// [팁] 비활성화 상태일 때 버튼 색상 피드백을 주면 더 자연스럽습니다.
|
||||
if (isValid)
|
||||
{
|
||||
btnRegister.BackColor = Color.FromArgb(65, 105, 225); // 원래 로열 블루 색상
|
||||
}
|
||||
else
|
||||
{
|
||||
btnRegister.BackColor = Color.FromArgb(160, 180, 240); // 연해진 블루
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCancel_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
// 취소 버튼
|
||||
this.Close();
|
||||
}
|
||||
|
||||
@@ -44,17 +120,23 @@ namespace ControlServer
|
||||
{
|
||||
// 1. DB 중복 데이터 확인
|
||||
|
||||
// 2. 중복 데이터 없을 경우 DB에 데이터 추가
|
||||
// DB 가져오면 데이터 넘겨주는게 아니라 테이블에 데이터 추가하고 Form1 화면에서 데이터 가져와 리스트 보여주는 형식으로 변경할 예정
|
||||
Popup popup = new Popup("등록되었습니다.");
|
||||
// 2. 메시지박스 띄우기 (알림 아이콘과 OK 버튼 포함)
|
||||
DialogResult result = MessageBox.Show(
|
||||
"등록되었습니다.",
|
||||
"알림",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information
|
||||
);
|
||||
|
||||
if (popup.ShowDialog() == DialogResult.OK)
|
||||
// 사용자가 메시지박스의 '확인'을 누르면 데이터 저장 진행
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
this.TerminalData = new TerminalInfo
|
||||
{
|
||||
TerminalName = txtBoxName.Text.Trim(),
|
||||
IP = txtBoxIP.Text.Trim(),
|
||||
Port = txtBoxPort.Text.Trim()
|
||||
Port = txtBoxPort.Text.Trim(),
|
||||
Mac = txtBoxMac.Text.Trim(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -62,4 +144,4 @@ namespace ControlServer
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user