UI 및 설정 변경사항 커밋
- 맵 에디터 메인폼 UI 개선 - AGV 캔버스 컨트롤 수정 - 설정 파일 업데이트 - 상태머신 AGV 로직 조정 - 자동 모드 화면 개선 - 메인폼 디자이너 및 로직 수정 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,8 @@ using System.CodeDom;
|
||||
using AR;
|
||||
using Project.StateMachine;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using AGVNavigationCore.Models;
|
||||
using System.IO;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
@@ -243,7 +245,8 @@ namespace Project
|
||||
|
||||
tmDisplay.Tick += tmDisplay_Tick;
|
||||
tmDisplay.Start(); //start Display
|
||||
this.btDebug.Visible = PUB.setting.UseDebugMode;
|
||||
|
||||
this.btDebug.Visible = System.Diagnostics.Debugger.IsAttached || PUB.setting.UseDebugMode;
|
||||
|
||||
PUB.log.Add("Program Start");
|
||||
|
||||
@@ -262,7 +265,7 @@ namespace Project
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region "Mouse Form Move"
|
||||
|
||||
@@ -887,5 +890,176 @@ namespace Project
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//mapsave
|
||||
using (var sd = new SaveFileDialog())
|
||||
{
|
||||
sd.Filter = "AGV Map Files (*.agvmap)|*.agvmap|All Files (*.*)|*.*";
|
||||
sd.DefaultExt = "agvmap";
|
||||
sd.FileName = PUB._mapCanvas.MapFileName;
|
||||
if (sd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
SaveMapToFile(sd.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//load
|
||||
|
||||
var od = new OpenFileDialog
|
||||
{
|
||||
Filter = "AGV Map Files (*.agvmap)|*.agvmap|All Files (*.*)|*.*",
|
||||
DefaultExt = "agvmap",
|
||||
FileName = PUB._mapCanvas.MapFileName,
|
||||
};
|
||||
|
||||
if (od.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadMapFromFile(od.FileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"맵 로드 중 오류가 발생했습니다: {ex.Message}", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadMapFromFile(string filePath)
|
||||
{
|
||||
var result = MapLoader.LoadMapFromFile(filePath);
|
||||
|
||||
if (result.Success)
|
||||
{
|
||||
var _mapCanvas = PUB._mapCanvas;
|
||||
PUB._mapNodes = result.Nodes;
|
||||
|
||||
// 맵 캔버스에 데이터 설정
|
||||
_mapCanvas.Nodes = result.Nodes;
|
||||
// RfidMappings 제거됨 - MapNode에 통합
|
||||
|
||||
// 🔥 맵 설정 적용 (배경색, 그리드 표시)
|
||||
if (result.Settings != null)
|
||||
{
|
||||
_mapCanvas.BackColor = System.Drawing.Color.FromArgb(result.Settings.BackgroundColorArgb);
|
||||
_mapCanvas.ShowGrid = result.Settings.ShowGrid;
|
||||
}
|
||||
|
||||
// 설정에 마지막 맵 파일 경로 저장
|
||||
PUB.setting.LastMapFile = filePath;
|
||||
PUB.setting.Save();
|
||||
|
||||
// 맵 로드 후 자동으로 맵에 맞춤
|
||||
_mapCanvas.FitToNodes();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"맵 파일 로딩 실패: {result.ErrorMessage}", "오류",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveMapToFile(string filePath)
|
||||
{
|
||||
// 🔥 백업 파일 생성 (기존 파일이 있을 경우)
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
// 날짜시간 포함 백업 파일명 생성
|
||||
var directory = Path.GetDirectoryName(filePath);
|
||||
var fileNameWithoutExt = Path.GetFileNameWithoutExtension(filePath);
|
||||
var extension = Path.GetExtension(filePath);
|
||||
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||
var backupFileName = $"{fileNameWithoutExt}_{timestamp}{extension}.bak";
|
||||
var backupFilePath = Path.Combine(directory, backupFileName);
|
||||
|
||||
// 기존 파일을 백업 파일로 복사
|
||||
File.Copy(filePath, backupFilePath, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 백업 파일 생성 실패 시 경고만 표시하고 계속 진행
|
||||
MessageBox.Show($"백업 파일 생성 실패: {ex.Message}\n원본 파일은 계속 저장됩니다.", "백업 경고",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
var _mapCanvas = PUB._mapCanvas;
|
||||
var _mapNodes = PUB._mapNodes;
|
||||
|
||||
// 🔥 현재 캔버스 설정을 맵 파일에 저장
|
||||
var settings = new MapLoader.MapSettings
|
||||
{
|
||||
BackgroundColorArgb = _mapCanvas.BackColor.ToArgb(),
|
||||
ShowGrid = _mapCanvas.ShowGrid
|
||||
};
|
||||
|
||||
if (MapLoader.SaveMapToFile(filePath, _mapNodes, settings))
|
||||
{
|
||||
// 설정에 마지막 맵 파일 경로 저장
|
||||
PUB.setting.LastMapFile = filePath;
|
||||
PUB.setting.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("맵 파일 저장 실패", "오류",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void editorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// MapEditor 실행 파일 경로 확인
|
||||
string mapEditorPath = "AGVMapEditor.exe";
|
||||
|
||||
// 경로가 설정되지 않았거나 파일이 없는 경우 사용자에게 선택을 요청
|
||||
if (string.IsNullOrEmpty(mapEditorPath) || !File.Exists(mapEditorPath))
|
||||
{
|
||||
using (var openDialog = new OpenFileDialog())
|
||||
{
|
||||
openDialog.Filter = "실행 파일 (*.exe)|*.exe|모든 파일 (*.*)|*.*";
|
||||
openDialog.Title = "AGV MapEditor 실행 파일 선택";
|
||||
openDialog.InitialDirectory = Application.StartupPath;
|
||||
|
||||
if (openDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
mapEditorPath = openDialog.FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return; // 사용자가 취소함
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MapEditor 실행
|
||||
var startInfo = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = mapEditorPath,
|
||||
UseShellExecute = true
|
||||
};
|
||||
|
||||
// 현재 로드된 맵 파일이 있으면 파라미터로 전달
|
||||
var _currentMapFilePath = PUB._mapCanvas.MapFileName;
|
||||
if (!string.IsNullOrEmpty(_currentMapFilePath) && File.Exists(_currentMapFilePath))
|
||||
{
|
||||
startInfo.Arguments = $"\"{_currentMapFilePath}\"";
|
||||
}
|
||||
|
||||
System.Diagnostics.Process.Start(startInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"MapEditor를 실행할 수 없습니다:\n{ex.Message}", "오류",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user