コード例 #1
0
 /// <inheritdoc />
 public PlasticSCMAddExecutor(IFileSystem fileSystem, ICakeEnvironment environment,
                              IProcessRunner processRunner, IToolLocator tools, ICakeLog log) : base(fileSystem, environment, processRunner, tools,
                                                                                                     "add", log)
 {
     FormatStrings.Add("format", "OK" + PlasticSCMAddParser.SEPARATOR_CHAR + "{0}");
     FormatStrings.Add("errorformat", "ERR" + PlasticSCMAddParser.SEPARATOR_CHAR + "{0}");
 }
コード例 #2
0
 public override string GetFullStatus(BrakeSystem lastCarBrakeSystem, Dictionary <BrakeSystemComponent, Pressure.Unit> units)
 {
     // display differently depending upon whether vacuum or air braked system
     if (Car.CarBrakeSystemType == "vacuum_piped")
     {
         string s = string.Format(" V {0}", FormatStrings.FormatPressure(Car.Train.EqualReservoirPressurePSIorInHg, Pressure.Unit.InHg, Pressure.Unit.InHg, true));
         if (lastCarBrakeSystem != null && lastCarBrakeSystem != this)
         {
             s += " EOT " + lastCarBrakeSystem.GetStatus(units);
         }
         if (HandbrakePercent > 0)
         {
             s += string.Format(" Handbrake {0:F0}%", HandbrakePercent);
         }
         return(s);
     }
     else // air braked by default
     {
         var s = string.Format("BP {0}", FormatStrings.FormatPressure(BrakeLine1PressurePSI, Pressure.Unit.PSI, units[BrakeSystemComponent.BrakePipe], false));
         if (lastCarBrakeSystem != null && lastCarBrakeSystem != this)
         {
             s += " EOT " + lastCarBrakeSystem.GetStatus(units);
         }
         if (HandbrakePercent > 0)
         {
             s += string.Format(" Handbrake {0:F0}%", HandbrakePercent);
         }
         return(s);
     }
 }
コード例 #3
0
        // draw fixed distance markers
        float drawDistanceMarkers(SpriteBatch spriteBatch, Point offset, float maxDistance, float distanceFactor, int zeroPoint, int numberOfMarkers, bool forward)
        {
            var maxDistanceD    = Me.FromM(maxDistance, metric); // in displayed units
            var markerIntervalD = maxDistanceD / numberOfMarkers;

            var roundingValue = roundingValues[0];

            foreach (var thisValue in roundingValues)
            {
                if (markerIntervalD > thisValue.Key)
                {
                    roundingValue = thisValue.Value;
                }
            }

            markerIntervalD = Convert.ToInt32(markerIntervalD / roundingValue) * roundingValue;
            var markerIntervalM = Me.ToM(markerIntervalD, metric);  // from display back to metre

            for (var ipos = 1; ipos <= numberOfMarkers; ipos++)
            {
                var actDistanceM = markerIntervalM * ipos;
                if (actDistanceM < maxDistance)
                {
                    var itemOffset     = Convert.ToInt32(actDistanceM * distanceFactor);
                    var itemLocation   = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset;
                    var distanceString = FormatStrings.FormatDistanceDisplay(actDistanceM, metric);
                    Font.Draw(spriteBatch, new Point(offset.X + distanceTextOffset, offset.Y + itemLocation + textOffset[forward ? 0 : 1]), distanceString, Color.White);
                }
            }

            return(markerIntervalM);
        }
コード例 #4
0
        // draw waiting point information
        int drawWaitingPoint(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, float firstLabelDistance, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem, ref bool firstLabelShown)
        {
            var displayItem      = waitingPointSprite;
            var newLabelPosition = lastLabelPosition;

            if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor))
            {
                var itemOffset   = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor);
                var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset;
                newLabelPosition = forward ? Math.Min(itemLocation, lastLabelPosition - textSpacing) : Math.Max(itemLocation, lastLabelPosition + textSpacing);

                var markerPlacement = new Rectangle(offset.X + waitingPointPosition[0], offset.Y + itemLocation + waitingPointPosition[forward ? 1 : 2], waitingPointPosition[3], waitingPointPosition[4]);
                spriteBatch.Draw(TrackMonitorImages, markerPlacement, displayItem, thisItem.Enabled ? Color.Yellow : Color.Red);

                if (itemOffset < firstLabelDistance && !firstLabelShown)
                {
                    var labelPoint     = new Point(offset.X + distanceTextOffset, offset.Y + newLabelPosition + textOffset[forward ? 0 : 1]);
                    var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric);
                    Font.Draw(spriteBatch, labelPoint, distanceString, Color.White);
                    firstLabelShown = true;
                }
            }

            return(newLabelPosition);
        }
コード例 #5
0
        // draw speedpost information
        int drawSpeedpost(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, int firstLabelPosition, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem, ref bool firstLabelShown)
        {
            var newLabelPosition = lastLabelPosition;

            if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor))
            {
                var itemOffset   = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor);
                var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset;
                newLabelPosition = forward ? Math.Min(itemLocation, lastLabelPosition - textSpacing) : Math.Max(itemLocation, lastLabelPosition + textSpacing);

                var allowedSpeed = thisItem.AllowedSpeedMpS;
                if (allowedSpeed > 998)
                {
                    if (!Program.Simulator.TimetableMode)
                    {
                        allowedSpeed = (float)Program.Simulator.TRK.Tr_RouteFile.SpeedLimit;
                    }
                }

                var labelPoint  = new Point(offset.X + speedTextOffset, offset.Y + newLabelPosition + textOffset[forward ? 0 : 1]);
                var speedString = FormatStrings.FormatSpeedLimit(allowedSpeed, metric);
                Font.Draw(spriteBatch, labelPoint, speedString, thisItem.SpeedObjectType == Train.TrainObjectItem.SpeedItemType.Standard ? Color.White :
                          (thisItem.SpeedObjectType == Train.TrainObjectItem.SpeedItemType.TempRestrictedStart ? Color.Red : Color.LightGreen));

                if (itemOffset < firstLabelPosition && !firstLabelShown)
                {
                    labelPoint = new Point(offset.X + distanceTextOffset, offset.Y + newLabelPosition + textOffset[forward ? 0 : 1]);
                    var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric);
                    Font.Draw(spriteBatch, labelPoint, distanceString, Color.White);
                    firstLabelShown = true;
                }
            }

            return(newLabelPosition);
        }
