示例#1
0
        public void UpdateInterface()
        {
            Reset();

            PageCount = (int)Math.Ceiling((double)GameScene.User.Mail.Count / 10);
            if (PageCount < 1)
            {
                PageCount = 1;
            }

            PageLabel.Text = string.Format("{0} / {1}", CurrentPage, PageCount);

            for (int i = 0; i < Rows.Length; i++)
            {
                if (i + StartIndex >= GameScene.User.Mail.Count)
                {
                    break;
                }

                if (Rows[i] != null)
                {
                    Rows[i].Dispose();
                }

                Rows[i] = new MailItemRow
                {
                    Mail     = GameScene.User.Mail[i + StartIndex],
                    Location = new Point(10, 55 + i * 33),
                    Parent   = this
                };

                Rows[i].Click += (o, e) =>
                {
                    MailItemRow row = (MailItemRow)o;

                    if (row.Mail != SelectedMail)
                    {
                        SelectedMail  = row.Mail;
                        SelectedIndex = FindSelectedIndex();
                        UpdateRows();
                    }
                    else
                    {
                        if (SelectedMail.Gold > 0 || SelectedMail.Items.Count > 0)
                        {
                            GameScene.Scene.MailReadParcelDialog.ReadMail(SelectedMail);
                        }
                        else
                        {
                            GameScene.Scene.MailReadLetterDialog.ReadMail(SelectedMail);
                        }
                    }
                };

                if (SelectedMail != null)
                {
                    if (SelectedMail.MailID == Rows[i].Mail.MailID)
                    {
                        SelectedMail = Rows[i].Mail;
                    }
                }
            }

            UpdateRows();
        }
示例#2
0
        public void UpdateInterface()
        {
            Reset();

            PageCount = (int)Math.Ceiling((double)GameScene.User.Mail.Count / 10);
            if (PageCount < 1) PageCount = 1;

            PageLabel.Text = string.Format("{0} / {1}", CurrentPage, PageCount);

            for (int i = 0; i < Rows.Length; i++)
            {
                if (i + StartIndex >= GameScene.User.Mail.Count) break;

                if (Rows[i] != null)
                    Rows[i].Dispose();

                Rows[i] = new MailItemRow
                {
                    Mail = GameScene.User.Mail[i + StartIndex],
                    Location = new Point(10, 55 + i * 33),
                    Parent = this
                };

                Rows[i].Click += (o, e) =>
                {
                    MailItemRow row = (MailItemRow)o;

                    if (row.Mail != SelectedMail)
                    {
                        SelectedMail = row.Mail;
                        SelectedIndex = FindSelectedIndex();
                        UpdateRows();
                    }
                    else
                    {
                        if (SelectedMail.Gold > 0 || SelectedMail.Items.Count > 0)
                        {
                            GameScene.Scene.MailReadParcelDialog.ReadMail(SelectedMail);
                        }
                        else
                        {
                            GameScene.Scene.MailReadLetterDialog.ReadMail(SelectedMail);
                        }
                    }
                };

                if (SelectedMail != null)
                {
                    if(SelectedMail.MailID == Rows[i].Mail.MailID)
                    {
                        SelectedMail = Rows[i].Mail;
                    }
                }
            }

            UpdateRows();
        }