From b4a1b49a8b5dbffad375c6f9e45ac687731b22dd Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 7 Mar 2012 01:55:10 +0000 Subject: [PATCH] windows: implement full (but ugly) balloons --- SparkleShare/Windows/SparkleBubbles.cs | 3 +- SparkleShare/Windows/SparkleShare.csproj | 4 --- SparkleShare/Windows/SparkleStatusIcon.cs | 34 ++++++++++++----------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/SparkleShare/Windows/SparkleBubbles.cs b/SparkleShare/Windows/SparkleBubbles.cs index bf895239..7bd87543 100644 --- a/SparkleShare/Windows/SparkleBubbles.cs +++ b/SparkleShare/Windows/SparkleBubbles.cs @@ -16,7 +16,6 @@ using System; -using System.Windows.Forms; namespace SparkleShare { @@ -30,7 +29,7 @@ namespace SparkleShare { Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) { - // TODO SparkleUI.StatusIcon.ShowBalloon (title, subtext, image_path); + SparkleUI.StatusIcon.ShowBalloon (title, subtext, image_path); }; } } diff --git a/SparkleShare/Windows/SparkleShare.csproj b/SparkleShare/Windows/SparkleShare.csproj index b3d885ed..0dd30953 100644 --- a/SparkleShare/Windows/SparkleShare.csproj +++ b/SparkleShare/Windows/SparkleShare.csproj @@ -203,10 +203,6 @@ Resources.Designer.cs Designer - - SparkleSetup.cs - Designer - Pixmaps\about.png diff --git a/SparkleShare/Windows/SparkleStatusIcon.cs b/SparkleShare/Windows/SparkleStatusIcon.cs index f20e164c..efb3ad81 100644 --- a/SparkleShare/Windows/SparkleStatusIcon.cs +++ b/SparkleShare/Windows/SparkleStatusIcon.cs @@ -19,12 +19,10 @@ using System; using System.Drawing; using System.IO; using System.Runtime.InteropServices; - -using Forms = System.Windows.Forms; -using System.Windows.Controls; using System.Windows; +using System.Windows.Controls; using System.Windows.Controls.Primitives; - +using Forms = System.Windows.Forms; namespace SparkleShare { @@ -41,11 +39,10 @@ namespace SparkleShare { private MenuItem exit_item; private Forms.NotifyIcon notify_icon = new Forms.NotifyIcon () { - Text = "SparkleShare", + Text = "SparkleShare", Visible = true }; - // Short alias for the translations public static string _ (string s) @@ -56,11 +53,6 @@ namespace SparkleShare { public SparkleStatusIcon () { - LostFocus += delegate { - - this.context_menu.IsOpen = false; - }; - AnimationFrames = CreateAnimationFrames (); Animation = CreateAnimation (); notify_icon.Icon = AnimationFrames [0]; @@ -112,9 +104,6 @@ namespace SparkleShare { } - [DllImport("user32.dll", EntryPoint = "DestroyIcon")] - static extern bool DestroyIcon(IntPtr hIcon); - // Slices up the graphic that contains the // animation frames. @@ -315,7 +304,16 @@ namespace SparkleShare { } } } - + + + public void ShowBalloon (string title, string subtext, string image_path) + { + // TODO: + // - Use the image pointed to by image_path + // - Find a way to use the prettier (Win7?) balloons + this.notify_icon.ShowBalloonTip (5 * 1000, title, subtext, Forms.ToolTipIcon.Info); + } + public void Dispose () { @@ -348,8 +346,12 @@ namespace SparkleShare { IntPtr unmanaged_icon = bitmap.GetHicon (); Icon icon = (Icon) Icon.FromHandle (unmanaged_icon).Clone (); DestroyIcon (unmanaged_icon); - + return icon; } + + + [DllImport("user32.dll", EntryPoint = "DestroyIcon")] + static extern bool DestroyIcon (IntPtr hIcon); } }