コード例 #6
0
        // draw reversal information
        int drawReversal(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, float firstLabelDistance, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem, ref bool firstLabelShown)
        {
            var displayItem      = reversalSprite;
            var newLabelPosition = lastLabelPosition;

            if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor))
            {
                var itemOffset   = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor);
                var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset;
                newLabelPosition = forward ? Math.Min(itemLocation, lastLabelPosition - textSpacing) : Math.Max(itemLocation, lastLabelPosition + textSpacing);

                // What was this offset all about? Shouldn't we draw the icons in the correct location ALL the time? -- James Ross
                // var correctingOffset = Program.Simulator.TimetableMode || !Program.Simulator.Settings.EnhancedActCompatibility ? 0 : 7;

                var markerPlacement = new Rectangle(offset.X + reversalPosition[0], offset.Y + itemLocation + reversalPosition[forward ? 1 : 2], reversalPosition[3], reversalPosition[4]);
                spriteBatch.Draw(TrackMonitorImages, markerPlacement, displayItem, thisItem.Enabled ? Color.LightGreen : Color.White);

                // Only show distance for enhanced MSTS compatibility (this is the only time the position is controlled by the author).
                if (itemOffset < firstLabelDistance && !firstLabelShown && !Program.Simulator.TimetableMode)
                {
                    var labelPoint     = new Point(offset.X + distanceTextOffset, offset.Y + newLabelPosition + textOffset[forward ? 0 : 1]);
                    var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric);
                    Font.Draw(spriteBatch, labelPoint, distanceString, Color.White);
                    firstLabelShown = true;
                }
            }

            return(newLabelPosition);
        }
コード例 #7
0
 public override string GetFullStatus(BrakeSystem lastCarBrakeSystem, Dictionary <BrakeSystemComponent, PressureUnit> units)
 {
     // display differently depending upon whether vacuum or air braked system
     if (Car.CarBrakeSystemType == "vacuum_piped")
     {
         var s = $" {Simulator.Catalog.GetString("V")} {FormatStrings.FormatPressure(Car.Train.EqualReservoirPressurePSIorInHg, PressureUnit.InHg, PressureUnit.InHg, true)}";
         if (lastCarBrakeSystem != null && lastCarBrakeSystem != this)
         {
             s += $" {Simulator.Catalog.GetString("EOT")} {lastCarBrakeSystem.GetStatus(units)}";
         }
         if (HandbrakePercent > 0)
         {
             s += $" {Simulator.Catalog.GetString("Handbrake")} {HandbrakePercent:F0}%";
         }
         return(s);
     }
     else // air braked by default
     {
         var s = $"{Simulator.Catalog.GetString("BP")} {FormatStrings.FormatPressure(BrakeLine1PressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakePipe], false)}";
         if (lastCarBrakeSystem != null && lastCarBrakeSystem != this)
         {
             s += $" {Simulator.Catalog.GetString("EOT")} {lastCarBrakeSystem.GetStatus(units)}";
         }
         if (HandbrakePercent > 0)
         {
             s += $" {Simulator.Catalog.GetString("Handbrake")} {HandbrakePercent:F0}%";
         }
         return(s);
     }
 }
コード例 #8
0
        public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
        {
            base.PrepareFrame(elapsedTime, updateFull);

            if (Animation && Owner.Viewer.RealTime > AnimationStart + AnimationLength)
            {
                Animation = false;
            }

            if (Owner.Viewer.RealTime > 0.1)
            {
                // TODO: Casting to MSTSLocomotive here suggests a problem with the data model in the Simulator.
                var playerLocomotive = Owner.Viewer.PlayerLocomotive as MSTSLocomotive;
                if (playerLocomotive != null && playerLocomotive.Train != null && playerLocomotive.OdometerVisible)
                {
                    SetNotice(Viewer.Catalog.GetStringFmt("Odometer {0}", FormatStrings.FormatShortDistanceDisplay(playerLocomotive.OdometerM, Owner.Viewer.MilepostUnitsMetric)));
                }
                // Camera notices are temporary so we put them after to override.
                if (Owner.Viewer.Camera != null)
                {
                    if (Owner.Viewer.Camera.Name != Camera)
                    {
                        Camera = Owner.Viewer.Camera.Name;
                        // Changing camera should not notify FOV change.
                        FieldOfView = Owner.Viewer.Camera.FieldOfView;
                        SetNotice(Viewer.Catalog.GetStringFmt("Camera: {0}", Camera));
                    }
                    else if (FieldOfView != Owner.Viewer.Camera.FieldOfView)
                    {
                        FieldOfView = Owner.Viewer.Camera.FieldOfView;
                        SetNotice(Viewer.Catalog.GetStringFmt("FOV: {0:F0}°", FieldOfView));
                    }
                }
            }
        }
コード例 #9
0
        public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
        {
            base.PrepareFrame(elapsedTime, updateFull);

            // Always get train details to pass on to TrackMonitor.
            var thisInfo = Owner.Viewer.PlayerTrain.GetTrainInfo();

            Monitor.StoreInfo(thisInfo);

            // Update text fields on full update only.
            if (updateFull)
            {
                SpeedCurrent.Text   = FormatStrings.FormatSpeedDisplay(Math.Abs(thisInfo.speedMpS), Owner.Viewer.MilepostUnitsMetric);
                SpeedProjected.Text = FormatStrings.FormatSpeedDisplay(Math.Abs(thisInfo.projectedSpeedMpS), Owner.Viewer.MilepostUnitsMetric);
                SpeedAllowed.Text   = FormatStrings.FormatSpeedLimit(thisInfo.allowedSpeedMpS, Owner.Viewer.MilepostUnitsMetric);

                var ControlText = ControlModeLabels[thisInfo.ControlMode];
                if (thisInfo.ControlMode == Train.TRAIN_CONTROL.AUTO_NODE)
                {
                    ControlText = FindAuthorityInfo(thisInfo.ObjectInfoForward, ControlText);
                }
                else if (thisInfo.ControlMode == Train.TRAIN_CONTROL.OUT_OF_CONTROL)
                {
                    ControlText = String.Concat(ControlText, OutOfControlLabels[thisInfo.ObjectInfoForward[0].OutOfControlReason]);
                }
                ControlMode.Text = String.Copy(ControlText);
            }
        }
