Exemplo n.º 1
0
        private List <string> WrappedLines(int width)
        {
            string[]      firstSplit   = Text.Split(new[] { "\r\n", @"\r\n" }, StringSplitOptions.None);
            List <string> wrappedLines = new List <string>();
            string        currentLine  = string.Empty;

            for (int j = 0; j < firstSplit.Length; j++)
            {
                for (int i = 0; i < firstSplit[j].Length; i++)
                {
                    char currentChar = firstSplit[j][i];
                    currentLine += currentChar;
                    if (myFont.MeasureString(currentLine).X > width)
                    {
                        // Exceeded length, back up to last space
                        int moveback = 0;
                        int lastChar = i - 1;
                        while (currentChar != ' ')
                        {
                            moveback++;
                            i--;
                            if (i == 0)
                            {
                                //No spaces found, so just drop back one char
                                i        = lastChar;
                                moveback = 1;
                                break;
                            }
                            currentChar = firstSplit[j][i];
                        }
                        string lineToAdd = currentLine.Substring(0, currentLine.Length - moveback);
                        wrappedLines.Add(lineToAdd.TrimStart());
                        currentLine = string.Empty;
                    }
                }
                wrappedLines.Add(currentLine.TrimStart());
                currentLine = string.Empty;
            }

            if (currentLine.Length > 0)
            {
                wrappedLines.Add(currentLine.TrimStart());
            }
            return(wrappedLines);
        }
Exemplo n.º 2
0
            internal Lamp(LampType Type)
            {
                this.Type = Type;
                switch (Type)
                {
                case LampType.None:
                    this.Text = null;
                    break;

                case LampType.Ats:
                    this.Text = Translations.GetInterfaceString("lamps_ats");
                    break;

                case LampType.AtsOperation:
                    this.Text = Translations.GetInterfaceString("lamps_atsoperation");
                    break;

                case LampType.AtsPPower:
                    this.Text = Translations.GetInterfaceString("lamps_atsppower");
                    break;

                case LampType.AtsPPattern:
                    this.Text = Translations.GetInterfaceString("lamps_atsppattern");
                    break;

                case LampType.AtsPBrakeOverride:
                    this.Text = Translations.GetInterfaceString("lamps_atspbrakeoverride");
                    break;

                case LampType.AtsPBrakeOperation:
                    this.Text = Translations.GetInterfaceString("lamps_atspbrakeoperation");
                    break;

                case LampType.AtsP:
                    this.Text = Translations.GetInterfaceString("lamps_atsp");
                    break;

                case LampType.AtsPFailure:
                    this.Text = Translations.GetInterfaceString("lamps_atspfailure");
                    break;

                case LampType.Atc:
                    this.Text = Translations.GetInterfaceString("lamps_atc");
                    break;

                case LampType.AtcPower:
                    this.Text = Translations.GetInterfaceString("lamps_atcpower");
                    break;

                case LampType.AtcUse:
                    this.Text = Translations.GetInterfaceString("lamps_atcuse");
                    break;

                case LampType.AtcEmergency:
                    this.Text = Translations.GetInterfaceString("lamps_atcemergency");
                    break;

                case LampType.Eb:
                    this.Text = Translations.GetInterfaceString("lamps_eb");
                    break;

                case LampType.ConstSpeed:
                    this.Text = Translations.GetInterfaceString("lamps_constspeed");
                    break;

                default:
                    this.Text = "TEXT";
                    break;
                }
                OpenGlFont font = Fonts.NormalFont;

                for (int i = 0; i < HUD.CurrentHudElements.Length; i++)
                {
                    if (HUD.CurrentHudElements[i].Subject.Equals("ats", StringComparison.OrdinalIgnoreCase))
                    {
                        font = HUD.CurrentHudElements[i].Font;
                        break;
                    }
                }
                System.Drawing.Size size = font.MeasureString(this.Text);
                this.Width  = size.Width;
                this.Height = size.Height;
            }