internal static Dictionary <string, bool> BuildCheckListDictionary(string thePath, List <string> regexsearchPat)
        {
            string pat_toapply = MakeFilesListRegexString(regexsearchPat);
            Dictionary <string, bool> thisCheckListDict = new Dictionary <string, bool>();

            if (!Directory.Exists(thePath))
            {
                return(thisCheckListDict);
            }
            try
            {
                IEnumerable <String> ResultsList = Directory.GetFiles(thePath).Select(Path.GetFileName).Where(file => Regex.IsMatch(file, pat_toapply, RegexOptions.IgnoreCase));
                foreach (string f in ResultsList)
                {
                    thisCheckListDict.Add(Path.GetFileName(f), false);
                }
            }
            catch (ArgumentException e)
            {
                string msg = "Not Good! It looks like the regular expression \"" + pat_toapply + "\" has an invalid syntax. ";
                msg = msg + " This is happening in the BuildCheckListDictionary function.";
                msg = msg + "\n\n" + e.Message;
                FormMsgWPF explain = new FormMsgWPF(null, 3);
                explain.SetMsg(msg, "Up The Creek Without A Paddle");
                explain.ShowDialog();
            }
            return(thisCheckListDict);
        }
        internal static void DeleteFileFromListBox(object sender, string rootPath, string contextSubPath)
        {
            ListBox lb = sender as ListBox;

            if (lb.SelectedItems.Count == 0)
            {
                return;
            }
            string msg = string.Empty;
            string ttl = "What? Delete This File?";

            if (lb.SelectedItems.Count > 1)
            {
                ttl = "What?, Delete These Files?";
            }
            foreach (ListBoxItem lbi in lb.SelectedItems)
            {
                msg = msg + lbi.Content.ToString() + "\n";
            }
            FormMsgWPF explain = new FormMsgWPF(null, 2);

            explain.SetMsg(msg, ttl);
            explain.ShowDialog();
            if (explain.TheResult == MessageBoxResult.OK)
            {
                foreach (ListBoxItem lbi in lb.SelectedItems)
                {
                    String fname = Helpers.CombineIntoPath(rootPath, contextSubPath, lbi.Content.ToString());
                    if (fname != string.Empty)
                    {
                        if (File.Exists(fname))
                        {
                            try
                            {
                                File.Delete(fname);
                            }
                            catch (Exception err)
                            {
                                msg     = "Cannot delete.";
                                msg     = msg + "\n\n" + err.Message;
                                explain = new FormMsgWPF(null, 3);
                                explain.SetMsg(msg, "IO Error");
                                explain.ShowDialog();
                            }
                        }
                    }
                }
            }
        }
 internal static void CreateThisPath(string newPathToCreate)
 {
     try
     {
         Directory.CreateDirectory(@newPathToCreate);
     }
     catch (Exception er)
     {
         string     ttl     = "Create Directory Error";
         string     msg     = "Unable to create the paths in " + newPathToCreate + "\n\n" + er.Message;
         FormMsgWPF explain = new FormMsgWPF(null, 3);
         explain.SetMsg(msg, ttl);
         explain.ShowDialog();
     }
 }
 internal static string CombineIntoPath(string partA_RootPath, string partB_PartialPathWithDot, string partC_OptionalFileName = "")
 {
     try
     {
         string fullPath = Path.Combine(partA_RootPath, partB_PartialPathWithDot);
         fullPath = fullPath.Replace(".\\", "") + partC_OptionalFileName;
         return(fullPath);
     }
     catch (ArgumentException e)
     {
         string msg = "Part of this path name " + partB_PartialPathWithDot + partC_OptionalFileName + " is illegal. You need to correct it";
         msg = msg + "\n\n" + e.Message;
         FormMsgWPF explain = new FormMsgWPF(null, 3);
         explain.SetMsg(msg, "The Path Has Illegal An Character");
         explain.ShowDialog();
     }
     return(string.Empty);
 }
        // reports if text in textbox would be ok for a windows filename
        internal static void SniffTextBoxToBeAValidFileName(TextBox theTextBox)
        {
            if (theTextBox == null)
            {
                return;
            }
            string fn = theTextBox.Text;

            if (fn.Trim() == string.Empty)
            {
                return;
            }
            if (!IsValidWindowsFileName(fn))
            {
                string     msg     = "Windows will not allow \n\n" + fn + "\n\n to be a file name.";
                FormMsgWPF explain = new FormMsgWPF(null, 3);
                explain.SetMsg(msg, "By The Way. Not A Valid Name");
                explain.ShowDialog();
            }
        }
        internal static BitmapImage GetBitmapImage(this Uri imageAbsolutePath, BitmapCacheOption bitmapCacheOption = BitmapCacheOption.Default)
        {
            BitmapImage bi = new BitmapImage();

            try
            {
                bi.BeginInit();
                bi.CacheOption   = bitmapCacheOption;
                bi.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                bi.UriSource     = imageAbsolutePath;
                bi.EndInit();
                return(bi);
            }
            catch (Exception e)
            {
                string msg = "Trouble viewing \"" + imageAbsolutePath + "\".";
                msg = msg + "\n\n" + e.Message;
                FormMsgWPF explain = new FormMsgWPF(null, 3);
                explain.SetMsg(msg, "Sorry Charlie");
                explain.ShowDialog();
                bi = null;
            }
            return(bi);
        }