From bdb317a8459e7522fc29461f59aa58863ee9c1a0 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 4 Mar 2012 14:09:31 +0000 Subject: [PATCH] windows: Finish up about dialog style --- SparkleShare/Windows/SparkleAbout.cs | 118 ++++++++++++---------- SparkleShare/Windows/SparkleStatusIcon.cs | 32 ++++-- 2 files changed, 85 insertions(+), 65 deletions(-) diff --git a/SparkleShare/Windows/SparkleAbout.cs b/SparkleShare/Windows/SparkleAbout.cs index 666577ca..b0d5bbc2 100644 --- a/SparkleShare/Windows/SparkleAbout.cs +++ b/SparkleShare/Windows/SparkleAbout.cs @@ -23,6 +23,9 @@ using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Imaging; + namespace SparkleShare { @@ -30,8 +33,6 @@ namespace SparkleShare { public SparkleAboutController Controller = new SparkleAboutController (); - private Label version; - private Label copyright; private Label updates; @@ -44,24 +45,20 @@ namespace SparkleShare { public SparkleAbout () { - Title = "About SparkleShare"; -// Icon = Icons.sparkleshare; - + Title = "About SparkleShare"; ResizeMode = ResizeMode.NoResize; + Height = 288; + Width = 640; - - //BackgroundImage = Icons.about; - Height = 300; - Width = 600; - //Closing - // += Close; - + Closing += Close; + CreateAbout (); - + Controller.ShowWindowEvent += delegate { Dispatcher.Invoke ((Action) delegate { Show (); + Activate (); BringIntoView (); }); }; @@ -97,63 +94,72 @@ namespace SparkleShare { private void CreateAbout () { - this.version = new Label () { - - - Content = "version " + Controller.RunningVersion - }; + Image image = new Image () { + Width = 640, + Height = 260 + }; + + BitmapImage bitmap_image = new BitmapImage(); + bitmap_image.BeginInit(); + // TODO: get relative reference to the image + bitmap_image.UriSource = new Uri(@"C:\Users\Hylke\Code\SparkleShare\data\about.png"); + bitmap_image.DecodePixelWidth = 640; + bitmap_image.EndInit(); + + image.Source = bitmap_image; + + + Label version = new Label () { + Content = "version " + Controller.RunningVersion, + FontSize = 11, + Foreground = new SolidColorBrush (Colors.White) + }; this.updates = new Label () { - Content = "Checking for updates..." + Content = "Checking for updates...", + FontSize = 11, + Foreground = new SolidColorBrush (Color.FromRgb(45, 62, 81)) }; - - - this.copyright = new Label () { - Content = "Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others.\n" + + TextBlock credits = new TextBlock () { + FontSize = 11, + Foreground = new SolidColorBrush (Colors.White), + Text = "Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others.\n" + + "\n" + "SparkleShare is Free and Open Source Software. You are free to use, modify, " + - "and redistribute it under the GNU General Public License version 3 or later." - }; - - Button b = new Button (); - b.Content = "FFF"; - + "and redistribute it under the GNU General Public License version 3 or later.", + TextWrapping = TextWrapping.Wrap, + Width = 318 + }; + + Canvas canvas = new Canvas (); - canvas.Children.Add(this.version); - Canvas.SetLeft(this.version, 302); - Canvas.SetTop(this.version, 102); + canvas.Children.Add (image); + Canvas.SetLeft (image, 0); + Canvas.SetTop (image, 0); + + canvas.Children.Add (version); + Canvas.SetLeft (version, 289); + Canvas.SetTop (version, 92); - canvas.Children.Add(this.updates); - Canvas.SetLeft(this.updates, 302); - Canvas.SetTop(this.updates, 122); - - canvas.Children.Add(this.copyright); - Canvas.SetLeft(this.copyright, 302); - Canvas.SetTop(this.copyright, 142); + canvas.Children.Add (this.updates); + Canvas.SetLeft (this.updates, 289); + Canvas.SetTop (this.updates, 109); + canvas.Children.Add (credits); + Canvas.SetLeft (credits, 294); + Canvas.SetTop (credits, 142); Content = canvas; - //AddChild(this.version); - //AddChild(this.updates); - //AddChild(this.copyright); - Show (); } - - - - /* - - private void Close (object sender, Clos) + + + private void Close (object sender, CancelEventArgs args) { - if (args.CloseReason != CloseReason.ApplicationExitCall && - args.CloseReason != CloseReason.TaskManagerClosing && - args.CloseReason != CloseReason.WindowsShutDown) { - Controller.WindowClosed (); - args.Cancel = true; - } - }*/ + args.Cancel = true; + } } } diff --git a/SparkleShare/Windows/SparkleStatusIcon.cs b/SparkleShare/Windows/SparkleStatusIcon.cs index ff2175e3..3c7d9767 100644 --- a/SparkleShare/Windows/SparkleStatusIcon.cs +++ b/SparkleShare/Windows/SparkleStatusIcon.cs @@ -48,20 +48,34 @@ namespace SparkleShare { - void notifier_MouseDown(object sender, WinForms.MouseEventArgs e) + void notifier_MouseDown(object o, EventArgs e) { + ContextMenu menu = new ContextMenu (); + MenuItem item0 = new MenuItem () {Header = " Files up to date"}; + item0.IsEnabled = false; MenuItem item = new MenuItem () {Header = " SparkleShare"}; - - MenuItem item2 = new MenuItem () {Header = " Add Hosted Project..."}; + + // item.Icon = ; - MenuItem item3 = new MenuItem () {Header = " View Recent Changes..."}; + MenuItem item2 = new MenuItem () {Header = " Add Hosted Project…"}; + + MenuItem item3 = new MenuItem () {Header = " View Recent Changes…"}; MenuItem item4 = new MenuItem () {Header = " Turn Notifications Off"}; MenuItem item5 = new MenuItem () {Header = " About SparkleShare"}; + item5.Click += delegate { + Controller.AboutClicked (); + }; + MenuItem item6 = new MenuItem () {Header = " Exit"}; + item6.Click += delegate { + this.status_icon.Dispose (); + Program.Controller.Quit (); + }; - MenuItem item6 = new MenuItem () {Header = " Quit"}; + menu.Items.Add (item0); + menu.Items.Add (new Separator ()); menu.Items.Add (item); menu.Items.Add (new Separator ());menu.Items.Add (item2); menu.Items.Add (new Separator ()); @@ -72,11 +86,11 @@ namespace SparkleShare { menu.Items.Add (new Separator ()); menu.Items.Add (item6); - menu.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint; + menu.Placement = System.Windows.Controls.Primitives.PlacementMode.Mouse; menu.IsOpen = true; menu.IsHitTestVisible=true; - Window w = new Window (); + /* Window w = new Window (); w.Title = "test"; w.Show (); @@ -85,7 +99,7 @@ namespace SparkleShare { w.BringIntoView (); - + */ } @@ -100,7 +114,7 @@ namespace SparkleShare { status_icon.Icon = Icons.sparkleshare; status_icon.Visible = true; - this.status_icon.MouseDown += new WinForms.MouseEventHandler(notifier_MouseDown); + this.status_icon.Click += notifier_MouseDown;