コード例 #10
0
ファイル: MessagesWindow.cs プロジェクト: wjcurrey/openrails
        public void AddMessage(string key, string text, double duration)
        {
            var clockTime = Owner.Viewer.Simulator.ClockTime;
            var gameTime  = Owner.Viewer.Simulator.GameTime;

            while (true)
            {
                // Store the original list and make a clone for replacing it thread-safely.
                var oldMessages = Messages;
                var newMessages = new List <Message>(oldMessages);

                // Find an existing message if there is one.
                var existingMessage = String.IsNullOrEmpty(key) ? null : newMessages.FirstOrDefault(m => m.Key == key);

                // Clean out any existing duplicate key and expired messages.
                newMessages = (from m in newMessages
                               where (String.IsNullOrEmpty(key) || m.Key != key) && m.EndTime + FadeTime > Owner.Viewer.Simulator.GameTime
                               select m).ToList();

                // Add the new message.
                newMessages.Add(new Message(key, String.Format("{0} {1}", FormatStrings.FormatTime(clockTime), text), existingMessage != null ? existingMessage.StartTime : gameTime, gameTime + duration));

                // Sort the messages.
                newMessages = (from m in newMessages
                               orderby m.StartTime descending
                               select m).ToList();

                // Thread-safely switch from the old list to the new list; we've only suceeded if the previous (return) value is the old list.
                if (Interlocked.CompareExchange(ref Messages, newMessages, oldMessages) == oldMessages)
                {
                    break;
                }
            }
            MessagesChanged = true;
        }
コード例 #11
0
        public override string GetDebugStatus()
        {
            var status = new StringBuilder(base.GetDebugStatus());

            if (DieselEngines.HasGearBox)
            {
                status.AppendFormat("\t{0} {1}", Simulator.Catalog.GetString("Gear"), DieselEngines[0].GearBox.CurrentGearIndex);
            }
            status.AppendFormat("\t{0} {1}\t\t{2}",
                                Simulator.Catalog.GetString("Fuel"),
                                FormatStrings.FormatFuelVolume(DieselLevelL, IsMetric, IsUK), DieselEngines.GetStatus());

            if (IsSteamHeatFitted && TrainFittedSteamHeat && this.IsLeadLocomotive() && Train.PassengerCarsNumber > 0)
            {
                // Only show steam heating HUD if fitted to locomotive and the train, has passenger cars attached, and is the lead locomotive
                // Display Steam Heat info
                status.AppendFormat("\n{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10:N0}\t{11}\t{12}\n",
                                    Simulator.Catalog.GetString("StHeat:"),
                                    Simulator.Catalog.GetString("Press"),
                                    FormatStrings.FormatPressure(CurrentSteamHeatPressurePSI, PressureUnit.PSI, MainPressureUnit, true),
                                    Simulator.Catalog.GetString("TrTemp"),
                                    FormatStrings.FormatTemperature(Train.TrainCurrentCarriageHeatTempC, IsMetric, false),
                                    Simulator.Catalog.GetString("StTemp"),
                                    FormatStrings.FormatTemperature(Train.TrainCurrentSteamHeatPipeTempC, IsMetric, false),
                                    Simulator.Catalog.GetString("OutTemp"),
                                    FormatStrings.FormatTemperature(Train.TrainOutsideTempC, IsMetric, false),
                                    Simulator.Catalog.GetString("NetHt"),
                                    Train.DisplayTrainNetSteamHeatLossWpTime,
                                    Simulator.Catalog.GetString("FuelLvl"),
                                    CurrentSteamHeatFuelCapacityL);
            }


            return(status.ToString());
        }
コード例 #12
0
 // This overides the information for each individual wagon in the extended HUD
 public override string[] GetDebugStatus(Dictionary <BrakeSystemComponent, PressureUnit> units)
 {
     // display differently depending upon whether vacuum or air braked system
     if (Car.CarBrakeSystemType == "vacuum_piped")
     {
         return(new string[] {
             DebugType,
             string.Empty,
             FormatStrings.FormatPressure(Vac.FromPress(BrakeLine1PressurePSI), PressureUnit.InHg, PressureUnit.InHg, true),
             string.Empty,
             string.Empty, // Spacer because the state above needs 2 columns.
             HandbrakePercent > 0 ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
             FrontBrakeHoseConnected ? "I" : "T",
             string.Format("A{0} B{1}", AngleCockAOpen ? "+" : "-", AngleCockBOpen ? "+" : "-"),
         });
     }
     else  // air braked by default
     {
         return(new string[] {
             DebugType,
             string.Empty,
             FormatStrings.FormatPressure(BrakeLine1PressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakePipe], true),
             string.Empty,
             string.Empty,
             string.Empty,
             string.Empty,
             string.Empty,
             string.Empty, // Spacer because the state above needs 2 columns.
             (Car as MSTSWagon).HandBrakePresent ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
             FrontBrakeHoseConnected ? "I" : "T",
             string.Format("A{0} B{1}", AngleCockAOpen ? "+" : "-", AngleCockBOpen ? "+" : "-"),
             BleedOffValveOpen ? Simulator.Catalog.GetString("Open") : string.Empty,
         });
     }
 }
