/// <summary> /// Event happens when user click Stop button , sender will be VoiceMailEntry, where you can retrieve file info /// </summary> internal void OnStopPlayingVoiceMail(VoiceMailEntry sender, EventArgs args) { if (StopPlayingVoiceMail != null) { StopPlayingVoiceMail(sender, args); } }
/// <summary> /// Clear out menu item from our control list /// </summary> /// <param name="entry"></param> internal void Purge(VoiceMailEntry entry) { toolButtonPlay.Visible = false; toolButtonEmail.Visible = false; toolButtonDelete.Visible = false; toolButtonGet.Visible = false; if (pEmailEntries.Controls.IndexOf(entry) > 0) { OnSelectedMailEntry((VoiceMailEntry)pEmailEntries.Controls[pEmailEntries.Controls.IndexOf(entry) - 1], new EventArgs()); } else if (pEmailEntries.Controls.Count > 1) { OnSelectedMailEntry((VoiceMailEntry)pEmailEntries.Controls[1], new EventArgs()); } pEmailEntries.Controls.Remove(entry); }
internal void OnSelectedMailEntry(VoiceMailEntry sender, EventArgs args) { if (SelectedMailEntry != null) { SelectedMailEntry(sender, args); } if (mSelectedVoiceMailEntry != null && mSelectedVoiceMailEntry != sender) { mSelectedVoiceMailEntry.Selected = false; mSelectedVoiceMailEntry.BackgroundImage = MailBackgroundImage; mSelectedVoiceMailEntry.BackgroundImageLayout = MailBackgroundImageLayout; mSelectedVoiceMailEntry.BackColor = MailBackgroundColor; } mSelectedVoiceMailEntry = sender; mSelectedVoiceMailEntry.Selected = true; mSelectedVoiceMailEntry.BackgroundImage = SelectedMailBackgroundImage; mSelectedVoiceMailEntry.BackgroundImageLayout = SelectedMailBackgroundImageLayout; mSelectedVoiceMailEntry.BackColor = SelectedMailBackgroundColor; if (mSelectedVoiceMailEntry.Cached) { toolButtonPlay.Visible = true; toolButtonEmail.Visible = true; toolButtonDelete.Visible = true; toolButtonDelete.Enabled = true; toolButtonGet.Visible = false; } else { toolButtonGet.Visible = !this.Synchronize; toolButtonDelete.Visible = true; toolButtonGet.Enabled = !mSelectedVoiceMailEntry.DownloadInProgress; toolButtonDelete.Enabled = !mSelectedVoiceMailEntry.DownloadInProgress; toolButtonPlay.Visible = false; toolButtonEmail.Visible = false; } }
void mTimer_SyncTick(object sender, EventArgs e) { if (Synchronize) { if (mDownloadingFile == false) { foreach (Control control in pEmailEntries.Controls) { VoiceMailEntry vm = (VoiceMailEntry)control; if (!vm.Cached) { vm.DownloadMail(); break; } } } //In this same timeout, we handle getting new data if (mPerformingUpdate) { return; } mlastUpdate = System.DateTime.Now; mPerformingUpdate = true; mMailSerive.VoiceMail_GetMessageListAsync(mUserName, mPassword); } else { TimeSpan interval = System.DateTime.Now - mlastUpdate; if (interval.TotalSeconds >= UpdateRateInSeconds) { toolButtonRefresh.Enabled = true; } } }
internal void OnSelectedMailEntry(VoiceMailEntry sender, EventArgs args) { if (SelectedMailEntry != null) SelectedMailEntry(sender, args); if (mSelectedVoiceMailEntry != null && mSelectedVoiceMailEntry != sender) { mSelectedVoiceMailEntry.Selected = false; mSelectedVoiceMailEntry.BackgroundImage = MailBackgroundImage; mSelectedVoiceMailEntry.BackgroundImageLayout = MailBackgroundImageLayout; mSelectedVoiceMailEntry.BackColor = MailBackgroundColor; } mSelectedVoiceMailEntry = sender; mSelectedVoiceMailEntry.Selected = true; mSelectedVoiceMailEntry.BackgroundImage = SelectedMailBackgroundImage; mSelectedVoiceMailEntry.BackgroundImageLayout = SelectedMailBackgroundImageLayout; mSelectedVoiceMailEntry.BackColor = SelectedMailBackgroundColor; if (mSelectedVoiceMailEntry.Cached) { toolButtonPlay.Visible = true; toolButtonEmail.Visible = true; toolButtonDelete.Visible = true; toolButtonDelete.Enabled = true; toolButtonGet.Visible = false; } else { toolButtonGet.Visible = !this.Synchronize; toolButtonDelete.Visible = true; toolButtonGet.Enabled = !mSelectedVoiceMailEntry.DownloadInProgress; toolButtonDelete.Enabled = !mSelectedVoiceMailEntry.DownloadInProgress; toolButtonPlay.Visible = false; toolButtonEmail.Visible = false; } }
void MessageListUpdate(MailService.FileInfo[] list) { int newInboxFiles = 0; int newArchiveFiles = 0; foreach (MailService.FileInfo info in list) { try { //File was not in our local list, so add it if (pEmailEntries.Controls.ContainsKey(info.FileName) == false) { if (info.Location == MailService.LocationType.INBOX) { ++newInboxFiles; } else if (info.Location == MailService.LocationType.ARCHIVE) { ++newArchiveFiles; } String newFileInfoName = this.BasePath + info.Location.ToString() + @"\" + info.FileName + ".xml";; String tempFileInfoName = Path.GetTempFileName(); XmlSerializer ser = new XmlSerializer(typeof(InfoFile)); FileStream fs = File.OpenWrite(tempFileInfoName); InfoFile infoFile = new InfoFile(info); infoFile.Cached = File.Exists(mBaseDirectory + info.Location.ToString() + @"\" + info.FileName); ser.Serialize(fs, infoFile); fs.Close(); //Now move files if (File.Exists(newFileInfoName)) { File.Delete(newFileInfoName); } File.Move(tempFileInfoName, newFileInfoName); pEmailEntries.Controls.Add(new VoiceMailEntry(this, infoFile)); } else { //Check for a message which may have moved from Inbox to Archive VoiceMailEntry entry = (VoiceMailEntry)pEmailEntries.Controls[info.FileName]; if ((MailService.LocationType)entry.Info.Location != info.Location && info.Location == MailService.LocationType.ARCHIVE) { entry.ArchiveLocal(); } } } catch { } } if (newInboxFiles > 0 || newArchiveFiles > 0) { OnNewMailEvent(this, newInboxFiles, newArchiveFiles); } }