コード例 #1
0
 public void WriteKeywords(string tags)
 {
     if (propertyWriter != null)
     {
         propertyWriter.WriteProperty(SystemProperties.System.Keywords, tags);
     }
 }
コード例 #2
0
        public static void editFileDates(MediaProcessingContext context)
        {
            ShellFile extendedFile = ShellFile.FromFilePath(context.movedFile.FullName);

            File.SetCreationTime(context.movedFile.FullName, context.oldestFileDate);
            File.SetLastWriteTime(context.movedFile.FullName, context.oldestFileDate);
            File.SetLastAccessTime(context.movedFile.FullName, context.oldestFileDate);

            ShellPropertyWriter writer = null;

            try {
                writer = extendedFile.Properties.GetPropertyWriter();
                if (context.mimeType.StartsWith("image"))
                {
                    writer.WriteProperty(SystemProperties.System.Photo.DateTaken, context.oldestFileDate);
                }
                if (context.mimeType.StartsWith("video"))
                {
                    writer.WriteProperty(SystemProperties.System.Media.DateEncoded, context.oldestFileDate);
                }
            } catch (Exception ignored) {
                Console.WriteLine("ERROR : {0}`s metadata writing failed", context.movedFile.Name);
            } finally {
                if (writer != null)
                {
                    writer.Close();
                }
            }
        }
コード例 #3
0
        private static void UpdateExif(string filePath, string title, string keywords)
        {
            var file = ShellFile.FromFilePath(filePath);

            using (ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter())
            {
                propertyWriter.WriteProperty(SystemProperties.System.Title, title);
                propertyWriter.WriteProperty(SystemProperties.System.Subject, title);
                propertyWriter.WriteProperty(SystemProperties.System.Keywords, keywords);
                propertyWriter.WriteProperty(SystemProperties.System.Comment, keywords);

                propertyWriter.Close();
            }
        }
コード例 #4
0
ファイル: Class1.cs プロジェクト: Nucs/Autocad-Utilities
 public static void SetSendDate(this FileInfo f, DateTime dt)
 {
     using (var file = ShellFile.FromFilePath(f.FullName)) {
         using (ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter()) {
             propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, DateTime.Now);
         }
     }
 }
コード例 #5
0
        public void FilePropertiesTest()
        {
            var file = ShellFile.FromFilePath(@"C:\Temp\test.jpg");

            //拡張プロパティ取得
            Console.WriteLine(file.Properties.System.Title.Value);
            Console.WriteLine(file.Properties.System.Author.Value);
            Console.WriteLine(file.Properties.System.Comment.Value);

            //拡張プロパティセット
            ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter();

            propertyWriter.WriteProperty(SystemProperties.System.Title, new string[] { "タイトル" });
            propertyWriter.WriteProperty(SystemProperties.System.Author, new string[] { "著者" });
            propertyWriter.WriteProperty(SystemProperties.System.Comment, new string[] { "コメント" });
            propertyWriter.Close();
        }
コード例 #6
0
        /// <summary>
        /// Sets the artist attribute in the given file.
        /// </summary>
        /// <param name="file">Target file</param>
        /// <param name="artist">The song's artist</param>
        public static void AddArtist(string file, string artist)
        {
            var _file = ShellFile.FromFilePath(file);

            try {
                ShellPropertyWriter propertyWriter = _file.Properties.GetPropertyWriter();
                propertyWriter.WriteProperty(SystemProperties.System.Music.Artist, new string[] { artist });
                propertyWriter.Close();
            } catch (Exception e) {
            }
        }
コード例 #7
0
        /// <summary>
        /// Sets the title attribute in the given file.
        /// </summary>
        /// <param name="file">Target file</param>
        /// <param name="title">The song's title</param>
        public static void AddTitle(string file, string title)
        {
            var _file = ShellFile.FromFilePath(file);

            try {
                ShellPropertyWriter propertyWriter = _file.Properties.GetPropertyWriter();
                propertyWriter.WriteProperty(SystemProperties.System.Title, new string[] { title });
                propertyWriter.Close();
            } catch (Exception e) {
            }
        }
コード例 #8
0
        private void ChangeTitleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string[] files = Directory.GetFiles(path, "*.mp3", SearchOption.AllDirectories);

                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo file = new FileInfo(files[i]);
                    if (NameCheck(file.Name) == "")
                    {
                        var fileshell = ShellFile.FromFilePath(file.DirectoryName + "\\" + file.Name);

                        Shell32.Shell      shell       = new Shell32.Shell();
                        var                strFileName = file.DirectoryName + "\\" + file.Name;
                        Shell32.Folder     objFolder   = shell.NameSpace(System.IO.Path.GetDirectoryName(strFileName));
                        Shell32.FolderItem folderItem  = objFolder.ParseName(System.IO.Path.GetFileName(strFileName));
                        var                title       = objFolder.GetDetailsOf(folderItem, 21);

                        if (title == "" || title.Contains("ntitled") || title.Contains("nknown") || title.Contains("nknown") || title.Contains("http") || title.Contains("www.") || title.Contains(".com") || title.Contains("Track"))
                        {
                            string   name    = objFolder.GetDetailsOf(folderItem, 0);
                            string[] newName = Regex.Split(name, "-");

                            if (newName.Length >= 2 && newName[1] != null)
                            {
                                string[] newest = Regex.Split(newName[1], "\\.");

                                ShellPropertyWriter propertyWriter = fileshell.Properties.GetPropertyWriter();
                                try
                                {
                                    propertyWriter.WriteProperty(SystemProperties.System.Title, new string[] { newest[0] });
                                }
                                finally
                                {
                                    propertyWriter.Close();
                                }
                            }
                        }
                    }
                    progressBar1.Value = Convert.ToInt32(100 * (i + 1) / files.Length);

                    if (i == files.Length - 1)
                    {
                        progressBar1.Value = 100;
                    }
                }
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("Files not found exception!", "Error!");
            }
        }
コード例 #9
0
        private void WriteTagsToFile(string fpath, string[] tags)
        {
            Log("Writing tags to file: " + Path.GetFileName(fpath));
            // read file.
            var shellobj = Microsoft.WindowsAPICodePack.Shell.ShellObject.FromParsingName(fpath);

            using (ShellPropertyWriter w = shellobj.Properties.GetPropertyWriter()) // get writer of the property.
            {
                // write new value of the property.
                w.WriteProperty(SystemProperties.System.Keywords, tags);
            }
        }
コード例 #10
0
        private static void updateMetadata(string fileNameWithoutExtension, string fileExt)
        {
            ShellFile           file   = ShellFile.FromFilePath(fileNameWithoutExtension + fileExt);
            ShellPropertyWriter writer = file.Properties.GetPropertyWriter();

            writer.WriteProperty(SystemProperties.System.Title, "test");
            writer.Close();
            //Debug.WriteLine(file.Properties.System.Title.Value);
            //file.Properties.System.Title.Value = "";// fileNameWithoutExtension;
            //FileInfo info = new FileInfo(fileName);
            //FileAttributes attributes = info.Attributes;
            //Debug.WriteLine(attributes.ToString());
        }
