Exemplo n.º 1
0
        internal PastNotification(Growl.DisplayStyle.NotificationLite nl, DateTime timestamp, string imageFile)

        {
            this.notification = nl;

            this.timestamp = timestamp;

            this.imageFile = imageFile;
        }
Exemplo n.º 2
0
        public static PastNotification Save(Growl.DisplayStyle.Notification notification, string requestID, DateTime timestamp)
        {
            Growl.DisplayStyle.NotificationLite notificationLite = Growl.DisplayStyle.NotificationLite.Clone(notification);
            string path = Growl.CoreLibrary.PathUtility.Combine(historyFolder, Growl.CoreLibrary.PathUtility.GetSafeFolderName(notificationLite.ApplicationName));

            Growl.CoreLibrary.PathUtility.EnsureDirectoryExists(path);

            // save image data
            string imageFile = null;

            if (notification.Image != null && notification.Image.IsSet)
            {
                System.Drawing.Image image = (System.Drawing.Image)notification.Image;
                using (image)
                {
                    System.Drawing.Image thumbnail = GenerateThumbnail(image, 48, 48);
                    if (thumbnail != null)
                    {
                        using (thumbnail)
                        {
                            string imagefilename = String.Format(@"{0}.img", requestID);
                            imageFile = Growl.CoreLibrary.PathUtility.Combine(path, imagefilename);

                            thumbnail.Save(imageFile);
                        }
                    }
                }
            }

            PastNotification pn = new PastNotification(notificationLite, timestamp, imageFile);

            // save text data
            string filename = String.Format(@"{0}.notification", requestID);
            string filepath = Growl.CoreLibrary.PathUtility.Combine(path, filename);

            System.IO.StreamWriter w = System.IO.File.CreateText(filepath);
            using (w)
            {
                string data = Serialization.SerializeObject(pn);
                w.Write(data);
                data = null;
            }

            return(pn);
        }