public MenuWindow(DMIMenuWindowDefinition definition, DriverMachineInterface dmi) : base(definition.WindowTitle, false, dmi) { int i = 0; foreach (var buttondef in definition.Buttons) { DMIButton b; if (buttondef is DMITextButtonDefinition) { b = new DMITextButton((buttondef as DMITextButtonDefinition).Label, buttondef.ConfirmerCaption, buttondef.Enabled, () => { /* TODO */ }, 153, 50, dmi); } else if (buttondef is DMIIconButtonDefinition) { b = new DMIIconButton((buttondef as DMIIconButtonDefinition).EnabledIconName, (buttondef as DMIIconButtonDefinition).DisabledIconName, buttondef.ConfirmerCaption, buttondef.Enabled, () => { /* TODO */ }, 153, 50, dmi); } else { i++; continue; } Buttons.Add(b); AddToLayout(b, new Point(i % 2 * 153, 50 + 50 * (i / 2))); i++; } }
public DataEntryField(DMIDataEntryValue field, int index, DataEntryWindow window, bool singleField) { Name = field.Name; Field = field; AcceptedValue = PreviousValue = field.Value ?? ""; Index = index; DataEntryWindow = window; DMI = DataEntryWindow.DMI; DataArea = new FieldDataArea(Name, !singleField, DMI); if (!singleField) { LabelArea = new FieldLabelArea(Name, DMI); LabelEchoText = new DMIArea.TextPrimitive(new Point((int)(DataEntryWindow.LabelFont.MeasureString(Name) / DMI.Scale), 0), Color.White, Name, DataEntryWindow.LabelFont); } if (field.Keyboard.Type == DMIKeyboard.KeyboardType.Dedicate) { Keyboard = new DedicateKeyboard(field.Keyboard.KeyLabels, this); } else if (field.Keyboard.Type == DMIKeyboard.KeyboardType.Numeric) { Keyboard = new NumericKeyboard(this); } else if (field.Keyboard.Type == DMIKeyboard.KeyboardType.Alphanumeric) { Keyboard = new AlphanumericKeyboard(this); } DataArea.PressedAction = () => DataEntryWindow.FieldSelected(Index); DataArea.ShowButtonBorder = false; UpdateText(); }
public MenuWindow(string title, List <DMIButton> buttons, DriverMachineInterface dmi) : base(title, false, dmi) { int i = 0; foreach (var button in buttons) { if (button != null) { Buttons.Add(button); AddToLayout(button, new Point(i % 2 * 153, 50 + 50 * (i / 2))); } i++; } Visible = true; }
public MessageArea(DriverMachineInterface dmi) : base(Viewer.Catalog.GetString("Acknowledge"), true, dmi, false) { MaxTextLines = dmi.IsSoftLayout ? 4 : 5; Height = MaxTextLines * RowHeight; Width = 234; DisplayedTexts = new TextPrimitive[MaxTextLines]; DisplayedTimes = new TextPrimitive[MaxTextLines]; ButtonScrollUp = new DMIIconButton("NA_13.bmp", "NA_15.bmp", Viewer.Catalog.GetString("Scroll Up"), true, () => { if (CurrentPage < NumPages - 1) { CurrentPage++; SetMessages(); } }, 46, Height / 2, dmi); ButtonScrollDown = new DMIIconButton("NA_14.bmp", "NA_16.bmp", Viewer.Catalog.GetString("Scroll Down"), true, () => { if (CurrentPage > 0) { CurrentPage--; SetMessages(); } }, 46, Height / 2, dmi); PressedAction = () => { if (AcknowledgingMessage != null) { var ackmsg = AcknowledgingMessage.Value; ackmsg.Acknowledgeable = false; ackmsg.Acknowledged = true; int index = MessageList.IndexOf(ackmsg); if (index != -1) { MessageList[index] = ackmsg; } AcknowledgingMessage = null; } }; ScaleChanged(); }
public DataEntryWindow(DMIDataEntryDefinition definition, DriverMachineInterface dmi) : base(definition.WindowTitle, definition.FullScreen || definition.Fields.Count > 1, dmi) { Definition = definition; Title = definition.WindowTitle; int i = 0; LabelFont = GetFont(FontHeightLabel); foreach (var field in Definition.Fields) { Fields.Add(new DataEntryField(field, i, this, !FullScreen)); i++; } if (FullScreen) { NextButton = new DMIIconButton("NA_17.bmp", "NA_18.2.bmp", Viewer.Catalog.GetString("Next"), true, () => { if ((ActiveField / 4) < (Fields.Count / 4)) { NextButton.Enabled = false; PrevButton.Enabled = true; ActiveField = 4 * (ActiveField / 4 + 1); PrepareLayout(); } }, 82, 50, dmi); PrevButton = new DMIIconButton("NA_18.bmp", "NA_19.bmp", Viewer.Catalog.GetString("Next"), true, () => { if (ActiveField > 3) { NextButton.Enabled = true; PrevButton.Enabled = false; ActiveField = 4 * (ActiveField / 4 - 1); PrepareLayout(); } }, 82, 50, dmi); DataEntryCompleteLabel = new DMITextLabel(Title + " data entry complete?", 334, 50, dmi); YesButton = new DMIYesButton(dmi); YesButton.PressedAction = () => { bool overrideOperational = YesButton.DelayType; YesButton.DelayType = false; Dictionary <string, string> values = new Dictionary <string, string>(); foreach (var field in Fields) { values[field.Name] = field.AcceptedValue; } bool checkPassed = true; foreach (var check in Definition.TechnicalCrossChecks) { var conflict = check.GetConflictingVariables(values); foreach (var name in conflict) { foreach (var field in Fields) { if (field.Name == name) { checkPassed = false; field.TechnicalCrossCheckInvalid = true; break; } } } } if (!checkPassed) { return; } if (overrideOperational) { foreach (var check in Definition.OperationalCrossChecks) { var conflict = check.GetConflictingVariables(values); foreach (var name in conflict) { foreach (var field in Fields) { if (field.Name == name) { checkPassed = false; field.OperationalCrossCheckInvalid = true; break; } } } } } if (!checkPassed) { YesButton.DelayType = true; return; } string result = WindowTitle + "\n"; foreach (var field in Fields) { result += field.Name + "=" + field.AcceptedValue + "\n"; } //if (DMI.ETCSStatus != null) DMI.ETCSStatus.DriverActionResult = result; DMI.ExitWindow(this); }; YesButton.ExtendedSensitiveArea = new Rectangle(0, 50, 0, 0); PrevButton.Enabled = false; NextButton.Enabled = false; } if (Fields.Count > 4) { NextButton.Enabled = true; } PrepareLayout(); Visible = true; }
public DMIYesButton(DriverMachineInterface dmi) : base(Viewer.Catalog.GetString("Yes"), true, null, 330, 40, dmi, false) { SetText(); }
public FieldDataArea(string name, bool hasLabel, DriverMachineInterface dmi) : base(name, true, null, hasLabel ? 102 : 306, 50, dmi) { Data = new TextPrimitive(new Point(10, (Height - FontHeightDataField) / 2), Color.Transparent, "", null); Enabled = true; SetFont(); }
public FieldLabelArea(string name, DriverMachineInterface dmi) : base(dmi, 204, 50) { Name = name; BackgroundColor = ColorDarkGrey; SetText(); }
public MenuBar(DriverMachineInterface dmi) { // Interface with TCS to be defined in the future }