public void AddButtonMailItems(ContentManager contentManager, IEnumerable <MailItem> inbox, IEnumerable <MailItem> outbox, IEnumerable <MailItem> archive) { string fontPath = contentManager.GetContentPath(Styles.Fonts.Arcade); Color fontColorTitle = Styles.Colors.PaleGreen; int fontSizeTitle = Styles.FontSizes.Title; int fontSizeContent = Styles.FontSizes.Content; foreach (MailItem mailItem in inbox) { ButtonMailItem buttonMailItem = new ButtonMailItem(mailItem); buttonMailItem.TextureFrame = contentManager.GetTexture("ButtonMailItem"); //buttonMailItem.TextureFrameHovered = contentManager.GetTexture("ButtonMailItemHover"); //buttonMailItem.TextureFrameSelected = contentManager.GetTexture("ButtonMailItemSelected"); buttonMailItem.IconMailUnread = ControlFactory.CreateIcon(contentManager, "IconMailUnread"); buttonMailItem.IconMailRead = ControlFactory.CreateIcon(contentManager, "IconMailRead"); buttonMailItem.LabelFrom = ControlFactory.CreateLabel(contentManager, fontPath, fontSizeContent, fontColorTitle, mailItem.From); buttonMailItem.LabelSubject = ControlFactory.CreateLabel(contentManager, fontPath, fontSizeContent, fontColorTitle, mailItem.Subject); Icon iconSeparator = ControlFactory.CreateIcon(contentManager, "IconSeparator"); AddButtonMailItemInbox(buttonMailItem, iconSeparator); } foreach (MailItem mailItem in outbox) { ButtonMailItem buttonMailItem = new ButtonMailItem(mailItem); buttonMailItem.TextureFrame = contentManager.GetTexture("ButtonMailItem"); //buttonMailItem.TextureFrameHovered = contentManager.GetTexture("ButtonMailItemHover"); //buttonMailItem.TextureFrameSelected = contentManager.GetTexture("ButtonMailItemSelected"); buttonMailItem.IconMailUnread = ControlFactory.CreateIcon(contentManager, "IconMailUnread"); buttonMailItem.IconMailRead = ControlFactory.CreateIcon(contentManager, "IconMailRead"); buttonMailItem.LabelFrom = ControlFactory.CreateLabel(contentManager, fontPath, fontSizeContent, fontColorTitle, mailItem.From); buttonMailItem.LabelSubject = ControlFactory.CreateLabel(contentManager, fontPath, fontSizeContent, fontColorTitle, mailItem.Subject); Icon iconSeparator = ControlFactory.CreateIcon(contentManager, "IconSeparator"); AddButtonMailItemOutbox(buttonMailItem, iconSeparator); } foreach (MailItem mailItem in archive) { ButtonMailItem buttonMailItem = new ButtonMailItem(mailItem); buttonMailItem.TextureFrame = contentManager.GetTexture("ButtonMailItem"); //buttonMailItem.TextureFrameHovered = contentManager.GetTexture("ButtonMailItemHover"); //buttonMailItem.TextureFrameSelected = contentManager.GetTexture("ButtonMailItemSelected"); buttonMailItem.IconMailUnread = ControlFactory.CreateIcon(contentManager, "IconMailUnread"); buttonMailItem.IconMailRead = ControlFactory.CreateIcon(contentManager, "IconMailRead"); buttonMailItem.LabelFrom = ControlFactory.CreateLabel(contentManager, fontPath, fontSizeContent, fontColorTitle, mailItem.From); buttonMailItem.LabelSubject = ControlFactory.CreateLabel(contentManager, fontPath, fontSizeContent, fontColorTitle, mailItem.Subject); Icon iconSeparator = ControlFactory.CreateIcon(contentManager, "IconSeparator"); AddButtonMailItemArchive(buttonMailItem, iconSeparator); } buttonMailOpen.Visible = false; buttonMailArchive.Visible = false; }
private void buttonMailItem_Clicked(object sender, EventArgs e) { ButtonMailItem clickedButtonMailItem = sender as ButtonMailItem; if (clickedButtonMailItem != null) { //foreach (var page in mailItemPages.Values) // foreach (var button in page.Buttons) // button.ToggleOff(); //clickedButtonMailItem.ToggleOn(); SelectedMailItem = clickedButtonMailItem.MailItem; buttonMailOpen.Visible = true; buttonMailArchive.Visible = true; } }
private void AddButtonMailItem(ButtonMailItem buttonMailItem, IDictionary <int, MailItemPage> mailItemPages, Icon iconSeparator) { // the last page number will indicate the key in which we check for the next items to add int lastPageNumber = mailItemPages.Keys.Count(); int buttonsOnLastPageCount = 0; MailItemPage lastPage = null; bool success = mailItemPages.TryGetValue(lastPageNumber, out lastPage); if (success) { // if there are pages in this page collection and the last page contains less than 4 entries, add the new entry to that page if (lastPage.Buttons.Count() < itemsPerPage) { lastPage.AddButton(buttonMailItem); lastPage.AddSeparator(iconSeparator); } // if there are 4 items on the last page, create a new page and add the item else { lastPage = new MailItemPage(); lastPage.AddButton(buttonMailItem); lastPage.AddSeparator(iconSeparator); mailItemPages.Add(lastPageNumber + 1, lastPage); } } else { // if there are no pages, create an entry and add the first page lastPage = new MailItemPage(); lastPage.AddButton(buttonMailItem); lastPage.AddSeparator(iconSeparator); mailItemPages.Add(1, lastPage); } buttonsOnLastPageCount = lastPage.Buttons.Count(); Vector buttonMailItemPosition = Vector.Zero; Vector iconSeparatorPosition = Vector.Zero; if (buttonsOnLastPageCount == 1) { iconSeparatorPosition = new Vector(Position.X + 156, Position.Y + 102); buttonMailItemPosition = new Vector(Position.X + 158, Position.Y + 70); } else if (buttonsOnLastPageCount == 2) { iconSeparatorPosition = new Vector(Position.X + 156, Position.Y + 139); buttonMailItemPosition = new Vector(Position.X + 158, Position.Y + 107); } else if (buttonsOnLastPageCount == 3) { iconSeparatorPosition = new Vector(Position.X + 156, Position.Y + 176); buttonMailItemPosition = new Vector(Position.X + 158, Position.Y + 144); } else if (buttonsOnLastPageCount == 4) { iconSeparatorPosition = new Vector(Position.X + 156, Position.Y + 213); buttonMailItemPosition = new Vector(Position.X + 158, Position.Y + 181); } else if (buttonsOnLastPageCount == 5) { iconSeparatorPosition = new Vector(Position.X + 156, Position.Y + 250); buttonMailItemPosition = new Vector(Position.X + 158, Position.Y + 218); } else if (buttonsOnLastPageCount >= itemsPerPage + 1) { return; } iconSeparator.Position = iconSeparatorPosition; buttonMailItem.Position = buttonMailItemPosition; buttonMailItem.Clicked += buttonMailItem_Clicked; SetActiveTab(activeTab); SetLabelPageNumber(); }
public void AddButtonMailItemArchive(ButtonMailItem buttonMailItem, Icon iconSeparator) { AddButtonMailItem(buttonMailItem, mailItemArchivePages, iconSeparator); }
public void AddButtonMailItemOutbox(ButtonMailItem buttonMailItem, Icon iconSeparator) { AddButtonMailItem(buttonMailItem, mailItemOutboxPages, iconSeparator); }
public void AddButton(ButtonMailItem button) { buttons.Add(button); }