예제 #1
0
        private void m_pToolbar_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Tag == null)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            if (e.ClickedItem.Tag.ToString() == "refresh")
            {
                LoadData();
            }
            else if (e.ClickedItem.Tag.ToString() == "save")
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.Filter   = "Email Message (*.eml)|*.eml";
                dlg.FileName = m_pMessages.SelectedItems[0].Text.Replace("\\", " ").Replace("/", " ").Replace(":", " ").Replace("*", " ").Replace("?", " ").Replace("<", " ").Replace(">", " ");
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    using (FileStream fs = File.Create(dlg.FileName)){
                        ListViewItem item = m_pMessages.SelectedItems[0];
                        m_pFolder.GetMessage((string)((object[])item.Tag)[0], fs);
                    }
                }
            }
            else if (e.ClickedItem.Tag.ToString() == "write")
            {
                wfrm_Compose compose = new wfrm_Compose(m_pFolder);
                if (compose.ShowDialog(this) == DialogResult.OK)
                {
                    MemoryStream ms = new MemoryStream(compose.Message);
                    ms.Position = 0;
                    m_pFolder.StoreMessage(ms);
                }
            }
            else if (e.ClickedItem.Tag.ToString() == "delete")
            {
                if (MessageBox.Show(this, "Are you sure you want to delete selected messages !", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    for (int i = 0; i < m_pMessages.SelectedItems.Count; i++)
                    {
                        ListViewItem item = m_pMessages.SelectedItems[i];
                        m_pFolder.DeleteMessage((string)((object[])item.Tag)[0], (int)((object[])item.Tag)[1]);
                        item.Remove();
                        i--;
                    }
                }
            }

            this.Cursor = Cursors.Default;
        }
예제 #2
0
        private void m_pToolbar_ItemClicked(object sender,ToolStripItemClickedEventArgs e)
        {
            if(e.ClickedItem.Tag == null){
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            if(e.ClickedItem.Tag.ToString() == "refresh"){
                LoadData();
            }
            else if(e.ClickedItem.Tag.ToString() == "save"){
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.Filter = "Email Message (*.eml)|*.eml";
                dlg.FileName = m_pMessages.SelectedItems[0].Text.Replace("\\"," ").Replace("/"," ").Replace(":"," ").Replace("*"," ").Replace("?"," ").Replace("<"," ").Replace(">"," ");
                if(dlg.ShowDialog(this) == DialogResult.OK){                    
                    using(FileStream fs = File.Create(dlg.FileName)){
                        ListViewItem item = m_pMessages.SelectedItems[0];
                        m_pFolder.GetMessage((string)((object[])item.Tag)[0],fs);
                    }
                }
            }
            else if(e.ClickedItem.Tag.ToString() == "write"){
                wfrm_Compose compose = new wfrm_Compose(m_pFolder);
                if(compose.ShowDialog(this) == DialogResult.OK){
                    MemoryStream ms = new MemoryStream(compose.Message);
                    ms.Position = 0;                    
                    m_pFolder.StoreMessage(ms);
                }
            }
            else if(e.ClickedItem.Tag.ToString() == "delete"){
                if(MessageBox.Show(this,"Are you sure you want to delete selected messages !","Confirm Delete",MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2) == DialogResult.Yes){
                    for(int i=0;i<m_pMessages.SelectedItems.Count;i++){
                        ListViewItem item = m_pMessages.SelectedItems[i];
                        m_pFolder.DeleteMessage((string)((object[])item.Tag)[0],(int)((object[])item.Tag)[1]);
                        item.Remove();
                        i--;
                    }
                }
            }

            this.Cursor = Cursors.Default;
        }