コード例 #13
0
        // This overides the information for each individual wagon in the extended HUD
        public override string[] GetDebugStatus(Dictionary <BrakeSystemComponent, PressureUnit> units)
        {
            // display differently depending upon whether manual brake is present or not

            if ((Car as MSTSWagon).ManualBrakePresent && LocomotiveSteamBrakeFitted)
            {
                return(new string[] {
                    DebugType,
                    string.Format("{0:F0}", FormatStrings.FormatPressure(SteamBrakeCylinderPressurePSI, PressureUnit.PSI, PressureUnit.PSI, true)),
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty, // Spacer because the state above needs 2 columns.
                    (Car as MSTSWagon).HandBrakePresent ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                });
            }
            else if ((Car as MSTSWagon).ManualBrakePresent) // Just manual brakes fitted
            {
                return(new string[] {
                    DebugType,
                    string.Format("{0:F0} %", ManualBrakingCurrentFraction),
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty, // Spacer because the state above needs 2 columns.
                    (Car as MSTSWagon).HandBrakePresent ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                });
            }
            else
            {
                return(new string[] {
                    DebugType,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty, // Spacer because the state above needs 2 columns.
                    (Car as MSTSWagon).HandBrakePresent ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                });
            }
        }
コード例 #14
0
        public void FormattedTimeStrings()
        {
            TimeSpan duration = new TimeSpan(1, 13, 37, 45, 20); //1d 13:37:45.020

            Assert.AreEqual("13:37:45", FormatStrings.FormatTime(duration.TotalSeconds));
            Assert.AreEqual("13:37:45.20", FormatStrings.FormatPreciseTime(duration.TotalSeconds));
            Assert.AreEqual("13:37", FormatStrings.FormatApproximateTime(duration.TotalSeconds));
        }
コード例 #15
0
        public override string GetFullStatus(BrakeSystem lastCarBrakeSystem, Dictionary <BrakeSystemComponent, PressureUnit> units)
        {
            string s = string.Format(" BC {0}", FormatStrings.FormatPressure(CylPressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakeCylinder], true));

            if (HandbrakePercent > 0)
            {
                s += string.Format(" Handbrake {0:F0}%", HandbrakePercent);
            }
            return(s);
        }
コード例 #16
0
        public override string GetFullStatus(BrakeSystem lastCarBrakeSystem, Dictionary <BrakeSystemComponent, PressureUnit> units)
        {
            var s = $" {Simulator.Catalog.GetString("BC")} {FormatStrings.FormatPressure(CylPressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakeCylinder], true)}";

            if (HandbrakePercent > 0)
            {
                s += $" {Simulator.Catalog.GetString("Handbrake")} {HandbrakePercent:F0}%";
            }
            return(s);
        }
コード例 #17
0
 public override string GetStatus(Dictionary <BrakeSystemComponent, PressureUnit> units)
 {
     // display differently depending upon whether vacuum or air braked system
     if (Car.CarBrakeSystemType == "vacuum_piped")
     {
         return($" {Simulator.Catalog.GetString("BP")} {FormatStrings.FormatPressure(Vac.FromPress(BrakeLine1PressurePSI), PressureUnit.InHg, PressureUnit.InHg, false)}");
     }
     else  // air braked by default
     {
         return($"{Simulator.Catalog.GetString("BP")} {FormatStrings.FormatPressure(BrakeLine1PressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakePipe], true)}");
     }
 }
コード例 #18
0
 public override string GetStatus(Dictionary <BrakeSystemComponent, Pressure.Unit> units)
 {
     // display differently depending upon whether vacuum or air braked system
     if (Car.CarBrakeSystemType == "vacuum_piped")
     {
         return(string.Format(" BP {0}", FormatStrings.FormatPressure(Pressure.Vacuum.FromPressure(BrakeLine1PressurePSI), Pressure.Unit.InHg, Pressure.Unit.InHg, false)));
     }
     else  // air braked by default
     {
         return(string.Format("BP {0}", FormatStrings.FormatPressure(BrakeLine1PressurePSI, Pressure.Unit.PSI, units[BrakeSystemComponent.BrakePipe], true)));
     }
 }
コード例 #19
0
ファイル: VacuumSinglePipe.cs プロジェクト: robwor/openrails
        public override string GetFullStatus(BrakeSystem lastCarBrakeSystem, Dictionary <BrakeSystemComponent, PressureUnit> units)
        {
            string s = string.Format(" V {0}", FormatStrings.FormatPressure(Car.Train.EqualReservoirPressurePSIorInHg, PressureUnit.InHg, PressureUnit.InHg, true));

            if (lastCarBrakeSystem != null && lastCarBrakeSystem != this)
            {
                s += " EOT " + lastCarBrakeSystem.GetStatus(units);
            }
            if (HandbrakePercent > 0)
            {
                s += string.Format(" Handbrake {0:F0}%", HandbrakePercent);
            }
            return(s);
        }
コード例 #20
0
        public override string GetFullStatus(BrakeSystem lastCarBrakeSystem, Dictionary <BrakeSystemComponent, PressureUnit> units)
        {
            var s = string.Format("BP {0}", FormatStrings.FormatPressure(BrakeLine1PressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakePipe], false));

            if (lastCarBrakeSystem != null && lastCarBrakeSystem != this)
            {
                s += " EOT " + lastCarBrakeSystem.GetStatus(units);
            }
            if (HandbrakePercent > 0)
            {
                s += string.Format(" Handbrake {0:F0}%", HandbrakePercent);
            }
            return(s);
        }
