コード例 #1
0
 /// <summary>Shows/hides and updates progress bar and status message.</summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="TextMessageViewer.MessageFolder.MessagesRetrievalProgressEventArgs"/> instance containing the event data.</param>
 private void MessageFolder_MessagesRetrievalProgress(object sender, MessageFolder.MessagesRetrievalProgressEventArgs e)
 {
     if (e.CurrentMessage == 1) {
         //first message
         progressBar.Visible = true;
         progressBar.Maximum = e.TotalMessages;
     } else if (e.CurrentMessage == e.TotalMessages) {
         progressBar.Visible = false;
     }
     statusBar.Text = "Reading items...[" + e.CurrentMessage + "/" + e.TotalMessages + "]...";
     progressBar.Value = e.CurrentMessage;
 }
コード例 #2
0
        public void RetrieveMessages(string path)
        {
            //subfolders
            string[] subfolders = Directory.GetDirectories(RetrievePath());
            Array.Sort<string>(subfolders);
            folders = new List<MessageFolder>(subfolders.Length);//avoid resizing of list
            foreach (string str in subfolders) {
                string[] pathSplit = str.Split(new char[] { '\\' });
                string displayString = pathSplit[pathSplit.Length - 1];
                MessageFolder folder = new MessageFolder(displayString);
                folder.parentFolder = this;
                folders.Add(folder);
            }

            messages.Clear();
            //messages
            MessageFormat format = RetrieveFormat();
            string fileFormat = MessageNameFormatAttribute.FileFormat(format);
            string[] files = Directory.GetFiles(RetrievePath(), fileFormat);
            messages = new List<TextMessage>(files.Length);//avoid resizing of list
            int numberOfMessages = files.Length, currentMessage = 0;
            foreach (string file in files) {
                messages.Add(TextMessage.ReadTextMessage(file, format));
                currentMessage++;
                OnMessagesRetrievalProgress(this, new MessagesRetrievalProgressEventArgs(currentMessage, numberOfMessages));
            }

            OnMessagesRetrieved(this, new EventArgs());
        }