示例#1
0
 private void DeleteMailButton_Click(object sender, EventArgs e)
 {
     if (selectedMail == null)
     {
         return;
     }
     browser.Load("about:blank");
     selectedMail.Remove();
     FileListFlow.Controls.Remove(selectedButton);
     mailcache.Remove(selectedMail.Id);
     selectedFile = null;
     selectedMail = null;
     if (FileListFlow.Controls.Count != 0)
     {
         OnFileButtonClick(FileListFlow.Controls[0], EventArgs.Empty);
     }
 }
示例#2
0
        private void Scan__AddMailItem(DirectoryInfo mail, ref int items, ref Int64 size)
        {
            LogVerbose("Found mail {mail}.", mail.FullName);
            mailcache.Add(mail.Name, new XMailObject(mail.Name, mail));
            XMailObject mailObject = mailcache[mail.Name];
            Control     c          = new Button
            {
                FlatStyle = FlatStyle.Popup,
                Size      = new Size(160, 64),
                Tag       = "mail@" + mail.Name,
                Text      = mailObject.From + ": " + mailObject.Subject,
                TextAlign = ContentAlignment.MiddleCenter
            };

            c.Click += OnFileButtonClick;
            FileListFlow.Controls.Add(c);
        }
示例#3
0
 private void OnFileButtonClick__SetMailFiles(XMailObject mail)
 {
     MailFilesFlow.Controls.Clear();
     FileInfo[] files = mail.GetFiles();
     foreach (FileInfo file in files)
     {
         Control c = new Button
         {
             FlatStyle = FlatStyle.Popup,
             Size      = new Size(160, 64),
             Tag       = "mail@" + mail.Id + "@" + file.FullName,
             Text      = file.Name,
             TextAlign = ContentAlignment.MiddleCenter
         };
         c.Click += OnFileButtonClick;
         MailFilesFlow.Controls.Add(c);
     }
 }
示例#4
0
        private void OnFileButtonClick(object sender, EventArgs e)
        {
            selectedButton = (Control)sender;
            string tag = (string)selectedButton.Tag;

            LogVerbose("User clicked button for file {file}.", tag);
            selectedPlainFile = tag.StartsWith("plain");
            selectedMailFile  = tag.StartsWith("mail");
            tag = tag.Substring(tag.IndexOf("@") + 1);
            string tagfile = "";

            if (tag.Contains("@"))
            {
                tagfile = tag.Substring(tag.IndexOf("@") + 1);
                tag     = tag.Substring(0, tag.IndexOf("@"));
            }
            if (selectedPlainFile)
            {
                selectedFile = new FileInfo(tag);
                selectedMail = null;
                splitContainer4.Panel2Collapsed = true;
                if (!selectedFile.Exists)
                {
                    LogWarning("File no longer exists");
                    MessageBox.Show("The file no longer exists. Maybe it has already been deleted by someone else.");
                    FileListFlow.Controls.Remove(selectedButton);
                    return;
                }
            }
            else if (selectedMailFile)
            {
                selectedFile = null;
                if (!mailcache.ContainsKey(tag))
                {
                    LogWarning("Mail not in cache");
                    MessageBox.Show("The file can't be found in cache.");
                    FileListFlow.Controls.Remove(selectedButton);
                    return;
                }
                selectedMail = mailcache[tag];
                if (tagfile != "")
                {
                    selectedFile = new FileInfo(tagfile);
                }
                else
                {
                    selectedFile = selectedMail.GetPreviewFile();
                }
                if (!selectedFile.Exists)
                {
                    LogWarning("File no longer exists");
                    MessageBox.Show("The file no longer exists. Maybe it has already been deleted by someone else.");
                    FileListFlow.Controls.Remove(selectedButton);
                    return;
                }
                splitContainer4.Panel2Collapsed  = false;
                splitContainer4.SplitterDistance = splitContainer4.Height - 100;
                OnFileButtonClick__SetMailFiles(selectedMail);
            }
            OnFileButtonClick__SetPreview();
            OnFileButtonClick__SetFields();
        }