Beispiel #1
0
        public Solution(string fileName)
        {
            if (fileName == null)
                throw new ArgumentNullException("fileName");

            RootNode = new ProjectItem(fileName, false);
            RootNode.SetProperty<Solution>(this);

            Dictionary = new TranslationDictionary();

            LoadSolution();
            Program.MainForm.LanguageChanged += MainForm_LanguageChanged;
        }
        private void AddNode(FileNode node, TranslationDictionary dictionary)
        {
            var editor = new ResourceNodeControl(node, dictionary)
            {
                Dock = DockStyle.Fill
            };

            editor.Changed += editor_Changed;
            editor.Visible = false;

            _tableLayoutPanel.RowCount = _tableLayoutPanel.Controls.Count + 1;

            while (_tableLayoutPanel.RowStyles.Count <= _tableLayoutPanel.RowCount)
            {
                _tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            }

            _tableLayoutPanel.SetRow(editor, _tableLayoutPanel.Controls.Count - 1);
            _tableLayoutPanel.Controls.Add(editor);
        }
        public ResourceNodeControl(FileNode node, TranslationDictionary dictionary)
            : this()
        {
            if (node == null)
                throw new ArgumentNullException("node");
            if (dictionary == null)
                throw new ArgumentNullException("dictionary");

            _dictionary = dictionary;

            _name.Text = node.Name;
            _source.Text = node.Source;
            _comment.Text = node.Comment;
            _originalSource.Text = node.OriginalSource;
            _translated.Text = node.Translated;
            _proposal.Text = dictionary.GetTranslation(node.Source);

            UpdateControlVisibility();
            UpdateColor();
        }
Beispiel #4
0
 void MainForm_LanguageChanged(object sender, EventArgs e)
 {
     Dictionary = new TranslationDictionary();
 }
Beispiel #5
0
        private void UpdateProjectItemState(TranslationDictionary dictionary, ProjectItem projectItem, TranslationFile file)
        {
            if (projectItem == null)
                throw new ArgumentNullException("projectItem");

            var fileContents = FileContents.Load(
                this,
                projectItem,
                file != null ? file.FindFile(projectItem) : null
            );

            bool anyPending = false;

            foreach (var node in fileContents.Nodes)
            {
                if (
                    node.Source != node.OriginalSource ||
                    (!node.Hidden && node.Translated == null)
                ) {
                    anyPending = true;
                }

                if (node.Translated != null)
                    dictionary.Add(node.OriginalSource, node.Translated);
            }

            if (fileContents.Nodes.Count == 0)
                projectItem.State = ProjectItemState.Unknown;
            else
                projectItem.State = anyPending ? ProjectItemState.Incomplete : ProjectItemState.Complete;
        }
Beispiel #6
0
        private void UpdateFromLanguage(TranslationDictionary dictionary, ProjectItem projectItem, TranslationFile file)
        {
            if (String.Equals(".resx", Path.GetExtension(projectItem.FileName), StringComparison.OrdinalIgnoreCase))
                UpdateProjectItemState(dictionary, projectItem, file);

            foreach (var child in projectItem.Children)
            {
                UpdateFromLanguage(dictionary, child, file);
            }
        }
Beispiel #7
0
        private void UpdateFromLanguage(TranslationDictionary dictionary)
        {
            var language = Program.MainForm.Language;
            TranslationFile file = null;
            if (language != null && _translations.Contains(language))
                file = _translations[language];

            UpdateFromLanguage(
                dictionary,
                RootNode,
                file
            );
        }