Ejemplo n.º 1
0
 public static IConverter OpenConverter(OpenFileDialog openExcelDialog, VSSolution solution)
 {
     switch (Path.GetExtension(openExcelDialog.FileName).Substring(1))
     {
         case "xls":
             return new ExcelConverter(solution);
         case "xlsx":
             return new XlsxConverter(solution);
         default:
             throw new Exception("File type not supported!");
     }
 }
Ejemplo n.º 2
0
        public VSSolutionFileParser(string filepath, VSSolution solution)
        {
            this.solution = solution;

            using(StreamReader streamReader = File.OpenText(filepath))
            {
                while (!streamReader.EndOfStream)
                {
                    string s = streamReader.ReadLine();

                    if (s.StartsWith("Project"))
                        RegisterProject(s);
                }
            }
        }
Ejemplo n.º 3
0
        public void LoadProjects(VSSolution s, IEnumerable<VSProject> projects)
        {
            solution = s;

            int i = 0;
            foreach (var project in solution.Projects.Values)
            {
                var item = new ProjectListViewEntry(project);
                this.Items.Add(item);

                if (projects.Contains(project))
                    this.SetSelected(i, true);

                i++;
            }
        }
Ejemplo n.º 4
0
        public void LoadCultures(VSSolution s, IEnumerable<VSCulture> selectedCultures)
        {
            solution = s;

            int i = 0;
            foreach (var culture in solution.Cultures.Values)
            {
                var item = new CultureListBoxEntry(culture);
                this.Items.Add(item);

                if (selectedCultures.Contains(culture))
                    this.SetSelected(i, true);

                i++;
            }
        }
Ejemplo n.º 5
0
        public VSProject(VSSolution solution, string filepath, string name)
            : base(null, null, filepath)
        {
            this.Solution = solution;

            string configPath = Path.Combine(Path.Combine(Solution.SolutionDirectory.FullName, CleanDirectoryPath(filepath)), Path.GetFileNameWithoutExtension(filepath) + ResxClientProjectFile.RESXCLIENTPROJECTFILE_EXTENSION);
            this.ResxProjectFile = new ResxClientProjectFile(configPath);

            this.FilePath = filepath;
            this.Name = name;
            this.Type = resolveProjectType(filepath);

            base.Init(CleanDirectoryPath(filepath));

            string tfsFile = Path.Combine(Solution.SolutionDirectory.FullName, filepath + VSS_PROJECT_METAFILE_EXTENSION);
            UnderTfsControl = File.Exists(tfsFile);
        }
