///<summary>Adds a new wikipage.</summary> private void butAdd_Click(object sender, EventArgs e) { FormWikiRename FormWR = new FormWikiRename(); FormWR.ShowDialog(); if (FormWR.DialogResult != DialogResult.OK) { return; } Action <string> onWikiSaved = new Action <string>((pageTitleNew) => { //return the new wikipage added to FormWikiEdit WikiPage wp = WikiPages.GetByTitle(pageTitleNew); if (wp != null && OwnerForm != null && !OwnerForm.IsDisposed) { OwnerForm.RefreshPage(wp); } }); FormWikiEdit FormWE = new FormWikiEdit(onWikiSaved); FormWE.WikiPageCur = new WikiPage(); FormWE.WikiPageCur.IsNew = true; FormWE.WikiPageCur.PageTitle = FormWR.PageTitle; FormWE.WikiPageCur.PageContent = "[[" + OwnerForm.WikiPageCur.PageTitle + "]]\r\n" //link back + "<h1>" + FormWR.PageTitle + "</h1>\r\n"; //page title FormWE.Show(); Close(); }
private void Edit_Click() { if (WikiPageCur == null) { return; } FormWikiEdit FormWE = new FormWikiEdit(); FormWE.WikiPageCur = WikiPageCur; FormWE.OwnerForm = this; FormWE.Show(); }
///<summary>Before calling this, make sure to increment/decrement the historyNavBack index to keep track of the position in history. If loading a new page, decrement historyNavBack before calling this function. </summary> private void LoadWikiPage(string pageTitle) { //This is called from 11 different places, any time the program needs to refresh a page from the db. //It's also called from the browser_Navigating event when a "wiki:" link is clicked. WikiPage wpage = WikiPages.GetByTitle(pageTitle); if (wpage == null) { if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "That page does not exist. Would you like to create it?")) { return; } FormWikiEdit FormWE = new FormWikiEdit(); FormWE.WikiPageCur = new WikiPage(); FormWE.WikiPageCur.IsNew = true; FormWE.WikiPageCur.PageTitle = pageTitle; FormWE.WikiPageCur.PageContent = "[[" + WikiPageCur.PageTitle + "]]\r\n" //link back + "<h1>" + pageTitle + "</h1>\r\n"; //page title FormWE.OwnerForm = this; FormWE.Show(); return; } WikiPageCur = wpage; webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(WikiPageCur.PageContent, false); Text = "Wiki - " + WikiPageCur.PageTitle; #region historyMaint //This region is duplicated in webBrowserWiki_Navigating() for external links. Modifications here will need to be reflected there. int indexInHistory = historyNav.Count - (1 + historyNavBack); //historyNavBack number of pages before the last page in history. This is the index of the page we are loading. if (historyNav.Count == 0) //empty history { historyNavBack = 0; historyNav.Add("wiki:" + pageTitle); } else if (historyNavBack < 0) //historyNavBack could be negative here. This means before the action that caused this load, we were not navigating through history, simply set back to 0 and add to historyNav[] if necessary. { historyNavBack = 0; if (historyNav[historyNav.Count - 1] != "wiki:" + pageTitle) { historyNav.Add("wiki:" + pageTitle); } } else if (historyNavBack >= 0 && historyNav[indexInHistory] != "wiki:" + pageTitle) //branching from page in history { historyNav.RemoveRange(indexInHistory, historyNavBack + 1); //remove "forward" history. branching off in a new direction historyNavBack = 0; historyNav.Add("wiki:" + pageTitle); } #endregion }
private void EditWikiDraft() { int selectedIndex=gridMain.GetSelectedIndex(); FormWikiEdit FormWE=new FormWikiEdit(); FormWE.WikiPageCur=_listWikiPage[selectedIndex]; FormWE.OwnerForm=this.OwnerForm; FormWE.ShowDialog(); if(FormWE.HasSaved) { Close(); return; } FillGrid(); gridMain.SetSelected(selectedIndex,true); webBrowserWiki.AllowNavigation=true; LoadWikiPage(_listWikiPage[selectedIndex]); gridMain.Focus(); }
///<summary>Before calling this, make sure to increment/decrement the historyNavBack index to keep track of the position in history. If loading a new page, decrement historyNavBack before calling this function. </summary> private void LoadWikiPage(string pageTitle) { //This is called from 11 different places, any time the program needs to refresh a page from the db. //It's also called from the browser_Navigating event when a "wiki:" link is clicked. WikiPage wpage=WikiPages.GetByTitle(pageTitle); if(wpage==null) { if(!MsgBox.Show(this,MsgBoxButtons.YesNo,"That page does not exist. Would you like to create it?")) { return; } FormWikiEdit FormWE=new FormWikiEdit(); FormWE.WikiPageCur=new WikiPage(); FormWE.WikiPageCur.IsNew=true; FormWE.WikiPageCur.PageTitle=pageTitle; FormWE.WikiPageCur.PageContent="[["+WikiPageCur.PageTitle+"]]\r\n"//link back +"<h1>"+pageTitle+"</h1>\r\n";//page title FormWE.OwnerForm=this; FormWE.Show(); return; } WikiPageCur=wpage; try { webBrowserWiki.DocumentText=WikiPages.TranslateToXhtml(WikiPageCur.PageContent,false); } catch(Exception ex) { webBrowserWiki.DocumentText=""; MessageBox.Show(this,Lan.g(this,"This page is broken and cannot be viewed. Error message:")+" "+ex.Message); } Text="Wiki - "+WikiPageCur.PageTitle; #region historyMaint //This region is duplicated in webBrowserWiki_Navigating() for external links. Modifications here will need to be reflected there. int indexInHistory=historyNav.Count-(1+historyNavBack);//historyNavBack number of pages before the last page in history. This is the index of the page we are loading. if(historyNav.Count==0) {//empty history historyNavBack=0; historyNav.Add("wiki:"+pageTitle); } else if(historyNavBack<0) {//historyNavBack could be negative here. This means before the action that caused this load, we were not navigating through history, simply set back to 0 and add to historyNav[] if necessary. historyNavBack=0; if(historyNav[historyNav.Count-1]!="wiki:"+pageTitle) { historyNav.Add("wiki:"+pageTitle); } } else if(historyNavBack>=0 && historyNav[indexInHistory]!="wiki:"+pageTitle) {//branching from page in history historyNav.RemoveRange(indexInHistory,historyNavBack+1);//remove "forward" history. branching off in a new direction historyNavBack=0; historyNav.Add("wiki:"+pageTitle); } #endregion }
public void AddWikiPage(Action <string> onNewPageSaved = null) { FormWikiRename FormWR = new FormWikiRename(); FormWR.ShowDialog(); if (FormWR.DialogResult != DialogResult.OK) { return; } FormWikiEdit FormWE = new FormWikiEdit(onNewPageSaved); FormWE.WikiPageCur = new WikiPage(); FormWE.WikiPageCur.IsNew = true; FormWE.WikiPageCur.PageTitle = FormWR.PageTitle; FormWE.WikiPageCur.PageContent = "[[" + WikiPageCur.PageTitle + "]]\r\n" //link back + "<h1>" + FormWR.PageTitle + "</h1>\r\n"; //page title FormWE.OwnerForm = this; FormWE.Show(); }
private void Add_Click() { FormWikiRename FormWR = new FormWikiRename(); FormWR.ShowDialog(); if (FormWR.DialogResult != DialogResult.OK) { return; } FormWikiEdit FormWE = new FormWikiEdit(); FormWE.WikiPageCur = new WikiPage(); FormWE.WikiPageCur.IsNew = true; FormWE.WikiPageCur.PageTitle = FormWR.PageTitle; FormWE.WikiPageCur.PageContent = "[[" + WikiPageCur.PageTitle + "]]\r\n" //link back + "<h1>" + FormWR.PageTitle + "</h1>\r\n"; //page title FormWE.OwnerForm = this; FormWE.Show(); }
private void Edit_Click() { if (Plugins.HookMethod(this, "FormWiki.Edit_Click")) { return; } if (WikiPageCur == null) { return; } if (WikiPages.GetDraftsByTitle(WikiPageCur.PageTitle).Count > 0 && MsgBox.Show(this, MsgBoxButtons.YesNo, "This page has one or more drafts associated with it. Would you like to open a draft instead of the current Wiki page?")) { FormWikiDrafts FormWD = new FormWikiDrafts(); FormWD.OwnerForm = this; FormWD.ShowDialog(); return; } FormWikiEdit FormWE = new FormWikiEdit(); FormWE.WikiPageCur = WikiPageCur.Copy(); FormWE.OwnerForm = this; FormWE.Show(); }
private void Add_Click() { FormWikiRename FormWR=new FormWikiRename(); FormWR.ShowDialog(); if(FormWR.DialogResult!=DialogResult.OK) { return; } FormWikiEdit FormWE=new FormWikiEdit(); FormWE.WikiPageCur=new WikiPage(); FormWE.WikiPageCur.IsNew=true; FormWE.WikiPageCur.PageTitle=FormWR.PageTitle; FormWE.WikiPageCur.PageContent="[["+WikiPageCur.PageTitle+"]]\r\n"//link back +"<h1>"+FormWR.PageTitle+"</h1>\r\n";//page title FormWE.OwnerForm=this; FormWE.Show(); }
private void Edit_Click() { if(WikiPageCur==null) { return; } FormWikiEdit FormWE=new FormWikiEdit(); FormWE.WikiPageCur=WikiPageCur; FormWE.OwnerForm=this; FormWE.Show(); }