示例#1
0
        /// <summary>
        /// Method for load messages.
        /// </summary>
        /// <param name="messageListType">The Message List Type.</param>
        public void LoadMessages(MessageListType messageListType)
        {
            Facade facade         = Facade.GetInstance();
            string selectedFolder = string.Empty;

            if (messageListType == MessageListType.Inbox ||
                messageListType == MessageListType.Unread ||
                messageListType == MessageListType.Read)
            {
                // Attach to Message Store
                this._store = facade.GetMessageStore();
            }
            else if (messageListType == MessageListType.SentItems)
            {
                // Attach to Message Store Sent items
                this._store = facade.GetMessageStoreSent();
            }
            else if (messageListType == MessageListType.DeletedItems)
            {
                // Attach to Message Store Sent items
                this._store = facade.GetMessageStoreDelete();
            }
            else if (messageListType == MessageListType.Custom)
            {
                // Attach to Message Store Sent items
                this._store    = facade.GetMessageStoreCustom();
                selectedFolder = MainForm.GetInstance().GetSelectedFolder();
            }
            else
            {
                this._store = new MessageStore();
            }

            // Reset DataSource
            this.messageBS.DataSource    = this._store.Messages;
            this.dataGridView.DataSource = this.messageBS;

            this.dataGridView.CurrentCell = null;

            CurrencyManager cm = (CurrencyManager)this.dataGridView.BindingContext[this.dataGridView.DataSource];

            cm.SuspendBinding();

            foreach (DataGridViewRow row in this.dataGridView.Rows)
            {
                MailMessage mailMessage = (MailMessage)row.DataBoundItem;

                if (messageListType == MessageListType.Unread && mailMessage.Read)
                {
                    row.Visible = false;
                }
                else if (messageListType == MessageListType.Read && !mailMessage.Read)
                {
                    row.Visible = false;
                }
                else if (messageListType == MessageListType.Custom &&
                         !mailMessage.ParentFolder.Equals(selectedFolder))
                {
                    row.Visible = false;
                }
                else
                {
                    row.Visible = true;
                }
            }

            cm.ResumeBinding();

            if (this.messageBS.Count > 0)
            {
                this.dataGridView.Sort(this.dataGridView.Columns[2], ListSortDirection.Descending);
            }

            MainForm mainForm = this.ParentForm as MainForm;

            mainForm.LoadSelectedMessage(this._store);

            this.Invalidate(true);
        }
示例#2
0
 // Region for Singleton
 #region Singleton
 
 /// <summary>
 /// Gets the singleton instance for the Facade.
 /// </summary>
 /// <returns>The Facade instance.</returns>
 public static Facade GetInstance()
 {
     if (facade == null)
     {
         facade = new Facade();
     }
     return facade;
 }