コード例 #1
0
ファイル: frmTray.cs プロジェクト: dylix/Gmail-Notifier
 private void menuSettings_Click(object Sender, EventArgs e)
 {
     if (!Variables.settingsOpened)
     {
         frmSettings _frmSettings = new frmSettings();
         _frmSettings.Show();
         Variables.settingsOpened = true;
     }
     else
     {
         (System.Windows.Forms.Application.OpenForms["frmSettings"] as frmSettings).BringToFront();
     }
 }
コード例 #2
0
ファイル: frmTray.cs プロジェクト: dylix/Gmail-Notifier
        public frmTray()
        {
            InitializeComponent();
            this.components      = new System.ComponentModel.Container();
            this.contextMenu1    = new System.Windows.Forms.ContextMenu();
            this.menuLine        = new System.Windows.Forms.MenuItem();
            this.menuLine2       = new System.Windows.Forms.MenuItem();
            this.menuLine3       = new System.Windows.Forms.MenuItem();
            this.menuCheckNow    = new System.Windows.Forms.MenuItem();
            this.menuTellMeAgain = new System.Windows.Forms.MenuItem();
            this.menuSettings    = new System.Windows.Forms.MenuItem();
            this.menuAbout       = new System.Windows.Forms.MenuItem();
            this.menuExit        = new System.Windows.Forms.MenuItem();
            this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuCheckNow, this.menuTellMeAgain, this.menuLine, this.menuSettings, this.menuLine2, this.menuAbout, this.menuLine3, this.menuExit });

            // Initialize menuCheckNow
            this.menuCheckNow.Index  = 0;
            this.menuCheckNow.Text   = "Check Now";
            this.menuCheckNow.Click += new System.EventHandler(this.menuCheckNow_Click);
            // Initialize menuTellMeAgain
            this.menuTellMeAgain.Index  = 1;
            this.menuTellMeAgain.Text   = "Tell Me Again";
            this.menuTellMeAgain.Click += new System.EventHandler(this.menuTellMeAgain_Click);
            // Initialize menuLine
            this.menuLine.Index = 2;
            this.menuLine.Text  = "-";
            // Initialize menuSettings
            this.menuSettings.Index  = 3;
            this.menuSettings.Text   = "Settings";
            this.menuSettings.Click += new System.EventHandler(this.menuSettings_Click);
            // Initialize menuLine
            this.menuLine2.Index = 4;
            this.menuLine2.Text  = "-";
            // Initialize menuSettings
            this.menuAbout.Index  = 5;
            this.menuAbout.Text   = "About";
            this.menuAbout.Click += new System.EventHandler(this.menuAbout_Click);
            // Initialize menuLine
            this.menuLine3.Index = 6;
            this.menuLine3.Text  = "-";
            // Initialize menuExit
            this.menuExit.Index  = 7;
            this.menuExit.Text   = "Exit";
            this.menuExit.Click += new System.EventHandler(this.menuExit_Click);
            // Set up how the form should be displayed.
            this.ClientSize      = new System.Drawing.Size(292, 266);
            this.Text            = "Notify Icon";
            ntfyIcon.ContextMenu = this.contextMenu1;

            byte[] passwordEnc = null;
            try
            {
                Microsoft.Win32.RegistryKey gmailRegKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\GmailNotifier");
                using (gmailRegKey)
                {
                    Variables.Username = (string)gmailRegKey.GetValue("Username");
                    passwordEnc        = (byte[])gmailRegKey.GetValue("Password");
                    if (passwordEnc != null)
                    {
                        Variables.Password = UTF8Encoding.UTF8.GetString(ProtectedData.Unprotect(passwordEnc, null, DataProtectionScope.CurrentUser));
                    }
                    Variables.ChkInterval  = (int)gmailRegKey.GetValue("ChkInterval");
                    Variables.NtfyInterval = (int)gmailRegKey.GetValue("NtfyInterval");
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show(e.Message);
                MessageBox.Show("Incomplete settings detected. This is not a fatal error. Please update your preferances accordingly.", e.Message, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //return;
                if (Variables.Username == null)
                {
                    Variables.Username = String.Empty;
                }
                if (passwordEnc == null)
                {
                    Variables.Password = String.Empty;
                }
                Variables.ChkInterval  = 5;
                Variables.NtfyInterval = 5;
                frmSettings _frmSettings = new frmSettings();
                _frmSettings.Show();
                Variables.settingsOpened = true;
            }
            if (Variables.Username == String.Empty || Variables.Password == String.Empty)
            {
                if (Variables.settingsOpened != true)
                {
                    frmSettings _frmSettings = new frmSettings();
                    _frmSettings.Show();
                    Variables.settingsOpened = true;
                }
            }
            else
            {
                checkMail();
            }
            tmrCheckMail.Interval = _ChkInterval(Variables.ChkInterval);
            tmrCheckMail.Enabled  = true;
        }
コード例 #3
0
ファイル: frmTray.cs プロジェクト: dylix/Gmail-Notifier
        public frmTray()
        {
            InitializeComponent();
            this.components = new System.ComponentModel.Container();
            this.contextMenu1 = new System.Windows.Forms.ContextMenu();
            this.menuLine = new System.Windows.Forms.MenuItem();
            this.menuLine2 = new System.Windows.Forms.MenuItem();
            this.menuLine3 = new System.Windows.Forms.MenuItem();
            this.menuCheckNow = new System.Windows.Forms.MenuItem();
            this.menuTellMeAgain = new System.Windows.Forms.MenuItem();
            this.menuSettings = new System.Windows.Forms.MenuItem();
            this.menuAbout = new System.Windows.Forms.MenuItem();
            this.menuExit = new System.Windows.Forms.MenuItem();
            this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuCheckNow, this.menuTellMeAgain,this.menuLine, this.menuSettings, this.menuLine2, this.menuAbout,this.menuLine3, this.menuExit });

            // Initialize menuCheckNow
            this.menuCheckNow.Index = 0;
            this.menuCheckNow.Text = "Check Now";
            this.menuCheckNow.Click += new System.EventHandler(this.menuCheckNow_Click);
            // Initialize menuTellMeAgain
            this.menuTellMeAgain.Index = 1;
            this.menuTellMeAgain.Text = "Tell Me Again";
            this.menuTellMeAgain.Click += new System.EventHandler(this.menuTellMeAgain_Click);
            // Initialize menuLine
            this.menuLine.Index = 2;
            this.menuLine.Text = "-";
            // Initialize menuSettings
            this.menuSettings.Index = 3;
            this.menuSettings.Text = "Settings";
            this.menuSettings.Click += new System.EventHandler(this.menuSettings_Click);
            // Initialize menuLine
            this.menuLine2.Index = 4;
            this.menuLine2.Text = "-";
            // Initialize menuSettings
            this.menuAbout.Index = 5;
            this.menuAbout.Text = "About";
            this.menuAbout.Click += new System.EventHandler(this.menuAbout_Click);
            // Initialize menuLine
            this.menuLine3.Index = 6;
            this.menuLine3.Text = "-";
            // Initialize menuExit 
            this.menuExit.Index = 7;
            this.menuExit.Text = "Exit";
            this.menuExit.Click += new System.EventHandler(this.menuExit_Click);
            // Set up how the form should be displayed. 
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Text = "Notify Icon";
            ntfyIcon.ContextMenu = this.contextMenu1;

            byte[] passwordEnc = null;
            try
            {
                Microsoft.Win32.RegistryKey gmailRegKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\GmailNotifier");
                using (gmailRegKey)
                {
                    Variables.Username = (string)gmailRegKey.GetValue("Username");
                    passwordEnc = (byte[])gmailRegKey.GetValue("Password");
                    if (passwordEnc != null)
                        Variables.Password = UTF8Encoding.UTF8.GetString(ProtectedData.Unprotect(passwordEnc, null, DataProtectionScope.CurrentUser));
                    Variables.ChkInterval = (int)gmailRegKey.GetValue("ChkInterval");
                    Variables.NtfyInterval = (int)gmailRegKey.GetValue("NtfyInterval");
                }

            }
            catch (Exception e)
            {
                //MessageBox.Show(e.Message);
                MessageBox.Show("Incomplete settings detected. This is not a fatal error. Please update your preferances accordingly.", e.Message, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //return;
                if (Variables.Username == null)
                    Variables.Username = String.Empty;
                if (passwordEnc == null)
                    Variables.Password = String.Empty;
                Variables.ChkInterval = 5;
                Variables.NtfyInterval = 5;
                frmSettings _frmSettings = new frmSettings();
                _frmSettings.Show();
                Variables.settingsOpened = true;
            }
            if (Variables.Username == String.Empty || Variables.Password == String.Empty)
            {
                if (Variables.settingsOpened != true)
                {
                    frmSettings _frmSettings = new frmSettings();
                    _frmSettings.Show();
                    Variables.settingsOpened = true;
                }
            }
            else
                checkMail();
            tmrCheckMail.Interval = _ChkInterval(Variables.ChkInterval);
            tmrCheckMail.Enabled = true;
        }
コード例 #4
0
ファイル: frmTray.cs プロジェクト: dylix/Gmail-Notifier
 private void menuSettings_Click(object Sender, EventArgs e)
 {
     if (!Variables.settingsOpened)
     {
         frmSettings _frmSettings = new frmSettings();
         _frmSettings.Show();
         Variables.settingsOpened = true;
     }
     else
     {
         (System.Windows.Forms.Application.OpenForms["frmSettings"] as frmSettings).BringToFront();
     }
 }