~ubuntu-branches/debian/squeeze/gnome-do-plugins/squeeze

« back to all changes in this revision

Viewing changes to BundledLibraries/libgoogle-data-mono-1.4.0.2/samples/YouTubeNotifier/Form1.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-06-27 16:11:49 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090627161149-b74nc297di2842u1
* New upstream release
  + Pidgin plugin now supports initial text for messages (LP: #338608)
  + Pidgin plugin opens conversations on the correct IM network (LP: #370965)
* debian/rules:
  + Update get-orig-source target.  Upstream no longer ships gdata* binaries,
    so we no longer need to strip them
* debian/patches/00_use_system_gdata
  + Drop.  Upstream now builds against system libgdata.
* debian/patches/04_fix_pidgin_dbus_ints
* debian/patches/10_fix_rhythmbox_file
* debian/patches/15_twitter_api
* debian/patches/20_twitter_overflow:
  + Drop.  Included upstream.
* debian/patches/01_firefox_iceweasel_rename:
  + Refresh for new version
* debian/patches/02_fix_banshee_plugin:
  + Drop refernce to /usr/lib/banshee-1/Banshee.CollectionIndexer.dll.
    This is unnecessary, and causes errors when Banshee isn't installed.
* debian/patches/00_debian_default_plugins:
  + Enable a bunch of useful plugins that do not require configuration from 
    the "Official" plugin set by default.  Makes Do more useful out of the 
    box.
* debian/control:
  + Bump versioned build-dep on gnome-do to 0.8.2
  + Split out gnome-do-plugin-evolution package, now that this is possible.
    libevolution5.0-cil has an annoyingly large dependency stack.
    (LP: #351535) (Closes: #524993).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
using System;
2
 
using System.Collections.Generic;
3
 
using System.ComponentModel;
4
 
using System.Data;
5
 
using System.Drawing;
6
 
using System.Text;
7
 
using System.Windows.Forms;
8
 
using System.IO;
9
 
using System.Net;
10
 
using Microsoft.Win32;
11
 
using Google.GData.YouTube;
12
 
using Google.GData.Client;
13
 
using Google.YouTube;
14
 
using NotifierForYT.Properties;
15
 
 
16
 
 
17
 
namespace NotifierForYT
18
 
{
19
 
    public partial class YouTubeNotifier : Form
20
 
    {
21
 
        private NotifyIcon nIcon;
22
 
        private string authToken;
23
 
        private YouTubeRequest ytRequest;
24
 
        private string user;
25
 
        private int initialPullinHours;
26
 
        private int updateFrequency;
27
 
        private int notificationDuration;
28
 
        private bool closeThis=false;
29
 
        private DateTime lastUpdate;
30
 
        private const string AppKey = "NotifierYT"; 
31
 
 
32
 
        private const string YTNOTIFIERKEY = "Software\\GoogleYouTubeNotifier";
33
 
        private const string YTCLIENTID = "ytapi-FrankMantek-TestaccountforGD-sjgv537n-0";
34
 
        private const string YTDEVKEY = "AI39si4v3E6oIYiI60ndCNDqnPP5lCqO28DSvvDPnQt-Mqia5uPz2e4E-gMSBVwHXwyn_LF1tWox4LyM-0YQd2o4i_3GcXxa2Q";
35
 
 
36
 
        private List<Activity> allActivities = new List<Activity>();
37
 
        private List<Video> allVideos = new List<Video>(); 
38
 
 
39
 
        public YouTubeNotifier()
40
 
        {
41
 
            InitializeComponent();
42
 
            CreateNotifyIcon();
43
 
            this.Icon = this.nIcon.Icon;
44
 
 
45
 
            if (CheckForFirstStartup() == true)
46
 
            {
47
 
                ShowSettings();
48
 
            }
49
 
            else
50
 
            {
51
 
                if (this.authToken != null)
52
 
                {
53
 
                    this.isAuthenticated.Checked = true;
54
 
                    UpdateActivities();
55
 
                }
56
 
            }
57
 
            this.Text = AppTitle;
58
 
            this.refreshTimer.Interval = 10000; 
59
 
            this.refreshTimer.Enabled = true;
60
 
        }
61
 
 
62
 
        private void ShowSettings()
63
 
        {
64
 
            ShowMe(this.tabPageSettings);
65
 
        }
66
 
 
67
 
        private void CreateNotifyIcon()
68
 
        {
69
 
            this.ShowInTaskbar = false;
70
 
            this.nIcon = new NotifyIcon(this.components);
71
 
            // Displays a TV Icon
72
 
            // Bitmap b = Resources.gdata_youtube;
73
 
            // this.nIcon.Icon = Icon.FromHandle(b.GetHicon());
74
 
            Bitmap b = Resources.ytfavicon;
75
 
            IntPtr Hicon = b.GetHicon();
76
 
 
77
 
            this.nIcon.Icon = Icon.FromHandle(Hicon);
78
 
 
79
 
            this.nIcon.Text = AppTitle + " - double click to restore it";
80
 
            this.nIcon.Visible = true;
81
 
            this.nIcon.ContextMenuStrip = this.defaultMenu;
82
 
            this.nIcon.DoubleClick += new EventHandler(nIcon_DoubleClick);
83
 
            HideMe();
84
 
        }
85
 
 
86
 
        private void nIcon_DoubleClick(Object sender, EventArgs e)
87
 
        {
88
 
            ToggleVisibility();
89
 
        }
90
 
 
91
 
        private bool CheckForFirstStartup()
92
 
        {
93
 
            RegistryKey ytNotifier = Registry.CurrentUser.OpenSubKey(YTNOTIFIERKEY);
94
 
 
95
 
            if (ytNotifier == null)
96
 
                return true;
97
 
 
98
 
            this.user = this.userName.Text = ytNotifier.GetValue("userName") as string;
99
 
            this.authToken = ytNotifier.GetValue("token") as string;
100
 
            this.InitialDataPullTime.Value = this.initialPullinHours = (int)ytNotifier.GetValue("initialDataPullTime", 24);
101
 
            this.UpdateFrequency.Value = this.updateFrequency = (int)ytNotifier.GetValue("updateFrequency", 15);
102
 
            this.notifcationBalloons.Value = this.notificationDuration = (int)ytNotifier.GetValue("notificationDuration", 10);
103
 
 
104
 
            string s = ytNotifier.GetValue("userList") as string;
105
 
            if (s != null)
106
 
            {
107
 
                string[] users = s.Split(',');
108
 
                foreach (string u in users)
109
 
                {
110
 
                    this.usernameGrid.Rows.Add(u);
111
 
                }
112
 
            }
113
 
 
114
 
 
115
 
            YouTubeRequestSettings settings = new YouTubeRequestSettings(AppKey, 
116
 
                    YTCLIENTID, 
117
 
                    YTDEVKEY,
118
 
                    this.userName.Text,
119
 
                    "");
120
 
 
121
 
            this.ytRequest = new YouTubeRequest(settings);
122
 
            OnAuthenticationModified(this.authToken);
123
 
            return false;
124
 
        }
125
 
 
126
 
 
127
 
        private void OnAuthenticationModified(string token)
128
 
        {
129
 
            this.authToken = token;
130
 
            this.isAuthenticated.Checked = token != null;
131
 
            if (this.ytRequest != null && this.ytRequest.Service != null)
132
 
                this.ytRequest.Service.SetAuthenticationToken(token);
133
 
        }
134
 
 
135
 
        private void ButtonSaveSettings_Click(object sender, EventArgs e)
136
 
        {
137
 
            bool fHide = true; 
138
 
            if (this.isAuthenticated.Checked == false && this.userName.Text.Length > 0)
139
 
            {
140
 
                // let's see if we get a valid authtoken back for the passed in credentials....
141
 
                YouTubeRequestSettings settings = new YouTubeRequestSettings(AppKey,
142
 
                                    YTCLIENTID,
143
 
                                    YTDEVKEY,
144
 
                                    this.userName.Text,
145
 
                                    this.passWord.Text);
146
 
                // settings.PageSize = 15;
147
 
                this.ytRequest = new YouTubeRequest(settings);
148
 
                try
149
 
                {
150
 
                    this.authToken = this.ytRequest.Service.QueryAuthenticationToken();
151
 
                    this.passWord.Text = ""; 
152
 
                }
153
 
                catch
154
 
                {
155
 
                    MessageBox.Show("There was a problem with your credentials");
156
 
                    this.authToken = null;
157
 
                    fHide = false; 
158
 
                }
159
 
                OnAuthenticationModified(this.authToken);
160
 
            }
161
 
 
162
 
            // let's save the username to the registry, but not the password
163
 
            RegistryKey ytNotifier = Registry.CurrentUser.OpenSubKey(YTNOTIFIERKEY, true);
164
 
 
165
 
            if (ytNotifier == null)
166
 
            {
167
 
                ytNotifier = Registry.CurrentUser.CreateSubKey(YTNOTIFIERKEY);
168
 
            }
169
 
 
170
 
           
171
 
            ytNotifier.SetValue("initialDataPullTime", this.InitialDataPullTime.Value, RegistryValueKind.DWord);
172
 
            ytNotifier.SetValue("updateFrequency", this.UpdateFrequency.Value, RegistryValueKind.DWord);
173
 
            ytNotifier.SetValue("notificationDuration", this.notifcationBalloons.Value, RegistryValueKind.DWord);
174
 
            ytNotifier.SetValue("userList", GetUserNamesToSave());
175
 
 
176
 
            this.initialPullinHours = (int)this.InitialDataPullTime.Value;
177
 
            this.updateFrequency = (int)this.UpdateFrequency.Value;
178
 
            this.notificationDuration = (int)this.notifcationBalloons.Value;
179
 
 
180
 
            if (this.authToken != null)
181
 
            {
182
 
                ytNotifier.SetValue("userName", this.userName.Text);
183
 
                ytNotifier.SetValue("token", this.authToken);
184
 
 
185
 
                this.user = this.userName.Text;
186
 
            }
187
 
 
188
 
            if (fHide == true)
189
 
            {
190
 
                HideMe();
191
 
                UpdateActivities();
192
 
            }
193
 
 
194
 
        }
195
 
 
196
 
 
197
 
        private void userName_TextChanged(object sender, EventArgs e)
198
 
        {
199
 
            this.isAuthenticated.Checked = false;
200
 
        }
201
 
 
202
 
        private void passWord_TextChanged(object sender, EventArgs e)
203
 
        {
204
 
            this.isAuthenticated.Checked = false; 
205
 
        }
206
 
 
207
 
        private void ButtonIgnore_Click(object sender, EventArgs e)
208
 
        {
209
 
            HideMe();
210
 
            this.userName.Text = this.user;
211
 
            this.passWord.Text = null;
212
 
            this.UpdateFrequency.Value = this.updateFrequency;
213
 
            this.InitialDataPullTime.Value = this.initialPullinHours;
214
 
            this.notifcationBalloons.Value = this.notificationDuration; 
215
 
        }
216
 
 
217
 
        private void refreshTimer_Tick(object sender, EventArgs e)
218
 
        {
219
 
            CheckForUpdateActivities();
220
 
        }
221
 
 
222
 
        private void CheckForUpdateActivities()
223
 
        {
224
 
            DateTime d = this.lastUpdate.AddMinutes(this.updateFrequency);
225
 
            if (d < DateTime.Now)
226
 
            {
227
 
                UpdateActivities();
228
 
            }
229
 
        }
230
 
 
231
 
 
232
 
        private List<string> GetUserNames()
233
 
        {
234
 
            // first update the not authenticated case. 
235
 
            List<string> users = new List<string>();
236
 
 
237
 
            foreach (DataGridViewRow r in this.usernameGrid.Rows)
238
 
            {
239
 
                if (r.Cells[0].Value != null)
240
 
                    users.Add(r.Cells[0].Value as string);
241
 
            }
242
 
            return users;
243
 
        }
244
 
 
245
 
        private string GetUserNamesToSave()
246
 
        {
247
 
            string ret = ""; 
248
 
            List<string> users = GetUserNames();
249
 
            foreach (string s in users)
250
 
            {
251
 
                if (String.IsNullOrEmpty(s) != true)
252
 
                {
253
 
                    if (ret.Length > 0)
254
 
                    {
255
 
                        ret += ",";
256
 
                    }
257
 
                    ret += s;
258
 
                }
259
 
            }
260
 
            return ret;
261
 
        }
262
 
 
263
 
 
264
 
        private void UpdateActivities()
265
 
        {
266
 
 
267
 
            this.refreshTimer.Enabled = false;
268
 
 
269
 
            DateTime since = DateTime.MinValue;
270
 
 
271
 
            if (this.allActivities.Count == 0)
272
 
            {
273
 
                // first call, do a modified-since query
274
 
                since = DateTime.Now.AddHours(-1 * this.initialPullinHours);
275
 
            
276
 
            }
277
 
 
278
 
 
279
 
            int iCounter = 0;
280
 
            this.nIcon.BalloonTipText = "";
281
 
          
282
 
            List<string> users = GetUserNames();
283
 
 
284
 
            if (users.Count > 0 && String.IsNullOrEmpty(users[0]) != true)
285
 
            {
286
 
 
287
 
                // let's see if we get a valid authtoken back for the passed in credentials....
288
 
                YouTubeRequestSettings settings = new YouTubeRequestSettings("YouTubeNotifier",
289
 
                                    YTCLIENTID,
290
 
                                    YTDEVKEY);
291
 
                // settings.PageSize = 15;
292
 
                YouTubeRequest r = new YouTubeRequest(settings);
293
 
                Feed<Activity> pf = r.GetActivities(users, since);
294
 
                iCounter += ProcessFeed(pf, since); 
295
 
            }
296
 
 
297
 
 
298
 
 
299
 
            if (this.authToken != null)
300
 
            {
301
 
                Feed<Activity> f = this.ytRequest.GetActivities(since);
302
 
 
303
 
                iCounter += ProcessFeed(f, since);
304
 
            }
305
 
 
306
 
 
307
 
            // now redo the layout in the right order of controls:
308
 
            this.linkList.SuspendLayout();
309
 
            this.linkList.Controls.Clear();
310
 
            foreach (Activity act in this.allActivities)
311
 
            {
312
 
                LinkLabel l = new LinkLabel();
313
 
                string when = act.Updated.ToShortDateString();
314
 
 
315
 
                if (act.Updated.Date == DateTime.Now.Date)
316
 
                {
317
 
                    // it happened today
318
 
                    when = act.Updated.ToShortTimeString();
319
 
                }
320
 
 
321
 
                if (act.Updated.Date == DateTime.Now.AddDays(-1).Date)
322
 
                {
323
 
                    when = "yesterday, at " + act.Updated.ToShortTimeString();
324
 
                }
325
 
 
326
 
                l.Text = act.Author + " has ";
327
 
 
328
 
                bool noLink = false;
329
 
                int len = 5; 
330
 
                switch (act.Type)
331
 
                {
332
 
                    case ActivityType.Commented:
333
 
                        l.Text += "commented on ";
334
 
                        len = AddVideoText(l, act.VideoId);
335
 
                        break;
336
 
                    case ActivityType.Favorited:
337
 
                        l.Text += "favorited ";
338
 
                        len = AddVideoText(l, act.VideoId);
339
 
                        break;
340
 
 
341
 
                    case ActivityType.FriendAdded:
342
 
                        l.Text += "added a friend - " + act.Username ;
343
 
                        noLink = true;
344
 
                        break;
345
 
                    case ActivityType.Rated:
346
 
                        l.Text += "rated ";
347
 
                        len = AddVideoText(l, act.VideoId);
348
 
                        break;
349
 
                    case ActivityType.Shared:
350
 
                        l.Text += "shared ";
351
 
                        len = AddVideoText(l, act.VideoId);
352
 
                        break;
353
 
                    case ActivityType.SubscriptionAdded:
354
 
                        l.Text += "subscriped to " + act.Username;
355
 
                        noLink = true;
356
 
                        break;
357
 
                    case ActivityType.Uploaded:
358
 
                        l.Text += "uploaded ";
359
 
                        len = AddVideoText(l, act.VideoId);
360
 
                        break;
361
 
                }
362
 
 
363
 
                l.AutoSize = true;
364
 
                if (noLink == false)
365
 
                {
366
 
                    l.Links[0].Start = l.Text.Length - len;
367
 
                    l.Links[0].Length = len;
368
 
                    l.Links[0].LinkData = YouTubeQuery.CreateVideoWatchUri(act.VideoId);
369
 
                    l.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.Label_LinkClicked);
370
 
                }
371
 
                else
372
 
                {
373
 
                    // create a link for the user
374
 
                    l.Links[0].Start = l.Text.Length - act.Username.Length;
375
 
                    l.Links[0].Length = act.Username.Length;
376
 
                    l.Links[0].LinkData = "http://www.youtube.com/user/" + act.Username;
377
 
                    l.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.Label_LinkClicked);
378
 
 
379
 
                }
380
 
                l.Text += " (" + when + ")";
381
 
 
382
 
                this.linkList.Controls.Add(l);
383
 
 
384
 
            }
385
 
            this.linkList.ResumeLayout();
386
 
 
387
 
            if (iCounter > 0)
388
 
            {
389
 
                this.nIcon.BalloonTipTitle = "YouTube activities for " + this.userName.Text + " friends";
390
 
                this.nIcon.ShowBalloonTip(this.notificationDuration * 1000);
391
 
            }
392
 
            UpdateTitle();
393
 
            this.refreshTimer.Enabled = true;
394
 
            this.lastUpdate = DateTime.Now;
395
 
        }
396
 
 
397
 
 
398
 
        private int AddVideoText(LinkLabel l, string videoId)
399
 
        {
400
 
            int len = 5; 
401
 
            Video v = FindVideo(videoId);
402
 
            if (v != null)
403
 
            {
404
 
                l.Text += v.Title;
405
 
                len = v.Title.Length;
406
 
            }
407
 
            else
408
 
            {
409
 
                l.Text += " a video";
410
 
            }
411
 
            return len; 
412
 
        }
413
 
 
414
 
 
415
 
        private void UpdateTitle()
416
 
        {
417
 
            this.nIcon.Text = AppTitle + " " + this.UnreadCount + " unread activities";
418
 
        }
419
 
 
420
 
 
421
 
        private int ProcessFeed(Feed<Activity> feed, DateTime since)
422
 
        {
423
 
            List<Activity> newGuys = new List<Activity>(); 
424
 
 
425
 
            try
426
 
            {
427
 
                foreach (Activity a in feed.Entries)
428
 
                {
429
 
                    // first check if the activity is inside our maximum timeframe
430
 
                    // substract the max number of hours to pull
431
 
                    DateTime oldest = DateTime.Now.AddHours(-1 * this.initialPullinHours);
432
 
 
433
 
                    if (a.Updated > oldest)
434
 
                    {
435
 
                        // so it's part of the timeline. Let's see if we already have it
436
 
 
437
 
                        if (IsContained(a) == false)
438
 
                        {
439
 
                            AddBallonText(newGuys.Count, a.ToString());
440
 
                            if (since == DateTime.MinValue)
441
 
                            {
442
 
                                this.allActivities.Insert(0, a);
443
 
                            }
444
 
                            else
445
 
                            {
446
 
                                this.allActivities.Add(a);
447
 
                            }
448
 
                            newGuys.Add(a);
449
 
                        }
450
 
                    }
451
 
                }
452
 
            }
453
 
            catch (GDataForbiddenException e)
454
 
            {
455
 
                MessageBox.Show("Your accesstoken has expired.", "Please reauthenticate by providing your password again");
456
 
                OnAuthenticationModified(null);
457
 
                ShowSettings();
458
 
            }
459
 
            catch (InvalidCredentialsException e)
460
 
            {
461
 
                MessageBox.Show("Your accesstoken has expired.", "Please reauthenticate by providing your password again");
462
 
                OnAuthenticationModified(null);
463
 
                ShowSettings();
464
 
            }
465
 
            catch (GDataRequestException e)
466
 
            {
467
 
                HttpWebResponse r = e.Response as HttpWebResponse;
468
 
                if (r != null && r.StatusCode == HttpStatusCode.Unauthorized)
469
 
                {
470
 
                    MessageBox.Show("Your accesstoken has expired.", "Please reauthenticate by providing your password again");
471
 
                    OnAuthenticationModified(null);
472
 
                    ShowSettings();
473
 
                }
474
 
                else if (r != null && r.StatusCode == HttpStatusCode.NotModified)
475
 
                {
476
 
                    // nothing new there, so ignore the exception.
477
 
                }
478
 
                else
479
 
                    MessageBox.Show(e.ResponseString, "There was a problem getting the data from YouTube");
480
 
            }
481
 
            // now get the metadata for the new guys
482
 
 
483
 
            GetMetaData(newGuys);
484
 
 
485
 
 
486
 
            return newGuys.Count; 
487
 
 
488
 
        }
489
 
 
490
 
 
491
 
        private void GetMetaData(List<Activity> list)
492
 
        {
493
 
            Feed<Video> meta = this.ytRequest.GetVideoMetaData(list);
494
 
 
495
 
            foreach (Video v in meta.Entries)
496
 
            {
497
 
                if (IsContained(v) == false)
498
 
                {
499
 
                    this.allVideos.Add(v);
500
 
                }
501
 
            }
502
 
        }
503
 
 
504
 
 
505
 
 
506
 
        private int UnreadCount
507
 
        {
508
 
            get
509
 
            {
510
 
                int iCounter = 0;
511
 
                foreach (LinkLabel l in linkList.Controls)
512
 
                {
513
 
                    if (l.Links[0].Visited == false)
514
 
                        iCounter++;
515
 
                }
516
 
                return iCounter;
517
 
            }
518
 
        }
519
 
 
520
 
        private void AddBallonText(int iCounter, string text)
521
 
        {
522
 
            if (iCounter == 0)
523
 
                this.nIcon.BalloonTipText = text;
524
 
            else if (iCounter < 4)
525
 
                this.nIcon.BalloonTipText += "\r" + text;
526
 
            else if (iCounter == 4)
527
 
                this.nIcon.BalloonTipText += "\r" + "and more...";
528
 
        }
529
 
 
530
 
        private bool IsContained(Activity a)
531
 
        {
532
 
            foreach (Activity act in this.allActivities)
533
 
            {
534
 
                if (act.Id == a.Id)
535
 
                    return true;
536
 
            }
537
 
            return false;
538
 
        }
539
 
 
540
 
        private bool IsContained(Video v)
541
 
        {
542
 
            foreach (Video video in this.allVideos)
543
 
            {
544
 
                if (video.Id == v.Id)
545
 
                    return true;
546
 
            }
547
 
            return false;
548
 
        }
549
 
 
550
 
        private Video FindVideo(string videoId)
551
 
        {
552
 
            foreach (Video video in this.allVideos)
553
 
            {
554
 
                if (video.VideoId == videoId)
555
 
                    return video;
556
 
            }
557
 
            return null;
558
 
        }
559
 
 
560
 
 
561
 
        private void HideMe()
562
 
        {
563
 
            this.Hide();
564
 
            this.WindowState = FormWindowState.Minimized;
565
 
 
566
 
        }
567
 
 
568
 
        private void ToggleVisibility()
569
 
        {
570
 
            if (this.WindowState == FormWindowState.Minimized)
571
 
            {
572
 
                ShowMe(null);
573
 
            }
574
 
            else
575
 
            {
576
 
                HideMe();
577
 
            }
578
 
        }
579
 
 
580
 
        private void ShowMe(TabPage page)
581
 
        {
582
 
            this.Show();
583
 
            this.WindowState = FormWindowState.Normal;
584
 
            this.Activate();
585
 
            if (page == null)
586
 
                this.tabControl.SelectedTab = this.tabPageActivities;
587
 
            else
588
 
                this.tabControl.SelectedTab = page;
589
 
        }
590
 
 
591
 
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
592
 
        {
593
 
            ShowSettings();
594
 
        }
595
 
 
596
 
        private void activitiesToolStripMenuItem_Click(object sender, EventArgs e)
597
 
        {
598
 
            ShowMe(this.tabPageActivities);
599
 
        }
600
 
 
601
 
  
602
 
        private void YouTubeNotifier_FormClosing(object sender, FormClosingEventArgs e)
603
 
        {
604
 
 
605
 
            if (e.CloseReason == CloseReason.UserClosing  && this.closeThis == false)
606
 
            {
607
 
                e.Cancel = true;
608
 
                HideMe();
609
 
                this.nIcon.BalloonTipText = "Use the context menu to exit or restore particular parts of the application";
610
 
                this.nIcon.BalloonTipTitle = AppTitle + " is still running !";
611
 
                this.nIcon.ShowBalloonTip(this.notificationDuration * 1000); 
612
 
            }
613
 
        }
614
 
 
615
 
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
616
 
        {
617
 
            this.closeThis = true;
618
 
            this.Close();
619
 
        }
620
 
 
621
 
        private void clearActivitiesToolStripMenuItem_Click(object sender, EventArgs e)
622
 
        {
623
 
            this.linkList.Controls.Clear();
624
 
            UpdateTitle();
625
 
        }
626
 
 
627
 
 
628
 
      
629
 
 
630
 
        private void YouTubeNotifier_Resize(object sender, EventArgs e)
631
 
        {
632
 
            if (this.WindowState == FormWindowState.Minimized)
633
 
                HideMe();
634
 
        }
635
 
 
636
 
 
637
 
        private void Label_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
638
 
        {
639
 
            string u = e.Link.LinkData as string;
640
 
 
641
 
            if (u != null)
642
 
            {
643
 
                try
644
 
                {
645
 
                    System.Diagnostics.Process.Start(u);
646
 
                }
647
 
                catch
648
 
                {
649
 
                    MessageBox.Show("There was a problem navigating to: " + u);
650
 
                }
651
 
                e.Link.Visited = true;
652
 
            }
653
 
            UpdateTitle();
654
 
        }
655
 
 
656
 
        private void button1_Click(object sender, EventArgs e)
657
 
        {
658
 
            // let's save the username to the registry, but not the password
659
 
            RegistryKey ytNotifier = Registry.CurrentUser.OpenSubKey(YTNOTIFIERKEY, true);
660
 
            if (ytNotifier == null)
661
 
            {
662
 
                ytNotifier = Registry.CurrentUser.CreateSubKey(YTNOTIFIERKEY);
663
 
            }
664
 
 
665
 
            ytNotifier.SetValue("userList", GetUserNamesToSave());
666
 
            HideMe();
667
 
            UpdateActivities();
668
 
        }
669
 
 
670
 
        private void usersToolStripMenuItem_Click(object sender, EventArgs e)
671
 
        {
672
 
            ShowMe(this.tabPageUsers);
673
 
        }
674
 
 
675
 
        private void usernameGrid_UserAddedRow(object sender, DataGridViewRowEventArgs e)
676
 
        {
677
 
            this.usernameGrid.AllowUserToAddRows = true; 
678
 
            if (this.usernameGrid.Rows.Count >= 20)
679
 
            {
680
 
                this.usernameGrid.AllowUserToAddRows = false; 
681
 
            }
682
 
        }
683
 
    }
684
 
}
 
 
b'\\ No newline at end of file'