Exemple #1
0
        private void SelectResource()
        {
            TreeNode selectedTreeNode = tvFolderStructure.SelectedNode;

            if(selectedTreeNode==null)
            {
                return;
            }

            if(selectedTreeNode.Tag is PathHolder)
            {
                return;
            }

            if(!(selectedTreeNode.Tag is ResourceHolder))
            {
                return; // Shouldn't happen
            }

            ResourceHolder resource = selectedTreeNode.Tag as ResourceHolder;

            OpenResource(resource);
            currentResource = resource;
            labelTitle.Visible = true;
        }
Exemple #2
0
        private void OpenResource(ResourceHolder resource)
        {
            labelTitle.Text = resource.Id;
            checkedListBoxLanguages.Items.Clear();

            foreach (LanguageHolder languageHolder in resource.Languages.Values)
            {
                checkedListBoxLanguages.Items.Add(languageHolder, true);
            }

            dgwResourceData.DataSource=resource.StringsTable;

            dgwResourceData.Columns["Comment"].Visible=false;
            dgwResourceData.Columns["Translated"].Visible=false;
            dgwResourceData.Columns["Error"].Visible=false;

            ApplyFilterCondition();
        }
Exemple #3
0
        private void FindResxFiles(string folder)
        {
            string displayFolder = "";

            if(folder.StartsWith(rootPath, StringComparison.InvariantCultureIgnoreCase))
            {
                FileInfo root=new FileInfo(rootPath.Trim('\\','/'));
                displayFolder=root.Name+folder.Substring(rootPath.Length);
            }

            displayFolder.TrimStart('\\', '/');

            string[] files = Directory.GetFiles(folder, "*.resx");

            foreach (string file in files)
            {
                string filename = Path.GetFileName(file);
                string filenameNoExt = Path.GetFileNameWithoutExtension(file);
                string[] fileParts = filenameNoExt.Split('.');

                if(fileParts.Length==0)
                {
                    continue;
                }

                string language = "";

                if(fileParts[fileParts.Length-1].Length==5&&fileParts[fileParts.Length-1][2]=='-')
                {
                    language=fileParts[fileParts.Length-1];
                }
                else if(fileParts[fileParts.Length-1].Length==2)
                {
                    language=fileParts[fileParts.Length-1];
                }
                if(!string.IsNullOrEmpty(language))
                {
                    filenameNoExt=Path.GetFileNameWithoutExtension(filenameNoExt);
                }

                ResourceHolder resourceHolder;
                string key = (displayFolder + "\\" + filenameNoExt).ToLower();

                if (!resources.TryGetValue(key, out resourceHolder))
                {
                    resourceHolder = new ResourceHolder();
                    resourceHolder.DisplayFolder = displayFolder;

                    if(string.IsNullOrEmpty(language))
                    {
                        resourceHolder.Filename=file;
                    }

                    resourceHolder.Id = filenameNoExt;

                    resources.Add(key, resourceHolder);
                }

                if(!string.IsNullOrEmpty(language))
                {
                    if(!resourceHolder.Languages.ContainsKey(language.ToLower()))
                    {
                        LanguageHolder languageHolder=new LanguageHolder();
                        languageHolder.Filename=file;
                        languageHolder.Id=language;
                        resourceHolder.Languages.Add(language.ToLower(), languageHolder);
                    }
                }
                else
                {
                    resourceHolder.Filename=file;
                }
            }

            string[] subfolders = Directory.GetDirectories(folder);
            foreach (string subfolder in subfolders)
            {
                FindResxFiles(subfolder);
            }
        }
Exemple #4
0
        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if(!CanClose())
            {
                return;
            }

            tvFolderStructure.Nodes.Clear();
            checkedListBoxLanguages.Items.Clear();

            resources=new Dictionary<string, ResourceHolder>();

            dgwResourceData.DataSource=null;
            dgwResourceData.Columns.Clear();
            dgwResourceData.Rows.Clear();

            labelTitle.Visible = false;

            currentResource = null;
        }
Exemple #5
0
        private void BuildTreeView(ResourceHolder resource)
        {
            TreeNode parentNode=null;
            string[] topFolders=resource.DisplayFolder.Split(new char[] {'\\'}, StringSplitOptions.RemoveEmptyEntries);

            foreach(string subFolder in topFolders)
            {
                TreeNodeCollection searchNodes=parentNode==null?tvFolderStructure.Nodes:parentNode.Nodes;
                bool found=false;

                foreach(TreeNode treeNode in searchNodes)
                {
                    if(treeNode.Tag is PathHolder&&(treeNode.Tag as PathHolder).Id.Equals(subFolder, StringComparison.InvariantCultureIgnoreCase))
                    {
                        found=true;
                        parentNode=treeNode;
                        break;
                    }
                }

                if(!found)
                {
                    TreeNode pathTreeNode=new TreeNode("["+subFolder+"]");
                    PathHolder pathHolder=new PathHolder();
                    pathHolder.Id=subFolder;
                    pathTreeNode.Tag=pathHolder;
                    searchNodes.Add(pathTreeNode);

                    parentNode=pathTreeNode;
                }
            }

            TreeNode leafNode=new TreeNode(resource.Id);
            leafNode.Tag=resource;
            parentNode.Nodes.Add(leafNode);
        }
Exemple #6
0
 public FormAddKey(ResourceHolder resourceHolder)
 {
     InitializeComponent();
     this.resourceHolder=resourceHolder;
 }