UserService moved out of the HiNc core package; Hi.Sample keeps its own copy under Sample.Common so the DemoSessionMessage #ShowStepPresent region (a live docfx code snippet referenced by two app-anatomy pages) still compiles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
142 lines
5.2 KiB
C#
142 lines
5.2 KiB
C#
using Hi.Common;
|
|
using Hi.Common.XmlUtils;
|
|
using System.Xml;
|
|
using System.Xml.Linq;
|
|
|
|
namespace Sample.Common;
|
|
|
|
/// <summary>
|
|
/// Per-user visibility flags for the Player page's divisions (charts and
|
|
/// info panels), flattened into a single all-boolean config persisted through
|
|
/// <see cref="UserConfig"/>.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Defaults are tuned for a first-time user: the two info panels
|
|
/// (<see cref="EnableStepDiv"/> and <see cref="MessageTable"/>) are ON
|
|
/// so the Player page looks populated without having to open the
|
|
/// Division Visibility dropdown; every chart toggle starts OFF.
|
|
/// </remarks>
|
|
public class PlayerDivConfig : IMakeXmlSource
|
|
{
|
|
#region XML IO
|
|
/// <summary>
|
|
/// Registers this type's deserializer with the given <see cref="XFactory"/>
|
|
/// (or <see cref="XFactory.Default"/> when <paramref name="factory"/> is
|
|
/// <c>null</c>). Idempotent.
|
|
/// </summary>
|
|
public static void Reg(XFactory factory = null)
|
|
{
|
|
factory ??= XFactory.Default;
|
|
factory.Generators.TryAdd(XName, (xml, baseDirectory, relFile, progress, res)
|
|
=> new PlayerDivConfig(xml));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Name for XML IO.
|
|
/// </summary>
|
|
public static string XName => nameof(PlayerDivConfig);
|
|
|
|
/// <summary>
|
|
/// Default constructor.
|
|
/// </summary>
|
|
public PlayerDivConfig() { }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="PlayerDivConfig"/> class from XML data.
|
|
/// </summary>
|
|
/// <param name="src">XML element containing player-div data.</param>
|
|
public PlayerDivConfig(XElement src)
|
|
{
|
|
if (src == null) return;
|
|
|
|
src.Element(nameof(EnableStripAvailabilityChart))?.Value?.SelfInvoke(
|
|
v => EnableStripAvailabilityChart = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(EnableStripRoughnessChart))?.Value?.SelfInvoke(
|
|
v => EnableStripRoughnessChart = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(ColorIndexTimeChart))?.Value?.SelfInvoke(
|
|
v => ColorIndexTimeChart = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(ForceCycleLineDiv))?.Value?.SelfInvoke(
|
|
v => ForceCycleLineDiv = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(SimSpindleMomentCycleLineDiv))?.Value?.SelfInvoke(
|
|
v => SimSpindleMomentCycleLineDiv = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(SensorSpindleMomentCycleLineDiv))?.Value?.SelfInvoke(
|
|
v => SensorSpindleMomentCycleLineDiv = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(DynamometerForceCycleLineDiv))?.Value?.SelfInvoke(
|
|
v => DynamometerForceCycleLineDiv = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(EnableStepDiv))?.Value?.SelfInvoke(
|
|
v => EnableStepDiv = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(MessageTable))?.Value?.SelfInvoke(
|
|
v => MessageTable = XmlConvert.ToBoolean(v));
|
|
src.Element(nameof(EnableDetailDiv0))?.Value?.SelfInvoke(
|
|
v => EnableDetailDiv0 = XmlConvert.ToBoolean(v));
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)
|
|
{
|
|
return new XElement(XName,
|
|
new XElement(nameof(EnableStripAvailabilityChart), EnableStripAvailabilityChart),
|
|
new XElement(nameof(EnableStripRoughnessChart), EnableStripRoughnessChart),
|
|
new XElement(nameof(ColorIndexTimeChart), ColorIndexTimeChart),
|
|
new XElement(nameof(ForceCycleLineDiv), ForceCycleLineDiv),
|
|
new XElement(nameof(SimSpindleMomentCycleLineDiv), SimSpindleMomentCycleLineDiv),
|
|
new XElement(nameof(SensorSpindleMomentCycleLineDiv), SensorSpindleMomentCycleLineDiv),
|
|
new XElement(nameof(DynamometerForceCycleLineDiv), DynamometerForceCycleLineDiv),
|
|
new XElement(nameof(EnableStepDiv), EnableStepDiv),
|
|
new XElement(nameof(MessageTable), MessageTable),
|
|
new XElement(nameof(EnableDetailDiv0), EnableDetailDiv0)
|
|
);
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// Availability strip chart (per-step timeline coloured by availability aspect).
|
|
/// </summary>
|
|
public bool EnableStripAvailabilityChart { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Surface-roughness strip chart (per-step timeline coloured by surface-roughness aspect).
|
|
/// </summary>
|
|
public bool EnableStripRoughnessChart { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Color-index strip chart (single-strip timeline coloured by arbitrary numeric/bool aspect).
|
|
/// </summary>
|
|
public bool ColorIndexTimeChart { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Cycle-line chart of cutting force along the step's rotation cycle.
|
|
/// </summary>
|
|
public bool ForceCycleLineDiv { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Cycle-line chart of simulation-derived spindle moment on spindle-rotation coordinate.
|
|
/// </summary>
|
|
public bool SimSpindleMomentCycleLineDiv { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Cycle-line chart of sensor-measured spindle moment (overlay on sim moment).
|
|
/// </summary>
|
|
public bool SensorSpindleMomentCycleLineDiv { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Cycle-line chart of sensor-measured force from an external dynamometer.
|
|
/// </summary>
|
|
public bool DynamometerForceCycleLineDiv { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Full / condensed step information panel (Selected Step Info).
|
|
/// </summary>
|
|
public bool EnableStepDiv { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Session messages panel.
|
|
/// </summary>
|
|
public bool MessageTable { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Developer-only raw step-property dump panel.
|
|
/// </summary>
|
|
public bool EnableDetailDiv0 { get; set; } = false;
|
|
}
|