コード例 #11
0
        void doIt()
        {
            DirectoryInfo d = new DirectoryInfo(folderpath);

            foreach (var file in d.GetFiles("*.jpg"))
            {
                string filePath = file.FullName;
                string name     = Path.GetFileNameWithoutExtension(filePath);
                var    img      = ShellFile.FromFilePath(filePath);
                try
                {
                    ShellPropertyWriter propertyWriter = img.Properties.GetPropertyWriter();
                    propertyWriter.WriteProperty(SystemProperties.System.Title, name);
                    propertyWriter.WriteProperty(SystemProperties.System.Subject, name);
                    propertyWriter.WriteProperty(SystemProperties.System.Rating, 99);
                    propertyWriter.WriteProperty(SystemProperties.System.Comment, "I like " + name);
                    propertyWriter.WriteProperty(SystemProperties.System.Title, name);
                    propertyWriter.WriteProperty(SystemProperties.System.Author, new string[] { comboBox1.Text });
                    propertyWriter.WriteProperty(SystemProperties.System.Copyright, comboBox1.Text);
                    propertyWriter.Close();
                    // Read and Write:

                    /*
                     * img.Properties.System.Title.Value = file.Name;
                     * img.Properties.System.Subject.Value = file.Name;
                     * img.Properties.System.Rating.Value = 99; // 5 stars
                     * img.Properties.System.Comment.Value = "I like " + file.Name;
                     * img.Properties.System.Author.Value = new string[] { comboBox1.Text };
                     * img.Properties.System.Copyright.Value = comboBox1.Text; */
                }
                catch (Exception e)
                {
                    //MessageBox.Show("Error !!!");
                    continue;
                }
            }
        }
コード例 #12
0
        private void ChangeArtistsInfoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string[] files = Directory.GetFiles(path, "*.mp3", SearchOption.AllDirectories);

                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo file = new FileInfo(files[i]);
                    if (NameCheck(file.Name) == "")
                    {
                        var fileshell = ShellFile.FromFilePath(file.DirectoryName + "\\" + file.Name);

                        Shell32.Shell      shell       = new Shell32.Shell();
                        var                strFileName = file.DirectoryName + "\\" + file.Name;
                        Shell32.Folder     objFolder   = shell.NameSpace(System.IO.Path.GetDirectoryName(strFileName));
                        Shell32.FolderItem folderItem  = objFolder.ParseName(System.IO.Path.GetFileName(strFileName));
                        var                contrArtist = objFolder.GetDetailsOf(folderItem, 13);

                        if (contrArtist == "" || contrArtist.Contains("ntitled") || contrArtist.Contains("various") || contrArtist.Contains("Various") || contrArtist.Contains("nknown") || contrArtist.Contains("http") || contrArtist.Contains("www.") || contrArtist.Contains(".com"))
                        {
                            string   name    = objFolder.GetDetailsOf(folderItem, 0);
                            string[] newName = Regex.Split(name, "-");
                            string[] newest  = Regex.Split(newName[0], "\\.");

                            ShellPropertyWriter propertyWriter = fileshell.Properties.GetPropertyWriter();
                            try
                            {
                                if (newest.Length >= 2 && newest[1] != null)
                                {
                                    propertyWriter.WriteProperty(SystemProperties.System.Music.Artist, new string[] { newest[1] });
                                }
                                else if (newest.Length < 2)
                                {
                                }
                            }
                            finally
                            {
                                propertyWriter.Close();
                            }
                        }
                        ShellObject song        = ShellObject.FromParsingName(strFileName);
                        var         albumArtist = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumArtist));

                        if (albumArtist == "" || albumArtist.Contains("ntitled") || albumArtist.Contains("various") || albumArtist.Contains("Various") || albumArtist.Contains("nknown") || contrArtist.Contains("nknown") || contrArtist.Contains("http") || contrArtist.Contains("www.") || contrArtist.Contains(".com"))
                        {
                            string   name    = objFolder.GetDetailsOf(folderItem, 0);
                            string[] newName = Regex.Split(name, "-");
                            string[] newest  = Regex.Split(newName[0], "\\.");

                            ShellPropertyWriter propertyWriter = fileshell.Properties.GetPropertyWriter();
                            try
                            {
                                if (newest.Length >= 2 && newest[1] != null)
                                {
                                    propertyWriter.WriteProperty(SystemProperties.System.Music.AlbumArtist, new string[] { newest[1] });
                                }
                                else if (newest.Length < 2)
                                {
                                }
                            }
                            finally
                            {
                                propertyWriter.Close();
                            }
                        }
                    }
                    progressBar1.Value = Convert.ToInt32(100 * (i + 1) / files.Length);

                    if (i == files.Length - 1)
                    {
                        progressBar1.Value = 100;
                    }
                }
            }
            catch (FileNotFoundException)
            {
                System.Windows.Forms.MessageBox.Show("Files not found exception!", "Message");
            }
        }
コード例 #13
0
        /// <summary>
        /// Maps all the filled <see cref="Storage.Task"/> properties to the corresponding extended file attributes
        /// </summary>
        /// <param name="message">The <see cref="Storage.Message"/> object</param>
        /// <param name="propertyWriter">The <see cref="ShellPropertyWriter"/> object</param>
        private void MapContactPropertiesToExtendedFileAttributes(Storage.Message message, ShellPropertyWriter propertyWriter)
        {
            // From
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromName, message.Sender.DisplayName);

            // Sent on
            propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, message.SentOn);

            // Full name
            propertyWriter.WriteProperty(SystemProperties.System.Contact.FullName, message.Contact.DisplayName);

            // Last name
            propertyWriter.WriteProperty(SystemProperties.System.Contact.LastName, message.Contact.SurName);

            // First name
            propertyWriter.WriteProperty(SystemProperties.System.Contact.FirstName, message.Contact.GivenName);

            // Job title
            propertyWriter.WriteProperty(SystemProperties.System.Contact.JobTitle, message.Contact.Function);

            // Department
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Department, message.Contact.Department);

            // Company
            propertyWriter.WriteProperty(SystemProperties.System.Company, message.Contact.Company);

            // Business address
            propertyWriter.WriteProperty(SystemProperties.System.Contact.BusinessAddress, message.Contact.WorkAddress);

            // Home address
            propertyWriter.WriteProperty(SystemProperties.System.Contact.HomeAddress, message.Contact.HomeAddress);

            // Other address
            propertyWriter.WriteProperty(SystemProperties.System.Contact.OtherAddress, message.Contact.OtherAddress);

            // Instant messaging
            propertyWriter.WriteProperty(SystemProperties.System.Contact.IMAddress, message.Contact.InstantMessagingAddress);

            // Business telephone number
            propertyWriter.WriteProperty(SystemProperties.System.Contact.BusinessTelephone, message.Contact.BusinessTelephoneNumber);

            // Assistant's telephone number
            propertyWriter.WriteProperty(SystemProperties.System.Contact.AssistantTelephone, message.Contact.AssistantTelephoneNumber);

            // Company main phone
            propertyWriter.WriteProperty(SystemProperties.System.Contact.CompanyMainTelephone, message.Contact.CompanyMainTelephoneNumber);

            // Home telephone number
            propertyWriter.WriteProperty(SystemProperties.System.Contact.HomeTelephone, message.Contact.HomeTelephoneNumber);

            // Mobile phone
            propertyWriter.WriteProperty(SystemProperties.System.Contact.MobileTelephone, message.Contact.CellularTelephoneNumber);

            // Car phone
            propertyWriter.WriteProperty(SystemProperties.System.Contact.CarTelephone, message.Contact.CarTelephoneNumber);

            // Callback
            propertyWriter.WriteProperty(SystemProperties.System.Contact.CallbackTelephone, message.Contact.CallbackTelephoneNumber);

            // Primary telephone number
            propertyWriter.WriteProperty(SystemProperties.System.Contact.PrimaryTelephone, message.Contact.PrimaryTelephoneNumber);

            // Telex
            propertyWriter.WriteProperty(SystemProperties.System.Contact.TelexNumber, message.Contact.TelexNumber);

            // TTY/TDD phone
            propertyWriter.WriteProperty(SystemProperties.System.Contact.TTYTDDTelephone, message.Contact.TextTelephone);

            // Business fax
            propertyWriter.WriteProperty(SystemProperties.System.Contact.BusinessFaxNumber, message.Contact.BusinessFaxNumber);

            // Home fax
            propertyWriter.WriteProperty(SystemProperties.System.Contact.HomeFaxNumber, message.Contact.HomeFaxNumber);

            // E-mail
            propertyWriter.WriteProperty(SystemProperties.System.Contact.EmailAddress, message.Contact.Email1EmailAddress);
            propertyWriter.WriteProperty(SystemProperties.System.Contact.EmailName, message.Contact.Email1DisplayName);

            // E-mail 2
            propertyWriter.WriteProperty(SystemProperties.System.Contact.EmailAddress2, message.Contact.Email2EmailAddress);

            // E-mail 3
            propertyWriter.WriteProperty(SystemProperties.System.Contact.EmailAddress3, message.Contact.Email3EmailAddress);

            // Birthday
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Birthday, message.Contact.Birthday);

            // Anniversary
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Anniversary, message.Contact.WeddingAnniversary);

            // Spouse/Partner
            propertyWriter.WriteProperty(SystemProperties.System.Contact.SpouseName, message.Contact.SpouseName);

            // Profession
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Profession, message.Contact.Profession);

            // Assistant
            propertyWriter.WriteProperty(SystemProperties.System.Contact.AssistantName, message.Contact.AssistantName);

            // Web page
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Webpage, message.Contact.Html);

            // Categories
            var categories = message.Categories;

            if (categories != null)
            {
                propertyWriter.WriteProperty(SystemProperties.System.Category, String.Join("; ", String.Join("; ", categories)));
            }
        }
