Пример #1
0
 private void butOk_Click(object sender, EventArgs e)
 {
     IsRaw = checkIsRaw.Checked;
     if (!IsRaw)             //do not validate for Raw emails. User is responsible for all validation themselves.
     {
         if (!MarkupL.ValidateMarkup(textContentEmail, true, true, true))
         {
             _isInvalidPreview = true;
             return;
         }
         if (_isInvalidPreview)
         {
             MsgBox.Show(this, "This page is in an invalid state and cannot be saved.");
             return;
         }
     }
     if (DoCheckForDisclaimer && PrefC.GetBool(PrefName.EmailDisclaimerIsOn) && !textContentEmail.Text.ToLower().Contains("[emaildisclaimer]"))
     {
         MsgBox.Show(this, "Email must contain the \"[EmailDisclaimer]\" tag.");
         return;
     }
     HtmlText     = webBrowserEmail.DocumentText;
     MarkupText   = textContentEmail.Text;
     DialogResult = DialogResult.OK;
     Close();
 }
Пример #2
0
        ///<summary>Saves the the currently edited Wikipage as a draft. This method is copied from Save_Click with a few modifications.</summary>
        private void SaveDraft_Click(bool showMsgBox = true)
        {
            if (showMsgBox && WikiPageCur.IsNew)
            {
                MsgBox.Show(this, "You may not save a new Wiki page as a draft.  Save the Wiki page, then create a draft.");
                return;
            }
            if (!MarkupL.ValidateMarkup(textContent, true, showMsgBox))
            {
                return;
            }
            if (showMsgBox && _isInvalidPreview)
            {
                MsgBox.Show(this, "This page is in an invalid state and cannot be saved as a draft.");
                return;
            }
            WikiPageCur.PageContent = WikiPages.ConvertTitlesToPageNums(textContent.Text);
            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
            if (WikiPageCur.IsDraft)                                                //If it's already a draft, overwrite the current one.
            {
                WikiPageCur.DateTimeSaved = DateTime.Now;
                try {
                    WikiPages.UpdateDraft(WikiPageCur);
                }
                catch (Exception ex) {
                    //should never happen due to the if Draft check above.
                    if (showMsgBox)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    return;
                }
            }
            else               //otherwise, set it as a draft, then insert it.
            {
                WikiPageCur.IsDraft = true;
                WikiPages.InsertAsDraft(WikiPageCur);
            }
            //HasSaved not set so that the user will stay in FormWikiDrafts when this window closes, causing the grid to update.
            Close();
        }
Пример #3
0
 private void H3_Click()
 {
     MarkupL.AddTag("<h3>", "</h3>", textContentEmail);
 }
Пример #4
0
 private void Font_Click()
 {
     MarkupL.AddTag("[[font:courier|", "]]", textContentEmail);
 }
Пример #5
0
 private void Color_Click()
 {
     MarkupL.AddTag("[[color:red|", "]]", textContentEmail);
 }
Пример #6
0
 private void Italic_Click()
 {
     MarkupL.AddTag("<i>", "</i>", textContentEmail);
 }
Пример #7
0
 private void Bold_Click()
 {
     MarkupL.AddTag("<b>", "</b>", textContentEmail);
 }
Пример #8
0
 private void H2_Click()
 {
     MarkupL.AddTag("<h2>", "</h2>", textContent);
 }
Пример #9
0
 private void H1_Click()
 {
     MarkupL.AddTag("<h1>", "</h1>", textContent);
 }
Пример #10
0
        private void Save_Click()
        {
            if (!MarkupL.ValidateMarkup(textContent, true))
            {
                return;
            }
            if (_isInvalidPreview)
            {
                MsgBox.Show(this, "This page is in an invalid state and cannot be saved.");
                return;
            }
            WikiPage wikiPageDB = WikiPages.GetByTitle(WikiPageCur.PageTitle);

            if (wikiPageDB != null && WikiPageCur.DateTimeSaved < wikiPageDB.DateTimeSaved)
            {
                if (WikiPageCur.IsDraft)
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "The wiki page has been edited since this draft was last saved.  Overwrite and continue?"))
                    {
                        return;
                    }
                }
                else if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This page has been modified and saved since it was opened on this computer.  Save anyway?"))
                {
                    return;
                }
            }
            List <string> listInvalidWikiPages = WikiPages.GetMissingPageTitles(textContent.Text);
            string        message = Lan.g(this, "This page has the following invalid wiki page link(s):") + "\r\n" + string.Join("\r\n", listInvalidWikiPages.Take(10)) + "\r\n"
                                    + (listInvalidWikiPages.Count > 10 ? "...\r\n\r\n" : "\r\n")
                                    + Lan.g(this, "Create the wikipage(s) automatically?");

            if (listInvalidWikiPages.Count != 0 && MsgBox.Show(this, MsgBoxButtons.YesNo, message))
            {
                foreach (string title in listInvalidWikiPages)
                {
                    WikiPage wp = new WikiPage();
                    wp.PageTitle   = title;
                    wp.UserNum     = Security.CurUser.UserNum;
                    wp.PageContent = "[[" + WikiPageCur.WikiPageNum + "]]\r\n" //link back
                                     + "<h1>" + title + "</h1>\r\n";           //page title
                    WikiPages.InsertAndArchive(wp);
                }
            }
            WikiPageCur.PageContent = WikiPages.ConvertTitlesToPageNums(textContent.Text);
            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
            if (WikiPageCur.IsDraft)
            {
                WikiPages.DeleteDraft(WikiPageCur);   //remove the draft from the database.
                WikiPageCur.IsDraft = false;          //no longer a draft
                if (wikiPageDB != null)               //wikiPageDb should never be null, otherwise there was no way to get to this draft.
                //We need to set the draft copy of the wiki page to the WikiPageNum of the real page.
                //This is because the draft is the most up to date copy of the wiki page, and is about to be saved, however, we want to maintain any
                //links there may be to the real wiki page, since we link by WikiPageNum instead of PageTitle (see JobNum 4429 for more info)
                {
                    WikiPageCur.WikiPageNum = wikiPageDB.WikiPageNum;
                }
            }
            WikiPages.InsertAndArchive(WikiPageCur);
            //If the form was given an action, fire it.
            _onWikiSaved?.Invoke(WikiPageCur.PageTitle);
            FormWiki formWiki = (FormWiki)this.OwnerForm;

            if (formWiki != null && !formWiki.IsDisposed)
            {
                formWiki.RefreshPage(WikiPageCur.PageTitle);
            }
            HasSaved = true;
            Close();            //should be dialog result??
        }