示例#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;
        }
示例#2
0
        public TableEditor(string tableHtml = null)
        {
            InitializeComponent();

            AppModel = mmApp.Model;

            mmApp.SetThemeWindowOverride(this);
            Owner = AppModel.Window;

            var data = new List <string[]>();

            if (tableHtml == null)
            {
                CreateInitialTableData();
            }
            else
            {
                var parser = new TableParser();
                TableData = parser.ParseMarkdownToData(tableHtml);
                if (tableHtml.StartsWith("+"))
                {
                    TableMode = "Grid Table";
                }
            }

            DataGridTableEditor.ParentWindow = this;
            DataGridTableEditor.AppModel     = mmApp.Model;
            DataGridTableEditor.TableSource  = TableData;

            ColumnKeyCommand = new CommandBase((parameter, command) =>
            {
            }, (p, c) => true);


            DataContext = this;
        }