From f3efcd956d62193390a6222e471de1eda0fb75b7 Mon Sep 17 00:00:00 2001 From: rollrat Date: Fri, 10 Apr 2020 23:43:53 +0900 Subject: [PATCH] cluster: Fix grid-splitter move when textbox is resized by exceeding max length of actual-width --- CustomCrawler/CustomCrawlerCluster.xaml | 21 ++++++++++----- CustomCrawler/CustomCrawlerCluster.xaml.cs | 30 +++++++++++++++++++--- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/CustomCrawler/CustomCrawlerCluster.xaml b/CustomCrawler/CustomCrawlerCluster.xaml index 53dd58d..254aebc 100644 --- a/CustomCrawler/CustomCrawlerCluster.xaml +++ b/CustomCrawler/CustomCrawlerCluster.xaml @@ -11,7 +11,7 @@ - + @@ -93,17 +93,23 @@ - + + + + + - @@ -145,7 +151,8 @@ HorizontalAlignment="Center" VerticalAlignment="Stretch"/> - + + @@ -263,10 +270,10 @@ - + - + diff --git a/CustomCrawler/CustomCrawlerCluster.xaml.cs b/CustomCrawler/CustomCrawlerCluster.xaml.cs index 0486066..b9b876b 100644 --- a/CustomCrawler/CustomCrawlerCluster.xaml.cs +++ b/CustomCrawler/CustomCrawlerCluster.xaml.cs @@ -79,6 +79,22 @@ public CustomCrawlerCluster(string url, HtmlTree tree) } KeyDown += CustomCrawlerCluster_KeyDown; + Loaded += CustomCrawlerCluster_Loaded; + } + + private void CustomCrawlerCluster_Loaded(object sender, RoutedEventArgs e) + { + Task.Run(() => + { + Thread.Sleep(500); + Application.Current.Dispatcher.BeginInvoke(new Action( + delegate + { + Attributes.Document.PageWidth = Attributes.ActualWidth + 10000; + CurrentCode.Document.PageWidth = CurrentCode.ActualWidth + 10000; + CurrentXPath.Document.PageWidth = CurrentXPath.ActualWidth + 10000; + })); + }); } private void Browser_IsBrowserInitializedChanged(object sender, DependencyPropertyChangedEventArgs e) @@ -698,7 +714,8 @@ public void hoverelem(string elem, bool adjust = false) before = $"ccw_tag=ccw_{i}_{j}"; before_border = instance.browser.EvaluateScriptAsync($"document.querySelector('[{before}]').style.border").Result.Result.ToString(); instance.browser.EvaluateScriptAsync($"document.querySelector('[{before}]').style.border = '0.2em solid red';").Wait(); - instance.CurrentXPath.Text = selected_node.XPath; + instance.CurrentXPath.Document.Blocks.Clear(); + instance.CurrentXPath.Document.Blocks.Add(new Paragraph(new Run(selected_node.XPath))); var builder = new StringBuilder(); builder.Append("public HtmlNode Extract(string html)\r\n"); @@ -708,19 +725,24 @@ public void hoverelem(string elem, bool adjust = false) builder.Append($" return document.DocumentNode.SelectSingleNode(\"{selected_node.XPath}\");\r\n"); builder.Append("}\r\n"); - instance.CurrentCode.Text = builder.ToString(); + instance.CurrentCode.Document.Blocks.Clear(); + instance.CurrentCode.Document.Blocks.Add(new Paragraph(new Run(builder.ToString()))); builder.Clear(); var cf = new Func((x) => { - if (x == "origin_onmouseenter") return "onmouseetner"; + if (x == "origin_onmouseenter") return "onmouseenter"; if (x == "origin_onmouseleave") return "onmouseleave"; return x; }); selected_node.Attributes.Where(x => !new [] { "onmouseenter", "onmouseleave", "ccw_tag" }.Contains(x.Name)) .ToList().ForEach(x => builder.Append($"{cf(x.Name)}=\"{x.Value}\"\r\n")); - instance.Attributes.Text = builder.ToString(); + var xy = instance.gs1; + + instance.Attributes.Document.Blocks.Clear(); + instance.Attributes.Document.Blocks.Add(new Paragraph(new Run(builder.ToString()))); + //instance.Attributes.Text = builder.ToString(); } catch { } }));