/// <summary> /// If this display is a remote server it will receive a description of the content, /// and will have to create a content object based on that. We don't want to send /// actual objects to remote servers. /// </summary> /// <param name="identity">A "description" of the content</param> public bool SetContent(ContentIdentity identity) { IContentOperations newContent = null; bool success = true; try { switch ((ContentType)identity.Type) { case ContentType.BibleVerseIdx: newContent = new ABibleVerse(bibleLib[identity.BibleTransl], identity.VerseIdx, Display.config); break; case ContentType.BibleVerseRef: BibleVersion bible = bibleLib[identity.BibleTransl]; int idx = bible.GetVerseIndex(identity.VerseRef); newContent = new ABibleVerse(bible, idx, Display.config); break; case ContentType.PlainText: newContent = new TextToolContents(identity.Text, Display.config); break; case ContentType.Song: string songFile = DreamTools.GetDirectory(DirType.Songs, identity.SongName); newContent = (Song)Song.DeserializeFrom(songFile, identity.SongStrophe, Display.config); break; } } catch { } // Covers a multitude of sins (non-existent translation, or song, or verse, etc...) if (newContent != null) { if (NextDisplay != null) { success = NextDisplay.SetContent(newContent); } if (success) { this.content = newContent; success = this.UpdateDisplay(false); } } else { success = false; } return(success); }
private void Verse_ComboBox_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (bibleVersion == null) { return; } string reference = Verse_ComboBox.Text; string normReference; normReference = bibleVersion.NormalizeRef(reference); if (normReference.Length == 0) { // Maybe the user forgot to enter the verse. Default to the first verse of the chapter. normReference = bibleVersion.NormalizeRef(reference + " 1"); } int index = bibleVersion.GetVerseIndex(normReference); if (index >= 0) { RegEx_ComboBox.Text = "^" + this.bibleVersion.GetSimpleRef(normReference, true) + @"\s+.*"; Query(true); //mainForm.DisplayPreview.SetContent(new ABibleVerse(this.bibleVersion, index, mainForm.Config)); mainForm.DisplayPreview.SetContent(new ABibleVerse(this.bibleVersion, index, mainForm.Config, mainForm.bibleThemeWidget.Theme)); if (!Verse_ComboBox.Items.Contains(reference)) { Verse_ComboBox.Items.Insert(0, reference); } Results.Focus(); } else { RegEx_ComboBox.Text = ""; Results.Populate(bibleVersion, 0); Results.Focus(); Verse_ComboBox.Focus(); } e.Handled = true; } }