diff --git a/MainForm.cs b/MainForm.cs index e247432..d2dddfc 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -31,6 +31,7 @@ private PictureBox _aperturePicture; private Label _apertureCurrentValue; private Label _apertureDifferenceValue; + private Label _apertureInstructionLabel; private ToolStripStatusLabel _cameraStatusLabel; private ToolStripStatusLabel _cameraInfoLabel; @@ -175,13 +176,13 @@ AddCaption(panel, "差(現在値 − 目標値)"); _apertureDifferenceValue = AddValueLabel(panel, "--"); - AddCaption(panel, "ROI位置微調整"); + //AddCaption(panel, "ROI位置微調整"); + _apertureInstructionLabel = AddInstruction( + panel, + BuildApertureInstructionText(AppSettings.ApertureCalculationRoi)); + panel.Controls.Add(CreateApertureRoiMovePanel()); - AddInstruction( - panel, - "現在値が目標値(±1.0)となるように\r\nレンズの開口を調整してください。\r\n\r\n" + - $"赤枠: 計算ROI 128×128\r\n表示ROI: (860, 625), 1280×960\r\nROI移動: {AppSettings.ApertureRoiMoveStep}px単位"); AddInstructionImage(panel, "LensApature.jpg"); page.Controls.Add(split); @@ -308,9 +309,9 @@ return label; } - private static void AddInstruction(Control parent, string text) + private static Label AddInstruction(Control parent, string text) { - parent.Controls.Add(new Label + var label = new Label { Text = text, AutoSize = false, @@ -319,7 +320,26 @@ Font = new Font("Yu Gothic UI", 12F), TextAlign = ContentAlignment.MiddleLeft, Padding = new Padding(8) - }); + }; + parent.Controls.Add(label); + return label; + } + + private static string BuildApertureInstructionText(Rectangle calculationRoi) + { + return "現在値が目標値(±1.0)となるように\r\nレンズの開口を調整してください。\r\n\r\n" + + "ROI位置微調整\r\n" + + $"赤枠: ROI ({calculationRoi.X}, {calculationRoi.Y}), {calculationRoi.Width}×{calculationRoi.Height}\r\n" + + //$"表示ROI: ({AppSettings.ApertureDisplayRoi.X}, {AppSettings.ApertureDisplayRoi.Y}), {AppSettings.ApertureDisplayRoi.Width}×{AppSettings.ApertureDisplayRoi.Height}\r\n" + + $"ROI移動: {AppSettings.ApertureRoiMoveStep}px単位"; + } + + private void UpdateApertureInstructionText(Rectangle calculationRoi) + { + if (_apertureInstructionLabel != null) + { + _apertureInstructionLabel.Text = BuildApertureInstructionText(calculationRoi); + } } private static void AddInstructionImage(Control parent, string fileName) @@ -458,6 +478,7 @@ var button = (Button)sender; var delta = (Point)button.Tag; Rectangle roi = _processor.MoveApertureCalculationRoi(delta.X, delta.Y); + UpdateApertureInstructionText(roi); SaveApertureRoi(roi); _logger.Info($"Aperture ROI moved to ({roi.X}, {roi.Y})."); } @@ -469,6 +490,7 @@ return; Rectangle applied = _processor.SetApertureCalculationRoi(roi.Value); + UpdateApertureInstructionText(applied); _logger.Info($"Aperture ROI restored to ({applied.X}, {applied.Y})."); }