コード例 #14
0
        /// <summary>
        /// Maps all the filled <see cref="Storage.Task"/> properties to the corresponding extended file attributes
        /// </summary>
        /// <param name="message">The <see cref="Storage.Message"/> object</param>
        /// <param name="propertyWriter">The <see cref="ShellPropertyWriter"/> object</param>
        private void MapTaskPropertiesToExtendedFileAttributes(Storage.Message message, ShellPropertyWriter propertyWriter)
        {
            // From
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromName, message.Sender.DisplayName);

            // Sent on
            propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, message.SentOn);

            // Subject
            propertyWriter.WriteProperty(SystemProperties.System.Subject, message.Subject);

            // Task startdate
            propertyWriter.WriteProperty(SystemProperties.System.StartDate, message.Task.StartDate);

            // Task duedate
            propertyWriter.WriteProperty(SystemProperties.System.DueDate, message.Task.DueDate);

            // Urgent
            propertyWriter.WriteProperty(SystemProperties.System.Importance, message.Importance);
            propertyWriter.WriteProperty(SystemProperties.System.ImportanceText, message.ImportanceText);

            // Status
            propertyWriter.WriteProperty(SystemProperties.System.Status, message.Task.StatusText);

            // Percentage complete
            propertyWriter.WriteProperty(SystemProperties.System.Task.CompletionStatus, message.Task.PercentageComplete);

            // Owner
            propertyWriter.WriteProperty(SystemProperties.System.Task.Owner, message.Task.Owner);

            // Categories
            propertyWriter.WriteProperty(SystemProperties.System.Category,
                                         message.Categories != null ? String.Join("; ", message.Categories) : null);

            // Companies
            propertyWriter.WriteProperty(SystemProperties.System.Company,
                                         message.Task.Companies != null ? String.Join("; ", message.Task.Companies) : null);

            // Billing information
            propertyWriter.WriteProperty(SystemProperties.System.Task.BillingInformation, message.Task.BillingInformation);

            // Mileage
            propertyWriter.WriteProperty(SystemProperties.System.MileageInformation, message.Task.Mileage);

            // Attachments
            var attachments = message.GetAttachmentNames();

            if (string.IsNullOrEmpty(attachments))
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, false);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, null);
            }
            else
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, true);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, attachments);
            }
        }
コード例 #15
0
        /// <summary>
        /// Maps all the filled <see cref="Storage.Appointment"/> properties to the corresponding extended file attributes
        /// </summary>
        /// <param name="message">The <see cref="Storage.Message"/> object</param>
        /// <param name="propertyWriter">The <see cref="ShellPropertyWriter"/> object</param>
        private void MapAppointmentPropertiesToExtendedFileAttributes(Storage.Message message, ShellPropertyWriter propertyWriter)
        {
            // From
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromName, message.Sender.DisplayName);

            // Sent on
            if (message.SentOn != null)
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, message.SentOn);
            }

            // Subject
            propertyWriter.WriteProperty(SystemProperties.System.Subject, message.Subject);

            // Location
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.Location, message.Appointment.Location);

            // Start
            propertyWriter.WriteProperty(SystemProperties.System.StartDate, message.Appointment.Start);

            // End
            propertyWriter.WriteProperty(SystemProperties.System.StartDate, message.Appointment.End);

            // Recurrence type
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.IsRecurring,
                                         message.Appointment.RecurrenceType != AppointmentRecurrenceType.None);

            // Status
            propertyWriter.WriteProperty(SystemProperties.System.Status, message.Appointment.ClientIntentText);

            // Appointment organizer (FROM)
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.OrganizerAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.OrganizerName, message.Sender.DisplayName);

            // Mandatory participants (TO)
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.RequiredAttendeeNames, message.Appointment.ToAttendees);

            // Optional participants (CC)
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.OptionalAttendeeNames, message.Appointment.CcAttendees);

            // Categories
            var categories = message.Categories;

            if (categories != null)
            {
                propertyWriter.WriteProperty(SystemProperties.System.Category, String.Join("; ", String.Join("; ", categories)));
            }

            // Urgent
            propertyWriter.WriteProperty(SystemProperties.System.Importance, message.Importance);
            propertyWriter.WriteProperty(SystemProperties.System.ImportanceText, message.ImportanceText);

            // Attachments
            var attachments = message.GetAttachmentNames();

            if (string.IsNullOrEmpty(attachments))
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, false);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, null);
            }
            else
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, true);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, attachments);
            }
        }
