示例#1
0
        /// <summary>
        /// 从一个文件里加载所有的信区对象
        /// </summary>
        /// <param name="sFileName"></param>
        /// <returns></returns>
        public static MailArea[] LoadAreasFromFile(string sFileName)
        {
            ArrayList  alAreas = new ArrayList(30);
            FileStream fs;

            try
            {
                fs = new FileStream(sFileName, FileMode.Open, FileAccess.Read);
            }
            catch
            {
                return(null);
            }


            BinaryReader br = new BinaryReader(fs);

            fs.Seek(6, SeekOrigin.Begin);
            //读信区
            while (fs.Position < fs.Length)
            {
                MailArea m = new MailArea(br);
                if (m != null)
                {
                    alAreas.Add(m);
                }
            }

            br.Close();
            MailArea[] arMailAreas = new MailArea[alAreas.Count];
            alAreas.CopyTo(arMailAreas);
            return(arMailAreas);
        }
示例#2
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;
        }
示例#3
0
        private void mnOpenJam_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog fd = new OpenFileDialog();

            fd.Title    = "请选择GECHO信区设置文件";
            fd.FileName = "AREAFILE.GE";
            fd.Filter   = "GECHO信区设置文件AREAFILE.GE|AREAFILE.GE";
            if (DialogResult.OK != fd.ShowDialog())
            {
                return;
            }
            // 打开信包
            MailArea[] Areas = MailArea.LoadAreasFromFile(fd.FileName);
            if (Areas == null || Areas.Length == 0)
            {
                MessageBox.Show("打开信区配置文件出错!或是没有配置任何信区.");
                return;
            }

            this.GEchoFile = fd.FileName;

            // 试着打开第一个文件
            if (!File.Exists(Areas[0].sFullPathName))
            {
                MessageBox.Show("没有找到信区配置里指定的文件,可能是因为计算机环境的改变引起的,您可以手工指定信包文件.");

                fd.Title    = "请选择指定的信包文件";
                fd.FileName = Areas[0].sFileName + ".JHR";
                fd.Filter   = "信包文件" + Areas[0].sFileName + ".JHR|" + Areas[0].sFileName + ".JHR";
                if (DialogResult.OK != fd.ShowDialog())
                {
                    MessageBox.Show("由于没有打到信包文件,信区无法打开");
                    return;
                }
                // 找出信包文件的路径
                string sPath = fd.FileName.Substring(0, fd.FileName.LastIndexOfAny(new char[] { '\\', ':' }) + 1);
                this.JamPath = sPath;
                this.OpenJam();
            }

            return;
        }
示例#4
0
        private void OpenJam()
        {
            this.Cursor = Cursors.WaitCursor;
            MailArea[] Areas = MailArea.LoadAreasFromFile(this.GEchoFile);
            if (Areas == null)
            {
                MessageBox.Show("打不开你指出的GECHO设置文件! 请您再指定一下");
                this.mnOpenJam_Click(null, null);
                return;
            }

            this.lvArea.Items.Clear();
            for (int i = 0; i < Areas.Length; i++)
            {
                Areas[i].ChangePath(this.JamPath);
                Areas[i].LoadAreaInfo();
                ListViewItem lvi = this.lvArea.Items.Add(Areas[i].sAreaname);
                lvi.SubItems.Add(Areas[i].sDes);
                lvi.SubItems.Add(Areas[i].lMailCount.ToString("#,0"));
                lvi.Tag = Areas[i];
            }
            this.Cursor = Cursors.Default;
        }
示例#5
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();
        }