Example #1
0
 public void FieldSelected(int index)
 {
     if (!FullScreen)
     {
         var  field = Fields[index];
         bool overrideOperational = field.DataArea.DelayType;
         field.SetAccepted(true);
         if (field.TechnicalRangeInvalid || field.TechnicalResolutionInvalid || (field.OperationalRangeInvalid && !overrideOperational))
         {
             if (field.OperationalRangeInvalid)
             {
                 field.DataArea.DelayType = true;
             }
             return;
         }
         string result = WindowTitle + "\n";
         result += field.Name + "=" + field.AcceptedValue + "\n";
         //if (DMI.ETCSStatus != null) DMI.ETCSStatus.DriverActionResult = result;
         DMI.ExitWindow(this);
     }
     else if (ActiveField == index)
     {
         var  field = Fields[index];
         bool overrideOperational = field.DataArea.DelayType;
         field.SetAccepted(true);
         if (field.TechnicalRangeInvalid || field.TechnicalResolutionInvalid || (field.OperationalRangeInvalid && !overrideOperational))
         {
             if (field.OperationalRangeInvalid)
             {
                 Fields[index].DataArea.DelayType = true;
             }
             for (int i = 0; i < Fields.Count; i++)
             {
                 if (i != index)
                 {
                     Fields[i].DataArea.Enabled = false;
                 }
             }
             PrevButton.Enabled = false;
             NextButton.Enabled = false;
             return;
         }
         if (index + 1 < Fields.Count)
         {
             ActiveField++;
         }
         else
         {
             ActiveField = 0;
         }
         NextButton.Enabled = CurrentPage + 1 < NumPages;
         PrevButton.Enabled = CurrentPage > 0;
         bool allaccepted = true;
         foreach (var f in Fields)
         {
             if (!f.Accepted)
             {
                 allaccepted = false;
                 break;
             }
         }
         if (allaccepted)
         {
             YesButton.Enabled = true;
         }
         else
         {
             YesButton.Enabled = false;
         }
         PrepareLayout();
     }
     else
     {
         ActiveField = index;
         PrepareLayout();
     }
 }
Example #2
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;
        }