private void Save_Click() { if (!ValidateWikiPage(true)) { return; } WikiPage wikiPageDB = WikiPages.GetByTitle(WikiPageCur.PageTitle); if (wikiPageDB != null && WikiPageCur.DateTimeSaved < wikiPageDB.DateTimeSaved) { if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This page has been modified and saved since it was opened on this computer. Save anyway?")) { return; } } WikiPageCur.PageContent = textContent.Text; //Fix case on all internal links MatchCollection matches = Regex.Matches(WikiPageCur.PageContent, @"\[\[.+?\]\]"); foreach (Match match in matches) { if (match.Value.StartsWith("[[img:") || match.Value.StartsWith("[[keywords:") || match.Value.StartsWith("[[file:") || match.Value.StartsWith("[[folder:") || match.Value.StartsWith("[[list:") || match.Value.StartsWith("[[color:")) { continue; //we don't care about these. We are only checking internal links } //Get the pagename of the link string oldTitle = match.Value.Substring(2, match.Value.Length - 4); string newTitle = WikiPages.GetTitle(oldTitle); if (oldTitle == newTitle) //casing matches { continue; } if (newTitle == "") //broken link, leave alone { continue; } WikiPageCur.PageContent = WikiPageCur.PageContent.Replace("[[" + oldTitle + "]]", "[[" + newTitle + "]]"); } WikiPageCur.UserNum = Security.CurUser.UserNum; Regex regex = new Regex(@"\[\[(keywords:).+?\]\]"); //only grab first match Match m = regex.Match(textContent.Text); WikiPageCur.KeyWords = m.Value.Replace("[[keywords:", "").TrimEnd(']'); //will be empty string if no match WikiPages.InsertAndArchive(WikiPageCur); FormWiki formWiki = (FormWiki)this.OwnerForm; if (formWiki != null && !formWiki.IsDisposed) { formWiki.RefreshPage(WikiPageCur.PageTitle); } closingIsSave = true; Close(); //should be dialog result?? }