コード例 #21
0
        // draw signal information
        int drawSignal(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, int firstLabelPosition, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem, ref bool signalShown, ref bool firstLabelShown)
        {
            var displayItem      = SignalMarkers[thisItem.SignalState];
            var newLabelPosition = lastLabelPosition;

            var displayRequired    = false;
            var itemLocation       = 0;
            var itemOffset         = 0;
            var maxDisplayDistance = maxDistance - (textSpacing / 2) / distanceFactor;

            if (thisItem.DistanceToTrainM < maxDisplayDistance)
            {
                itemOffset      = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor);
                itemLocation    = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset;
                displayRequired = true;
                signalShown     = true;
            }
            else if (!signalShown)
            {
                itemOffset      = 2 * startObjectArea;
                itemLocation    = forward ? startObjectArea : endObjectArea;
                displayRequired = true;
                signalShown     = true;
            }

            if (displayRequired)
            {
                spriteBatch.Draw(SignalAspects, new Rectangle(offset.X + signalPosition[0], offset.Y + itemLocation + signalPosition[forward ? 1 : 2], signalPosition[3], signalPosition[4]), displayItem, Color.White);

                if (thisItem.SignalState != TrackMonitorSignalAspect.Stop && thisItem.AllowedSpeedMpS > 0)
                {
                    var labelPoint  = new Point(offset.X + speedTextOffset, offset.Y + itemLocation + textOffset[forward ? 0 : 1]);
                    var speedString = FormatStrings.FormatSpeedLimit(thisItem.AllowedSpeedMpS, metric);
                    Font.Draw(spriteBatch, labelPoint, speedString, Color.White);
                }

                if ((itemOffset < firstLabelPosition && !firstLabelShown) || thisItem.DistanceToTrainM > maxDisplayDistance)
                {
                    var labelPoint     = new Point(offset.X + distanceTextOffset, offset.Y + itemLocation + textOffset[forward ? 0 : 1]);
                    var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric);
                    Font.Draw(spriteBatch, labelPoint, distanceString, Color.White);
                    firstLabelShown = true;
                }
            }

            return(newLabelPosition);
        }
コード例 #22
0
        public string GetStatus()
        {
            var result = new StringBuilder();

            result.AppendFormat(Simulator.Catalog.GetString("Status"));
            foreach (var eng in DEList)
            {
                result.AppendFormat("\t{0}", Simulator.Catalog.GetString(GetStringAttribute.GetPrettyName(eng.EngineStatus)));
            }

            result.AppendFormat("\t{0}\t{1}", Simulator.Catalog.GetParticularString("HUD", "Power"), FormatStrings.FormatPower(MaxOutputPowerW, Locomotive.IsMetric, false, false));
            foreach (var eng in DEList)
            {
                result.AppendFormat("\t{0}", FormatStrings.FormatPower(eng.MaxOutputPowerW, Locomotive.IsMetric, false, false));
            }

            result.AppendFormat("\t{0}", Simulator.Catalog.GetString("Load"));
            foreach (var eng in DEList)
            {
                result.AppendFormat("\t{0:F1}%", eng.LoadPercent);
            }

            foreach (var eng in DEList)
            {
                result.AppendFormat("\t{0:F0} {1}", eng.RealRPM, FormatStrings.rpm);
            }

            result.AppendFormat("\t{0}", Simulator.Catalog.GetString("Flow"));
            foreach (var eng in DEList)
            {
                result.AppendFormat("\t{0}/{1}", FormatStrings.FormatFuelVolume(pS.TopH(eng.DieselFlowLps), Locomotive.IsMetric, Locomotive.IsUK), FormatStrings.h);
            }

            result.Append("\t");
            foreach (var eng in DEList)
            {
                result.AppendFormat("\t{0}", FormatStrings.FormatTemperature(eng.DieselTemperatureDeg, Locomotive.IsMetric, false));
            }

            result.AppendFormat("\t{0}", Simulator.Catalog.GetString("Oil"));
            foreach (var eng in DEList)
            {
                result.AppendFormat("\t{0}", FormatStrings.FormatPressure(eng.DieselOilPressurePSI, PressureUnit.PSI, Locomotive.MainPressureUnit, true));
            }

            return(result.ToString());
        }
コード例 #23
0
ファイル: VacuumSinglePipe.cs プロジェクト: robwor/openrails
 public override string[] GetDebugStatus(Dictionary <BrakeSystemComponent, PressureUnit> units)
 {
     return(new string[] {
         "1V",
         FormatStrings.FormatPressure(P2V(CylPressurePSIA), PressureUnit.InHg, PressureUnit.InHg, true),
         FormatStrings.FormatPressure(P2V(BrakeLine1PressurePSI), PressureUnit.InHg, PressureUnit.InHg, true),
         FormatStrings.FormatPressure(P2V(VacResPressureAdjPSIA()), PressureUnit.InHg, PressureUnit.InHg, true),
         string.Empty,
         string.Empty,
         string.Empty,
         string.Empty,
         string.Empty,
         HandbrakePercent > 0 ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
         FrontBrakeHoseConnected ? "I" : "T",
         string.Format("A{0} B{1}", AngleCockAOpen ? "+" : "-", AngleCockBOpen ? "+" : "-"),
     });
 }
