/// <summary> /// Refresh the <see cref="Control"/>s contained in the <see cref="Menu"/> /// </summary> public void Refresh() { Book book = Library.GetLibrary.GetBook(CurrentItemID.ToString()); #region Refresh Header Header.Text = ((book != null) ? (book.Title) : ("Error")); Header.Position = new Vector2(Vector2.CenterX(Header.Text.Length + 2), HeaderPosY); #endregion #region Refresh Author string author = ((book != null) ? (book.Author) : ("Error")); authorText.Text = author; authorLabel.Position = new Vector2(Vector2.CenterX(authorLabel.Size.x + authorText.Text.Length + 2), HeaderPosY + HeaderOffset); authorText.Position = new Vector2(authorLabel.Position.x + authorLabel.Size.x - 1, HeaderPosY + HeaderOffset); #endregion #region Refresh ISBN Code string isbnCode = ((book != null) ? (book.ISBNCode) : ("Error")); isbnCodeText.Text = isbnCode; isbnCodeLabel.Position = new Vector2(Vector2.CenterX(isbnCodeLabel.Size.x + isbnCodeText.Text.Length + 2), authorLabel.Position.y + 3); isbnCodeText.Position = new Vector2(isbnCodeLabel.Position.x + isbnCodeLabel.Size.x - 1, isbnCodeLabel.Position.y); #endregion #region Refresh Category string category = ((book != null) ? (book.Category) : ("Error")); categoryText.Text = category; categoryLabel.Position = new Vector2(Vector2.CenterX(categoryLabel.Size.x + categoryText.Text.Length + 2), isbnCodeText.Position.y + 3); categoryText.Position = new Vector2(categoryLabel.Position.x + categoryLabel.Size.x - 1, categoryLabel.Position.y); #endregion #region Refresh Status string status = ((book != null) ? ((book.IsBorrowed) ? ("Borrowed") : ("Available")) : ("Error")); statusText.Text = status; statusLabel.Position = new Vector2(Vector2.CenterX(statusLabel.Size.x + statusText.Text.Length + 2), categoryText.Position.y + 3); statusText.Position = new Vector2(statusLabel.Position.x + statusLabel.Size.x - 1, statusLabel.Position.y); #endregion #region Refresh Category string dol = ((book != null) ? (book.DateOfLending.ToShortDateString()) : ("Error")); dolText.Text = dol; dolLabel.Position = new Vector2(Vector2.CenterX(dolLabel.Size.x + dolText.Text.Length + 2), statusText.Position.y + 3); dolText.Position = new Vector2(dolLabel.Position.x + dolLabel.Size.x - 1, dolLabel.Position.y); #endregion }
public Task <bool> SendiTunesRadioNeverPlayThisSongCommandAsync() { if (!IsPlayingiTunesRadio) { return(Task.FromResult(false)); } DacpRequest request = new DacpRequest("/ctrl-int/1/setproperty"); request.QueryParameters["com.apple.itunes.liked-state"] = "3"; request.QueryParameters["database-spec"] = DacpQueryPredicate.Is("dmap.itemid", "0x" + CurrentDatabaseID.ToString("x")).ToString(); request.QueryParameters["item-spec"] = DacpQueryPredicate.Is("dmap.itemid", "0x" + CurrentItemID.ToString("x")).ToString(); return(SendCommandAsync(request)); }
public async Task <bool> SendiTunesRadioNeverPlayThisSongAsync() { if (!IsCurrentlyPlayingiTunesRadio) { return(false); } DACPRequest request = new DACPRequest("/ctrl-int/1/setproperty"); request.QueryParameters["com.apple.itunes.liked-state"] = "3"; request.QueryParameters["database-spec"] = DACPQueryPredicate.Is("dmap.itemid", "0x" + CurrentDatabaseID.ToString("x")).ToString(); request.QueryParameters["item-spec"] = DACPQueryPredicate.Is("dmap.itemid", "0x" + CurrentItemID.ToString("x")).ToString(); try { await SubmitRequestAsync(request); } catch { return(false); } return(true); }