Ejemplo n.º 1
0
        private void saveDraft_Click(object sender, EventArgs e)
        {
            var        mail       = new Mail(DataWorker.CurrentUser.Login + "@mymail.com", emailTo.Text, subject.Text, letterText.Text, "Draft");
            DataWorker dataWorker = DataWorker.Instance;

            dataWorker.SendMail(mail);
            Hide();
        }
Ejemplo n.º 2
0
        private void DeleteLetter_Click(object sender, EventArgs e)
        {
            DataWorker dataWorker = DataWorker.Instance;

            while (mailList.CheckedItems.Count > 0)
            {
                dataWorker.DeleteMail(mails[mailList.CheckedItems[0].Index]);
                mails.RemoveAt(mailList.CheckedItems[0].Index);
                mailList.Items.Remove(mailList.CheckedItems[0]);
            }
        }
Ejemplo n.º 3
0
        private void Refresh_Click(object sender, EventArgs e)
        {
            DataWorker dataWorker = DataWorker.Instance;

            mailList.Items.Clear();
            mails.Clear();
            foreach (var item in dataWorker.GetMails(currentFolder))
            {
                mailList.Items.Add(new ListViewItem(new[] { item.From, item.To, item.Subject }));
                mails.Add(item);
            }
        }
Ejemplo n.º 4
0
        //Загрузка сообщений из файла и заполнение ими ListView
        private void LoadMails(string folderName)
        {
            DataWorker dataWorker = DataWorker.Instance;

            mailList.Items.Clear();
            mails.Clear();
            foreach (var item in dataWorker.GetMails(folderName))
            {
                mailList.Items.Add(new ListViewItem(new[] { item.From, item.To, item.Subject }));
                mails.Add(item);
            }
            mailList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            mailList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Ejemplo n.º 5
0
        private void submit_Click(object sender, EventArgs e)
        {
            DataWorker dataWorker = DataWorker.Instance;

            if (changeColor.SelectedIndex == 0)
            {
                dataWorker.ChangeTheme("Default");
            }
            else
            {
                dataWorker.ChangeTheme("Green");
            }
            dataWorker.ChangeSignature(signature.Text);
            Close();
            Inbox?.PerformRefresh();
        }
Ejemplo n.º 6
0
        private void mailList_ItemClicked(object sender, MouseEventArgs e)
        {
            DataWorker dataWorker = DataWorker.Instance;

            if (e.Button == MouseButtons.Left)
            {
                if (mailList.SelectedItems.Count > 0)
                {
                    mailText.Text = dataWorker.GetMails(currentFolder)[mailList.SelectedItems[0].Index].Body;
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (currentFolder != "Sent Mail")
                {
                    //проверяет что нажатие произведено в пределах выделенного элемента
                    if (mailList.FocusedItem.Bounds.Contains(e.Location))
                    {
                        var moveToItem = (ToolStripMenuItem)mailMenuStrip.Items[0];
                        //Если папок стало больше
                        if (moveToItem.DropDownItems.Count < dataWorker.GetFolders().Count - 2)
                        {
                            moveToItem.DropDownItems.Clear();
                            foreach (var folder in dataWorker.GetFolders())
                            {
                                if (folder != currentFolder && folder != "Sent Mail")
                                {
                                    /*var copyItem = new ToolStripMenuItem(folder);
                                     * copyItem.Click += CopyMail;
                                     * ((ToolStripMenuItem) mailMenuStrip.Items[0]).DropDownItems.Add(copyItem);*/

                                    var moveItem = new ToolStripMenuItem(folder);
                                    moveItem.Click += MoveMail;
                                    moveToItem.DropDownItems.Add(moveItem);
                                }
                            }
                        }
                        mailMenuStrip.Show(Cursor.Position);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void openContactsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var excel = new Excel.Application
            {
                SheetsInNewWorkbook = 1
            };

            excel.Workbooks.Add();
            Excel.Worksheet table      = excel.Workbooks[1].Worksheets.get_Item(1);
            DataWorker      dataWorker = DataWorker.Instance;
            var             contacts   = dataWorker.GetContacts();

            table.Range["A1", "A1"].Value = "User name";
            table.Range["B1", "B1"].Value = "Login";
            for (int i = 2; i < contacts.Count + 2; i++)
            {
                table.Range["A" + i, "A" + i].Value = contacts.ElementAt(i - 2).Item1;
                table.Range["B" + i, "B" + i].Value = contacts.ElementAt(i - 2).Item2;
            }
            excel.Visible = true;
        }
Ejemplo n.º 8
0
        private void openContactsInWordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataWorker dataWorker = DataWorker.Instance;
            var        word       = new Word.Application {
                Visible = true
            };
            var doc = word.Documents.Add();

            doc.Paragraphs[1].Range.Text = "Users table\n";
            var wdRange  = doc.Paragraphs[2].Range;
            var contacts = dataWorker.GetContacts();
            var table    = doc.Tables.Add(wdRange, contacts.Count + 1, 2);

            table.set_Style("Сетка таблицы");
            table.Cell(1, 1).Range.Text = "User name";
            table.Cell(1, 2).Range.Text = "Login";
            for (int i = 0; i < contacts.Count; i++)
            {
                table.Cell(i + 2, 1).Range.Text = contacts.ElementAt(i).Item1;
                table.Cell(i + 2, 2).Range.Text = contacts.ElementAt(i).Item2;
            }
            doc.Paragraphs[(contacts.Count + 1) * 3 + 2].Range.Text = "Press Ctrl+P for print\n";
        }