public bool OnClickHide(string strId) { int nVerseIndex, nConversationIndex; ConsultNotesDataConverter theCNsDC; ConsultNoteDataConverter theCNDC; if (!GetDataConverters(strId, out nVerseIndex, out nConversationIndex, out theCNsDC, out theCNDC)) { return(false); } // if there's only one and it's empty, then just delete it if (!theCNDC.HasData) { OnClickDelete(strId); } theCNDC.Visible = (theCNDC.Visible) ? false : true; if (TheSE.hiddenVersesToolStripMenuItem.Checked) { // then we just swap the text on the button if (Document != null) { // repaint the button to be 'hide' // since the strId might be from a Delete request (where the user // said "yes" to our request to hide it instead), we have to // rebuild the ID for the Hide button, which is: strId = ConsultNoteDataConverter.ButtonId(nVerseIndex, nConversationIndex, ConsultNoteDataConverter.CnBtnIndexHide); HtmlElement elemButtonHide = Document.GetElementById(strId); if (elemButtonHide != null) { elemButtonHide.InnerText = (theCNDC.Visible) ? ConsultNoteDataConverter.CstrButtonLabelHide : ConsultNoteDataConverter.CstrButtonLabelUnhide; return(true); } } } // otherwise remove the row of buttons and the embedded conversation table // if it's not invisible (but only if it's the last conversation... if it // isn't the last one, then just hiding it won't work, because the subsequent // conversations will have the wrong index (so we *must* do LoadDoc) else if (!theCNDC.Visible && (theCNsDC.Count == (nConversationIndex - 1)) && RemoveHtmlNodeById(ConsultNoteDataConverter.ButtonRowId(nVerseIndex, nConversationIndex)) && RemoveHtmlNodeById(ConsultNoteDataConverter.ConversationTableRowId(nVerseIndex, nConversationIndex))) { return(true); } // otherwise, we have to reload the document LoadDocument(); return(true); }
public bool OnClickDelete(string strId) { int nVerseIndex, nConversationIndex; ConsultNotesDataConverter theCNsDC; ConsultNoteDataConverter theCNDC; if (!GetDataConverters(strId, out nVerseIndex, out nConversationIndex, out theCNsDC, out theCNDC)) { return(false); } if (theCNDC.HasData) { DialogResult res = MessageBox.Show( Properties.Resources.IDS_NoteNotEmptyHideQuery, Properties.Resources.IDS_Caption, MessageBoxButtons.YesNoCancel); if (res == DialogResult.Yes) { return(OnClickHide(strId)); } if (res == DialogResult.Cancel) { return(true); } } bool bRemovedLast = (theCNsDC.IndexOf(theCNDC) == (theCNsDC.Count - 1)); theCNsDC.Remove(theCNDC); // remove the HTML elements for the row of buttons and the conversation table // (but only if it was the last conversation. If it wasn't, then the other // conversations will have out of sequence ids, so we'll just *have* to do // LoadDoc if (bRemovedLast && RemoveHtmlNodeById(ConsultNoteDataConverter.ButtonRowId(nVerseIndex, nConversationIndex)) && RemoveHtmlNodeById(ConsultNoteDataConverter.ConversationTableRowId(nVerseIndex, nConversationIndex))) { return(true); } LoadDocument(); return(true); }