Ejemplo n.º 1
0
        public MainController()
        {
            //Type t = typeof(MainCatalog_ru_RU);

            View                 = new UIView();
            View.Frame           = new RectangleF(0f, 0f, 320f, 460f);
            View.BackgroundColor = UIColor.White;

            UILabel l = new UILabel();

            l.Frame         = new RectangleF(0f, 0f, 320f, 200f);
            l.Lines         = 0;
            l.LineBreakMode = UILineBreakMode.WordWrap;

            View.AddSubview(l);

            CultureInfo ci = new CultureInfo("ru-RU");

            GettextResourceManager catalog = new GettextResourceManager("MainCatalog", new DifferentNamesSingleFolderPathResolver());

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(catalog.GetString(Text.MyNameIs, ci))
            .AppendLine(catalog.GetString(Text.MyAge, ci))
            .AppendLine(catalog.GetString(Text.ILove, ci));

            for (int i = 0; i < 6; i++)
            {
                sb.AppendLine(string.Format(catalog.GetPluralString(Text.PluralDay, Text.PluralDays, i, ci), i));
            }

            l.Text = sb.ToString();
        }
Ejemplo n.º 2
0
        static void ShowMessages()
        {
            Console.WriteLine("Current culture {0}", System.Threading.Thread.CurrentThread.CurrentUICulture);
            GettextResourceManager catalog = new GettextResourceManager();

            Console.WriteLine(catalog.GetString("Hello, world!"));
            // GetStringFmt is an Gettext.NET extension
            Console.WriteLine(catalog.GetStringFmt("This program is running as process number \"{0}\".",
                                                   Process.GetCurrentProcess().Id));
            Console.WriteLine(String.Format(
                                  catalog.GetPluralString("found {0} similar word", "found {0} similar words", 1),
                                  1));
            // GetPluralStringFmt is an Gettext.NET extension
            Console.WriteLine(catalog.GetPluralStringFmt("found {0} similar word", "found {0} similar words", 2));
            Console.WriteLine(String.Format(
                                  catalog.GetPluralString("found {0} similar word", "found {0} similar words", 5),
                                  5));

            Console.WriteLine("{0} ('computers')", catalog.GetParticularString("Computers", "Text encoding"));
            Console.WriteLine("{0} ('military')", catalog.GetParticularString("Military", "Text encoding"));
            Console.WriteLine("{0} (non cotextual)", catalog.GetString("Text encoding"));

            Console.WriteLine(catalog.GetString(
                                  "Here is an example of how one might continue a very long string\nfor the common case the string represents multi-line output.\n"));
        }
