Ejemplo n.º 1
0
 private void OnDocumentPropertyChanged()
 {
     if (!ArePropertiesChangedBySystem && !string.IsNullOrWhiteSpace(firstSelectedFile))
     {
         var newTmpFilename = PostHelper.GetShortFilenameWithExtensionFromProperties(Company, Date, Description);
         if (string.IsNullOrWhiteSpace(newTmpFilename))
         {
             // All properties are still empty
             return;
         }
         var oldShortFilenameWithExtension = Path.GetFileName(firstSelectedFile);
         var newFullFilename = firstSelectedFile.Replace(oldShortFilenameWithExtension, newTmpFilename);
         if (string.IsNullOrEmpty(newFullFilename))
         {
             return;
         }
         int    i = 2;
         string replacedFilename = newFullFilename;
         while (File.Exists(replacedFilename))
         {
             replacedFilename = newFullFilename.Replace(
                 ".jpg", " (" + (i++) + ").jpg"
                 );
         }
         SaveCommand.CanExecuteValue = true;
         NewFilename = replacedFilename;
     }
 }
Ejemplo n.º 2
0
 private void OnFileSelectionChanged(object sender, EventArgs e)
 {
     ArePropertiesChangedBySystem = true;
     SelectedFiles.Clear();
     foreach (var selectedFile in fileSelectionWatcher.Selected)
     {
         var dir = Path.GetDirectoryName(selectedFile);
         if (/*dir == Directory.GetCurrentDirectory() && */ Path.GetExtension(selectedFile).ToLower().EndsWith("jpg"))
         {
             firstSelectedFile = selectedFile;
             SelectedFiles.Add(selectedFile);
             string   selectedcompany;
             DateTime selecteddate;
             string   selecteddescription;
             if (
                 PostHelper.GetPropertiesFromFilename(
                     selectedFile,
                     out selectedcompany,
                     out selecteddate,
                     out selecteddescription
                     )
                 )
             {
                 Company     = selectedcompany;
                 Date        = selecteddate;
                 Description = selecteddescription;
             }
             else
             {
                 //
                 // File was not properly formatted OR it is new
                 //
                 Company     = null;
                 Date        = DateTime.Today;
                 Description = null;
             }
             // Only support single selection for now. Or take the first in the case of multiselection.
             //break;
         }
     }
     ArePropertiesChangedBySystem = false;
 }
Ejemplo n.º 3
0
        private void GetUsedCompaniesAndDescriptions(ref List <string> companies, ref List <string> descriptions)
        {
            string   company;
            DateTime date;
            string   description;

            companies.Clear();
            descriptions.Clear();
            string[] files = PostHelper.GetPdfFilesFromDefaultFolder();
            foreach (var file in files)
            {
                if (PostHelper.GetPropertiesFromFilename(file, out company, out date, out description))
                {
                    if (!string.IsNullOrWhiteSpace(company) && !companies.Contains(company))
                    {
                        companies.Add(company);
                    }
                    if (!string.IsNullOrWhiteSpace(description) && !descriptions.Contains(description))
                    {
                        descriptions.Add(description);
                    }
                }
            }
        }