コード例 #16
0
ファイル: SingleEdit.cs プロジェクト: bogy159/MusicApp
        public void SetData(string location)
        {
            var fileshell = ShellFile.FromFilePath(location);
            ShellPropertyWriter propertyWriter = fileshell.Properties.GetPropertyWriter();

            try
            {
                if (yearTextBox.Text != "" && Convert.ToInt16(yearTextBox.Text) <= Convert.ToInt16(DateTime.Now.Year) && Convert.ToInt16(yearTextBox.Text) > 1900)
                {
                    propertyWriter.WriteProperty(SystemProperties.System.Media.Year, new int[] { Convert.ToInt16(yearTextBox.Text) });
                }
                else if (yearTextBox.Text == "" || Convert.ToInt16(yearTextBox.Text) == 0)
                {
                    propertyWriter.WriteProperty(SystemProperties.System.Media.Year, new int[] { 0 });
                }
                else
                {
                    DialogResult dialogResult = MessageBox.Show("Invalid year!" + Environment.NewLine + "Do you want to continue with the year change?", "Inpropper year!", MessageBoxButtons.YesNoCancel);

                    if (dialogResult == DialogResult.Yes)
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Media.Year, new int[] { Convert.ToInt16(yearTextBox.Text) });
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                    }
                    else if (dialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                propertyWriter.WriteProperty(SystemProperties.System.Music.AlbumArtist, new string[] { aArtistTextBox.Text });
                propertyWriter.WriteProperty(SystemProperties.System.Title, new string[] { titleTextBox.Text });
                propertyWriter.WriteProperty(SystemProperties.System.Music.AlbumTitle, new string[] { albumTextBox.Text });
                propertyWriter.WriteProperty(SystemProperties.System.Music.Artist, new string[] { contributingTextBox.Text });
                propertyWriter.WriteProperty(SystemProperties.System.Music.Genre, new string[] { genreBox.Text });
                propertyWriter.WriteProperty(SystemProperties.System.Music.Lyrics, new string[] { lyricsTextBox.Text });
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: " + e, "Setting data error!");
            }
            finally
            {
                propertyWriter.Close();
            }
            try
            {
                string message = Index.NameCheck(nameTextBox.Text);
                if (message == "")
                {
                    System.IO.File.Move(location, System.IO.Path.GetDirectoryName(location) + "\\" + nameTextBox.Text);
                    Close();
                }
                else
                {
                    DialogResult dialogResult = MessageBox.Show("Name check returned: " + message + Environment.NewLine + "Do you want to continue with the name change?", "Inpropper name!", MessageBoxButtons.YesNoCancel);

                    if (dialogResult == DialogResult.Yes)
                    {
                        System.IO.File.Move(location, System.IO.Path.GetDirectoryName(location) + "\\" + nameTextBox.Text);
                        Close();
                    }
                    else if (dialogResult == DialogResult.No)
                    {
                    }
                    else if (dialogResult == DialogResult.Cancel)
                    {
                        Close();
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: " + e, "Renaming error!");
            }
        }
コード例 #17
0
ファイル: Reader.cs プロジェクト: iraychen/MSGReader
        /// <summary>
        /// Maps all the filled <see cref="Storage.Appointment"/> properties to the corresponding extended file attributes
        /// </summary>
        /// <param name="message">The <see cref="Storage.Message"/> object</param>
        /// <param name="propertyWriter">The <see cref="ShellPropertyWriter"/> object</param>
        private void MapAppointmentPropertiesToExtendedFileAttributes(Storage.Message message, ShellPropertyWriter propertyWriter)
        {
            // From
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromName, message.Sender.DisplayName);

            // Sent on
            if (message.SentOn != null)
                propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, message.SentOn);

            // Subject
            propertyWriter.WriteProperty(SystemProperties.System.Subject, message.Subject);

            // Location
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.Location, message.Appointment.Location);

            // Start
            propertyWriter.WriteProperty(SystemProperties.System.StartDate, message.Appointment.Start);

            // End
            propertyWriter.WriteProperty(SystemProperties.System.StartDate, message.Appointment.End);

            // Recurrence type
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.IsRecurring,
                message.Appointment.ReccurrenceType != Storage.Appointment.AppointmentRecurrenceType.None);

            // Status
            propertyWriter.WriteProperty(SystemProperties.System.Status, message.Appointment.ClientIntentText);

            // Appointment organizer (FROM)
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.OrganizerAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.OrganizerName, message.Sender.DisplayName);

            // Mandatory participants (TO)
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.RequiredAttendeeNames, message.Appointment.ToAttendees);

            // Optional participants (CC)
            propertyWriter.WriteProperty(SystemProperties.System.Calendar.OptionalAttendeeNames, message.Appointment.CclAttendees);

            // Categories
            var categories = message.Categories;
            if (categories != null)
                propertyWriter.WriteProperty(SystemProperties.System.Category, String.Join("; ", String.Join("; ", categories)));

            // Urgent
            propertyWriter.WriteProperty(SystemProperties.System.Importance, message.Importance);
            propertyWriter.WriteProperty(SystemProperties.System.ImportanceText, message.ImportanceText);

            // Attachments
            var attachments = message.GetAttachmentNames();
            if (string.IsNullOrEmpty(attachments))
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, false);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, null);
            }
            else
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, true);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, attachments);
            }
        }
コード例 #18
0
ファイル: Downloader.xaml.cs プロジェクト: ghost1372/ArtWork
        private void Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                HandyControl.Controls.MessageBox.Error("Download Canceled!");
            }
            else
            {
                shDownloadedItem.Status = Convert.ToInt32(shDownloadedItem.Status) + 1;
                // Handle Rename

                ShellFile file = ShellFile.FromFilePath(@Imagepath);

                string isNude = "NOTNUDE";


                //Check Nud

                if (DomainExists(System.IO.Path.GetFileNameWithoutExtension(@JsonPath)))
                {
                    isNude = "ITSNUDE";
                }
                else
                {
                    isNude = "NOTNUDE";
                }

                string date = sig.Substring(sig.LastIndexOf(',') + 1);



                try
                {
                    //Set Attrib
                    ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter();
                    propertyWriter.WriteProperty(SystemProperties.System.Title, FixInvalidCharacter(title) ?? "Empty");
                    propertyWriter.WriteProperty(SystemProperties.System.Subject, FixInvalidCharacter(sig) ?? "Empty");
                    propertyWriter.WriteProperty(SystemProperties.System.Comment, FixInvalidCharacter(gal) ?? "Empty");
                    propertyWriter.WriteProperty(SystemProperties.System.Author, FixInvalidCharacter(wikiartist) ?? "Unknown Artist");
                    propertyWriter.WriteProperty(SystemProperties.System.Keywords, new string[] {
                        FixInvalidCharacter(city) ?? "Location Unknown", FixInvalidCharacter(country) ?? "Location Unknown", FixInvalidCharacter(lat.ToString()) ?? "Empty",
                        FixInvalidCharacter(@long.ToString()) ?? "Empty", FixInvalidCharacter(sig) ?? "Empty", FixInvalidCharacter(title) ?? "Empty",
                        FixInvalidCharacter(wikiartist) ?? "Empty", FixInvalidCharacter(gal) ?? "Empty", isNude ?? "Empty", FixInvalidCharacter(date) ?? "Empty"
                    });

                    propertyWriter.Close();

                    string wikiart       = wikiartist ?? "Unknown Artist";
                    string cleanFileName = string.Join("", wikiart.Split(System.IO.Path.GetInvalidFileNameChars()));
                    if (!Directory.Exists(GlobalData.Config.DataPath + @"\" + cleanFileName))
                    {
                        Directory.CreateDirectory(GlobalData.Config.DataPath + @"\" + cleanFileName);
                    }
                    File.Move(@Imagepath, GlobalData.Config.DataPath + @"\" + cleanFileName.Trim() + @"\" + System.IO.Path.GetFileName(@Imagepath));
                }
                catch (Exception)
                {
                }

                DownloadFile();
            }
        }
コード例 #19
0
        public static void SearchAndReplace(string templatePath, string destinationFilePath, Dictionary <string, string> fieldValues, string Author)
        {
            File.Copy(templatePath, destinationFilePath, true);
            FileInfo finfo = new FileInfo(destinationFilePath);

            finfo.Attributes = FileAttributes.Directory | FileAttributes.Normal;

            string docText = "";

            var file = ShellFile.FromFilePath(destinationFilePath);
            ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter();

            propertyWriter.WriteProperty(SystemProperties.System.Author, new string[] { Author });
            propertyWriter.WriteProperty(SystemProperties.System.ComputerName, new string[] { "Asia Soft" });
            propertyWriter.Close();

            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(destinationFilePath, true))
            {
                using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream()))
                {
                    docText = sr.ReadToEnd();
                    sr.Close();
                    sr.Dispose();
                }

                foreach (var item in fieldValues)
                {
                    docText = ReplaceWholeWord(docText, item.Key, item.Value);
                }

                foreach (FooterPart footer in wordDoc.MainDocumentPart.FooterParts)
                {
                    string footerText = null;
                    using (StreamReader sr = new StreamReader(footer.GetStream()))
                    {
                        footerText = sr.ReadToEnd();
                    }

                    foreach (var item in fieldValues)
                    {
                        footerText = ReplaceWholeWord(footerText, item.Key, item.Value);
                    }

                    using (StreamWriter sw = new StreamWriter(footer.GetStream(FileMode.Create)))
                    {
                        sw.Write(footerText);
                    }
                    //Save Header
                    footer.Footer.Save();
                }

                foreach (HeaderPart footer in wordDoc.MainDocumentPart.HeaderParts)
                {
                    string footerText = null;
                    using (StreamReader sr = new StreamReader(footer.GetStream()))
                    {
                        footerText = sr.ReadToEnd();
                    }

                    foreach (var item in fieldValues)
                    {
                        footerText = ReplaceWholeWord(footerText, item.Key, item.Value);
                    }

                    using (StreamWriter sw = new StreamWriter(footer.GetStream(FileMode.Create)))
                    {
                        sw.Write(footerText);
                    }
                    //Save Header
                    footer.Header.Save();
                }



                using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create)))
                {
                    sw.Write(docText);
                    sw.Close();
                    sw.Dispose();
                }

                wordDoc.Close();
                wordDoc.Dispose();
            }
        }
