Exemplo n.º 1
0
        private static void FillTreeView(TreeViewModel parentItem, string path)
        {
            foreach (string str in Directory.EnumerateDirectories(path))
            {
                //Generate Tree View Node For Each Directory
                TreeViewModel item = new TreeViewModel();
                item.Name    = str.Substring(str.LastIndexOf('\\') + 1);
                item.Tag     = str;
                item.Tooltip = str;

                //Track Node  By Adding It List
                nodeList.Add(str, item);

                //Add node to parent's descendants
                parentItem.Children.Add(item);

                //Recurse to find additional sub-directories
                FillTreeView(item, str);
            }

            //Catalog All Files As Check Boxes
            foreach (string file in Directory.EnumerateFiles(path))
            {
                FileInfo fi = new FileInfo(file);

                //Check to ensure the file type is an acceptable one
                if (ExtensionUniformer.UnifyExtension(fi.Extension) == null)
                {
                    continue;
                }

                TreeViewModel item_file = new TreeViewModel();

                item_file.Name    = fi.Name;
                item_file.Tag     = file;
                item_file.Tooltip = file;

                item_file.PropertyChanged += CheckBoxChanged;

                parentItem.Children.Add(item_file);

                //Track Node  By Adding It List
                nodeList.Add(file, item_file);

                item_file.Initialize();
            }
        }
Exemplo n.º 2
0
        private void AttempConversion()
        {
            //Deep Copy Selected Items So User Can Manipulate List Still, And Filter Based On User-Desired Extensions
            List <string> targetedFiles = new List <string>();

            foreach (var file in SelectedFiles)
            {
                if (null != ExtensionUniformer.UnifyExtension(System.IO.Path.GetExtension(file)))
                {
                    if ((bool)RB_STRICT.IsChecked)
                    {
                        foreach (string extension in CCB_FROM.SelectedItems)
                        {
                            if (extension == System.IO.Path.GetExtension(file))
                            {
                                targetedFiles.Add(file);
                            }
                        }
                    }
                }
                else if ((bool)RB_ALL.IsChecked)
                {
                    targetedFiles.Add(file);
                }
            }

            //Start Up The Progress Reporting Dialog
            ProgressDialog progressDialog = new ProgressDialog();

            progressDialog.Maximum = targetedFiles.Count;
            progressDialog.Show();

            //Generate string for destination file type
            string dest = (string)CMBB_TO.SelectedValue;

            //Start A Thread On Conversions
            Thread thread = new Thread(() => Conversion.RunConversions(targetedFiles, dest, progressDialog.UpdateFields, deleteOriginals));

            thread.Start();
        }