windows: improve UI

This commit is contained in:
wimh 2011-06-12 01:24:22 +02:00
parent b60a21731a
commit 532085c3ab
8 changed files with 332 additions and 34 deletions

View file

@ -973,7 +973,7 @@ namespace SparkleShare {
foreach (SparkleRepoBase repo in Repositories)
repo.Dispose ();
Environment.Exit (0);
Gtk.Application.Quit ();
}

View file

@ -21,6 +21,7 @@ using System.Timers;
using Gtk;
using Mono.Unix;
using SparkleLib;
namespace SparkleShare {
@ -272,7 +273,11 @@ namespace SparkleShare {
// Makes the menu visible
private void ShowMenu (object o, EventArgs args)
{
Menu.Popup (null, null, SetPosition, 0, Global.CurrentEventTime);
if ((SparkleBackend.Platform == PlatformID.Unix ||
SparkleBackend.Platform == PlatformID.MacOSX))
Menu.Popup (null, null, SetPosition, 0, Global.CurrentEventTime);
else
Menu.Popup (null, null, null, 0, Global.CurrentEventTime);
}

View file

@ -169,6 +169,7 @@ namespace SparkleShare {
public void Run ()
{
Application.Run ();
StatusIcon.Dispose ();
}
}
}

View file

@ -16,40 +16,77 @@
using System;
using Gdk;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
namespace Notifications
{
public enum Urgency : byte {
Low = 0,
Normal,
Critical
}
public class ActionArgs : EventArgs {
private string action;
public string Action {
get { return action; }
}
public ActionArgs (string action) {
this.action = action;
}
}
public delegate void ActionHandler (object o, ActionArgs args);
public class Notification
public partial class Notification : Form
{
public Pixbuf Icon;
private Timer animationTimer;
private int startPosX;
private int startPosY;
public new Gdk.Pixbuf Icon;
public Notification ()
{
}
InitializeComponent ();
public Notification (string title, string subtext)
{
}
TopMost = true;
ShowInTaskbar = false;
animationTimer = new Timer ();
animationTimer.Interval = 50;
animationTimer.Tick += timer_Tick;
}
public Notification (string title, string subtext)
: this()
{
this.title.Text = title;
this.subtext.Text = subtext;
}
protected override void OnLoad (EventArgs e)
{
// Move window out of screen
startPosX = Screen.PrimaryScreen.WorkingArea.Width - Width;
startPosY = Screen.PrimaryScreen.WorkingArea.Height;
SetDesktopLocation (startPosX, startPosY);
base.OnLoad (e);
// Begin animation
animationTimer.Start ();
}
protected override void OnShown (EventArgs e)
{
base.OnShown (e);
// hacky way to move the image from a Gdk.Pixbuf to a winforms bitmap
string Filename = Path.GetTempFileName ();
File.Delete (Filename);
Filename = Path.ChangeExtension (Filename, "bmp");
if (File.Exists (Filename))
File.Delete (Filename);
this.Icon.Save (Filename, "bmp");
using (Stream s = File.OpenRead (Filename))
pictureBox1.Image = Bitmap.FromStream (s);
File.Delete (Filename);
}
void timer_Tick (object sender, EventArgs e)
{
startPosY -= 5;
if (startPosY < Screen.PrimaryScreen.WorkingArea.Height - Height)
animationTimer.Stop ();
else
SetDesktopLocation (startPosX, startPosY);
}
public void AddAction (string action, string label, ActionHandler handler)
{
@ -63,8 +100,29 @@ namespace Notifications
{
}
public void Show ()
{
}
}
public enum Urgency : byte
{
Low = 0,
Normal,
Critical
}
public class ActionArgs : EventArgs
{
private string action;
public string Action
{
get { return action; }
}
public ActionArgs (string action)
{
this.action = action;
}
}
public delegate void ActionHandler (object o, ActionArgs args);
}

View file

@ -0,0 +1,96 @@
namespace Notifications
{
partial class Notification
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox ();
this.title = new System.Windows.Forms.Label ();
this.subtext = new System.Windows.Forms.Label ();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit ();
this.SuspendLayout ();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point (12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size (40, 42);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// title
//
this.title.AutoSize = true;
this.title.Font = new System.Drawing.Font ("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.title.Location = new System.Drawing.Point (58, 9);
this.title.Name = "title";
this.title.Size = new System.Drawing.Size (28, 13);
this.title.TabIndex = 1;
this.title.Text = "title";
//
// subtext
//
this.subtext.AutoSize = true;
this.subtext.Location = new System.Drawing.Point (58, 22);
this.subtext.MaximumSize = new System.Drawing.Size (171, 0);
this.subtext.Name = "subtext";
this.subtext.Size = new System.Drawing.Size (41, 13);
this.subtext.TabIndex = 2;
this.subtext.Text = "subtext";
//
// Notification
//
this.AutoScaleDimensions = new System.Drawing.SizeF (6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size (241, 64);
this.ControlBox = false;
this.Controls.Add (this.subtext);
this.Controls.Add (this.title);
this.Controls.Add (this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Notification";
this.Opacity = 0.8;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit ();
this.ResumeLayout (false);
this.PerformLayout ();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label title;
private System.Windows.Forms.Label subtext;
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -24,7 +24,11 @@ namespace SparkleShare {
public SparkleBubble (string title, string subtext) : base (title, subtext)
{
}
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer ();
timer.Tick += delegate { this.Close (); };
timer.Interval = 4500;
timer.Start ();
}
// Checks whether the system allows adding buttons to a notification,
// prevents error messages in Ubuntu.

View file

@ -58,6 +58,8 @@
</Reference>
<Reference Include="System" />
<Reference Include="Mono.Posix" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
<Reference Include="webkit-sharp, Version=1.1.15.0, Culture=neutral, PublicKeyToken=eaa1d335d2e19745">
<SpecificVersion>False</SpecificVersion>
@ -72,8 +74,15 @@
<DependentUpon>GlobalAssemblyInfo.tt</DependentUpon>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Notification.cs" />
<Compile Include="SparkleBubble.cs" />
<Compile Include="Notification.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Notification.designer.cs">
<DependentUpon>Notification.cs</DependentUpon>
</Compile>
<Compile Include="SparkleBubble.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="..\SparkleIntro.cs" />
<Compile Include="..\SparkleShare.cs" />
<Compile Include="..\SparkleSpinner.cs" />
@ -140,4 +149,9 @@
<PropertyGroup>
<PreBuildEvent>$(ProjectDir)transform_tt.cmd</PreBuildEvent>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Notification.resx">
<DependentUpon>Notification.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
</Project>