public MailDialog() { TitleLabel.Text = "邮件"; HasFooter = true; SetClientSize(new Size(350, 350)); //Rows Header = new MailRow { Parent = this, Location = ClientArea.Location, IsHeader = true, }; Rows = new MailRow[15]; ScrollBar = new DXVScrollBar { Parent = this, Size = new Size(14, ClientArea.Height - 2 - 22), Location = new Point(ClientArea.Right - 14, ClientArea.Top + 1 + 22), VisibleSize = 15, Change = 3, }; ScrollBar.ValueChanged += ScrollBar_ValueChanged; MouseWheel += ScrollBar.DoMouseWheel; DXControl panel = new DXControl { Parent = this, Location = new Point(ClientArea.Location.X, ClientArea.Location.Y + Header.Size.Height + 2), Size = new Size(ClientArea.Width - 16, ClientArea.Size.Height - 22) }; for (int i = 0; i < 15; i++) { int index = i; Rows[index] = new MailRow { Parent = panel, Location = new Point(0, 22 * i), Visible = false, }; Rows[index].MouseClick += (o, e) => { GameScene.Game.ReadMailBox.Mail = Rows[index].Mail; if (Rows[index].Mail.Opened) { return; } Rows[index].Mail.Opened = true; Rows[index].RefreshIcon(); GameScene.Game.MailBox.UpdateIcon(); CEnvir.Enqueue(new C.MailOpened { Index = Rows[index].Mail.Index }); }; Rows[index].MouseWheel += ScrollBar.DoMouseWheel; } CollectAllButton = new DXButton { Location = new Point(ClientArea.Right - 100, Size.Height - 43), Size = new Size(80, DefaultHeight), Parent = this, Label = { Text = "签收" } }; CollectAllButton.MouseClick += (o, e) => { int count = 15; foreach (ClientMailInfo mail in MailList) { if (count <= 0) { break; } if (mail.Items.Count == 0) { continue; } if (!mail.Opened) { mail.Opened = true; CEnvir.Enqueue(new C.MailOpened { Index = mail.Index }); count--; foreach (MailRow row in Rows) { if (row.Mail != mail) { continue; } row.RefreshIcon(); break; } } foreach (ClientUserItem item in mail.Items) { CEnvir.Enqueue(new C.MailGetItem { Index = mail.Index, Slot = item.Slot }); } count--; } GameScene.Game.MailBox.UpdateIcon(); }; DeleteAll = new DXButton { Location = new Point(ClientArea.Right - 200, Size.Height - 43), Size = new Size(80, DefaultHeight), Parent = this, Label = { Text = "删除" } }; DeleteAll.MouseClick += (o, e) => { int count = 15; foreach (ClientMailInfo mail in MailList) { if (count <= 0) { break; } if (mail.Items.Count > 0) { continue; } CEnvir.Enqueue(new C.MailDelete { Index = mail.Index }); count--; } }; NewButton = new DXButton { Location = new Point(ClientArea.Right - 300, Size.Height - 43), Size = new Size(80, DefaultHeight), Parent = this, Label = { Text = "写邮件" } }; NewButton.MouseClick += (o, e) => { GameScene.Game.SendMailBox.Visible = true; GameScene.Game.SendMailBox.BringToFront(); }; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (CollectAllButton != null) { if (!CollectAllButton.IsDisposed) { CollectAllButton.Dispose(); } CollectAllButton = null; } if (DeleteAll != null) { if (!DeleteAll.IsDisposed) { DeleteAll.Dispose(); } DeleteAll = null; } if (NewButton != null) { if (!NewButton.IsDisposed) { NewButton.Dispose(); } NewButton = null; } if (Header != null) { if (!Header.IsDisposed) { Header.Dispose(); } Header = null; } if (ScrollBar != null) { if (!ScrollBar.IsDisposed) { ScrollBar.Dispose(); } ScrollBar = null; } if (NewButton != null) { if (!NewButton.IsDisposed) { NewButton.Dispose(); } NewButton = null; } if (Rows != null) { for (int i = 0; i < Rows.Length; i++) { if (Rows[i] != null) { if (!Rows[i].IsDisposed) { Rows[i].Dispose(); } Rows[i] = null; } } Rows = null; } MailList.Clear(); MailList = null; } }