/// <summary>
 /// Creates a instance of the <see cref="NotificationType"/> class.
 /// </summary>
 /// <param name="name">The name of this type of notification</param>
 /// <param name="displayName">The display name of this type of notification</param>
 /// <param name="icon">The default icon for notifications of this type</param>
 /// <param name="enabled"><c>true</c> if this type of notification should be enabled by default; <c>false</c> if this type of notification should be disabled by default</param>
 public NotificationType(string name, string displayName, Resource icon, bool enabled)
 {
     this.name = name;
     this.displayName = displayName;
     this.icon = icon;
     this.enabled = enabled;
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a instance of the <see cref="Notification"/> class.
 /// </summary>
 /// <param name="applicationName">The name of the application sending the notification</param>
 /// <param name="notificationName">The notification name (type)</param>
 /// <param name="id">A unique ID for the notification</param>
 /// <param name="title">The notification title</param>
 /// <param name="text">The notification text</param>
 /// <param name="icon">A <see cref="Resource"/> for the icon associated with the notification</param>
 /// <param name="sticky"><c>true</c> to suggest that the notification should be sticky;<c>false</c> otherwise</param>
 /// <param name="priority">The <see cref="Priority"/> of the notification</param>
 /// <param name="coalescingID">The coalescing (grouping) ID (used to replace exisiting notifications)</param>
 public Notification(string applicationName, string notificationName, string id, string title, string text, Resource icon, bool sticky, Priority priority, string coalescingID)
 {
     this.applicationName = applicationName;
     this.name = notificationName;
     this.id = id;
     this.title = title;
     this.text = text;
     this.icon = icon;
     this.sticky = sticky;
     this.priority = priority;
     this.coalescingID = coalescingID;
 }
Esempio n. 3
0
        /// <summary>
        /// Adds the specified resource to the cache
        /// </summary>
        /// <param name="applicationName">The application that owns the resource</param>
        /// <param name="resource"><see cref="Resource"/> to cache</param>
        /// <returns>The ID of the added resource</returns>
        public static string Add(string applicationName, Resource resource)
        {
            string id = null;
            if (IsCacheConfigured && !String.IsNullOrEmpty(applicationName) && resource != null)
            {
                string path = GetApplicationCacheDirectoryName(applicationName);
                DirectoryInfo appDirectory = CreateAppCacheDirectory(path); // do this every time, in case the underlying filesystem has changed
                if (!cache.ContainsKey(appDirectory.FullName))
                {
                    cache.Add(appDirectory.FullName, new Dictionary<string, string>());
                }

                id = PathUtility.GetSafeFileName(resource.GetKey());

                Dictionary<string, string> appCache = cache[appDirectory.FullName];
                if (appCache.ContainsKey(id)) appCache.Remove(id);

                string filename = String.Format(@"{0}{1}", id, EXTENSION);
                string filepath = PathUtility.Combine(appDirectory.FullName, filename);

                System.Drawing.Image image = (Image)resource;
                using (image)
                {
                    if(image != null) image.Save(filepath);
                }

                if (!appCache.ContainsKey(id))
                    appCache.Add(id, filepath);
            }
            return id;
        }
Esempio n. 4
0
 /// <summary>
 /// Creates a new instance of the <see cref="Header"/> class
 /// </summary>
 /// <param name="name">The header name</param>
 /// <param name="val">The header value</param>
 public Header(string name, Resource val)
 {
     if (val != null)
     {
         Initialize(name, val.ToString());
         if (val.IsRawData) this.GrowlResource = val.Data;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Creates a new instance of the <see cref="DataHeader"/> class
 /// </summary>
 /// <param name="name">The header name</param>
 /// <param name="val">The header value</param>
 public DataHeader(string name, Resource val)
     : base(FormatName(name), val)
 {
 }
 public void SetIcon(Resource resource)
 {
     this.IconID = ImageCache.Add(this.Name, resource);
 }
 public void SetIcon(Resource resource, string applicationName)
 {
     this.IconID = ImageCache.Add(applicationName, resource);
 }
 public void SetIcon(Resource resource)
 {
     SetIcon(resource, this.ApplicationName);
 }