void loadCard(dsLanguageData.CardRow card) { clearCard(); _curCard = card; if (_curCard != null) { txtAnswer.Text = _curCard.Answer; txtQuestion.Text = _curCard.Question; LanguageData dataLayer = new LanguageData(); dsLanguageData.PictureDataTable dtPic = dataLayer.daPicture.GetDataByCardID(_curCard.ID); if (dtPic != null && dtPic.Rows.Count > 0 && dtPic[0].Image.Length > 0) { cardPreviewPictureBox.Image = dataLayer.ByteArrayToImage(dtPic[0].Image); } } }
/// <summary> /// Loads the card and also checks to make sure the user is finished with the previous card. /// </summary> /// <param name="card"></param> /// <returns>Whether or not the card was loaded</returns> public bool LoadCard(dsLanguageData.CardRow card) { bool result = false; if (ChangesHaveBeenSavedOrIgnored()) { ClearCard(); if (card == null) return true; SuspendLayout(); _curCard = card; LanguageData dataLayer = new LanguageData(); dsLanguageData.SoundClipDataTable dtSound = dataLayer.daSoundClip.GetDataByCardID(_curCard.ID); if (dtSound.Rows.Count > 0 && dtSound[0].SoundClip != null) { _curSoundClip = dtSound[0]; _dictaphone.WavStream = new MemoryStream(_curSoundClip.SoundClip); _dictaphone.ClosePlayer(); setSoundButton(true); } dsLanguageData.PictureDataTable dtPic = dataLayer.daPicture.GetDataByCardID(_curCard.ID); if (dtPic.Rows.Count > 0 && dtPic[0].Image != null) { pictureBox.Image = dataLayer.ByteArrayToImage(dtPic[0].Image); } txtQuestion.Text = getTextForQuestion(_curCard); if (chkBoxShowAnswer.Checked) ShowInformation(); txtNotes.Text = _curCard.Notes; Difficulty = _curCard.Difficulty; result = true; ResumeLayout(); } if (result) { SetEnable(true); } return result; }