Example #1
0
        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 DMIButton(string displayName, bool upType, DriverMachineInterface dmi, bool showButtonBorder) : base(dmi)
 {
     DisplayName      = displayName;
     Enabled          = false;
     UpType           = upType;
     ShowButtonBorder = showButtonBorder;
 }
Example #3
0
        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 CircularSpeedGaugeRenderer(Viewer viewer, MSTSLocomotive locomotive, CabViewDigitalControl control, CabShader shader)
     : base(viewer, locomotive, control, shader)
 {
     // Height is adjusted to keep compatibility
     driverMachineInterface = new DriverMachineInterface((int)(Control.Bounds.Width * 640 / 280), (int)(Control.Bounds.Height * 480 / 300), locomotive, viewer, control);
     viewer.UserCommandController.AddEvent(CommonUserCommand.AlternatePointerPressed, MouseRightButtonPressed);
     viewer.UserCommandController.AddEvent(CommonUserCommand.AlternatePointerReleased, MouseRightButtonReleased);
 }
 public DMITextLabel(string caption, int width, int height, DriverMachineInterface dmi) :
     base(dmi, width, height)
 {
     Caption     = caption.Split('\n');
     CaptionText = new TextPrimitive[Caption.Length];
     SetFont();
     SetText();
 }
 public DMISubwindow(string title, bool fullScreen, DriverMachineInterface dmi) : base(dmi, fullScreen ? 640 : 306, 450)
 {
     WindowTitle         = title;
     FullScreen          = fullScreen;
     CloseButton         = new DMIIconButton("NA_11.bmp", "NA_12.bmp", Viewer.Catalog.GetString("Close"), true, () => dmi.ExitWindow(this), 82, 50, dmi);
     CloseButton.Enabled = true;
     BackgroundColor     = DMI.BlackWhiteTheme ? Color.Black : ColorBackground;
     SetFont();
     AddToLayout(CloseButton, new Point(fullScreen ? 334 : 0, 400));
 }
Example #7
0
 public PlanningWindow(DriverMachineInterface dmi) : base(dmi, 246, 300)
 {
     ButtonScaleUp   = new DMIIconButton("NA_03.bmp", "NA_05.bmp", Viewer.Catalog.GetString("Scale Up"), true, ScaleUp, 40, 15, dmi);
     ButtonScaleDown = new DMIIconButton("NA_04.bmp", "NA_06.bmp", Viewer.Catalog.GetString("Scale Down"), true, ScaleDown, 40, 15, dmi);
     ButtonScaleDown.ExtendedSensitiveArea = new Rectangle(0, 15, 0, 0);
     ButtonScaleUp.ExtendedSensitiveArea   = new Rectangle(0, 0, 0, 15);
     ButtonScaleUp.ShowButtonBorder        = false;
     ButtonScaleDown.ShowButtonBorder      = false;
     ButtonScaleUp.Enabled   = MaxViewingDistanceM > MinZoomDistanceM;
     ButtonScaleDown.Enabled = MaxViewingDistanceM < MaxZoomDistanceM;
     ScaleChanged();
 }
Example #8
0
        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;
        }
Example #9
0
        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();
        }
Example #10
0
 public TargetDistance(DriverMachineInterface dmi) : base(dmi, 54, 221)
 {
     ScaleChanged();
 }
Example #11
0
        public CircularSpeedGauge(int maxSpeed, bool unitMetric, bool unitVisible, bool dialQuarterLines, int maxVisibleScale, DriverMachineInterface dmi) : base(dmi, 280, 300)
        {
            UnitVisible = unitVisible;
            SetUnit(unitMetric);

            DialQuarterLines = dialQuarterLines;
            MaxSpeed         = maxSpeed;
            MaxVisibleScale  = maxVisibleScale;

            SetRange(MaxSpeed);

            CurrentSpeed = new TextPrimitive[3];
            for (var i = 0; i < CurrentSpeed.Length; i++)
            {
                CurrentSpeed[i] = new TextPrimitive(new Point(CurrentSpeedPosition[i], CurrentSpeedPosition[3]), Color.Black, "0", FontCurrentSpeed);
            }

            ReleaseSpeed = new TextPrimitive(ReleaseSpeedPosition, ColorGrey, String.Empty, FontReleaseSpeed);

            if (NeedleTextureData == null)
            {
                NeedleTextureData = new Color[128 * 16];

                // Needle texture is according to ETCS specification
                for (var v = 0; v < 128; v++)
                {
                    for (var u = 0; u < 16; u++)
                    {
                        NeedleTextureData[u + 16 * v] = (
                            v <= 15 && 5 < u && u < 9 ||
                            15 < v && v <= 23 && 5f - (float)(v - 15) / 8f * 3f < u && u < 9f + (float)(v - 15) / 8f * 3f ||
                            23 < v && v < 82 && 2 < u && u < 12
                            ) ? Color.White : Color.Transparent;
                    }
                }
            }
        }
 public DMIArea(DriverMachineInterface dmi)
 {
     DMI = dmi;
 }
Example #13
0
 public TTIandLSSMArea(DriverMachineInterface dmi) : base(dmi, 54, 54)
 {
 }
Example #14
0
 public MenuBar(DriverMachineInterface dmi)
 {
     // Interface with TCS to be defined in the future
 }
 public DMIArea(DriverMachineInterface dmi, int width, int height)
 {
     DMI    = dmi;
     Width  = width;
     Height = height;
 }
