Exemple #1
0
		private void LoadWikiPage(WikiPage WikiPageCur) {
			try {
				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 LoadWikiPage(WikiPage wikiPage)
 {
     try {
         webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(wikiPage.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);
     }
 }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
        ///<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 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);
     }
 }
Exemple #6
0
 private void RefreshHtml()
 {
     webBrowserWiki.AllowNavigation = true;
     try {
         //remember scroll
         if (webBrowserWiki.Document != null)
         {
             ScrollTop = webBrowserWiki.Document.GetElementsByTagName("HTML")[0].ScrollTop;
         }
         webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(textContent.Text, true);
     }
     catch (Exception ex) {
         //don't refresh
     }
     //textContent.Focus();//this was causing a bug where it would re-highlight text after a backspace.
 }
Exemple #7
0
 private void LoadWikiPage(string WikiPageTitleCur)
 {
     webBrowserWiki.AllowNavigation = true;
     butRestore.Enabled             = false;
     try {
         if (checkArchivedOnly.Checked)
         {
             webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(WikiPages.GetByTitle(WikiPageTitleCur, isDeleted: true).PageContent, true);
             butRestore.Enabled          = true;
         }
         else
         {
             webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(WikiPages.GetByTitle(WikiPageTitleCur).PageContent, true);
         }
     }
     catch (Exception ex) {
         webBrowserWiki.DocumentText = "";
         MessageBox.Show(this, Lan.g(this, "This page is broken and cannot be viewed.  Error message:") + " " + ex.Message);
     }
 }
Exemple #8
0
        ///<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)
            {
                string errorMsg = "";
                if (!WikiPages.IsWikiPageTitleValid(pageTitle, out errorMsg))
                {
                    MsgBox.Show(this, "That page does not exist and cannot be made because the page title contains invalid characters.");
                    return;
                }
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "That page does not exist. Would you like to create it?"))
                {
                    return;
                }
                Action <string> onWikiSaved = new Action <string>((pageTitleNew) => {
                    //Insert the pageTitleNew where the pageTitle exists in the existing WikiPageCur
                    //(guaranteed to be unique because all INVALID WIKIPAGE LINK's have an ID at the end)
                    string pageContent      = WikiPages.GetWikiPageContentWithWikiPageTitles(WikiPageCur.PageContent);
                    WikiPageCur.PageContent = pageContent.Replace(pageTitle, pageTitleNew);
                    WikiPageCur.PageContent = WikiPages.ConvertTitlesToPageNums(WikiPageCur.PageContent);
                    WikiPages.Update(WikiPageCur);
                });
                AddWikiPage(onWikiSaved);
                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
        }
Exemple #9
0
 private void LoadWikiPage(WikiPage wikiPage)
 {
     webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(wikiPage.PageContent, false);
 }
Exemple #10
0
 private void LoadWikiPage(WikiPageHist WikiPageCur)
 {
     webBrowserWiki.DocumentText = WikiPages.TranslateToXhtml(WikiPageCur.PageContent, false);
     textContent.Text            = WikiPageCur.PageContent;
 }