~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/monomac/samples/TwoMinuteGrowler/MainWindowController.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
using System;
3
 
using System.Collections.Generic;
4
 
using System.Linq;
5
 
using MonoMac.Foundation;
6
 
using MonoMac.AppKit;
7
 
using MonoMac.Growl;
8
 
 
9
 
namespace TwoMinuteGrowler {
10
 
        public partial class MainWindowController : MonoMac.AppKit.NSWindowController {
11
 
                CountDownTimer counter;
12
 
 
13
 
                public MainWindowController (IntPtr handle) : base (handle) { }
14
 
 
15
 
                [Export("initWithCoder:")]
16
 
                public MainWindowController (NSCoder coder) : base(coder) { }
17
 
 
18
 
                public MainWindowController () : base("MainWindow") { }
19
 
 
20
 
 
21
 
                public override void AwakeFromNib () 
22
 
                {                       
23
 
                        GrowlApplicationBridge.WeakDelegate = this;
24
 
                        counter = new CountDownTimer ();
25
 
                        Bind ("countDown", counter, "timeLeft", null);
26
 
                }
27
 
 
28
 
                partial void startStopAction (NSButton sender) 
29
 
                {
30
 
                        if (sender.Title == "Start") {
31
 
                                counter.Start ();
32
 
                                sender.Title = "Stop";
33
 
                                GrowlApplicationBridge.Notify ("The two-minute rule is magic.", 
34
 
                                                               "You now have two minutes to Get Your Things Done.", "Start", null, 0, false, null);
35
 
                        } else {
36
 
                                counter.Stop ();
37
 
                                sender.Title = "Start";
38
 
                                if (counter.TimerMark.Minutes > 0 && counter.TimerMark.Seconds > 0)
39
 
                                        GrowlApplicationBridge.Notify ("Action Completed", String.Format ("You still have {0} left.  Step back and breath.  " + "Take a second and contemplate what you have achieved.  " + "You'll be suprised how many two-minute actions you can " + "perform even on your most critical projects", counter.TimeLeft), "Stop", null, 0, true, null);
40
 
                        }
41
 
                }
42
 
 
43
 
                [Export("countDown")]
44
 
                public string CountDown {
45
 
                        get { return countDownLabel.StringValue; }
46
 
                        set {
47
 
                                countDownLabel.StringValue = counter.TimeLeft;
48
 
                                if (counter.TimerMark.Minutes == 0 && counter.TimerMark.Seconds == 0) {
49
 
                                        GrowlApplicationBridge.Notify ("Time is up", 
50
 
                                                                       "Your two minutes is up.  Did you get everything done?  " 
51
 
                                                                       + "You need to clarify what is next and then manage that accordingly.", "Stop", null, 0, false, null);
52
 
                                        counter.Stop ();
53
 
                                        startStopButton.Title = "Start";
54
 
                                        
55
 
                                } else if (counter.TimerMark.Minutes == 1 && counter.TimerMark.Seconds == 0) {
56
 
                                        GrowlApplicationBridge.Notify ("One Minute Warning", "This is your one minute warning.  " 
57
 
                                                                       + "Not to put more pressure on you but you had better get a move on!", "Info", null, 0, false, null);
58
 
                                }
59
 
                        }
60
 
                }
61
 
 
62
 
                [Export("registrationDictionaryForGrowl")]
63
 
                NSDictionary RegistrationDictionaryForGrowl () 
64
 
                {
65
 
                        var regPath = NSBundle.MainBundle.PathForResource ("GrowlRegistrationTicket", "plist");
66
 
                        var reg = NSDictionary.FromFile (regPath);
67
 
                        return reg;
68
 
                }
69
 
        
70
 
        }
71
 
}
72