Example #16
0
 public DMIYesButton(DriverMachineInterface dmi) : base(Viewer.Catalog.GetString("Yes"), true, null, 330, 40, dmi, false)
 {
     SetText();
 }
Example #17
0
        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;
        }
Example #18
0
 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();
 }
 protected DMIWindow(DriverMachineInterface dmi, int width, int height) : base(dmi, width, height)
 {
 }
Example #20
0
 public FieldLabelArea(string name, DriverMachineInterface dmi) : base(dmi, 204, 50)
 {
     Name            = name;
     BackgroundColor = ColorDarkGrey;
     SetText();
 }
 public ETCSDefaultWindow(DriverMachineInterface dmi, CabViewControl control) : base(dmi, 640, 480)
 {
     if (control is CabViewDigitalControl)
     {
         var dig = control as CabViewDigitalControl;
         CircularSpeedGauge = new CircularSpeedGauge(
             (int)dig.ScaleRangeMax,
             dig.ControlUnit != CabViewControlUnit.Miles_Per_Hour,
             dig.ControlUnit != CabViewControlUnit.None,
             dig.ScaleRangeMax == 240 || dig.ScaleRangeMax == 260,
             (int)dig.ScaleRangeMin,
             DMI);
     }
     else
     {
         var param    = (control as CabViewScreenControl).CustomParameters;
         int maxSpeed = 400;
         if (param.ContainsKey("maxspeed"))
         {
             int.TryParse(param["maxspeed"], out maxSpeed);
         }
         int maxVisibleSpeed = maxSpeed;
         if (param.ContainsKey("maxvisiblespeed"))
         {
             int.TryParse(param["maxvisiblespeed"], out maxVisibleSpeed);
         }
         CircularSpeedGauge = new CircularSpeedGauge(
             maxSpeed,
             control.ControlUnit != CabViewControlUnit.Miles_Per_Hour,
             param.ContainsKey("displayunits") && param["displayunits"] == "1",
             maxSpeed == 240 || maxSpeed == 260,
             maxVisibleSpeed,
             dmi
             );
     }
     if (DMI.GaugeOnly)
     {
         AddToLayout(CircularSpeedGauge, new Point(0, 0));
         return;
     }
     PlanningWindow           = new PlanningWindow(dmi);
     TTIandLSSMArea           = new TTIandLSSMArea(dmi);
     TargetDistance           = new TargetDistance(dmi);
     MessageArea              = new MessageArea(dmi);
     MenuBar                  = new MenuBar(dmi);
     CircularSpeedGauge.Layer = -1;
     TargetDistance.Layer     = -1;
     TTIandLSSMArea.Layer     = -1;
     MessageArea.Layer        = -1;
     AddToLayout(CircularSpeedGauge, new Point(54, DMI.IsSoftLayout ? 0 : 15));
     AddToLayout(PlanningWindow, new Point(334, DMI.IsSoftLayout ? 0 : 15));
     AddToLayout(PlanningWindow.ButtonScaleDown, new Point(334, DMI.IsSoftLayout ? 0 : 15));
     AddToLayout(PlanningWindow.ButtonScaleUp, new Point(334, 285 + (DMI.IsSoftLayout ? 0 : 15)));
     AddToLayout(TTIandLSSMArea, new Point(0, DMI.IsSoftLayout ? 0 : 15));
     AddToLayout(TargetDistance, new Point(0, 54 + (DMI.IsSoftLayout ? 0 : 15)));
     AddToLayout(MessageArea, new Point(54, DMI.IsSoftLayout ? 350 : 365));
     AddToLayout(MessageArea.ButtonScrollUp, new Point(54 + 234, DMI.IsSoftLayout ? 350 : 365));
     AddToLayout(MessageArea.ButtonScrollDown, new Point(54 + 234, MessageArea.Height / 2 + (DMI.IsSoftLayout ? 350 : 365)));
     for (int i = 0; i < MenuBar.Buttons.Count; i++)
     {
         AddToLayout(MenuBar.Buttons[i], new Point(580, 15 + 50 * i));
     }
 }
 public DMIButton(string displayName, bool upType, Action pressedAction, int width, int height, DriverMachineInterface dmi, bool showButtonBorder = false) : base(dmi, width, height)
 {
     DisplayName      = displayName;
     Enabled          = false;
     UpType           = upType;
     PressedAction    = pressedAction;
     ShowButtonBorder = showButtonBorder;
 }
 public DMITextButton(string caption, string displayName, bool upType, Action pressedAction, int width, int height, DriverMachineInterface dmi, int fontHeight = 12) :
     base(displayName, upType, pressedAction, width, height, dmi, true)
 {
     Caption          = caption.Split('\n');
     CaptionText      = new TextPrimitive[Caption.Length];
     ConfirmerCaption = caption;
     FontHeightButton = fontHeight;
     SetFont();
     SetText();
 }
 public DMIIconButton(string enabledSymbol, string disabledSymbol, string displayName, bool upType, Action pressedAction, int width, int height, DriverMachineInterface dmi) :
     base(displayName, upType, pressedAction, width, height, dmi, true)
 {
     DisabledSymbol = disabledSymbol;
     EnabledSymbol  = enabledSymbol;
     SetIcon();
 }