private bool close(MarkdownEditor meditor) { if (meditor.AlreadyUpdate) { DialogResult dr = MessageBox.Show("修改还没有保存,需要保存吗?", "提示", MessageBoxButtons.YesNoCancel); if (dr == DialogResult.Cancel) { return(false); } if (dr == DialogResult.Yes) { if (!save(meditor)) { return(false); } } } int ind = TabSelectRec.GetLast(); if (ind > -1 && ind < _tabparent.TabCount) { _tabparent.SelectedIndex = ind; } _editors.Remove((int)meditor.MarkdownPage.Tag); _tabparent.TabPages.Remove(meditor.MarkdownPage); return(true); }
private bool filetypeConvert(MarkdownEditor meditor) { string marktext = meditor.GetMarkdown(); if (string.IsNullOrEmpty(marktext)) { return(false); } string ext = Path.GetExtension(meditor.FileName); if (_regexExtMarkdowns.IsMatch(ext)) { Markdown mark = new Markdown(); string html = mark.Transform(marktext); rtbHtml.Text = html; webBrowser1.DocumentText = meditorManager.GetHTMLStyle(html); return(true); } if (_regexExtHtml.IsMatch(ext)) { webBrowser1.DocumentText = marktext; rtbHtml.Text = marktext; return(true); } if (_regexExtOthertext.IsMatch(ext)) { webBrowser1.DocumentText = meditorManager.GetHTMLStyle("<pre><code>" + marktext + "</code></pre>"); rtbHtml.Text = marktext; return(true); } return(false); }
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { string url = e.Url.ToString(); if (url == "about:blank") { return; } if (url.StartsWith("http://") || url.StartsWith("https://")) { return; } //if (url.EndsWith(".md")) //{ url = url.Remove(0, 6); MarkdownEditor me = meditorManager.GetCurrEditor(); if (me == null) { return; } url = Path.Combine(Path.GetDirectoryName(me.FileName), url); if (_regexExtMarkdowns.IsMatch(url) || _regexExtOthertext.IsMatch(url)) { e.Cancel = true; openfile(url); } //webBrowser1.Navigate(url); //} }
private void PreviewHtml() { MarkdownEditor meditor = meditorManager.SetStyle(); if (meditor == null) { return; } this.toolStripStatusLabel1.Text = " 正在转换。。。。 "; if (filetypeConvert(meditor)) { if (isLeft) { if (splitContainer1.Panel2Collapsed) { splitContainer1.Panel2Collapsed = false; } } else { if (splitContainer1.Panel1Collapsed) { splitContainer1.Panel1Collapsed = false; } } } tabBrowser.Text = meditor.MarkdownPage.Text; this.toolStripStatusLabel1.Text = "当前文档:" + meditor.FileName; //tabControl1.Focus(); meditor.GetTextBox().Focus(); }
private bool saveas(MarkdownEditor meditor) { SaveFileDialog fileone = new SaveFileDialog(); fileone.Filter = myExtName; fileone.FilterIndex = 1; if (fileone.ShowDialog() == DialogResult.OK) { try { if (_thisModify.ContainsKey(meditor.FileName)) { _thisModify.Remove(meditor.FileName); } meditor.Save(fileone.FileName); mruManager.Add(meditor.FileName); // when file is successfully opened if (!_thisModify.ContainsKey(meditor.FileName)) { _thisModify.Add(meditor.FileName, true); } return(true); } catch (ArgumentException) { MessageBox.Show("保存不成功"); return(false); } } else { return(false); } }
private void 查找替换ToolStripMenuItem_Click(object sender, EventArgs e) { MarkdownEditor me = meditorManager.GetCurrEditor(); if (me == null) { return; } }
private void 转为小写ToolStripMenuItem_Click(object sender, EventArgs e) { MarkdownEditor me = meditorManager.GetCurrEditor(); if (me == null) { return; } me.GetTextBox().SelectedText = me.GetTextBox().SelectedText.ToLower(); }
public bool SaveAs() { MarkdownEditor meditor = GetCurrEditor(); if (meditor == null) { return(true); } return(saveas(meditor)); }
public bool Close() { MarkdownEditor meditor = GetCurrEditor(); if (meditor == null) { return(true); } return(close(meditor)); }
public void Save() { MarkdownEditor meditor = GetCurrEditor(); if (meditor == null) { return; } save(meditor); }
public TextEditor GetTextBox() { MarkdownEditor meditor = GetCurrEditor(); if (meditor == null) { return(null); } return(meditor.GetTextBox()); }
public MarkdownEditor SetStyle() { MarkdownEditor m = GetCurrEditor(); if (m == null) { return(null); } m.SetStyle(_bgColor, _foreColor, _font, _wordWrap, _tabWidth); return(m); }
public void openDir() { MarkdownEditor meditor = GetCurrEditor(); if (meditor == null) { return; } System.IO.FileInfo fi = new FileInfo(meditor.FileName); System.Diagnostics.Process.Start("explorer.exe", fi.Directory.ToString()); }
private bool save(MarkdownEditor meditor) { if (string.IsNullOrEmpty(meditor.FileName) || meditor.FileName.IndexOf("未命名") != -1) { return(saveas(meditor)); } meditor.Save(); if (!_thisModify.ContainsKey(meditor.FileName)) { _thisModify.Add(meditor.FileName, true); } mruManager.Add(meditor.FileName); // when file is successfully opened return(true); }
private void 转到行ToolStripMenuItem_Click(object sender, EventArgs e) { MarkdownEditor me = meditorManager.GetCurrEditor(); if (me == null) { return; } if (me.GetTextBox().Document.LineCount > 0) { //Show the dialog GoToLineDialog gtl = new GoToLineDialog(me.GetTextBox()); gtl.ShowDialog(); } }
private bool openfile_(string file) { TabPage markPage = new TabPage(GetDisplayName(file)); markPage.ToolTipText = file; _tabparent.TabPages.Add(markPage); markPage.Tag = _fileInd; MarkdownEditor meditor = new MarkdownEditor(_thisForm, markPage, _previewBrowser); _editors.Add(_fileInd++, meditor); bool rel = meditor.Openfile(file); if (rel) { _tabparent.SelectedTab = markPage; } return(rel); }
private bool save(MarkdownEditor meditor) { if (string.IsNullOrEmpty(meditor.FileName) || meditor.FileName.IndexOf("未命名")!=-1) { return saveas(meditor); } meditor.Save(); if (!_thisModify.ContainsKey(meditor.FileName)) { _thisModify.Add(meditor.FileName, true); } mruManager.Add(meditor.FileName); // when file is successfully opened return true; }
private bool close(MarkdownEditor meditor) { if (meditor.AlreadyUpdate) { DialogResult dr= MessageBox.Show("修改还没有保存,需要保存吗?", "提示", MessageBoxButtons.YesNoCancel) ; if(dr==DialogResult.Cancel) return false; if (dr== DialogResult.Yes) { if (!save(meditor)) return false; } } int ind=TabSelectRec.GetLast(); ind = TabSelectRec.GetLast(); if (ind > -1 && ind<_tabparent.TabCount) _tabparent.SelectedIndex = ind; _editors.Remove((int)meditor.MarkdownPage.Tag); _tabparent.TabPages.Remove(meditor.MarkdownPage); return true; }
private bool openfile_(string file) { TabPage markPage = new TabPage(GetDisplayName(file)); markPage.ToolTipText = file; _tabparent.TabPages.Add(markPage); markPage.Tag = _fileInd; MarkdownEditor meditor = new MarkdownEditor(_thisForm, markPage); _editors.Add(_fileInd, meditor); _fileInd++; meditor.SetStyle(_bgColor, _foreColor, _font, _wordWrap, _tabWidth); bool rel = meditor.Openfile(file); if (rel) { _tabparent.SelectedTab = markPage; } return rel; }
private bool filetypeConvert(MarkdownEditor meditor) { string marktext = meditor.GetMarkdown(); if (string.IsNullOrEmpty(marktext)) { return false; } string ext = Path.GetExtension(meditor.FileName); if (_regexExtMarkdowns.IsMatch(ext)) { string html = ""; html = Utils.ConvertTextToHTML(marktext); rtbHtml.Text = html; webControl1.LoadHTML(meditorManager.GetHTMLStyle(html)); return true; } if (_regexExtHtml.IsMatch(ext)) { webControl1.LoadHTML(marktext); rtbHtml.Text = marktext; return true; } if (_regexExtOthertext.IsMatch(ext)) { webControl1.LoadHTML(meditorManager.GetHTMLStyle("<pre><code>" + marktext + "</code></pre>")); rtbHtml.Text = marktext; return true; } return false; }
private bool saveas(MarkdownEditor meditor) { SaveFileDialog fileone = new SaveFileDialog(); fileone.Filter = myExtName; fileone.FilterIndex = 1; if (fileone.ShowDialog() == DialogResult.OK) { try { if (_thisModify.ContainsKey(meditor.FileName)) { _thisModify.Remove(meditor.FileName); } meditor.Save(fileone.FileName); mruManager.Add(meditor.FileName); // when file is successfully opened if (!_thisModify.ContainsKey(meditor.FileName)) { _thisModify.Add(meditor.FileName, true); } return true; } catch (ArgumentException) { MessageBox.Show("保存不成功"); return false; } } else { return false; } }
private bool filetypeConvert(MarkdownEditor meditor) { string marktext = meditor.GetMarkdown(); if (string.IsNullOrEmpty(marktext)) { return false ; } string ext = Path.GetExtension(meditor.FileName); if (_regexExtMarkdowns.IsMatch(ext)) { string html=""; Markdown mark = new Markdown(); html = mark.Transform(marktext); rtbHtml.Text = html; webBrowser1.DocumentText = meditorManager.GetHTMLStyle(html); return true; } if (_regexExtHtml.IsMatch(ext)) { webBrowser1.DocumentText = marktext; rtbHtml.Text = marktext; return true; } if (_regexExtOthertext.IsMatch(ext)) { webBrowser1.DocumentText = meditorManager.GetHTMLStyle("<pre><code>"+marktext+"</code></pre>"); rtbHtml.Text = marktext; return true; } return false; }