コード例 #20
0
ファイル: tag_to_system.cs プロジェクト: Rp70/fvc
        static public void Run(IScripting scripting, string argument)
        {
            scripting.GetConsole().Clear();
            var         catalog   = scripting.GetVideoCatalogService();
            ISelection  selection = scripting.GetSelection();
            List <long> selected  = selection.GetSelectedVideos();

            foreach (long video in selected)
            {
                try
                {
                    var entry = catalog.GetVideoFileEntry(video);

                    IUtilities utilities     = scripting.GetUtilities();
                    var        selected_path = utilities.ConvertToLocalPath(entry.FilePath);

                    var file = ShellFile.FromFilePath(selected_path);

                    var selected_videos = new long[1];
                    selected_videos[0] = video;
                    var           TagInstances = catalog.GetTagsForVideos(selected_videos);
                    List <string> tag_list     = new List <string>();
                    foreach (var tag in TagInstances)
                    {
                        tag_list.Add(tag.Name);
                    }

                    scripting.GetConsole().Write("Tagging : " + selected_path + " ...");
                    ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter();
                    propertyWriter.WriteProperty(SystemProperties.System.Keywords, tag_list.ToArray());
                    int Rating = 0;
                    if (entry.Rating == 1)
                    {
                        Rating = 1;
                    }
                    if (entry.Rating == 2)
                    {
                        Rating = 25;
                    }
                    if (entry.Rating == 3)
                    {
                        Rating = 50;
                    }
                    if (entry.Rating == 4)
                    {
                        Rating = 75;
                    }
                    if (entry.Rating == 5)
                    {
                        Rating = 99;
                    }
                    propertyWriter.WriteProperty(SystemProperties.System.Rating, Rating);
                    propertyWriter.WriteProperty(SystemProperties.System.Comment, entry.Description);
                    propertyWriter.Close();

                    scripting.GetConsole().WriteLine("Done ");
                }
                catch (Exception ex)
                {
                    scripting.GetConsole().WriteLine(ex.Message);
                }
            }
        }
コード例 #21
0
        private void MusixmatchUpdateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string[] files = Directory.GetFiles(path, "*.mp3", SearchOption.AllDirectories);
                errorList = "No data for the following: ";

                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo file        = new FileInfo(files[i]);
                    var      strFileName = file.DirectoryName + "\\" + file.Name;

                    ShellObject song   = ShellObject.FromParsingName(strFileName);
                    string      artist = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumArtist));
                    string      title  = GetValue(song.Properties.GetProperty(SystemProperties.System.Title));

                    if (artist != "" && title != "")
                    {
                        var    year  = GetValue(song.Properties.GetProperty(SystemProperties.System.Media.Year));
                        string album = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumTitle));

                        Shell32.Shell      shell      = new Shell32.Shell();
                        Shell32.Folder     objFolder  = shell.NameSpace(System.IO.Path.GetDirectoryName(strFileName));
                        Shell32.FolderItem folderItem = objFolder.ParseName(System.IO.Path.GetFileName(strFileName));
                        var genre = objFolder.GetDetailsOf(folderItem, 16);

                        if (year.ToString() == "" || Convert.ToInt16(year) == 0 || album == "" || genre.ToString() == "")
                        {
                            var fileshell = ShellFile.FromFilePath(strFileName);
                            ShellPropertyWriter propertyWriter = fileshell.Properties.GetPropertyWriter();

                            try
                            {
                                var trackJSON = SingleEdit.MusixmatchGet(artist, title);

                                if (trackJSON.Item1 != null)
                                {
                                    try
                                    {
                                        string yearMM = "";//trackJSON.Item1.FirstReleaseDate.Year.ToString();
                                        if ((year.ToString() == "" || Convert.ToInt16(year) == 0) && yearMM != "" && Convert.ToInt16(yearMM) <= Convert.ToInt16(DateTime.Now.Year) && Convert.ToInt16(yearMM) > 1900)
                                        {
                                            propertyWriter.WriteProperty(SystemProperties.System.Media.Year, new int[] { Convert.ToInt16(yearMM) });
                                        }
                                    }
                                    catch
                                    {
                                        errorList += Environment.NewLine + "Year error in: " + file.Name;
                                    }
                                    try
                                    {
                                        string albumMM = trackJSON.Item1.AlbumName.ToString();
                                        if (album == "" && albumMM != "")
                                        {
                                            propertyWriter.WriteProperty(SystemProperties.System.Music.AlbumTitle, new string[] { albumMM });
                                        }
                                    }
                                    catch
                                    {
                                        errorList += Environment.NewLine + "Album error in: " + file.Name;
                                    }
                                    if (genre.ToString() == "")
                                    {
                                        try
                                        {
                                            string genreMM = trackJSON.Item1.PrimaryGenres.MusicGenreList[0].MusicGenre.MusicGenreName.ToString();
                                            if (genreMM.ToString() != "")
                                            {
                                                propertyWriter.WriteProperty(SystemProperties.System.Music.Genre, new string[] { genreMM });
                                            }
                                        }
                                        catch (IndexOutOfRangeException)
                                        {
                                            errorList += Environment.NewLine + "Genre error in: " + file.Name;
                                        }
                                    }
                                }
                                else if (trackJSON.Item2 == true)
                                {
                                    break;
                                }
                                else
                                {
                                    errorList += Environment.NewLine + file.Name;
                                }
                            }
                            finally
                            {
                                propertyWriter.Close();
                            }
                        }
                    }
                    progressBar1.Value = Convert.ToInt32(100 * (i + 1) / files.Length);

                    if (i == files.Length - 1)
                    {
                        progressBar1.Value = 100;
                    }
                }
                ErrorList errorForm = new ErrorList(errorList);
                errorForm.ShowDialog();
            }
            catch (FileNotFoundException)
            {
                System.Windows.Forms.MessageBox.Show("Files not found exception!", "Message");
            }
        }
