/// <summary></summary> private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g(this, "Title"), 70); gridMain.Columns.Add(col); //col=new ODGridColumn(Lan.g(this,"Saved"),42); //gridMain.Columns.Add(col); gridMain.Rows.Clear(); if (checkDeletedOnly.Checked) { listWikiPageTitles = WikiPageHists.GetDeletedPages(textSearch.Text, checkIgnoreContent.Checked); } else { listWikiPageTitles = WikiPages.GetForSearch(textSearch.Text, checkIgnoreContent.Checked); } for (int i = 0; i < listWikiPageTitles.Count; i++) { ODGridRow row = new ODGridRow(); row.Cells.Add(listWikiPageTitles[i]); gridMain.Rows.Add(row); } gridMain.EndUpdate(); webBrowserWiki.DocumentText = ""; }
private void LoadWikiPage(string WikiPageTitleCur) { webBrowserWiki.AllowNavigation = true; butRestore.Enabled = false; if (checkDeletedOnly.Checked) { webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(WikiPageHists.GetDeletedByTitle(WikiPageTitleCur).PageContent, true); butRestore.Enabled = true; } else { webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(WikiPages.GetByTitle(WikiPageTitleCur).PageContent, true); } }
private void LoadWikiPage(WikiPageHist wikiPageCur) { try { if (string.IsNullOrEmpty(wikiPageCur.PageContent)) { //if this is the first time the user has clicked on this revision, get page content from db (the row's tag will have this as well) wikiPageCur.PageContent = WikiPageHists.GetPageContent(wikiPageCur.WikiPageNum); } textContent.Text = WikiPages.GetWikiPageContentWithWikiPageTitles(wikiPageCur.PageContent); webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(textContent.Text, false, hasWikiPageTitles: true); } catch (Exception ex) { webBrowserWiki.DocumentText = ""; MessageBox.Show(this, Lan.g(this, "This page is broken and cannot be viewed. Error message:") + " " + ex.Message); } }
private void butRestore_Click(object sender, EventArgs e) { if (gridMain.GetSelectedIndex() == -1) { return; //should never happen. } wikiPageTitleSelected = listWikiPageTitles[gridMain.SelectedIndices[0]]; if (WikiPages.GetByTitle(wikiPageTitleSelected) != null) { MsgBox.Show(this, "Selected page has already been restored."); //should never happen. return; } WikiPage wikiPageRestored = WikiPageHists.RevertFrom(WikiPageHists.GetDeletedByTitle(listWikiPageTitles[gridMain.SelectedIndices[0]])); wikiPageRestored.UserNum = Security.CurUser.UserNum; WikiPages.InsertAndArchive(wikiPageRestored); DialogResult = DialogResult.OK; }
private void butRevert_Click(object sender, EventArgs e) { if (gridMain.GetSelectedIndex() == -1) { return; } if (gridMain.GetSelectedIndex() == gridMain.Rows.Count - 1) //current revision of page //DialogResult=DialogResult.OK; { return; } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Revert page to currently selected revision?")) { return; } WikiPage wikiPageNew = WikiPageHists.RevertFrom(gridMain.Rows[gridMain.GetSelectedIndex()].Tag as WikiPageHist); wikiPageNew.UserNum = Security.CurUser.UserNum; WikiPages.InsertAndArchive(wikiPageNew); FillGrid(); }
/// <summary></summary> private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g(this, "User"), 70); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Del"), 25); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Saved"), 80); gridMain.Columns.Add(col); gridMain.Rows.Clear(); List <WikiPageHist> listWikiPageHists = WikiPageHists.GetByTitleNoPageContent(PageTitleCur); WikiPage wp = WikiPages.GetByTitle(PageTitleCur); if (wp != null) { listWikiPageHists.Add(WikiPages.PageToHist(wp)); } Dictionary <long, string> dictUsers = Userods.GetUsers(listWikiPageHists.Select(x => x.UserNum).Distinct().ToList()) //gets from cache, very fast .ToDictionary(x => x.UserNum, x => x.UserName); //create dictionary of key=UserNum, value=UserName for fast lookup foreach (WikiPageHist wPage in listWikiPageHists) { ODGridRow row = new ODGridRow(); string userName; if (!dictUsers.TryGetValue(wPage.UserNum, out userName)) { userName = ""; } row.Cells.Add(userName); row.Cells.Add((wPage.IsDeleted?"X":"")); row.Cells.Add(wPage.DateTimeSaved.ToString()); row.Tag = wPage; gridMain.Rows.Add(row); } gridMain.EndUpdate(); gridMain.SetSelected(gridMain.Rows.Count - 1, true); //There will always be at least one page in the history (the current revision of the page) gridMain.ScrollToEnd(); //in case there are LOTS of revisions }
/// <summary></summary> private void FillGrid() { gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g(this, "User"), 70); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Del"), 25); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Saved"), 80); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ListWikiPageHists = WikiPageHists.GetByTitle(PageTitleCur); ListWikiPageHists.Add(WikiPages.PageToHist(WikiPages.GetByTitle(PageTitleCur))); for (int i = 0; i < ListWikiPageHists.Count; i++) { ODGridRow row = new ODGridRow(); row.Cells.Add(Userods.GetName(ListWikiPageHists[i].UserNum)); row.Cells.Add((ListWikiPageHists[i].IsDeleted?"X":"")); row.Cells.Add(ListWikiPageHists[i].DateTimeSaved.ToString()); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void butRevert_Click(object sender, EventArgs e) { if (gridMain.GetSelectedIndex() == -1) { return; } if (gridMain.GetSelectedIndex() == gridMain.Rows.Count - 1) //current revision of page //DialogResult=DialogResult.OK; { return; } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Revert page to currently selected revision?")) { return; } WikiPage wikiPageNew = WikiPageHists.RevertFrom(ListWikiPageHists[gridMain.GetSelectedIndex()]); wikiPageNew.UserNum = Security.CurUser.UserNum; WikiPages.InsertAndArchive(wikiPageNew); FillGrid(); gridMain.SetSelected(false); gridMain.SetSelected(gridMain.Rows.Count - 1, true); //select the new revision. gridMain.ScrollToEnd(); //in case there are LOTS of revisions. Should this go in the fill grid code? }