Ejemplo n.º 6
0
        public VSSolutionFileParser(string filepath, VSSolution solution)
        {
            Solution = solution;

            using (var streamReader = File.OpenText(filepath))
            {
                while (!streamReader.EndOfStream)
                {
                    string s = streamReader.ReadLine();

                    if (s.StartsWith("Project"))
                    {
                        RegisterProject(s);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public VSProject(VSSolution solution, string filepath, string name) : base(null, null, filepath)
        {
            Solution = solution;

            string configPath = Path.Combine(Path.Combine(Solution.SolutionDirectory.FullName, CleanDirectoryPath(filepath)), Path.GetFileNameWithoutExtension(filepath) + ResxClientConfigurationBase.RESXCLIENTPROJECTFILE_EXTENSION);

            ResxProjectFile = new ProjectConfiguration(configPath);

            FilePath  = filepath;
            Name      = name;
            ShortName = solution.generateProjectShortName(name);
            Type      = resolveProjectType(filepath);

            base.Init(CleanDirectoryPath(filepath));

            string tfsFile = Path.Combine(Solution.SolutionDirectory.FullName, filepath + VSS_PROJECT_METAFILE_EXTENSION);

            UnderTfsControl = File.Exists(tfsFile);
        }
Ejemplo n.º 8
0
        private void openSolution(string filename)
        {
            try
            {
                setToolbarStatusText(Resources.LoadingSolution);

                CurrentSolution = new VSSolution(filename);

                this.menuStrip1.Invoke((MethodInvoker)(() => this.toolStripMenuItemExport.Enabled = true));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.itemSaveResources.Enabled = true));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.toolStripMenuItemImport.Enabled = true));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.itemOpenSolution.Enabled = true));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.storeAllTranslationsToolStripMenuItem.Enabled = true));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.itemCloseSolution.Enabled = true));

                this.toolStrip1.Invoke((MethodInvoker)(() => this.toolSaveAll.Enabled = true));
                this.toolStrip1.Invoke((MethodInvoker)(() => this.toolImport.Enabled = true));
                this.toolStrip1.Invoke((MethodInvoker)(() => this.toolExport.Enabled = true));
                this.toolStrip1.Invoke((MethodInvoker)(() => this.toolFillTranslations.Enabled = true));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.toolStripMenuItemTranslateAll.Enabled = true));

                solutionTree1.LoadTree();
            }
            catch
            {
                throw;
            }
            finally
            {
                resetToolbarStatusText();
            }

            if (CurrentSolution.Projects.Count == 0)
            {
                MessageBox.Show(String.Format(Properties.Resources.WarningNoProjects, filename), Properties.Resources.WarningOpenSolutionTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (CurrentSolution.Cultures.Count == 0)
            {
                MessageBox.Show(String.Format(Properties.Resources.WarningNoCultures, filename), Properties.Resources.WarningOpenSolutionTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 9
0
        private void closeSolution()
        {
            var result = testSolutionHasChanged();

            if (result != System.Windows.Forms.DialogResult.Cancel)
            {
                this.CurrentSolution = null;

                solutionTree1.LoadTree();

                this.menuStrip1.Invoke((MethodInvoker)(() => this.toolStripMenuItemExport.Enabled = false));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.itemSaveResources.Enabled = false));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.toolStripMenuItemImport.Enabled = false));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.storeAllTranslationsToolStripMenuItem.Enabled = false));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.itemCloseSolution.Enabled = false));

                this.toolStrip1.Invoke((MethodInvoker)(() => this.toolSaveAll.Enabled = false));
                this.toolStrip1.Invoke((MethodInvoker)(() => this.toolImport.Enabled = false));
                this.toolStrip1.Invoke((MethodInvoker)(() => this.toolExport.Enabled = false));
                this.toolStrip1.Invoke((MethodInvoker)(() => this.toolFillTranslations.Enabled = false));
                this.menuStrip1.Invoke((MethodInvoker)(() => this.toolStripMenuItemTranslateAll.Enabled = false));
            }
        }
        public void Store(VSSolution solution)
        {
            using (TranslationStorage store = new TranslationStorage(getConnectionString()))
            {
                foreach (var project in solution.Projects.Values)
                {
                    foreach (var fileGroup in project.ResxGroups.Values)
                    {
                        foreach (var dataGroup in fileGroup.AllData.Values)
                        {
                            var existingTranslationTexts = new List<TranslationText>();
                            foreach (var data in dataGroup.ResxData.Values)
                            {
                                existingTranslationTexts.AddRange(store.FindTranslations(data.Value, data.ResxFile.Culture.Name));
                            }

                            if (existingTranslationTexts.Count == 0)
                            {
                                var t = new Translation();

                                foreach (var data in dataGroup.ResxData.Values)
                                {
                                    var text = new TranslationText();
                                    text.Text = data.Value;
                                    text.Culture = GetCulture(data.ResxFile.Culture, store);
                                    text.CreatedDate = DateTime.Now;
                                    text.ModifiedDate = DateTime.Now;
                                    t.Translations.Add(text);
                                }

                                store.Translations.AddObject(t);
                                store.SaveChanges();
                            }
                            else
                            {
                                var list = from transText in existingTranslationTexts
                                           join data in dataGroup.ResxData.Values
                                           on transText.Text.ToLowerInvariant() equals data.Value.ToLowerInvariant()
                                           group transText by transText.Translation into translation
                                           select new { Translation = translation.Key, Count = translation.Count() };

                                var topCandidate = list.OrderByDescending(t => t.Count)
                                    .FirstOrDefault();

                                if (topCandidate == null)
                                    throw new Exception("TODO: Error");

                                var notExistingCultures = (from c in dataGroup.ResxData.Keys select c)
                                    .Except(from cn in topCandidate.Translation.Translations select CultureInfo.GetCultureInfo(cn.Culture.CultureName));

                                foreach (var culture in notExistingCultures)
                                {
                                    var text = new TranslationText();
                                    text.Text = dataGroup.ResxData[culture].Value;
                                    text.Culture = GetCulture(culture, store);
                                    text.CreatedDate = DateTime.Now;
                                    text.ModifiedDate = DateTime.Now;

                                    topCandidate.Translation.Translations.Add(text);
                                }
                                store.SaveChanges();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
 public XlsxConverter(IEnumerable<IResourceFileGroup> fileGroups, VSSolution solution)
     : base(fileGroups, solution)
 {
 }
Ejemplo n.º 12
0
 public XlsxConverter(VSSolution solution)
     : base(solution)
 {
 }
Ejemplo n.º 13
0
 public ConverterBase(IEnumerable<IResourceFileGroup> fileGroups, VSSolution solution)
 {
     this.FileGroups = fileGroups;
     this.Solution = solution;
 }
Ejemplo n.º 14
0
 public ConverterBase(VSSolution solution)
 {
     this.Solution = solution;
 }
Ejemplo n.º 15
0
 public ExcelConverter(VSSolution solution)
     : base(solution)
 {
 }