コード例 #1
0
 /// <summary>TODO: comment</summary>
 public void SaveChanges(bool fireTranslationChanged)
 {
     if (AnyChanges)
     {
         Lingo.SaveTranslation(_translationType, _moduleName, _translation);
         if (fireTranslationChanged && TranslationChanged != null)
         {
             TranslationChanged(Lingo.LoadTranslation(_translationType, _moduleName, _language));
         }
         _anyChanges = false;
     }
 }
コード例 #2
0
        /// <summary>Main constructor.</summary>
        /// <param name="translationType">The type containing the <see cref="TrString"/> and <see cref="TrStringNum"/> fields to be translated.</param>
        /// <param name="settings">Settings of the <see cref="TranslationWindow"/>.</param>
        /// <param name="icon">Application icon to use.</param>
        /// <param name="programTitle">Title of the program. Used in the title bar.</param>
        /// <param name="moduleName">Used for locating the translation file to be edited under the Translations directory.</param>
        /// <param name="language">The language to be edited.</param>
        public TranslationWindow(Type translationType, Settings settings, ImageSource icon, string programTitle, string moduleName, Language language)
            : base(settings)
        {
            InitializeComponent();

            _translationType = translationType;
            _moduleName      = moduleName;
            _language        = language;

            if (icon != null)
            {
                Icon = icon;
            }
            Title = "Translating " + programTitle;

            CommandBindings.Add(new CommandBinding(TranslationCommands.SaveAndApply, delegate { SaveChanges(true); }));
            CommandBindings.Add(new CommandBinding(TranslationCommands.Close, delegate { Close(); }));
            CommandBindings.Add(new CommandBinding(TranslationCommands.Find, find));
            CommandBindings.Add(new CommandBinding(TranslationCommands.FindNext, findNext));
            CommandBindings.Add(new CommandBinding(TranslationCommands.FindPrevious, findPrevious));
            CommandBindings.Add(new CommandBinding(TranslationCommands.GotoNextOutOfDateString, gotoNextOutOfDateString));
            CommandBindings.Add(new CommandBinding(TranslationCommands.MarkCurrentStringOutOfDate, markCurrentStringOutOfDate));
            CommandBindings.Add(new CommandBinding(TranslationCommands.MarkAllStringsOutOfDate, markAllStringsOutOfDate));
            CommandBindings.Add(new CommandBinding(TranslationCommands.MarkAllStringsUpToDate, markAllStringsUpToDate));
            CommandBindings.Add(new CommandBinding(TranslationCommands.Font, font));

            CommandBindings.Add(new CommandBinding(TranslationCommands.PrevTextBox, delegate { gotoTextBox(up: true); }));
            CommandBindings.Add(new CommandBinding(TranslationCommands.NextTextBox, delegate { gotoTextBox(up: false); }));
            CommandBindings.Add(new CommandBinding(TranslationCommands.PrevGroup, delegate { gotoGroup(up: true); }));
            CommandBindings.Add(new CommandBinding(TranslationCommands.NextGroup, delegate { gotoGroup(up: false); }));

            var original = (TranslationBase)Activator.CreateInstance(translationType);

            _translation = Lingo.LoadTranslation(translationType, moduleName, language);

            foreach (var group in TranslationDialogHelper.GetGroups(translationType, original, _translation))
            {
                _groups.Add(group);
            }

            ctGroups.Items.Clear();
            ctGroups.ItemsSource = _groups;
        }