Ejemplo n.º 1
0
        public void CreateTableFromClipboardHtml(string html = null)
        {
            if (string.IsNullOrEmpty(html))
            {
                html = ClipboardHelper.GetHtmlFromClipboard();
                if (string.IsNullOrEmpty(html))
                {
                    html = ClipboardHelper.GetText();
                }
            }

            var parser = new TableParser();

            ObservableCollection <ObservableCollection <CellContent> > data = null;

            if (html.Contains("<tr>"))
            {
                data = parser.ParseHtmlToData(html);
            }
            else if (html.Contains("-|-") || html.Contains("- | -") || html.Contains(""))
            {
                data = parser.ParseMarkdownToData(html);
            }
            else if (html.Contains("-|-") || html.Contains("- | -") || html.Contains(""))
            {
                data = parser.ParseMarkdownToData(html);
            }
            else if (html.Contains("-+-"))
            {
                data = parser.ParseMarkdownGridTableToData(html);
            }

            if (data == null || data.Count < 1)
            {
                AppModel.Window.ShowStatusError("No HTML Table to process found...");
                return;
            }

            TableData = data;
            DataGridTableEditor.TableSource = TableData;
        }