コード例 #22
0
ファイル: Reader.cs プロジェクト: iraychen/MSGReader
        /// <summary>
        /// Maps all the filled <see cref="Storage.Message"/> properties to the corresponding extended file attributes
        /// </summary>
        /// <param name="message">The <see cref="Storage.Message"/> object</param>
        /// <param name="propertyWriter">The <see cref="ShellPropertyWriter"/> object</param>
        private void MapEmailPropertiesToExtendedFileAttributes(Storage.Message message, ShellPropertyWriter propertyWriter)
        {
            // From
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromName, message.Sender.DisplayName);

            // Sent on
            propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, message.SentOn);

            // To
            propertyWriter.WriteProperty(SystemProperties.System.Message.ToAddress,
                message.GetEmailRecipients(Storage.Recipient.RecipientType.To, false, false));

            // CC
            propertyWriter.WriteProperty(SystemProperties.System.Message.CcAddress,
                message.GetEmailRecipients(Storage.Recipient.RecipientType.Cc, false, false));

            // BCC
            propertyWriter.WriteProperty(SystemProperties.System.Message.BccAddress,
                message.GetEmailRecipients(Storage.Recipient.RecipientType.Bcc, false, false));

            // Subject
            propertyWriter.WriteProperty(SystemProperties.System.Subject, message.Subject);

            // Urgent
            propertyWriter.WriteProperty(SystemProperties.System.Importance, message.Importance);
            propertyWriter.WriteProperty(SystemProperties.System.ImportanceText, message.ImportanceText);

            // Attachments
            var attachments = message.GetAttachmentNames();
            if (string.IsNullOrEmpty(attachments))
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, false);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, null);
            }
            else
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, true);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, attachments);
            }

            // Clear properties
            propertyWriter.WriteProperty(SystemProperties.System.StartDate, null);
            propertyWriter.WriteProperty(SystemProperties.System.DueDate, null);
            propertyWriter.WriteProperty(SystemProperties.System.DateCompleted, null);
            propertyWriter.WriteProperty(SystemProperties.System.IsFlaggedComplete, null);
            propertyWriter.WriteProperty(SystemProperties.System.FlagStatusText, null);

            // Follow up
            if (message.Flag != null)
            {
                propertyWriter.WriteProperty(SystemProperties.System.IsFlagged, true);
                propertyWriter.WriteProperty(SystemProperties.System.FlagStatusText, message.Flag.Request);

                // Flag status text
                propertyWriter.WriteProperty(SystemProperties.System.FlagStatusText, message.Task.StatusText);

                // When complete
                if (message.Task.Complete != null && (bool)message.Task.Complete)
                {
                    // Flagged complete
                    propertyWriter.WriteProperty(SystemProperties.System.IsFlaggedComplete, true);

                    // Task completed date
                    if (message.Task.CompleteTime != null)
                        propertyWriter.WriteProperty(SystemProperties.System.DateCompleted, (DateTime)message.Task.CompleteTime);
                }
                else
                {
                    // Flagged not complete
                    propertyWriter.WriteProperty(SystemProperties.System.IsFlaggedComplete, false);

                    propertyWriter.WriteProperty(SystemProperties.System.DateCompleted, null);

                    // Task startdate
                    if (message.Task.StartDate != null)
                        propertyWriter.WriteProperty(SystemProperties.System.StartDate, (DateTime)message.Task.StartDate);

                    // Task duedate
                    if (message.Task.DueDate != null)
                        propertyWriter.WriteProperty(SystemProperties.System.DueDate, (DateTime)message.Task.DueDate);
                }
            }

            // Categories
            var categories = message.Categories;
            if (categories != null)
                propertyWriter.WriteProperty(SystemProperties.System.Category, String.Join("; ", String.Join("; ", categories)));
        }
コード例 #23
0
        private void LyricsUpdateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string[] files = Directory.GetFiles(path, "*.mp3", SearchOption.AllDirectories);
                errorList = "No lyrics for the following: ";

                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo file        = new FileInfo(files[i]);
                    var      strFileName = file.DirectoryName + "\\" + file.Name;

                    ShellObject song   = ShellObject.FromParsingName(strFileName);
                    string      artist = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.AlbumArtist));
                    string      title  = GetValue(song.Properties.GetProperty(SystemProperties.System.Title));
                    string      lyrics = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.Lyrics));

                    if (artist != "" && title != "" && (lyrics == "" || lyrics.Contains(".com") || lyrics.Contains("www.") || lyrics.Contains("http")))
                    {
                        //string lyrics = GetValue(song.Properties.GetProperty(SystemProperties.System.Music.Lyrics));

                        var fileshell = ShellFile.FromFilePath(strFileName);
                        ShellPropertyWriter propertyWriter = fileshell.Properties.GetPropertyWriter();

                        try
                        {
                            var lyricsValues = SingleEdit.ChartLyricsGet(artist, title);

                            if (lyricsValues.Item1 != null && lyricsValues.Item1 != "")
                            {
                                propertyWriter.WriteProperty(SystemProperties.System.Music.Lyrics, new string[] { lyricsValues.Item1 });
                            }
                            else if (lyricsValues.Item2 == true)
                            {
                                break;
                            }
                            else
                            {
                                errorList += Environment.NewLine + file.Name;
                            }
                        }
                        finally
                        {
                            propertyWriter.Close();
                        }
                    }
                    progressBar1.Value = Convert.ToInt32(100 * (i + 1) / files.Length);

                    if (i == files.Length - 1)
                    {
                        progressBar1.Value = 100;
                    }
                }
                ErrorList errorForm = new ErrorList(errorList);
                errorForm.ShowDialog();
            }
            catch (FileNotFoundException)
            {
                System.Windows.Forms.MessageBox.Show("Files not found exception!", "Error!");
            }
        }
コード例 #24
0
        /// <summary>
        /// Maps all the filled <see cref="Storage.Message"/> properties to the corresponding extended file attributes
        /// </summary>
        /// <param name="message">The <see cref="Storage.Message"/> object</param>
        /// <param name="propertyWriter">The <see cref="ShellPropertyWriter"/> object</param>
        private void MapEmailPropertiesToExtendedFileAttributes(Storage.Message message, ShellPropertyWriter propertyWriter)
        {
            // From
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromName, message.Sender.DisplayName);

            // Sent on
            propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, message.SentOn);

            // To
            propertyWriter.WriteProperty(SystemProperties.System.Message.ToAddress,
                                         message.GetEmailRecipients(RecipientType.To, false, false));

            // CC
            propertyWriter.WriteProperty(SystemProperties.System.Message.CcAddress,
                                         message.GetEmailRecipients(RecipientType.Cc, false, false));

            // BCC
            propertyWriter.WriteProperty(SystemProperties.System.Message.BccAddress,
                                         message.GetEmailRecipients(RecipientType.Bcc, false, false));

            // Subject
            propertyWriter.WriteProperty(SystemProperties.System.Subject, message.Subject);

            // Urgent
            propertyWriter.WriteProperty(SystemProperties.System.Importance, message.Importance);
            propertyWriter.WriteProperty(SystemProperties.System.ImportanceText, message.ImportanceText);

            // Attachments
            var attachments = message.GetAttachmentNames();

            if (string.IsNullOrEmpty(attachments))
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, false);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, null);
            }
            else
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, true);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, attachments);
            }

            // Clear properties
            propertyWriter.WriteProperty(SystemProperties.System.StartDate, null);
            propertyWriter.WriteProperty(SystemProperties.System.DueDate, null);
            propertyWriter.WriteProperty(SystemProperties.System.DateCompleted, null);
            propertyWriter.WriteProperty(SystemProperties.System.IsFlaggedComplete, null);
            propertyWriter.WriteProperty(SystemProperties.System.FlagStatusText, null);

            // Follow up
            if (message.Flag != null)
            {
                propertyWriter.WriteProperty(SystemProperties.System.IsFlagged, true);
                propertyWriter.WriteProperty(SystemProperties.System.FlagStatusText, message.Flag.Request);

                // Flag status text
                propertyWriter.WriteProperty(SystemProperties.System.FlagStatusText, message.Task.StatusText);

                // When complete
                if (message.Task.Complete != null && (bool)message.Task.Complete)
                {
                    // Flagged complete
                    propertyWriter.WriteProperty(SystemProperties.System.IsFlaggedComplete, true);

                    // Task completed date
                    if (message.Task.CompleteTime != null)
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.DateCompleted, (DateTime)message.Task.CompleteTime);
                    }
                }
                else
                {
                    // Flagged not complete
                    propertyWriter.WriteProperty(SystemProperties.System.IsFlaggedComplete, false);

                    propertyWriter.WriteProperty(SystemProperties.System.DateCompleted, null);

                    // Task startdate
                    if (message.Task.StartDate != null)
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.StartDate, (DateTime)message.Task.StartDate);
                    }

                    // Task duedate
                    if (message.Task.DueDate != null)
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.DueDate, (DateTime)message.Task.DueDate);
                    }
                }
            }

            // Categories
            var categories = message.Categories;

            if (categories != null)
            {
                propertyWriter.WriteProperty(SystemProperties.System.Category, String.Join("; ", String.Join("; ", categories)));
            }
        }
