Esempio n. 1
0
        private void выходИзАккаунтаToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (currentUser == null)
            {
                return;
            }
            usersBox.Items.Remove(currentUser.login);
            usersBox.SelectedText = "";
            currentUser.imapClient.DisconnectFromServer();

            authorizedUsers.Remove(currentUser);
            listView1.Items.Clear();
            listView2.Items.Clear();
            listView3.Items.Clear();
            ClearInputs();

            webBrowser1.DocumentText = "";
            SubjectLabel.Text        = "";
            label1.Text    = "";
            label2.Text    = "";
            label3.Text    = "";
            usersBox.Text  = "";
            currentUser    = null;
            mailFolderInfo = null;
        }
Esempio n. 2
0
        private async void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (currentUser == null)
            {
                return;
            }
            string AccountName = currentUser.login.Substring(0, currentUser.login.IndexOf("@"));

            FilesWork.CheckAllNeededFoldersExists(AccountName);

            var selItem = listView1.SelectedItems;

            if (selItem.Count <= 0)
            {
                return;
            }
            mailFolderInfo = new mailFolderInfo();

            string foldPath = "mail\\" + AccountName + "-mails\\" + selItem[0].Text;

            mailFolderInfo.path = foldPath;

            int BoxNum = currentUser.imapClient.FindBox(selItem[0].Text);

            // здесб
            if (BoxNum >= 0)
            {
                LastUNSEEN = await Task.Run(() => currentUser.imapClient.GetNewEmailsInBox(BoxNum, FilesWork.GetAllLoadedEmailsInForder(foldPath), foldPath));

                //LastUNSEEN = currentUser.imapClient.GetNewEmailsInBox(BoxNum, FilesWork.GetAllLoadedEmailsInForder(foldPath), foldPath);
                mailFolderInfo.number = BoxNum;
            }

            //FilesWork.ShowEmailsInFolder("mail\\" + AccountName + "-mails\\" + selItem[0].Text,listView2,ref mailFolderInfo);
            FilesWork.ShowEmailsInFolder(mailFolderInfo.path, listView2, ref mailFolderInfo, LastUNSEEN);
        }
Esempio n. 3
0
        public static void ShowEmailsInFolder(string path, ListView lv, ref mailFolderInfo mf, List <int> UNSEEN)
        {
            lv.Items.Clear();
            DirectoryInfo d   = new DirectoryInfo(path);
            var           f   = d.GetFiles();
            int           ind = 0;

            DateTime time      = new DateTime();
            string   groupName = "";

            foreach (FileInfo info in f)
            {
                ListViewItem tmp = new ListViewItem(MimeDecrypter.GetSubjectAndDate(info.FullName, ref time));
                if (tmp.Text == "")
                {
                    tmp.Text = "No data";
                }
                //if () { }
                groupName = time.Day.ToString() + "." + time.Month.ToString() + "." + time.Year.ToString();
                bool NeednewGroup = true;
                foreach (ListViewGroup g in lv.Groups)
                {
                    if (g.Name == groupName)
                    {
                        tmp.Group    = g;
                        NeednewGroup = false;
                    }
                }
                if (NeednewGroup)
                {
                    ListViewGroup group = new ListViewGroup();
                    group.Name   = groupName;
                    group.Header = groupName;

                    lv.Groups.Add(group);
                    tmp.Group = group;
                }
                int MessageUid = FilesWork.GetFileNumb(info.FullName);
                if (UNSEEN.Contains(MessageUid))
                {
                    tmp.ForeColor = System.Drawing.Color.DarkBlue;
                }

                lv.Items.Add(tmp);
                if (mf != null)
                {
                    mf.Mails.Add(new MailInfo(tmp.Text, MessageUid));
                }
                ind++;
            }
            lv.ListViewItemSorter = new ListViewComparer(0, SortOrder.Ascending);
            lv.Sort();

            ListViewGroup[] groups = new ListViewGroup[lv.Groups.Count];
            lv.Groups.CopyTo(groups, 0);

            Array.Sort(groups, (IComparer <ListViewGroup>)(new GroupComparer()));

            lv.BeginUpdate();
            lv.Groups.Clear();
            lv.Groups.AddRange(groups);
            lv.EndUpdate();
        }