コード例 #24
0
ファイル: Conversions.cs プロジェクト: xiaomailong/OpenRails
        public static void FormattedStrings()
        {
            // Note: Only pressure is tested at the moment, mainly because of its complexity.

            Assert.Equal(String.Empty, FormatStrings.FormatPressure(1.2f, PressureUnit.None, PressureUnit.KPa, true));
            Assert.Equal(String.Empty, FormatStrings.FormatPressure(1.2f, PressureUnit.KPa, PressureUnit.None, true));

            Assert.Equal("1 kPa", FormatStrings.FormatPressure(1.2f, PressureUnit.KPa, PressureUnit.KPa, true));
            Assert.Equal("1 kPa", FormatStrings.FormatPressure(KPa.ToBar(1.2f), PressureUnit.Bar, PressureUnit.KPa, true));
            Assert.Equal("1 kPa", FormatStrings.FormatPressure(KPa.ToInHg(1.2f), PressureUnit.InHg, PressureUnit.KPa, true));
            Assert.Equal("1 kPa", FormatStrings.FormatPressure(KPa.ToKgfpCm2(1.2f), PressureUnit.KgfpCm2, PressureUnit.KPa, true));
            Assert.Equal("1 kPa", FormatStrings.FormatPressure(KPa.ToPSI(1.2f), PressureUnit.PSI, PressureUnit.KPa, true));

            var barResult = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:F1} bar", 1.2f);

            Assert.Equal(barResult, FormatStrings.FormatPressure(Bar.ToKPa(1.2f), PressureUnit.KPa, PressureUnit.Bar, true));
            Assert.Equal(barResult, FormatStrings.FormatPressure(1.2f, PressureUnit.Bar, PressureUnit.Bar, true));
            Assert.Equal(barResult, FormatStrings.FormatPressure(Bar.ToInHg(1.2f), PressureUnit.InHg, PressureUnit.Bar, true));
            Assert.Equal(barResult, FormatStrings.FormatPressure(Bar.ToKgfpCm2(1.2f), PressureUnit.KgfpCm2, PressureUnit.Bar, true));
            Assert.Equal(barResult, FormatStrings.FormatPressure(Bar.ToPSI(1.2f), PressureUnit.PSI, PressureUnit.Bar, true));

            var psiResult = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:F0} psi", 1.2f);

            Assert.Equal(psiResult, FormatStrings.FormatPressure(KPa.FromPSI(1.2f), PressureUnit.KPa, PressureUnit.PSI, true));
            Assert.Equal(psiResult, FormatStrings.FormatPressure(KPa.ToBar(KPa.FromPSI(1.2f)), PressureUnit.Bar, PressureUnit.PSI, true));
            Assert.Equal(psiResult, FormatStrings.FormatPressure(KPa.ToInHg(KPa.FromPSI(1.2f)), PressureUnit.InHg, PressureUnit.PSI, true));
            Assert.Equal(psiResult, FormatStrings.FormatPressure(KPa.ToKgfpCm2(KPa.FromPSI(1.2f)), PressureUnit.KgfpCm2, PressureUnit.PSI, true));
            Assert.Equal(psiResult, FormatStrings.FormatPressure(KPa.ToPSI(KPa.FromPSI(1.2f)), PressureUnit.PSI, PressureUnit.PSI, true));

            var inhgResult = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:F0} inHg", 1.2f);

            Assert.Equal(inhgResult, FormatStrings.FormatPressure(KPa.FromInHg(1.2f), PressureUnit.KPa, PressureUnit.InHg, true));
            Assert.Equal(inhgResult, FormatStrings.FormatPressure(KPa.ToBar(KPa.FromInHg(1.2f)), PressureUnit.Bar, PressureUnit.InHg, true));
            Assert.Equal(inhgResult, FormatStrings.FormatPressure(KPa.ToInHg(KPa.FromInHg(1.2f)), PressureUnit.InHg, PressureUnit.InHg, true));
            Assert.Equal(inhgResult, FormatStrings.FormatPressure(KPa.ToKgfpCm2(KPa.FromInHg(1.2f)), PressureUnit.KgfpCm2, PressureUnit.InHg, true));
            Assert.Equal(inhgResult, FormatStrings.FormatPressure(KPa.ToPSI(KPa.FromInHg(1.2f)), PressureUnit.PSI, PressureUnit.InHg, true));

            var kgfResult = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:F1} kgf/cm^2", 1.2f);

            Assert.Equal(kgfResult, FormatStrings.FormatPressure(KPa.FromKgfpCm2(1.2f), PressureUnit.KPa, PressureUnit.KgfpCm2, true));
            Assert.Equal(kgfResult, FormatStrings.FormatPressure(KPa.ToBar(KPa.FromKgfpCm2(1.2f)), PressureUnit.Bar, PressureUnit.KgfpCm2, true));
            Assert.Equal(kgfResult, FormatStrings.FormatPressure(KPa.ToInHg(KPa.FromKgfpCm2(1.2f)), PressureUnit.InHg, PressureUnit.KgfpCm2, true));
            Assert.Equal(kgfResult, FormatStrings.FormatPressure(KPa.ToKgfpCm2(KPa.FromKgfpCm2(1.2f)), PressureUnit.KgfpCm2, PressureUnit.KgfpCm2, true));
            Assert.Equal(kgfResult, FormatStrings.FormatPressure(KPa.ToPSI(KPa.FromKgfpCm2(1.2f)), PressureUnit.PSI, PressureUnit.KgfpCm2, true));
        }