コード例 #25
0
ファイル: Reader.cs プロジェクト: iraychen/MSGReader
        /// <summary>
        /// Maps all the filled <see cref="Storage.Task"/> properties to the corresponding extended file attributes
        /// </summary>
        /// <param name="message">The <see cref="Storage.Message"/> object</param>
        /// <param name="propertyWriter">The <see cref="ShellPropertyWriter"/> object</param>
        private void MapTaskPropertiesToExtendedFileAttributes(Storage.Message message, ShellPropertyWriter propertyWriter)
        {
            // From
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromName, message.Sender.DisplayName);

            // Sent on
            propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, message.SentOn);

            // Subject
            propertyWriter.WriteProperty(SystemProperties.System.Subject, message.Subject);

            // Task startdate
            propertyWriter.WriteProperty(SystemProperties.System.StartDate, message.Task.StartDate);

            // Task duedate
            propertyWriter.WriteProperty(SystemProperties.System.DueDate, message.Task.DueDate);

            // Urgent
            propertyWriter.WriteProperty(SystemProperties.System.Importance, message.Importance);
            propertyWriter.WriteProperty(SystemProperties.System.ImportanceText, message.ImportanceText);

            // Status
            propertyWriter.WriteProperty(SystemProperties.System.Status, message.Task.StatusText);

            // Percentage complete
            propertyWriter.WriteProperty(SystemProperties.System.Task.CompletionStatus, message.Task.PercentageComplete);

            // Owner
            propertyWriter.WriteProperty(SystemProperties.System.Task.Owner, message.Task.Owner);

            // Categories
            propertyWriter.WriteProperty(SystemProperties.System.Category,
                message.Categories != null ? String.Join("; ", message.Categories) : null);

            // Companies
            propertyWriter.WriteProperty(SystemProperties.System.Company,
                message.Task.Companies != null ? String.Join("; ", message.Task.Companies) : null);

            // Billing information
            propertyWriter.WriteProperty(SystemProperties.System.Task.BillingInformation, message.Task.BillingInformation);

            // Mileage
            propertyWriter.WriteProperty(SystemProperties.System.MileageInformation, message.Task.Mileage);

            // Attachments
            var attachments = message.GetAttachmentNames();
            if (string.IsNullOrEmpty(attachments))
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, false);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, null);
            }
            else
            {
                propertyWriter.WriteProperty(SystemProperties.System.Message.HasAttachments, true);
                propertyWriter.WriteProperty(SystemProperties.System.Message.AttachmentNames, attachments);
            }
        }
コード例 #26
0
ファイル: Window1.xaml.cs プロジェクト: kagada/Arianrhod
        private void SaveProperties(ShellObject so)
        {
            // Get the property writer for each file
            using (ShellPropertyWriter sw = so.Properties.GetPropertyWriter())
            {
                // Write the same set of property values for each file, since the user has selected
                // multiple files.
                // ignore the ones that aren't changed...

                #region Description Properties

                // Title
                if (TextBoxTitle.Text != MultipleValuesText)
                {
                    sw.WriteProperty(so.Properties.System.Title, !string.IsNullOrEmpty(TextBoxTitle.Text) ? TextBoxTitle.Text : null);
                }

                // Subject
                if (TextBoxSubject.Text != MultipleValuesText)
                {
                    sw.WriteProperty(so.Properties.System.Subject, !string.IsNullOrEmpty(TextBoxSubject.Text) ? TextBoxSubject.Text : null);
                }

                // Rating
                if (RatingValueControl.RatingValue != 0)
                {
                    sw.WriteProperty(so.Properties.System.SimpleRating, Convert.ToUInt32(RatingValueControl.RatingValue));
                }

                // Tags / Keywords
                // read-only property for now

                // Comments
                if (TextBoxComments.Text != MultipleValuesText)
                {
                    sw.WriteProperty(so.Properties.System.Comment, !string.IsNullOrEmpty(TextBoxComments.Text) ? TextBoxComments.Text : null);
                }

                #endregion

                #region Origin Properties

                // Authors
                // read-only property for now

                // Date Taken
                // read-only property for now

                // Date Acquired
                // read-only property for now

                // Copyright
                if (TextBoxCopyright.Text != MultipleValuesText)
                {
                    sw.WriteProperty(so.Properties.System.Copyright, !string.IsNullOrEmpty(TextBoxCopyright.Text) ? TextBoxCopyright.Text : null);
                }

                #endregion

                #region Image Properties

                // Dimensions
                // Read-only property

                // Horizontal Resolution
                // Read-only property

                // Vertical Resolution
                // Read-only property

                // Bit Depth
                // Read-only property

                #endregion
            }
        }
