feat: expand p-rec-annot user surface and datum controls

This commit is contained in:
codex
2026-08-07 14:00:54 +03:00
parent fcdec4d227
commit 064cfdd803
6 changed files with 50 additions and 3 deletions
@@ -370,12 +370,27 @@ internal static class RibbonIntegration
if (tab is null) { tab = new RibbonTab { Id = TabId, Title = "Промхимпроект" }; ribbon.Tabs.Add(tab); }
var panel = tab.Panels.FirstOrDefault(x => string.Equals(x.Source?.Id, PanelId, StringComparison.OrdinalIgnoreCase));
if (panel is not null) { RuntimeDiagnostics.Write("RibbonAlreadyExists", resultStatus: "AlreadyExists"); RuntimeDiagnostics.Write("RibbonInitializationCompleted", resultStatus: "AlreadyExists"); return; }
// Keep the existing legacy-compatible PHP_REC_ANNOT action and expose the
// production command surface from the same composite panel.
var source = new RibbonPanelSource { Id = PanelId, Title = "Аннотации" };
source.Items.Add(new RibbonButton { Id = ButtonId, Text = "Аннотировать", ShowText = true, CommandParameter = "PHP_REC_ANNOT " });
AddButton(source, "LineNumber", "Line number", "PXP-LN");
AddButton(source, "LineConnections", "Line connections", "PXP-ALC");
AddButton(source, "AutoElevation", "Auto elevation", "PXP-AE");
AddButton(source, "InsertElevation", "Insert elevation", "PXP-IE");
AddButton(source, "OrthoAnnotate", "Ortho annotate", "PXP-OA");
AddButton(source, "AnnotateView", "Annotate view", "PXP-AAV");
AddButton(source, "ManualPalette", "Manual annotations", "mto-ma");
tab.Panels.Add(new RibbonPanel { Source = source });
RuntimeDiagnostics.Write("RibbonInitializationCompleted", resultStatus: "Created");
}
private static void AddButton(RibbonPanelSource? source, string suffix, string text, string command)
{
if (source is null) return;
source.Items.Add(new RibbonButton { Id = $"{PanelId}.{suffix}", Text = text, ShowText = true, CommandParameter = command + " " });
}
public static void Terminate()
{
if (!deferred) return;
@@ -47,6 +47,9 @@ internal sealed class ManualAnnotationControl : WinForms.UserControl
private readonly WinForms.Button place = new() { Text = "Place", AutoSize = true };
private readonly WinForms.Button reconnect = new() { Text = "Reconnect / refresh", AutoSize = true };
private readonly WinForms.Button help = new() { Text = "Help", AutoSize = true };
private readonly WinForms.RadioButton absoluteDatum = new() { Text = "Absolute datum", AutoSize = true, Checked = true };
private readonly WinForms.RadioButton relativeDatum = new() { Text = "Relative datum", AutoSize = true };
private readonly WinForms.NumericUpDown datumOffset = new() { DecimalPlaces = 3, Minimum = -100000, Maximum = 100000, Increment = 0.001M, Enabled = false };
private readonly Dictionary<WinForms.RadioButton, ManualAnnotationKind> kinds = new();
public ManualAnnotationControl()
{
@@ -55,8 +58,11 @@ internal sealed class ManualAnnotationControl : WinForms.UserControl
Add("Instrument position", ManualAnnotationKind.InstrumentPosition); Add("Section elevation", ManualAnnotationKind.SectionElevation); Add("Instrument connection point", ManualAnnotationKind.InstrumentConnection);
Add("AutoCAD block", ManualAnnotationKind.AutoCadBlock); Add("Platform elevation", ManualAnnotationKind.PlatformElevation); Add("Other elevation", ManualAnnotationKind.OtherElevation);
place.Click += (_, _) => Place(); reconnect.Click += (_, _) => Reconnect(); help.Click += (_, _) => OpenHelp();
var datum = new WinForms.FlowLayoutPanel { Dock = WinForms.DockStyle.Top, AutoSize = true }; datum.Controls.Add(absoluteDatum); datum.Controls.Add(relativeDatum); datum.Controls.Add(datumOffset);
absoluteDatum.CheckedChanged += (_, _) => datumOffset.Enabled = relativeDatum.Checked;
relativeDatum.CheckedChanged += (_, _) => datumOffset.Enabled = relativeDatum.Checked;
var actions = new WinForms.FlowLayoutPanel { Dock = WinForms.DockStyle.Top, AutoSize = true }; actions.Controls.Add(place); actions.Controls.Add(reconnect); actions.Controls.Add(help);
Controls.Add(actions); Controls.Add(choices); RefreshTheme();
Controls.Add(datum); Controls.Add(actions); Controls.Add(choices); RefreshTheme();
}
private void Add(string text, ManualAnnotationKind kind, bool selected = false) { var button = new WinForms.RadioButton { Text = text, AutoSize = true, Checked = selected }; kinds.Add(button, kind); choices.Controls.Add(button); }
public void RefreshAvailability() { var available = AcadApplication.DocumentManager.MdiActiveDocument is not null && PlantApplication.CurrentProject is not null; place.Enabled = available; reconnect.Enabled = available; RefreshTheme(); }