Ejemplo n.º 3
0
 Route(string path)
 {
     if (Directory.Exists(path))
     {
         var trkFilePath = MSTSPath.GetTRKFileName(path);
         try
         {
             var trkFile = new RouteFile(trkFilePath);
             Name        = trkFile.Tr_RouteFile.Name.Trim();
             RouteID     = trkFile.Tr_RouteFile.RouteID;
             Description = trkFile.Tr_RouteFile.Description.Trim();
         }
         catch
         {
             Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileName(path) + ">";
         }
         if (string.IsNullOrEmpty(Name))
         {
             Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(path) + ">";
         }
         if (string.IsNullOrEmpty(Description))
         {
             Description = null;
         }
     }
     else
     {
         Name = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileName(path) + ">";
     }
     Path = path;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor. This will try to have the requested .pat file parsed for its metadata
 /// </summary>
 /// <param name="filePath">The full name of the .pat file</param>
 internal Path(string filePath)
 {
     if (File.Exists(filePath))
     {
         try
         {
             var patFile = new PathFile(filePath);
             this.IsPlayerPath = patFile.IsPlayerPath;
             Name  = patFile.Name.Trim();
             Start = patFile.Start.Trim();
             End   = patFile.End.Trim();
         }
         catch
         {
             Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (string.IsNullOrEmpty(Name))
         {
             Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (string.IsNullOrEmpty(Start))
         {
             Start = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (string.IsNullOrEmpty(End))
         {
             End = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
     }
     else
     {
         Name = Start = End = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
     }
     this.FilePath = filePath;
 }
Ejemplo n.º 5
0
 protected Activity(string filePath, Folder folder, Route route)
 {
     if (filePath == null)
     {
         Name = catalog.GetString("- Explore Route -");
     }
     else if (File.Exists(filePath))
     {
         var showInList = true;
         try
         {
             var actFile = new ActivityFile(filePath);
             var srvFile = new ServiceFile(System.IO.Path.Combine(System.IO.Path.Combine(route.Path, "SERVICES"), actFile.Tr_Activity.Tr_Activity_File.Player_Service_Definition.Name + ".srv"));
             // ITR activities are excluded.
             showInList  = actFile.Tr_Activity.Tr_Activity_Header.Mode != ActivityMode.IntroductoryTrainRide;
             Name        = actFile.Tr_Activity.Tr_Activity_Header.Name.Trim();
             Description = actFile.Tr_Activity.Tr_Activity_Header.Description;
             Briefing    = actFile.Tr_Activity.Tr_Activity_Header.Briefing;
             StartTime   = actFile.Tr_Activity.Tr_Activity_Header.StartTime;
             Season      = actFile.Tr_Activity.Tr_Activity_Header.Season;
             Weather     = actFile.Tr_Activity.Tr_Activity_Header.Weather;
             Difficulty  = actFile.Tr_Activity.Tr_Activity_Header.Difficulty;
             Duration    = actFile.Tr_Activity.Tr_Activity_Header.Duration;
             Consist     = new Consist(System.IO.Path.Combine(System.IO.Path.Combine(System.IO.Path.Combine(folder.Path, "TRAINS"), "CONSISTS"), srvFile.Train_Config + ".con"), folder);
             Path        = new Path(System.IO.Path.Combine(System.IO.Path.Combine(route.Path, "PATHS"), srvFile.PathID + ".pat"));
             if (!Path.IsPlayerPath)
             {
                 // Not nice to throw an error now. Error was originally thrown by new Path(...);
                 throw new InvalidDataException("Not a player path");
             }
         }
         catch
         {
             Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (!showInList)
         {
             throw new InvalidDataException(catalog.GetStringFmt("Activity '{0}' is excluded.", filePath));
         }
         if (string.IsNullOrEmpty(Name))
         {
             Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (string.IsNullOrEmpty(Description))
         {
             Description = null;
         }
         if (string.IsNullOrEmpty(Briefing))
         {
             Briefing = null;
         }
     }
     else
     {
         Name = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
     }
     FilePath = filePath;
 }
Ejemplo n.º 6
0
Archivo: hello.cs Proyecto: coypoop/drm
    public static void Main(String[] args)
    {
        GettextResourceManager catalog =
            new GettextResourceManager("hello-csharp");

        Console.WriteLine(catalog.GetString("Hello, world!"));
        Console.WriteLine(
            String.Format(
                catalog.GetString("This program is running as process number {0}."),
                Process.GetCurrentProcess().Id));
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Routine to localize (make languague-dependent) a WPF/framework element, like a menu.
        /// </summary>
        /// <param name="element">The element that is checked for localizable parameters</param>
        public static void Localize(System.Windows.FrameworkElement element)
        {
            foreach (var child in System.Windows.LogicalTreeHelper.GetChildren(element))
            {
                System.Windows.FrameworkElement childAsElement = child as System.Windows.FrameworkElement;
                if (childAsElement != null)
                {
                    Localize(childAsElement);
                }
            }

            var          objType = element.GetType();
            PropertyInfo property;

            string[] propertyTags = { "Content", "Header", "Text", "Title", "ToolTip" };

            foreach (var tag in propertyTags)
            {
                property = objType.GetProperty(tag);
                if (property != null && property.CanRead && property.CanWrite && property.GetValue(element, null) is String)
                {
                    property.SetValue(element, catalog.GetString(property.GetValue(element, null) as string), null);
                }
            }
        }
Ejemplo n.º 8
0
        private void SetTexts()
        {
            GettextResourceManager catalog = new GettextResourceManager(PathResolver.Default);

            // If satellite assemblies have another base name use GettextResourceManager("Examples.HelloForms.Messages") constructor
            // If you call from another assembly, use GettextResourceManager(anotherAssembly) constructor
            Localizer.Localize(this, catalog, store);
            // We need pass 'store' argument only to be able revert original text and switch languages on fly
            // Common use case doesn't required it: Localizer.Localize(this, catalog);

            // Manually formatted strings
            label2.Text = catalog.GetStringFmt("This program is running as process number \"{0}\".",
                                               System.Diagnostics.Process.GetCurrentProcess().Id);
            label3.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 1),
                1);
            label4.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 2),
                2);
            label5.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 5),
                5);
            label6.Text = String.Format("{0} ('computers')", catalog.GetParticularString("Computers", "Text encoding"));
            label7.Text = String.Format("{0} ('military')", catalog.GetParticularString("Military", "Text encoding"));
            label8.Text = String.Format("{0} (non contextual)", catalog.GetString("Text encoding"));
        }
 /// <inheritdoc />
 /// <seealso cref="GettextResourceManager.GetString(string)"/>
 public string GetString(string text)
 {
     if (text == null)
     {
         throw new ArgumentNullException(nameof(text));
     }
     return(resourceManager.GetString(text));
 }
        private void LocalizeProperty(GettextResourceManager catalog, string propertyName)
        {
            string text = GetPropertyValue(propertyName);

            if (text != null)
            {
                SetPropertyValue(propertyName, catalog.GetString(text));
            }
        }
Ejemplo n.º 11
0
        public ResumeForm(UserSettings settings, Route route, MainForm.UserAction mainFormAction, Activity activity, TimetableInfo timetable,
                          MainForm parentForm)
        {
            MainForm       = parentForm;
            SelectedAction = mainFormAction;
            Multiplayer    = SelectedAction == MainForm.UserAction.MultiplayerClient || SelectedAction == MainForm.UserAction.MultiplayerServer;
            InitializeComponent();  // Needed so that setting StartPosition = CenterParent is respected.

            Localizer.Localize(this, catalog);

            // Windows 2000 and XP should use 8.25pt Tahoma, while Windows
            // Vista and later should use 9pt "Segoe UI". We'll use the
            // Message Box font to allow for user-customizations, though.
            Font = SystemFonts.MessageBoxFont;

            Settings  = settings;
            Route     = route;
            Activity  = activity;
            Timetable = timetable;

            checkBoxReplayPauseBeforeEnd.Checked = Settings.ReplayPauseBeforeEnd;
            numericReplayPauseBeforeEnd.Value    = Settings.ReplayPauseBeforeEndS;

            gridSaves_SelectionChanged(null, null);

            if (SelectedAction == MainForm.UserAction.SinglePlayerTimetableGame)
            {
                Text = String.Format("{0} - {1} - {2}", Text, route.Name, Path.GetFileNameWithoutExtension(Timetable.fileName));
                pathNameDataGridViewTextBoxColumn.Visible = true;
            }
            else
            {
                Text = String.Format("{0} - {1} - {2}", Text, route.Name, activity.FilePath != null ? activity.Name :
                                     activity.Name == "+ " + catalog.GetString("Explore in Activity Mode") + " +" ? catalog.GetString("Explore in Activity Mode") : catalog.GetString("Explore Route"));
                pathNameDataGridViewTextBoxColumn.Visible = activity.FilePath == null;
            }

            if (Multiplayer)
            {
                Text += " - Multiplayer ";
            }

            LoadSaves();
        }
Ejemplo n.º 12
0
        internal Locomotive(string filePath)
        {
            if (filePath == null)
            {
                Name = catalog.GetString("- Any Locomotive -");
            }
            else if (File.Exists(filePath))
            {
                EngineFile engFile;
                try
                {
                    engFile = new EngineFile(filePath);
                }
                catch
                {
                    Name    = $"<{catalog.GetString("load error:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";
                    engFile = null;
                }
                if (engFile != null)
                {
                    bool showInList = !string.IsNullOrEmpty(engFile.CabViewFile);
                    if (!showInList)
                    {
                        throw new InvalidDataException(catalog.GetStringFmt("Locomotive '{0}' is excluded.", filePath));
                    }

                    string name = (engFile.Name ?? "").Trim();
                    Name = name != "" ? name : $"<{catalog.GetString("unnamed:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";

                    string description = (engFile.Description ?? "").Trim();
                    if (description != "")
                    {
                        Description = description;
                    }
                }
            }
            else
            {
                Name = $"<{catalog.GetString("missing:")} {System.IO.Path.GetFileNameWithoutExtension(filePath)}>";
            }
            FilePath = filePath;
        }
Ejemplo n.º 13
0
 protected TimetableInfo(string filePath)
 {
     if (File.Exists(filePath))
     {
         try
         {
             ORTTList.Add(new TimetableFileLite(filePath));
             Description = String.Copy(ORTTList[0].Description);
             fileName    = String.Copy(filePath);
         }
         catch
         {
             Description = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
     }
     else
     {
         Description = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
     }
 }
Ejemplo n.º 14
0
 internal Consist(string filePath, Folder folder)
 {
     if (File.Exists(filePath))
     {
         try
         {
             var conFile = new ConsistFile(filePath);
             Name       = conFile.Name.Trim();
             Locomotive = GetLocomotive(conFile, folder);
         }
         catch
         {
             Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (Locomotive == null)
         {
             throw new InvalidDataException("Consist '" + filePath + "' is excluded.");
         }
         if (string.IsNullOrEmpty(Name))
         {
             Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
     }
     else
     {
         Name = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
     }
     FilePath = filePath;
 }
Ejemplo n.º 15
0
 internal Locomotive(string filePath)
 {
     if (filePath == null)
     {
         Name = catalog.GetString("- Any Locomotive -");
     }
     else if (File.Exists(filePath))
     {
         var showInList = true;
         try
         {
             var engFile = new EngineFile(filePath);
             showInList  = !string.IsNullOrEmpty(engFile.CabViewFile);
             Name        = engFile.Name.Trim();
             Description = engFile.Description.Trim();
         }
         catch
         {
             Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (!showInList)
         {
             throw new InvalidDataException(catalog.GetStringFmt("Locomotive '{0}' is excluded.", filePath));
         }
         if (string.IsNullOrEmpty(Name))
         {
             Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (string.IsNullOrEmpty(Description))
         {
             Description = null;
         }
     }
     else
     {
         Name = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
     }
     FilePath = filePath;
 }
Ejemplo n.º 16
0
        public string CheckForErrors(byte[] buttonSettings)
        {
            StringBuilder errors = new StringBuilder();

            var duplicates = buttonSettings.Where(button => button < 255).
                             Select((value, index) => new { Index = index, Button = value }).
                             GroupBy(g => g.Button).
                             Where(g => g.Count() > 1).
                             OrderBy(g => g.Key);

            foreach (var duplicate in duplicates)
            {
                errors.Append(catalog.GetStringFmt("Button {0} is assigned to \r\n\t", duplicate.Key));
                foreach (var buttonMapping in duplicate)
                {
                    errors.Append($"\"{catalog.GetString(((UserCommand)buttonMapping.Index).GetDescription())}\" and ");
                }
                errors.Remove(errors.Length - 5, 5);
                errors.AppendLine();
            }
            return(errors.ToString());
        }
Ejemplo n.º 17
0
        public static string gettext(string message)
        {
            if (manager == null)
            {
                return(message);
            }

            string text = manager.GetString(message);

            if (text == null)
            {
                return(message);
            }
            else
            {
                return(text);
            }
        }
Ejemplo n.º 18
0
        public ImportExportSaveForm(ResumeForm.Save save)
        {
            InitializeComponent();  // Needed so that setting StartPosition = CenterParent is respected.

            Localizer.Localize(this, catalog);

            // Windows 2000 and XP should use 8.25pt Tahoma, while Windows
            // Vista and later should use 9pt "Segoe UI". We'll use the
            // Message Box font to allow for user-customizations, though.
            Font = SystemFonts.MessageBoxFont;

            Save = save;
            if (!Directory.Exists(UserSettings.SavePackFolder))
            {
                Directory.CreateDirectory(UserSettings.SavePackFolder);
            }
            UpdateFileList(null);
            bExport.Enabled      = !(Save == null);
            ofdImportSave.Filter = Application.ProductName + catalog.GetString("Save Packs") + " (*." + SavePackFileExtension + ")|*." + SavePackFileExtension + "|" + catalog.GetString("All files") + " (*.*)|*";
        }
Ejemplo n.º 19
0
        public void Localize(GettextResourceManager catalog)
        {
            LocalizeProperty(catalog, "Text");
            LocalizeProperty(catalog, "HeaderText");
            LocalizeProperty(catalog, "ToolTipText");

            if (Source is Control)
            {
                foreach(ToolTip toolTip in ToolTips)
                {
                    string hint = toolTip.GetToolTip(Source as Control);
                    if (hint != null)
                    {
                        StoreIfOriginal("FromToolTipText", hint);
                        string translatedHint = catalog.GetString(hint);
                        if (translatedHint != toolTip.GetToolTip(Source as Control))
                            toolTip.SetToolTip((Source as Control), translatedHint);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// get the translated string
        /// </summary>
        public static string GetString(string AEnglishMessage)
        {
            if (catalog == null)
            {
                return(AEnglishMessage);
            }

            string result = AEnglishMessage;

            try
            {
                result = catalog.GetString(AEnglishMessage);
            }
            catch (Exception e)
            {
                TLogging.Log("GetText: Catalog.GetString: problem for getting text for \"" + AEnglishMessage + "\"");
                TLogging.Log(e.ToString());
            }

            return(result);
        }
        public void Localize(GettextResourceManager catalog)
        {
            LocalizeProperty(catalog, "Text");
            LocalizeProperty(catalog, "HeaderText");
            LocalizeProperty(catalog, "ToolTipText");

            if (Source is Control)
            {
                foreach (ToolTip toolTip in ToolTips)
                {
                    string hint = toolTip.GetToolTip(Source as Control);
                    if (hint != null)
                    {
                        StoreIfOriginal("FromToolTipText", hint);
                        string translatedHint = catalog.GetString(hint);
                        if (translatedHint != toolTip.GetToolTip(Source as Control))
                        {
                            toolTip.SetToolTip((Source as Control), translatedHint);
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public OptionsForm(UserSettings settings, UpdateManager updateManager, bool initialContentSetup)
        {
            InitializeComponent();

            Localizer.Localize(this, catalog);

            Settings      = settings;
            UpdateManager = updateManager;

            // Collect all the available language codes by searching for
            // localisation files, but always include English (base language).
            var languageCodes = new List <string> {
                "en"
            };

            foreach (var path in Directory.GetDirectories(Path.GetDirectoryName(Application.ExecutablePath)))
            {
                if (Directory.GetFiles(path, "*.Messages.resources.dll").Length > 0)
                {
                    languageCodes.Add(Path.GetFileName(path));
                }
            }

            // Turn the list of codes in to a list of code + name pairs for
            // displaying in the dropdown list.
            comboLanguage.DataSource =
                new[] { new ComboBoxMember {
                            Code = "", Name = "System"
                        } }
            .Union(languageCodes
                   .SelectMany(lc =>
            {
                try
                {
                    return(new[] { new ComboBoxMember {
                                       Code = lc, Name = CultureInfo.GetCultureInfo(lc).NativeName
                                   } });
                }
                catch (ArgumentException)
                {
                    return(new ComboBoxMember[0]);
                }
            })
                   .OrderBy(l => l.Name)
                   )
            .ToList();
            comboLanguage.DisplayMember = "Name";
            comboLanguage.ValueMember   = "Code";
            comboLanguage.SelectedValue = Settings.Language;
            if (comboLanguage.SelectedValue == null)
            {
                comboLanguage.SelectedIndex = 0;
            }

            comboBoxOtherUnits.DataSource = new[] {
                new ComboBoxMember {
                    Code = "Route", Name = catalog.GetString("Route")
                },
                new ComboBoxMember {
                    Code = "Automatic", Name = catalog.GetString("Player's location")
                },
                new ComboBoxMember {
                    Code = "Metric", Name = catalog.GetString("Metric")
                },
                new ComboBoxMember {
                    Code = "US", Name = catalog.GetString("Imperial US")
                },
                new ComboBoxMember {
                    Code = "UK", Name = catalog.GetString("Imperial UK")
                },
            }.ToList();
            comboBoxOtherUnits.DisplayMember = "Name";
            comboBoxOtherUnits.ValueMember   = "Code";
            comboBoxOtherUnits.SelectedValue = Settings.Units;

            comboPressureUnit.DataSource = new[] {
                new ComboBoxMember {
                    Code = "Automatic", Name = catalog.GetString("Automatic")
                },
                new ComboBoxMember {
                    Code = "bar", Name = catalog.GetString("bar")
                },
                new ComboBoxMember {
                    Code = "PSI", Name = catalog.GetString("psi")
                },
                new ComboBoxMember {
                    Code = "inHg", Name = catalog.GetString("inHg")
                },
                new ComboBoxMember {
                    Code = "kgf/cm^2", Name = catalog.GetString("kgf/cm²")
                },
            }.ToList();
            comboPressureUnit.DisplayMember = "Name";
            comboPressureUnit.ValueMember   = "Code";
            comboPressureUnit.SelectedValue = Settings.PressureUnit;

            // Windows 2000 and XP should use 8.25pt Tahoma, while Windows
            // Vista and later should use 9pt "Segoe UI". We'll use the
            // Message Box font to allow for user-customizations, though.
            Font = SystemFonts.MessageBoxFont;
            AdhesionLevelValue.Font = new Font(Font, FontStyle.Bold);

            // Fix up the TrackBars on TabPanels to match the current theme.
            if (!Application.RenderWithVisualStyles)
            {
                trackAdhesionFactor.BackColor       = BackColor;
                trackAdhesionFactorChange.BackColor = BackColor;
                trackDayAmbientLight.BackColor      = BackColor;
                trackLODBias.BackColor = BackColor;
            }

            // General tab
            checkAlerter.Checked               = Settings.Alerter;
            checkAlerterExternal.Enabled       = Settings.Alerter;
            checkAlerterExternal.Checked       = Settings.Alerter && !Settings.AlerterDisableExternal;
            checkSpeedControl.Checked          = Settings.SpeedControl;
            checkConfirmations.Checked         = !Settings.SuppressConfirmations;
            checkViewDispatcher.Checked        = Settings.ViewDispatcher;
            checkUseLargeAddressAware.Checked  = Settings.UseLargeAddressAware;
            checkRetainers.Checked             = Settings.RetainersOnAllCars;
            checkGraduatedRelease.Checked      = Settings.GraduatedRelease;
            numericBrakePipeChargingRate.Value = Settings.BrakePipeChargingRate;
            comboLanguage.Text             = Settings.Language;
            comboPressureUnit.Text         = Settings.PressureUnit;
            comboBoxOtherUnits.Text        = settings.Units;
            checkDisableTCSScripts.Checked = Settings.DisableTCSScripts;


            // Audio tab
            checkMSTSBINSound.Checked                 = Settings.MSTSBINSound;
            numericSoundVolumePercent.Value           = Settings.SoundVolumePercent;
            numericSoundDetailLevel.Value             = Settings.SoundDetailLevel;
            numericExternalSoundPassThruPercent.Value = Settings.ExternalSoundPassThruPercent;

            // Video tab
            checkDynamicShadows.Checked       = Settings.DynamicShadows;
            checkShadowAllShapes.Checked      = Settings.ShadowAllShapes;
            checkFastFullScreenAltTab.Checked = Settings.FastFullScreenAltTab;
            checkWindowGlass.Checked          = Settings.WindowGlass;
            checkModelInstancing.Checked      = Settings.ModelInstancing;
            checkWire.Checked             = Settings.Wire;
            checkVerticalSync.Checked     = Settings.VerticalSync;
            numericCab2DStretch.Value     = Settings.Cab2DStretch;
            numericViewingDistance.Value  = Settings.ViewingDistance;
            checkDistantMountains.Checked = Settings.DistantMountains;
            labelDistantMountainsViewingDistance.Enabled   = checkDistantMountains.Checked;
            numericDistantMountainsViewingDistance.Enabled = checkDistantMountains.Checked;
            numericDistantMountainsViewingDistance.Value   = Settings.DistantMountainsViewingDistance / 1000;
            numericViewingFOV.Value         = Settings.ViewingFOV;
            numericWorldObjectDensity.Value = Settings.WorldObjectDensity;
            comboWindowSize.Text            = Settings.WindowSize;
            trackDayAmbientLight.Value      = Settings.DayAmbientLight;
            trackDayAmbientLight_ValueChanged(null, null);
            checkDoubleWire.Checked = Settings.DoubleWire;

            // Simulation tab
            checkUseAdvancedAdhesion.Checked               = Settings.UseAdvancedAdhesion;
            labelAdhesionMovingAverageFilterSize.Enabled   = checkUseAdvancedAdhesion.Checked;
            numericAdhesionMovingAverageFilterSize.Enabled = checkUseAdvancedAdhesion.Checked;
            numericAdhesionMovingAverageFilterSize.Value   = Settings.AdhesionMovingAverageFilterSize;
            checkBreakCouplers.Checked                = Settings.BreakCouplers;
            checkCurveResistanceDependent.Checked     = Settings.CurveResistanceDependent;
            checkCurveSpeedDependent.Checked          = Settings.CurveSpeedDependent;
            checkTunnelResistanceDependent.Checked    = Settings.TunnelResistanceDependent;
            checkWindResistanceDependent.Checked      = Settings.WindResistanceDependent;
            checkOverrideNonElectrifiedRoutes.Checked = Settings.OverrideNonElectrifiedRoutes;
            checkHotStart.Checked  = Settings.HotStart;
            checkAutopilot.Checked = Settings.Autopilot;
            checkForcedRedAtStationStops.Checked = !Settings.NoForcedRedAtStationStops;
            checkExtendedAIShunting.Checked      = Settings.ExtendedAIShunting;
            checkDoorsAITrains.Checked           = Settings.OpenDoorsInAITrains;

            // Keyboard tab
            InitializeKeyboardSettings();

            // DataLogger tab
            var dictionaryDataLoggerSeparator = new Dictionary <string, string>();

            dictionaryDataLoggerSeparator.Add("comma", catalog.GetString("comma"));
            dictionaryDataLoggerSeparator.Add("semicolon", catalog.GetString("semicolon"));
            dictionaryDataLoggerSeparator.Add("tab", catalog.GetString("tab"));
            dictionaryDataLoggerSeparator.Add("space", catalog.GetString("space"));
            comboDataLoggerSeparator.DataSource    = new BindingSource(dictionaryDataLoggerSeparator, null);
            comboDataLoggerSeparator.DisplayMember = "Value";
            comboDataLoggerSeparator.ValueMember   = "Key";
            comboDataLoggerSeparator.Text          = catalog.GetString(Settings.DataLoggerSeparator);
            var dictionaryDataLogSpeedUnits = new Dictionary <string, string>();

            dictionaryDataLogSpeedUnits.Add("route", catalog.GetString("route"));
            dictionaryDataLogSpeedUnits.Add("mps", catalog.GetString("m/s"));
            dictionaryDataLogSpeedUnits.Add("kmph", catalog.GetString("km/h"));
            dictionaryDataLogSpeedUnits.Add("mph", catalog.GetString("mph"));
            comboDataLogSpeedUnits.DataSource    = new BindingSource(dictionaryDataLogSpeedUnits, null);
            comboDataLogSpeedUnits.DisplayMember = "Value";
            comboDataLogSpeedUnits.ValueMember   = "Key";
            comboDataLogSpeedUnits.Text          = catalog.GetString(Settings.DataLogSpeedUnits);
            checkDataLogger.Checked              = Settings.DataLogger;
            checkDataLogPerformance.Checked      = Settings.DataLogPerformance;
            checkDataLogPhysics.Checked          = Settings.DataLogPhysics;
            checkDataLogMisc.Checked             = Settings.DataLogMisc;
            checkDataLogSteamPerformance.Checked = Settings.DataLogSteamPerformance;

            // Evaluation tab
            checkDataLogTrainSpeed.Checked     = Settings.DataLogTrainSpeed;
            labelDataLogTSInterval.Enabled     = checkDataLogTrainSpeed.Checked;
            numericDataLogTSInterval.Enabled   = checkDataLogTrainSpeed.Checked;
            checkListDataLogTSContents.Enabled = checkDataLogTrainSpeed.Checked;
            numericDataLogTSInterval.Value     = Settings.DataLogTSInterval;
            checkListDataLogTSContents.Items.AddRange(new object[] {
                catalog.GetString("Time"),
                catalog.GetString("Train Speed"),
                catalog.GetString("Max. Speed"),
                catalog.GetString("Signal State"),
                catalog.GetString("Track Elevation"),
                catalog.GetString("Direction"),
                catalog.GetString("Control Mode"),
                catalog.GetString("Distance Travelled"),
                catalog.GetString("Throttle %"),
                catalog.GetString("Brake Cyl Press"),
                catalog.GetString("Dyn Brake %"),
                catalog.GetString("Gear Setting")
            });
            for (var i = 0; i < checkListDataLogTSContents.Items.Count; i++)
            {
                checkListDataLogTSContents.SetItemChecked(i, Settings.DataLogTSContents[i] == 1);
            }
            checkDataLogStationStops.Checked = Settings.DataLogStationStops;

            // Content tab
            bindingSourceContent.DataSource = (from folder in Settings.Folders.Folders
                                               orderby folder.Key
                                               select new ContentFolder()
            {
                Name = folder.Key, Path = folder.Value
            }).ToList();
            if (initialContentSetup)
            {
                tabOptions.SelectedTab      = tabPageContent;
                buttonContentBrowse.Enabled = false; // Initial state because browsing a null path leads to an exception
                try
                {
                    bindingSourceContent.Add(new ContentFolder()
                    {
                        Name = "Train Simulator", Path = MSTSPath.Base()
                    });
                }
                catch { }
            }

            // Updater tab
            var updateChannelNames = new Dictionary <string, string> {
                { "stable", catalog.GetString("Stable (recommended)") },
                { "testing", catalog.GetString("Testing") },
                { "unstable", catalog.GetString("Unstable") },
                { "", catalog.GetString("None") },
            };
            var updateChannelDescriptions = new Dictionary <string, string> {
                { "stable", catalog.GetString("Infrequent updates to official, hand-picked versions. Recommended for most users.") },
                { "testing", catalog.GetString("Weekly updates which may contain noticable defects. For project supporters.") },
                { "unstable", catalog.GetString("Daily updates which may contain serious defects. For developers only.") },
                { "", catalog.GetString("No updates.") },
            };
            var spacing = labelUpdateChannel.Margin.Size;
            var indent  = 20;
            var top     = labelUpdateChannel.Bottom + spacing.Height;

            foreach (var channel in UpdateManager.GetChannels())
            {
                var radio = new RadioButton()
                {
                    Text     = updateChannelNames[channel.ToLowerInvariant()],
                    Margin   = labelUpdateChannel.Margin,
                    Left     = spacing.Width,
                    Top      = top,
                    Checked  = updateManager.ChannelName.Equals(channel, StringComparison.InvariantCultureIgnoreCase),
                    AutoSize = true,
                    Tag      = channel,
                };
                tabPageUpdater.Controls.Add(radio);
                top += radio.Height + spacing.Height;
                var label = new Label()
                {
                    Text     = updateChannelDescriptions[channel.ToLowerInvariant()],
                    Margin   = labelUpdateChannel.Margin,
                    Left     = spacing.Width + indent,
                    Top      = top,
                    Width    = tabPageUpdater.ClientSize.Width - indent - spacing.Width * 2,
                    AutoSize = true,
                };
                tabPageUpdater.Controls.Add(label);
                top += label.Height + spacing.Height;
            }

            // Experimental tab
            numericUseSuperElevation.Value        = Settings.UseSuperElevation;
            numericSuperElevationMinLen.Value     = Settings.SuperElevationMinLen;
            numericSuperElevationGauge.Value      = Settings.SuperElevationGauge;
            checkPerformanceTuner.Checked         = Settings.PerformanceTuner;
            labelPerformanceTunerTarget.Enabled   = checkPerformanceTuner.Checked;
            numericPerformanceTunerTarget.Enabled = checkPerformanceTuner.Checked;
            numericPerformanceTunerTarget.Value   = Settings.PerformanceTunerTarget;
            trackLODBias.Value = Settings.LODBias;
            trackLODBias_ValueChanged(null, null);
            checkConditionalLoadOfNightTextures.Checked = Settings.ConditionalLoadOfDayOrNightTextures;
            checkSignalLightGlow.Checked         = Settings.SignalLightGlow;
            checkCircularSpeedGauge.Checked      = Settings.CircularSpeedGauge;
            checkLODViewingExtention.Checked     = Settings.LODViewingExtention;
            checkPreferDDSTexture.Checked        = Settings.PreferDDSTexture;
            checkUseLocationPassingPaths.Checked = Settings.UseLocationPassingPaths;
            checkUseMSTSEnv.Checked            = Settings.UseMSTSEnv;
            trackAdhesionFactor.Value          = Settings.AdhesionFactor;
            checkAdhesionPropToWeather.Checked = Settings.AdhesionProportionalToWeather;
            trackAdhesionFactorChange.Value    = Settings.AdhesionFactorChange;
            trackAdhesionFactor_ValueChanged(null, null);
            checkShapeWarnings.Checked   = !Settings.SuppressShapeWarnings;
            precipitationBoxHeight.Value = Settings.PrecipitationBoxHeight;
            precipitationBoxWidth.Value  = Settings.PrecipitationBoxWidth;
            precipitationBoxLength.Value = Settings.PrecipitationBoxLength;
            checkCorrectQuestionableBrakingParams.Checked = Settings.CorrectQuestionableBrakingParams;
            numericActRandomizationLevel.Value            = Settings.ActRandomizationLevel;
            numericActWeatherRandomizationLevel.Value     = Settings.ActWeatherRandomizationLevel;
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Wrapper for Cat.GetString for faster code entry
 /// </summary>
 /// <param name='msg'>
 /// Message.
 /// </param>
 public string GetString(string msg)
 {
     return(Cat.GetString(msg));
 }
Ejemplo n.º 24
0
 private void LocalizeProperty(GettextResourceManager catalog, string propertyName)
 {
     string text = GetPropertyValue(propertyName);
     if (text != null)
         SetPropertyValue(propertyName, catalog.GetString(text));
 }
Ejemplo n.º 25
0
 public static void Main(string[] args)
 {
     //This string is modified adding the method GetString() from the catalog variable
     System.Console.WriteLine(_catalog.GetString("Hello world!"));
 }
Ejemplo n.º 26
0
        private void SetTexts()
        {
            GettextResourceManager catalog = new GettextResourceManager(PathResolver.Default);
            // If satellite assemblies have another base name use GettextResourceManager("Examples.HelloForms.Messages") constructor
            // If you call from another assembly, use GettextResourceManager(anotherAssembly) constructor
            Localizer.Localize(this, catalog, store);
            // We need pass 'store' argument only to be able revert original text and switch languages on fly
            // Common use case doesn't required it: Localizer.Localize(this, catalog);

            // Manually formatted strings
            label2.Text = catalog.GetStringFmt("This program is running as process number \"{0}\".",
                                               System.Diagnostics.Process.GetCurrentProcess().Id);
            label3.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 1),
                1);
            label4.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 2),
                2);
            label5.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 5),
                5);
            label6.Text = String.Format("{0} ('computers')",  catalog.GetParticularString("Computers", "Text encoding"));
            label7.Text = String.Format("{0} ('military')",  catalog.GetParticularString("Military", "Text encoding"));
            label8.Text = String.Format("{0} (non contextual)",  catalog.GetString("Text encoding"));
        }
Ejemplo n.º 27
0
        public string CheckForErrors()
        {
            // Make sure all modifiable input commands are synchronized first.
            foreach (var command in Commands)
            {
                (command as UserCommandModifiableKeyInput)?.SynchronizeCombine();
            }

            StringBuilder errors = new StringBuilder();

            // Check for commands which both require a particular modifier, and ignore it.
            foreach (var command in EnumExtension.GetValues <UserCommand>())
            {
                if (Commands[(int)command] is UserCommandModifiableKeyInput modInput)
                {
                    if (modInput.Shift && modInput.IgnoreShift)
                    {
                        errors.AppendLine(settingsCatalog.GetStringFmt("{0} requires and is modified by Shift", commonCatalog.GetString(command.GetDescription())));
                    }
                    if (modInput.Control && modInput.IgnoreControl)
                    {
                        errors.AppendLine(settingsCatalog.GetStringFmt("{0} requires and is modified by Control", commonCatalog.GetString(command.GetDescription())));
                    }
                    if (modInput.Alt && modInput.IgnoreAlt)
                    {
                        errors.AppendLine(settingsCatalog.GetStringFmt("{0} requires and is modified by Alt", commonCatalog.GetString(command.GetDescription())));
                    }
                }
            }

            // Check for two commands assigned to the same key
            UserCommand firstCommand = EnumExtension.GetValues <UserCommand>().Min();
            UserCommand lastCommand  = EnumExtension.GetValues <UserCommand>().Max();

            for (UserCommand command1 = firstCommand; command1 <= lastCommand; command1++)
            {
                var input1 = Commands[(int)command1];

                // Modifier inputs don't matter as they don't represent any key.
                if (input1 is UserCommandModifierInput)
                {
                    continue;
                }

                for (var command2 = command1 + 1; command2 <= lastCommand; command2++)
                {
                    var input2 = Commands[(int)command2];

                    // Modifier inputs don't matter as they don't represent any key.
                    if (input2 is UserCommandModifierInput)
                    {
                        continue;
                    }

                    // Ignore problems when both inputs are on defaults. (This protects the user somewhat but leaves developers in the dark.)
                    //if (input1.PersistentDescriptor == InputSettings.DefaultCommands[(int)command1].PersistentDescriptor && input2.PersistentDescriptor == InputSettings.DefaultCommands[(int)command2].PersistentDescriptor)
                    if (input1.UniqueDescriptor == DefaultCommands[(int)command1].UniqueDescriptor &&
                        input2.UniqueDescriptor == DefaultCommands[(int)command2].UniqueDescriptor)
                    {
                        continue;
                    }

                    var unique1      = input1.GetUniqueInputs();
                    var unique2      = input2.GetUniqueInputs();
                    var sharedUnique = unique1.Where(id => unique2.Contains(id));
                    foreach (var uniqueInput in sharedUnique)
                    {
                        errors.AppendLine(settingsCatalog.GetStringFmt("{0} and {1} both match {2}", commonCatalog.GetString(command1.GetDescription()),
                                                                       commonCatalog.GetString(command2.GetDescription()), KeyboardMap.GetPrettyUniqueInput(uniqueInput)));
                    }
                }
            }

            return(errors.ToString());
        }