コード例 #1
0
        private ListViewItem CreateItem(PastNotification pn)
        {
            ListViewGroup group = null;

            if (this.groupBy == HistoryGroupItemsBy.Date)
            {
                group = GetDateGroup(pn.Timestamp);
            }
            else
            {
                group = this.Groups[pn.Notification.ApplicationName];
            }

            string title   = Escape(pn.Notification.Title);
            string text    = Escape(pn.Notification.Description);
            string appName = Escape(pn.Notification.ApplicationName);
            string origin  = (!String.IsNullOrEmpty(pn.Notification.OriginMachineName) ? pn.Notification.OriginMachineName : "Local Machine");
            string tooltipAppNameappName = Escape(String.Format("{0}{1}", pn.Notification.ApplicationName, (!String.IsNullOrEmpty(pn.Notification.OriginMachineName) ? String.Format("[{0}]", pn.Notification.OriginMachineName) : "")));
            string tooltip = String.Format("{0}\r\n{1}\r\n{4}: {2}\r\n{5}: {3}", pn.Notification.Title, pn.Notification.Description, tooltipAppNameappName, pn.Timestamp.ToString(), Properties.Resources.LiteralString_ReceivedFrom, Properties.Resources.LiteralString_ReceivedAt);

            string[]     items = new string[] { title, text, appName, pn.Timestamp.ToString(), origin };
            ListViewItem lvi   = new ListViewItem(items, group);

            lvi.ToolTipText = tooltip;
            lvi.Tag         = pn;
            return(lvi);
        }
コード例 #2
0
        public void AddNotification(PastNotification pn)

        {
            this.pastNotifications.Add(pn);



            this.Draw();
        }
コード例 #3
0
 /// <summary>
 /// Gets the specified from the cache
 /// </summary>
 /// <param name="applicationName">The application that owns the resource</param>
 /// <param name="resourceID">The resource ID</param>
 /// <returns>
 /// <see cref="Image"/> if the resource exists in the cache, <c>null</c> otherwise
 /// </returns>
 public static Image GetImage(PastNotification pn)
 {
     Image image = null;
     if (pn != null && pn.HasImage)
     {
         try
         {
             image = Growl.CoreLibrary.ImageConverter.ImageFromUrl(pn.ImageFile);
         }
         catch
         {
         }
     }
     return image;
 }
コード例 #4
0
        private ListViewItem CreateItem(PastNotification pn)
        {
            ListViewGroup group = null;
            if (this.groupBy == HistoryGroupItemsBy.Date)
            {
                group = GetDateGroup(pn.Timestamp);
            }
            else
            {
                group = this.Groups[pn.Notification.ApplicationName];
            }

            string title = Escape(pn.Notification.Title);
            string text = Escape(pn.Notification.Description);
            string appName = Escape(pn.Notification.ApplicationName);
            string origin = (!String.IsNullOrEmpty(pn.Notification.OriginMachineName) ? pn.Notification.OriginMachineName : "Local Machine");
            string tooltipAppNameappName = Escape(String.Format("{0}{1}", pn.Notification.ApplicationName, (!String.IsNullOrEmpty(pn.Notification.OriginMachineName) ? String.Format("[{0}]", pn.Notification.OriginMachineName) : "")));
            string tooltip = String.Format("{0}\r\n{1}\r\n{4}: {2}\r\n{5}: {3}", pn.Notification.Title, pn.Notification.Description, tooltipAppNameappName, pn.Timestamp.ToString(), Properties.Resources.LiteralString_ReceivedFrom, Properties.Resources.LiteralString_ReceivedAt);

            string[] items = new string[] { title, text, appName, pn.Timestamp.ToString(), origin };
            ListViewItem lvi = new ListViewItem(items, group);
            lvi.ToolTipText = tooltip;
            lvi.Tag = pn;
            return lvi;
        }
コード例 #5
0
        public void AddNotification(PastNotification pn)
        {
            this.pastNotifications.Add(pn);

            this.Draw();
        }
コード例 #6
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;
        }
コード例 #7
0
ファイル: EventArgs.cs プロジェクト: iwaim/growl-for-windows
 public NotificationPastEventArgs(PastNotification pn)
 {
     this.pn = pn;
 }
コード例 #8
0
 private void OnNotificationPast(PastNotification pn)
 {
     if (this.synchronizingObject != null && this.synchronizingObject.InvokeRequired)
     {
         MethodInvoker invoker = new MethodInvoker(delegate()
         {
             OnNotificationPast(pn);
         });
         this.synchronizingObject.Invoke(invoker, null);
     }
     else
     {
         if (this.NotificationPast != null)
         {
             this.NotificationPast(pn);
         }
     }
 }