コード例 #25
0
        public void FormattedStrings()
        {
            // Note: Only pressure is tested at the moment, mainly because of its complexity.

            Assert.AreEqual(string.Empty, FormatStrings.FormatPressure(1.2f, Pressure.Unit.None, Pressure.Unit.KPa, true));
            Assert.AreEqual(string.Empty, FormatStrings.FormatPressure(1.2f, Pressure.Unit.KPa, Pressure.Unit.None, true));

            Assert.AreEqual("1 kPa", FormatStrings.FormatPressure(1.2f, Pressure.Unit.KPa, Pressure.Unit.KPa, true));
            Assert.AreEqual("1 kPa", FormatStrings.FormatPressure(Pressure.Standard.ToBar(1.2f), Pressure.Unit.Bar, Pressure.Unit.KPa, true));
            Assert.AreEqual("1 kPa", FormatStrings.FormatPressure(Pressure.Standard.ToInHg(1.2f), Pressure.Unit.InHg, Pressure.Unit.KPa, true));
            Assert.AreEqual("1 kPa", FormatStrings.FormatPressure(Pressure.Standard.ToKgfpCm2(1.2f), Pressure.Unit.KgfpCm2, Pressure.Unit.KPa, true));
            Assert.AreEqual("1 kPa", FormatStrings.FormatPressure(Pressure.Standard.ToPSI(1.2f), Pressure.Unit.PSI, Pressure.Unit.KPa, true));

            var barResult = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:F1} bar", 1.2f);

            Assert.AreEqual(barResult, FormatStrings.FormatPressure(Pressure.Atmospheric.ToKPa(1.2f), Pressure.Unit.KPa, Pressure.Unit.Bar, true));
            Assert.AreEqual(barResult, FormatStrings.FormatPressure(1.2f, Pressure.Unit.Bar, Pressure.Unit.Bar, true));
            Assert.AreEqual(barResult, FormatStrings.FormatPressure(Pressure.Atmospheric.ToInHg(1.2f), Pressure.Unit.InHg, Pressure.Unit.Bar, true));
            Assert.AreEqual(barResult, FormatStrings.FormatPressure(Pressure.Atmospheric.ToKgfpCm2(1.2f), Pressure.Unit.KgfpCm2, Pressure.Unit.Bar, true));
            Assert.AreEqual(barResult, FormatStrings.FormatPressure(Pressure.Atmospheric.ToPSI(1.2f), Pressure.Unit.PSI, Pressure.Unit.Bar, true));

            var psiResult = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:F0} psi", 1.2f);

            Assert.AreEqual(psiResult, FormatStrings.FormatPressure(Pressure.Standard.FromPSI(1.2f), Pressure.Unit.KPa, Pressure.Unit.PSI, true));
            Assert.AreEqual(psiResult, FormatStrings.FormatPressure(Pressure.Standard.ToBar(Pressure.Standard.FromPSI(1.2f)), Pressure.Unit.Bar, Pressure.Unit.PSI, true));
            Assert.AreEqual(psiResult, FormatStrings.FormatPressure(Pressure.Standard.ToInHg(Pressure.Standard.FromPSI(1.2f)), Pressure.Unit.InHg, Pressure.Unit.PSI, true));
            Assert.AreEqual(psiResult, FormatStrings.FormatPressure(Pressure.Standard.ToKgfpCm2(Pressure.Standard.FromPSI(1.2f)), Pressure.Unit.KgfpCm2, Pressure.Unit.PSI, true));
            Assert.AreEqual(psiResult, FormatStrings.FormatPressure(Pressure.Standard.ToPSI(Pressure.Standard.FromPSI(1.2f)), Pressure.Unit.PSI, Pressure.Unit.PSI, true));

            var inhgResult = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:F0} inHg", 1.2f);

            Assert.AreEqual(inhgResult, FormatStrings.FormatPressure(Pressure.Standard.FromInHg(1.2f), Pressure.Unit.KPa, Pressure.Unit.InHg, true));
            Assert.AreEqual(inhgResult, FormatStrings.FormatPressure(Pressure.Standard.ToBar(Pressure.Standard.FromInHg(1.2f)), Pressure.Unit.Bar, Pressure.Unit.InHg, true));
            Assert.AreEqual(inhgResult, FormatStrings.FormatPressure(Pressure.Standard.ToInHg(Pressure.Standard.FromInHg(1.2f)), Pressure.Unit.InHg, Pressure.Unit.InHg, true));
            Assert.AreEqual(inhgResult, FormatStrings.FormatPressure(Pressure.Standard.ToKgfpCm2(Pressure.Standard.FromInHg(1.2f)), Pressure.Unit.KgfpCm2, Pressure.Unit.InHg, true));
            Assert.AreEqual(inhgResult, FormatStrings.FormatPressure(Pressure.Standard.ToPSI(Pressure.Standard.FromInHg(1.2f)), Pressure.Unit.PSI, Pressure.Unit.InHg, true));

            var kgfResult = string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:F1} " + FormatStrings.kgfpcm2, 1.2f);

            Assert.AreEqual(kgfResult, FormatStrings.FormatPressure(Pressure.Standard.FromKgfpCm2(1.2f), Pressure.Unit.KPa, Pressure.Unit.KgfpCm2, true));
            Assert.AreEqual(kgfResult, FormatStrings.FormatPressure(Pressure.Standard.ToBar(Pressure.Standard.FromKgfpCm2(1.2f)), Pressure.Unit.Bar, Pressure.Unit.KgfpCm2, true));
            Assert.AreEqual(kgfResult, FormatStrings.FormatPressure(Pressure.Standard.ToInHg(Pressure.Standard.FromKgfpCm2(1.2f)), Pressure.Unit.InHg, Pressure.Unit.KgfpCm2, true));
            Assert.AreEqual(kgfResult, FormatStrings.FormatPressure(Pressure.Standard.ToKgfpCm2(Pressure.Standard.FromKgfpCm2(1.2f)), Pressure.Unit.KgfpCm2, Pressure.Unit.KgfpCm2, true));
            Assert.AreEqual(kgfResult, FormatStrings.FormatPressure(Pressure.Standard.ToPSI(Pressure.Standard.FromKgfpCm2(1.2f)), Pressure.Unit.PSI, Pressure.Unit.KgfpCm2, true));
        }
コード例 #26
0
 public override string[] GetDebugStatus(Dictionary <BrakeSystemComponent, PressureUnit> units)
 {
     return(new string[] {
         DebugType,
         this is SingleTransferPipe ? string.Empty : FormatStrings.FormatPressure(CylPressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakeCylinder], true),
         FormatStrings.FormatPressure(BrakeLine1PressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakePipe], true),
         this is SingleTransferPipe ? string.Empty : FormatStrings.FormatPressure(AuxResPressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.AuxiliaryReservoir], true),
         (Car as MSTSWagon).EmergencyReservoirPresent ? FormatStrings.FormatPressure(EmergResPressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.EmergencyReservoir], true) : string.Empty,
         TwoPipes ? FormatStrings.FormatPressure(BrakeLine2PressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.MainPipe], true) : string.Empty,
         (Car as MSTSWagon).RetainerPositions == 0 ? string.Empty : RetainerDebugState,
         this is SingleTransferPipe ? string.Empty : Simulator.Catalog.GetString(GetStringAttribute.GetPrettyName(TripleValveState)),
         string.Empty, // Spacer because the state above needs 2 columns.
         (Car as MSTSWagon).HandBrakePresent ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
         FrontBrakeHoseConnected ? "I" : "T",
         string.Format("A{0} B{1}", AngleCockAOpen ? "+" : "-", AngleCockBOpen ? "+" : "-"),
         BleedOffValveOpen ? Simulator.Catalog.GetString("Open") : string.Empty,
     });
 }
