Exemplo n.º 1
0
        /// <summary>
        /// 切换当前信区
        /// </summary>
        /// <param name="iIndex"></param>
        private void ChangeCurrentAreaTo(int iIndex)
        {
            if (this.iCurrentArea == iIndex)
            {
                return;
            }

            if (this.lvArea.Items.Count <= iIndex)
            {
                return;
            }

            if (this.lvArea.Items[iIndex].Tag == null)
            {
                return;
            }

            // 更新查找书签
            this.iFindRecord  = 0;
            this.iFindArea    = iIndex;
            this.iCurrentArea = iIndex;

            // 滚动LIST
            this.lvArea.SelectedItems.Clear();
            this.lvArea.Items[iIndex].Selected = true;
            this.lvArea.EnsureVisible(this.iCurrentArea);

            this.Cursor = Cursors.WaitCursor;
            this.lvMail.Items.Clear();
            MailArea m = (MailArea)this.lvArea.Items[iIndex].Tag;

            this.arCurrentMails = m.LoadMails();

            if (this.arCurrentMails == null || this.arCurrentMails.Length == 0)
            {
                ListViewItem lvi = this.lvMail.Items.Add("空信区");
                this.Cursor = Cursors.Default;
                return;
            }

            for (int i = 0; i < this.arCurrentMails.Length; i++)
            {
                JamMail      jm  = this.arCurrentMails[i];
                ListViewItem lvi = this.lvMail.Items.Add(jm.sFrom);
                lvi.SubItems.Add(jm.sTo);
                lvi.SubItems.Add(jm.sSubject);
                lvi.SubItems.Add(jm.uSize.ToString("#,0"));
                lvi.SubItems.Add(jm.dtSendTime.ToString());
                lvi.SubItems.Add(jm.dtReciveTime.ToString());
                lvi.Tag = jm;
            }
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 2
0
        public JamMail[] LoadMails()
        {
            JamMail[]  arMails = null;
            FileStream fs      = null;

            try
            {
                fs = new FileStream(this.sFullPathName + ".jhr", FileMode.Open, FileAccess.Read);
            }
            catch
            {
                return(null);
            }
            BinaryReader br = new BinaryReader(fs);

            fs.Seek(0x400, SeekOrigin.Begin);
            ArrayList alMails = new ArrayList((int)this.lMailCount);

            while (fs.Position < fs.Length && alMails.Count < this.lMailCount)
            {
                JamMail jm = new JamMail();
                jm.sFileName = this.sFullPathName;
                try
                {
                    jm.LoadInfoFromStream(br);
                }
                catch
                {
                    br.Close();
                    arMails = new JamMail[alMails.Count];
                    alMails.CopyTo(arMails);
                    return(arMails);
                }

                alMails.Add(jm);
            }
            br.Close();
            arMails = new JamMail[alMails.Count];
            alMails.CopyTo(arMails);
            return(arMails);
        }
Exemplo n.º 3
0
        private void ShowCurrentMail()
        {
            if (this.lvMail.SelectedItems.Count == 0)
            {
                return;
            }
            if (this.lvMail.SelectedItems[0].Tag == null)
            {
                return;
            }

            JamMail jm = (JamMail)this.lvMail.SelectedItems[0].Tag;

            this.lbInfo.Text = jm.GetInfoString();

            this.txtContent.Clear();
            this.txtContent.ClearUndo();
            this.txtContent.Text = jm.LoadText();

            // this.txtContent.Text = jm.LoadText();
            this.iFindRecord = this.lvMail.SelectedItems[0].Index + 1;
            this.iFindArea   = this.lvArea.SelectedItems[0].Index;
        }
Exemplo n.º 4
0
        private void mnFindNext_Click(object sender, System.EventArgs e)
        {
            string sFindText = this.frmFind.txtFindText.Text;

            if (this.frmFind.chkNoCase.Checked)
            {
                sFindText = sFindText.ToLower();
            }
            bool bFound = false;
            int  i = 0, j;
            int  iEndArea = this.frmFind.chkAllArea.Checked ?
                            this.lvArea.Items.Count - 1: this.iFindArea;

            for (j = this.iFindArea; j < iEndArea; j++)
            {
                MailArea m = (MailArea)this.lvArea.Items[j].Tag;

                JamMail [] jms;
                // 如果是当前信区,那么不需要再读文件了.
                if (this.iCurrentArea != j)
                {
                    jms = m.LoadMails();
                }
                else
                {
                    jms = this.arCurrentMails;
                }
                if (jms == null)
                {
                    continue;
                }

                #region look up a mail in a area
                for (i = this.iFindRecord; i < jms.Length; i++)
                {
                    JamMail jm = (JamMail)jms[i];
                    bFound = jm.FindText(
                        this.frmFind.txtFindText.Text,
                        this.frmFind.chkFrom.Checked,
                        this.frmFind.chkTo.Checked,
                        this.frmFind.chkSubject.Checked,
                        this.frmFind.chkContent.Checked,
                        this.frmFind.chkNoCase.Checked,
                        false
                        );
                    if (bFound)
                    {
                        // 找到了.
                        break;
                    }
                }
                if (bFound)
                {
                    break;
                }
                else
                {
                    // 从下个区的开始找.
                    this.iFindRecord = 0;
                }

                #endregion
            }
            if (!bFound)
            {
                MessageBox.Show("没有了.");
                return;
            }
            // 要切换到找到的信区和信里.
            if (j != this.iCurrentArea)
            {
                //不是当前区,要切换到J信区里
                this.ChangeCurrentAreaTo(j);
            }
            this.lvMail.SelectedItems.Clear();
            this.lvMail.Items[i].Selected = true;
            this.ShowCurrentMail();
            this.lvMail.Items[i].EnsureVisible();
            this.txtContent.Focus();
        }