コード例 #9
0
 private void AddToMissedNotificationList(PastNotification pn)
 {
     if (this.CheckForIdle || this.idle || this.paused)
         this.missedNotifications.Add(pn);
 }
コード例 #10
0
        void HistoryListView_DrawItem(object sender, DrawListViewItemEventArgs e)

        {
            if (e.ItemIndex < 0)
            {
                return;
            }



            if (this.View == View.Tile)

            {
                // draw the background and focus rectangle for selected and non-selected states

                if (this.SelectedIndices.Contains(e.ItemIndex))

                {
                    e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);

                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Bounds);
                }

                else

                {
                    e.DrawBackground();
                }



                // draw icon

                PastNotification pn = (PastNotification)e.Item.Tag;

                int newX = e.Bounds.Left;

                if (pn != null)

                {
                    System.Drawing.Image img = PastNotificationManager.GetImage(pn);

                    using (img)

                    {
                        if (img != null)

                        {
                            int x = e.Bounds.Left + 1;

                            int y = e.Bounds.Top + 1;

                            e.Graphics.DrawImage(img, x, y);

                            newX = e.Bounds.Left + img.Width + this.Margin.Right;
                        }
                    }
                }



                // draw main text

                System.Drawing.RectangleF rect = new System.Drawing.RectangleF(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);

                System.Drawing.StringFormat sf = new System.Drawing.StringFormat();

                sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;

                sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip;

                System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(e.Item.ForeColor);

                string text = e.Item.Text.Replace("\r", " - ");

                using (foreBrush)

                {
                    e.Graphics.DrawString(text,

                                          e.Item.Font,

                                          foreBrush,

                                          rect,

                                          sf);
                }



                // draw subitems

                System.Drawing.Color subColor = System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb());

                System.Drawing.SolidBrush subBrush = new System.Drawing.SolidBrush(subColor);

                using (subBrush)

                {
                    for (int i = 1; i < this.Columns.Count; i++)

                    {
                        if (i < e.Item.SubItems.Count)

                        {
                            text = e.Item.SubItems[i].Text.Replace("\r", " - ");

                            rect.Offset(0, e.Item.Font.Height);

                            e.Graphics.DrawString(text,

                                                  e.Item.Font,

                                                  subBrush,

                                                  rect,

                                                  sf);
                        }
                    }
                }
            }

            else

            {
                // DO NOT call e.DrawDefault or the DrawSubItem event will not be fired

                //e.DrawDefault = true;
            }
        }
コード例 #11
0
        void HistoryListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)

        {
            if (e.ItemIndex < 0)
            {
                return;
            }



            //Console.WriteLine(e.ItemIndex + "-" + e.Bounds);



            if (this.SelectedIndices.Contains(e.ItemIndex))

            {
                e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds);

                ControlPaint.DrawFocusRectangle(e.Graphics, e.Item.Bounds);
            }

            else

            {
                e.DrawBackground();
            }



            // if this is the first column, we want to draw an icon as well

            int newX = e.Bounds.Left;

            if (e.ColumnIndex == 0)

            {
                // draw the icon

                newX = newX + 20;

                PastNotification pn = (PastNotification)e.Item.Tag;

                if (pn != null)

                {
                    System.Drawing.Image img = PastNotificationManager.GetImage(pn);

                    using (img)

                    {
                        if (img != null)

                        {
                            int x = e.Bounds.Left + 2;

                            int y = e.Bounds.Top;

                            e.Graphics.DrawImage(img, new System.Drawing.Rectangle(x, y, 16, 16));
                        }
                    }
                }
            }



            // draw text

            string text = e.SubItem.Text.Replace("\r", " - ");

            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height);

            System.Drawing.StringFormat sf = new System.Drawing.StringFormat();

            sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;

            sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip | System.Drawing.StringFormatFlags.NoWrap;

            System.Drawing.Color color = (e.ColumnIndex == 0 ? e.Item.ForeColor : System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb()));

            System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(color);

            using (foreBrush)

            {
                //TextFormatFlags flags = TextFormatFlags.Default | TextFormatFlags.ExternalLeading | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.NoClipping | TextFormatFlags.EndEllipsis | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine;

                //TextRenderer.DrawText(e.Graphics, text, e.SubItem.Font, rect, e.SubItem.ForeColor, System.Drawing.Color.Transparent, flags);



                e.Graphics.DrawString(text,

                                      e.SubItem.Font,

                                      foreBrush,

                                      rect,

                                      sf);
            }
        }