Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit cd32db54a279389d99f6a4a2f8b7af508f3ebc60 @shellscape committed Jul 26, 2010
Showing 311 changed files with 78,727 additions and 0 deletions.
@@ -0,0 +1 @@
+/*.suo
@@ -0,0 +1,87 @@
+namespace GmailNotifierPlus {
+
+ using System;
+ using System.Xml;
+ using System.Xml.Serialization;
+
+ public enum AccountTypes {
+ Regular,
+ GoogleApps
+ }
+
+ public class Account {
+
+ public static class Domains {
+ public const String Gmail = "gmail.com";
+ public const String GmailAlt = "googlemail.com";
+ public const String GmailUK = "googlemail.co.uk";
+ public const String WindowTitle = "Gmail Notifier Plus";
+ }
+
+ public String Login { get; set; }
+ public String Password { get; set; }
+ public Boolean Default { get; set; }
+
+ [XmlIgnore]
+ public String Domain { get; private set; }
+
+ [XmlIgnore]
+ public String FullAddress { get; private set; }
+
+ [XmlIgnore]
+ public String Name { get; private set; }
+
+ [XmlIgnore]
+ public AccountTypes Type { get; private set; }
+
+ public Account() {
+ this.Login = this.Password = this.Name = this.Domain = this.FullAddress = String.Empty;
+ this.Type = AccountTypes.Regular;
+ }
+
+ public Account(String login, String password) {
+
+ this.Login = login;
+ this.Password = password;
+
+ Init();
+ }
+
+ public void Init() {
+ if (!String.IsNullOrEmpty(this.Login)) {
+ String[] strArray = this.Login.Split(new char[] { '@' });
+
+ if ((strArray.Length > 1) && !String.IsNullOrEmpty(strArray[1])) {
+ this.Name = strArray[0];
+ this.Domain = strArray[1];
+ }
+ else {
+ this.Name = this.Login;
+ this.Domain = Domains.Gmail;
+ }
+
+ if (((this.Domain == Domains.Gmail) || (this.Domain == Domains.GmailAlt)) || (this.Domain == Domains.GmailUK)) {
+ this.Type = AccountTypes.Regular;
+ }
+ else {
+ this.Type = AccountTypes.GoogleApps;
+ }
+
+ this.FullAddress = this.Name + "@" + this.Domain;
+ }
+ }
+
+ [XmlIgnore]
+ public bool IsEmpty {
+ get {
+ if (!String.IsNullOrEmpty(this.Login)) {
+ return String.IsNullOrEmpty(this.Password);
+ }
+ return true;
+ }
+ }
+
+
+ }
+}
+
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace GmailNotifierPlus {
+
+ [XmlRoot("Config")]
+ public class Config {
+
+ private static readonly String _AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ private static readonly String _Path = Path.Combine(_AppData, GmailNotifierPlus.Resources.Resources.WindowTitle);
+ private static readonly String _FileName = "app.config";
+
+ public static void Init() {
+ if (!Directory.Exists(_Path)) {
+ Directory.CreateDirectory(_Path);
+ }
+
+ Config config = new Config();
+ String xml = null;
+ FileInfo file = new FileInfo(Path.Combine(_Path, _FileName));
+
+ if(file.Exists){
+ using (FileStream fs = new FileStream(file.FullName, FileMode.Create, FileAccess.ReadWrite)) {
+ using (StreamReader sr = new StreamReader(fs)) {
+ xml = sr.ReadToEnd();
+ }
+ }
+
+ if(!String.IsNullOrEmpty(xml)){
+ config = Utilities.Serializer.Deserialize<Config>(xml);
+ }
+ }
+
+ Config.Current = config;
+
+ config.Save();
+ }
+
+ public static Config Current {
+ get;
+ private set;
+ }
+
+ public Config() {
+ this.Interval = 60;
+ this.Language = "en-US";
+ this.Sound = "default";
+ this.PlaySound = true;
+ this.FirstRun = true;
+ }
+
+ public event ConfigSavedEventHandler Saved;
+
+ public int Interval { get; set; }
+ public String Language { get; set; }
+ public String Sound { get; set; }
+ public Boolean PlaySound { get; set; }
+ public List<Account> Accounts { get; set; }
+ public Boolean FirstRun { get; set; }
+
+ [XmlIgnore]
+ public Account DefaultAccount {
+ get {
+ Account account = (from a in Accounts where a.Default == true select a).First();
+ return account;
+ }
+ }
+
+ public void Save() {
+
+ String serialized = Utilities.Serializer.Serialize<Config>(this);
+
+ using (FileStream fs = new FileStream(Path.Combine(_Path, _FileName), FileMode.Create, FileAccess.ReadWrite)) {
+ using (StreamWriter sw = new StreamWriter(fs)) {
+ sw.Write(serialized);
+ }
+ }
+
+ if (this.Saved != null) {
+ this.Saved(this, EventArgs.Empty);
+ }
+
+ }
+ }
+
+}
@@ -0,0 +1,96 @@
+namespace GmailNotifierPlus.Controls
+{
+ using System;
+ using System.Drawing;
+ using System.Runtime.InteropServices;
+ using System.Windows.Forms;
+
+ public class ImageButton : PictureBox
+ {
+ private Bitmap defaultImage;
+ private Bitmap disabledImage;
+ private Bitmap hoverImage;
+ private Bitmap pressedImage;
+
+ public ImageButton()
+ {
+ base.SizeMode = PictureBoxSizeMode.AutoSize;
+ }
+
+ [DllImport("user32.dll")]
+ public static extern int LoadCursor(int hInstance, int lpCursorName);
+ protected override void OnEnabledChanged(EventArgs e)
+ {
+ base.OnEnabledChanged(e);
+ if (this.disabledImage != null)
+ {
+ base.Image = base.Enabled ? this.defaultImage : this.disabledImage;
+ }
+ }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ if (base.Enabled && (this.pressedImage != null))
+ {
+ base.Image = this.pressedImage;
+ }
+ }
+
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ base.OnMouseEnter(e);
+ if (base.Enabled && (this.hoverImage != null))
+ {
+ base.Image = this.hoverImage;
+ }
+ }
+
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ if (base.Enabled && (this.hoverImage != null))
+ {
+ base.Image = this.defaultImage;
+ }
+ }
+
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+ if (base.Enabled && (this.pressedImage != null))
+ {
+ base.Image = this.defaultImage;
+ }
+ }
+
+ [DllImport("user32.dll")]
+ public static extern int SetCursor(int hCursor);
+ public void SetImage(Bitmap defaultImage)
+ {
+ this.SetImages(defaultImage, null, null, null);
+ }
+
+ public void SetImages(Bitmap defaultImage, Bitmap disabledImage, Bitmap hoverImage, Bitmap pressedImage)
+ {
+ base.Image = this.defaultImage = defaultImage;
+ this.disabledImage = disabledImage;
+ this.hoverImage = hoverImage;
+ this.pressedImage = pressedImage;
+ }
+
+ protected override void WndProc(ref Message m)
+ {
+ if (m.Msg == 0x20)
+ {
+ SetCursor(LoadCursor(0, 0x7f89));
+ m.Result = IntPtr.Zero;
+ }
+ else
+ {
+ base.WndProc(ref m);
+ }
+ }
+ }
+}
+
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace GmailNotifierPlus {
+
+ public delegate void CheckFinishedEventHandler(Notifier sender, EventArgs e);
+ public delegate void ConfigSavedEventHandler(object sender, EventArgs e);
+
+}
Oops, something went wrong.

0 comments on commit cd32db5

Please sign in to comment.