コード例 #27
0
        public void Initialize(Dictionary <String, CalculationInfoBase> members, Dictionary <String, CalculationInfoBase> sets, CubeDefInfo cubeInfo, String measureGroupName)
        {
            m_Members = members;
            m_Sets    = sets;
            m_ClearButton.IsEnabled = (Members.Count + Sets.Count) > 0;

            MemberCtrl.InitializeMetadata(cubeInfo);

            if (CubeBrowser.CubeInfo != cubeInfo)
            {
                CubeBrowser.Initialize(cubeInfo);
            }
            CubeBrowser.MeasureGroupName = measureGroupName;

            MemberCtrl.IsEnabled = SetCtrl.IsEnabled = false;

            foreach (CalculationInfoBase info in Members.Values)
            {
                CalcMemberInfo member = info as CalcMemberInfo;
                if (member != null)
                {
                    // Добавляем в список стандартных пользовательские строки форматирования
                    if (!String.IsNullOrEmpty(member.FormatString))
                    {
                        if (!FormatStrings.Contains(member.FormatString))
                        {
                            FormatStrings.Add(member.FormatString);
                        }
                    }
                }
            }

            MemberCtrl.FormatStrings = FormatStrings;
            MembersList.Initialize(members, sets);

            RefreshMetadataTree();

            //CalcMemberInfo memberInfo = MembersList.CurrentObject as CalcMemberInfo;
            //if (memberInfo != null)
            //{
            //    MemberCtrl.Initialize(memberInfo);
            //}
        }
コード例 #28
0
        public override string GetFullStatus(BrakeSystem lastCarBrakeSystem, Dictionary <BrakeSystemComponent, PressureUnit> units)
        {
            string s = string.Format(" EQ {0}", FormatStrings.FormatPressure(Car.Train.BrakeLine1PressurePSIorInHg, PressureUnit.PSI, units[BrakeSystemComponent.EqualizingReservoir], true));

            s += string.Format(
                " BC {0} BP {1}",
                FormatStrings.FormatPressure(CylPressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakeCylinder], true),
                FormatStrings.FormatPressure(BrakeLine1PressurePSI, PressureUnit.PSI, units[BrakeSystemComponent.BrakePipe], true)
                );
            if (lastCarBrakeSystem != null && lastCarBrakeSystem != this)
            {
                s += " EOT " + lastCarBrakeSystem.GetStatus(units);
            }
            if (HandbrakePercent > 0)
            {
                s += string.Format(" Handbrake {0:F0}%", HandbrakePercent);
            }
            return(s);
        }
コード例 #29
0
        // This overides the information for each individual wagon in the extended HUD
        public override string[] GetDebugStatus(Dictionary <BrakeSystemComponent, PressureUnit> units)
        {
            if (!(Car as MSTSWagon).NonAutoBrakePresent)
            {
                // display as a automatic vacuum brake

                return(new string[] {
                    "1V",
                    FormatStrings.FormatPressure(Vac.FromPress(CylPressurePSIA), PressureUnit.InHg, PressureUnit.InHg, true),
                    FormatStrings.FormatPressure(Vac.FromPress(BrakeLine1PressurePSI), PressureUnit.InHg, PressureUnit.InHg, true),
                    FormatStrings.FormatPressure(Vac.FromPress(VacResPressureAdjPSIA()), PressureUnit.InHg, PressureUnit.InHg, true),
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    HandbrakePercent > 0 ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
                    FrontBrakeHoseConnected? "I" : "T",
                    string.Format("A{0} B{1}", AngleCockAOpen? "+" : "-", AngleCockBOpen? "+" : "-"),
                });
            }
            else
            {
                // display as a straight vacuum brake

                return(new string[] {
                    "1VS",
                    FormatStrings.FormatPressure(Vac.FromPress(CylPressurePSIA), PressureUnit.InHg, PressureUnit.InHg, true),
                    FormatStrings.FormatPressure(Vac.FromPress(BrakeLine1PressurePSI), PressureUnit.InHg, PressureUnit.InHg, true),
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    HandbrakePercent > 0 ? string.Format("{0:F0}%", HandbrakePercent) : string.Empty,
                    FrontBrakeHoseConnected? "I" : "T",
                    string.Format("A{0} B{1}", AngleCockAOpen? "+" : "-", AngleCockBOpen? "+" : "-"),
                });
            }
        }
コード例 #30
0
        // draw authority information
        void drawAuthority(SpriteBatch spriteBatch,Point offset,int startObjectArea,int endObjectArea,int zeroPoint,float maxDistance,float distanceFactor,int firstLabelPosition,bool forward,int lastLabelPosition,Train.TrainObjectItem thisItem,ref bool firstLabelShown)
        {
            var displayItem     = new Rectangle(0, 0, 0, 0);
            var displayRequired = false;
            var offsetArray     = new int[0];

            if (thisItem.AuthorityType == Train.END_AUTHORITY.END_OF_AUTHORITY ||
                thisItem.AuthorityType == Train.END_AUTHORITY.END_OF_PATH ||
                thisItem.AuthorityType == Train.END_AUTHORITY.END_OF_TRACK ||
                thisItem.AuthorityType == Train.END_AUTHORITY.RESERVED_SWITCH ||
                thisItem.AuthorityType == Train.END_AUTHORITY.LOOP)
            {
                displayItem     = endAuthoritySprite;
                offsetArray     = endAuthorityPosition;
                displayRequired = true;
            }
            else if (thisItem.AuthorityType == Train.END_AUTHORITY.TRAIN_AHEAD)
            {
                displayItem     = forward ? oppositeTrainForwardSprite : oppositeTrainBackwardSprite;
                offsetArray     = otherTrainPosition;
                displayRequired = true;
            }

            if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor) && displayRequired)
            {
                var itemOffset   = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor);
                var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset;
                spriteBatch.Draw(TrackMonitorImages,new Rectangle(offset.X + offsetArray[0],offset.Y + itemLocation + offsetArray[forward ? 1 : 2],offsetArray[3],offsetArray[4]), displayItem, Color.White);

                if (itemOffset < firstLabelPosition && !firstLabelShown)
                {
                    var labelPoint     = new Point(offset.X + distanceTextOffset, offset.Y + itemLocation + textOffset[forward ? 0 : 1]);
                    var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric);
                    Font.Draw(spriteBatch, labelPoint, distanceString, Color.White);
                    firstLabelShown = true;
                }
            }
        }