Esempio n. 1
0
        public EditorControl()
        {
            InitializeComponent();
            // http://stackoverflow.com/questions/4823468/comments-in-markdown
            // (empty line)
            // [comment]: # (This actually is the most platform independent comment)

            // https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
            // I didn't implement the Youtube video option
            operations.Add("H1", "# ");
            operations.Add("H2", "## ");
            operations.Add("H3", "### ");
            operations.Add("H4", "#### ");
            operations.Add("H5", "##### ");
            operations.Add("H6", "###### ");
            operations.Add("Alt-H1", string.Empty, t => { return("\r\n" + new string('=', t.Length)); });
            operations.Add("Alt-H2", string.Empty, t => { return("\r\n" + new string('-', t.Length)); });
            operations.Add("Italic", "_", "_");
            operations.Add("Bold", "**", "**");
            operations.Add("Strike", "~~", "~~");
            operations.Add("HR", "\r\n----");
            operations.Add("Link", t => { return(LinkForm.CreateLinkText()); }, string.Empty);
            operations.Add("Ordered List", "1. ");
            operations.Add("Unordered List", "+ ");
            operations.Add("Image", t => { return(ImageForm.CreateImageText(Path.GetDirectoryName(fileName))); }, string.Empty);
            operations.Add("Code", t => { return(CodeForm.CreateLanguageText()); }, "\n```");
            operations.Add("Quote", t => { StringBuilder sb = new StringBuilder("\n" + t); sb.Replace("\n", "\n> "); return(sb.ToString().TrimStart().TrimEnd(new char[] { '\n', '>', ' ' })); }, string.Empty);
            operations["Quote"].KeepOriginal = false;
            operations.Add("Dictionary", "<dl>\n", "</dl>");
            operations.Add("Definition", t => { return(DefinitionForm.CreateDefinitionText()); }, string.Empty);
            operations.Add("Header", t => { return(TableForm.CreateTableText()); }, string.Empty);
            operations.Add("Row", string.Empty, t =>
            {
                int cols = t.Occurrences('|') + 1; if (t.StartsWith("|"))
                {
                    cols--;
                }
                if (t.TrimEnd().EndsWith("|"))
                {
                    cols--;
                }
                StringBuilder sb = new StringBuilder("\n|"); for (int i = 0; i < cols; i++)
                {
                    sb.Append("value|");
                }
                return(sb.ToString());
            });
            operations.Add("Task", "- [ ]", string.Empty);

            autoSaveTimer          = new Timer();
            autoSaveTimer.Tick    += AutoSaveTimer_Tick;
            autoSaveTimer.Interval = 3000;
            autoSaveTimer.Enabled  = false;
        }
Esempio n. 2
0
        public static string CreateLinkText()
        {
            string rtnVal = string.Empty;

            LinkForm form = new LinkForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                string display  = string.Empty;
                string linkText = string.Empty;
                string tooltip  = string.Empty;

                if (!string.IsNullOrEmpty(form.Display))
                {
                    display = form.Display;
                }
                else
                {
                    if (!string.IsNullOrEmpty(form.LinkText))
                    {
                        display = form.LinkText;
                    }
                }

                linkText = form.LinkText;
                tooltip  = form.Tooltip;

                if (string.IsNullOrEmpty(linkText))
                {
                    return(string.Empty);
                }

                if (!string.IsNullOrEmpty(tooltip))
                {
                    linkText = string.Format("{0} \"{1}\"", linkText, tooltip);
                }

                rtnVal = string.Format("[{0}]({1})", display, linkText);
            }
            return(rtnVal);
        }
Esempio n. 3
0
 private void toolStripButton6_Click(object sender, EventArgs e)
 {
     string text = LinkForm.CreateLinkText();
 }