Esempio n. 1
0
        public static void Start(GmailDataHelper gdh)
        {
            _countdown = new CountdownEvent(1);

            Thread th = new Thread(new ParameterizedThreadStart(ThreadStartingWindow));

            //for UI thread
            th.SetApartmentState(ApartmentState.STA);
            th.IsBackground = true;
            th.Start(gdh);

            _countdown.Wait(5000);
        }
Esempio n. 2
0
        public GmailDataHelper Create()
        {
            int            n    = 0;
            PromptSettings ps   = _recorder.LoadData("Prompt" + n);
            String         pass = "";

            if (!String.IsNullOrEmpty(ps.Password))
            {
                ps.SecurePassword = ProtectData.DecryptString(ps.Password);
                pass        = "******".Repeat(ps.SecurePassword.Length);
                ps.Password = pass;
            }
            PromptWindow pw = new PromptWindow();

            pw.DataContext = ps;

            if (pw.ShowDialog() == true)
            {
                if (!String.Equals(pass, ps.Password))
                {
                    ps.SecurePassword = new SecureString();
                    foreach (char c in ps.Password)
                    {
                        ps.SecurePassword.AppendChar(c);
                    }
                }
                var credit = new NetworkCredential(ps.Login, ps.SecurePassword);

                ps.Password       = ProtectData.EncryptString(ps.SecurePassword);
                ps.SecurePassword = null;
                _recorder.StoreData("Prompt" + n, ps);

                GmailDataHelper gdhn = new GmailDataHelper(ps.Login, credit);
                new MailTray(gdhn);
                gdhn.AutoRefresh();
                return(gdhn);
            }
            return(null);
        }
Esempio n. 3
0
        public MailTray(GmailDataHelper gdh)
        {
            this.gdh = gdh;
            LoadImage();
            ni = new NotifyIcon();

            try
            {
                ni.Icon = EmptyIco;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to retreive the Icon " + ex.Message);
                ni.Icon = new Icon(SystemIcons.Application, 40, 40);
            }

            #region Left Click
            niMenuLeftClick = new System.Windows.Forms.ContextMenuStrip();
            niMenuLeftClick.Items.Add(gdh.Datas.Login, peopleIM);
            niMenuLeftClick.Items.Add("-");
            niMenuLeftClick.Items.Add(new ToolStripMenuItem("Update", mailUpdateIM, (s, ee) =>
            {
                gdh.UpdateData();
            }));
            niMenuLeftClick.Items.Add(new ToolStripMenuItem("Again", mailAgainIM, (s, ee) =>
            {
                foreach (var mail in gdh.Datas.Mails)
                {
                    gdh.NotifyMail(mail);
                }
            }));
            niMenuLeftClick.Items.Add(new ToolStripMenuItem("Open", mailViewIM, (s, ee) =>
            {
                System.Diagnostics.Process.Start(gdh.Datas.Link);
            }));
            niMenuLeftClick.Items.Add("-");
            niMenuLeftClick.Items.Add(new ToolStripMenuItem("Quit", closeIM, (s, ee) =>
            {
                if (System.Windows.Forms.Application.MessageLoop)
                {
                    // WinForms app
                    System.Windows.Forms.Application.Exit();
                }
                else
                {
                    // Console app
                    System.Environment.Exit(1);
                }
            }));
            #endregion

            #region Right Click
            niMenuRightClick    = new System.Windows.Forms.ContextMenuStrip();
            ni.ContextMenuStrip = niMenuRightClick;


            ni.ContextMenuStrip.Items.Add(new ToolStripMenuItem("About", infoIM, (s, ee) => {
                if (Wabout == null)
                {
                    Wabout          = new AboutWindow();
                    Wabout.Closing += (ss, e) =>
                    {
                        e.Cancel = true;
                        Wabout.Hide();
                    };
                    Wabout.Show();
                }
                else
                {
                    UIUtil.BringToFrontWindow(Wabout);
                }
            }));

            ni.ContextMenuStrip.Items.Add(new ToolStripMenuItem("Config", gearIM, (s, ee) =>
            {
                if (Wsettings == null)
                {
                    Wsettings             = new SettingsWindow();
                    Wsettings.DataContext = new SettingsVM(gdh.Datas.Login, gdh.Settings);
                    Wsettings.Closing    += (ss, e) =>
                    {
                        e.Cancel = true;
                        Wsettings.Hide();
                    };
                    Wsettings.Show();
                }
                else
                {
                    UIUtil.BringToFrontWindow(Wsettings);
                }
            }));
            #endregion

            gdh.Datas.PropertyChanged         += gdh_PropertyChanged;
            gdh.Datas.Mails.CollectionChanged += Mails_CollectionChanged;

            ni.MouseClick += new MouseEventHandler(ni_MouseClick);
            ni.Visible     = true;
            ni.Text        = gdh.ToString();
        }