コード例 #27
0
ファイル: Form1.cs プロジェクト: ExpLife0011/JuusanKoubou
        private void saveFileButton_Click(object sender, EventArgs e)
        {
            // Initialize
            detailsListView.Items.Clear();
            pictureBox1.Image = null;

            // Show a CommonSaveFileDialog with couple of file filters.
            // Also show some properties (specific to the filter selected)
            // that the user can update from the dialog itself.
            CommonSaveFileDialog saveCFD = new CommonSaveFileDialog();

            saveCFD.AlwaysAppendDefaultExtension = true;
            saveCFD.DefaultExtension             = ".docx";

            // When the file type changes, we will add the specific properties
            // to be collected from the dialog (refer to the saveCFD_FileTypeChanged event handler)
            saveCFD.FileTypeChanged += new EventHandler(saveCFD_FileTypeChanged);

            saveCFD.Filters.Add(new CommonFileDialogFilter("Word Documents", "*.docx"));
            saveCFD.Filters.Add(new CommonFileDialogFilter("JPEG Files", "*.jpg"));

            if (saveCFD.ShowDialog() == CommonFileDialogResult.Ok)
            {
                // Get the selected file (this is what we'll save...)
                // Save it to disk, so we can read/write properties for it

                // Because we can't really create a Office file or Picture file, just copying
                // an existing file to show the properties
                if (saveCFD.SelectedFileTypeIndex == 1)
                {
                    File.Copy(Path.Combine(Directory.GetCurrentDirectory(), "sample files\\test.docx"), saveCFD.FileName, true);
                }
                else
                {
                    File.Copy(Path.Combine(Directory.GetCurrentDirectory(), "sample files\\test.jpg"), saveCFD.FileName, true);
                }

                // Get the ShellObject for this file
                ShellObject selectedSO = ShellFile.FromFilePath(saveCFD.FileName);

                // Get the properties from the dialog (user might have updated the properties)
                ShellPropertyCollection propColl = saveCFD.CollectedProperties;

                // Write the properties on our shell object
                using (ShellPropertyWriter propertyWriter = selectedSO.Properties.GetPropertyWriter())
                {
                    if (propColl.Contains(SystemProperties.System.Title))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Title, propColl[SystemProperties.System.Title].ValueAsObject);
                    }

                    if (propColl.Contains(SystemProperties.System.Author))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Author, propColl[SystemProperties.System.Author].ValueAsObject);
                    }

                    if (propColl.Contains(SystemProperties.System.Keywords))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Keywords, propColl[SystemProperties.System.Keywords].ValueAsObject);
                    }

                    if (propColl.Contains(SystemProperties.System.Comment))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Comment, propColl[SystemProperties.System.Comment].ValueAsObject);
                    }

                    if (propColl.Contains(SystemProperties.System.Category))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Category, propColl[SystemProperties.System.Category].ValueAsObject);
                    }

                    if (propColl.Contains(SystemProperties.System.ContentStatus))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Title, propColl[SystemProperties.System.Title].ValueAsObject);
                    }

                    if (propColl.Contains(SystemProperties.System.Photo.DateTaken))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Photo.DateTaken, propColl[SystemProperties.System.Photo.DateTaken].ValueAsObject);
                    }

                    if (propColl.Contains(SystemProperties.System.Photo.CameraModel))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Photo.CameraModel, propColl[SystemProperties.System.Photo.CameraModel].ValueAsObject);
                    }

                    if (propColl.Contains(SystemProperties.System.Rating))
                    {
                        propertyWriter.WriteProperty(SystemProperties.System.Rating, propColl[SystemProperties.System.Rating].ValueAsObject);
                    }
                }

                currentlySelected = selectedSO;
                DisplayProperties(selectedSO);

                showChildItemsButton.Enabled = selectedSO is ShellContainer ? true : false;
            }
        }
コード例 #28
0
ファイル: Reader.cs プロジェクト: iraychen/MSGReader
        /// <summary>
        /// Maps all the filled <see cref="Storage.Task"/> properties to the corresponding extended file attributes
        /// </summary>
        /// <param name="message">The <see cref="Storage.Message"/> object</param>
        /// <param name="propertyWriter">The <see cref="ShellPropertyWriter"/> object</param>
        private void MapContactPropertiesToExtendedFileAttributes(Storage.Message message, ShellPropertyWriter propertyWriter)
        {
            // From
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromAddress, message.Sender.Email);
            propertyWriter.WriteProperty(SystemProperties.System.Message.FromName, message.Sender.DisplayName);

            // Sent on
            propertyWriter.WriteProperty(SystemProperties.System.Message.DateSent, message.SentOn);

            // Full name
            propertyWriter.WriteProperty(SystemProperties.System.Contact.FullName, message.Contact.DisplayName);

            // Last name
            propertyWriter.WriteProperty(SystemProperties.System.Contact.LastName, message.Contact.SurName);

            // First name
            propertyWriter.WriteProperty(SystemProperties.System.Contact.FirstName, message.Contact.GivenName);

            // Job title
            propertyWriter.WriteProperty(SystemProperties.System.Contact.JobTitle, message.Contact.Function);

            // Department
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Department, message.Contact.Department);

            // Company
            propertyWriter.WriteProperty(SystemProperties.System.Company, message.Contact.Company);

            // Business address
            propertyWriter.WriteProperty(SystemProperties.System.Contact.BusinessAddress, message.Contact.WorkAddress);

            // Home address
            propertyWriter.WriteProperty(SystemProperties.System.Contact.HomeAddress, message.Contact.HomeAddress);

            // Other address
            propertyWriter.WriteProperty(SystemProperties.System.Contact.OtherAddress, message.Contact.OtherAddress);

            // Instant messaging
            propertyWriter.WriteProperty(SystemProperties.System.Contact.IMAddress, message.Contact.InstantMessagingAddress);

            // Business telephone number
            propertyWriter.WriteProperty(SystemProperties.System.Contact.BusinessTelephone, message.Contact.BusinessTelephoneNumber);

            // Assistant's telephone number
            propertyWriter.WriteProperty(SystemProperties.System.Contact.AssistantTelephone, message.Contact.AssistantTelephoneNumber);

            // Company main phone
            propertyWriter.WriteProperty(SystemProperties.System.Contact.CompanyMainTelephone, message.Contact.CompanyMainTelephoneNumber);

            // Home telephone number
            propertyWriter.WriteProperty(SystemProperties.System.Contact.HomeTelephone, message.Contact.HomeTelephoneNumber);

            // Mobile phone
            propertyWriter.WriteProperty(SystemProperties.System.Contact.MobileTelephone, message.Contact.CellularTelephoneNumber);

            // Car phone
            propertyWriter.WriteProperty(SystemProperties.System.Contact.CarTelephone, message.Contact.CarTelephoneNumber);

            // Callback
            propertyWriter.WriteProperty(SystemProperties.System.Contact.CallbackTelephone, message.Contact.CallbackTelephoneNumber);

            // Primary telephone number
            propertyWriter.WriteProperty(SystemProperties.System.Contact.PrimaryTelephone, message.Contact.PrimaryTelephoneNumber);

            // Telex
            propertyWriter.WriteProperty(SystemProperties.System.Contact.TelexNumber, message.Contact.TelexNumber);

            // TTY/TDD phone
            propertyWriter.WriteProperty(SystemProperties.System.Contact.TTYTDDTelephone, message.Contact.TextTelephone);

            // Business fax
            propertyWriter.WriteProperty(SystemProperties.System.Contact.BusinessFaxNumber, message.Contact.BusinessFaxNumber);

            // Home fax
            propertyWriter.WriteProperty(SystemProperties.System.Contact.HomeFaxNumber, message.Contact.HomeFaxNumber);

            // E-mail
            propertyWriter.WriteProperty(SystemProperties.System.Contact.EmailAddress, message.Contact.Email1EmailAddress);
            propertyWriter.WriteProperty(SystemProperties.System.Contact.EmailName, message.Contact.Email1DisplayName);

            // E-mail 2
            propertyWriter.WriteProperty(SystemProperties.System.Contact.EmailAddress2, message.Contact.Email2EmailAddress);

            // E-mail 3
            propertyWriter.WriteProperty(SystemProperties.System.Contact.EmailAddress3, message.Contact.Email3EmailAddress);

            // Birthday
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Birthday, message.Contact.Birthday);

            // Anniversary
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Anniversary, message.Contact.WeddingAnniversary);

            // Spouse/Partner
            propertyWriter.WriteProperty(SystemProperties.System.Contact.SpouseName, message.Contact.SpouseName);

            // Profession
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Profession, message.Contact.Profession);

            // Assistant
            propertyWriter.WriteProperty(SystemProperties.System.Contact.AssistantName, message.Contact.AssistantName);

            // Web page
            propertyWriter.WriteProperty(SystemProperties.System.Contact.Webpage, message.Contact.Html);

            // Categories
            var categories = message.Categories;
            if (categories != null)
                propertyWriter.WriteProperty(SystemProperties.System.Category, String.Join("; ", String.Join("; ", categories)));
        }