OSDN Git Service

行を生成するメソッドをLineToIndexTableに移動した
[fooeditengine/FooEditEngine.git] / WPF / FooEditEngine / WPF / WPFRender.cs
index a1f9274..18241c2 100644 (file)
@@ -351,15 +351,8 @@ namespace FooEditEngine.WPF
 
         public bool ShowLineBreak
         {
-            get
-            {
-                throw new NotImplementedException();
-            }
-
-            set
-            {
-                throw new NotImplementedException();
-            }
+            get;
+            set;
         }
 
         public event ChangedRenderResourceEventHandler ChangedRenderResource;
@@ -463,7 +456,7 @@ namespace FooEditEngine.WPF
             this.Context.DrawRectangle(this.Brushes[this.Background], null, rect);
         }
 
-        public void DrawOneLine(LineToIndexTable lti, int row, double x, double y, IEnumerable<Selection> SelectRanges)
+        public void DrawOneLine(Document doc, LineToIndexTable lti, int row, double x, double y)
         {
             TextLayout layout = (TextLayout)lti.GetLayout(row);
 
@@ -472,6 +465,12 @@ namespace FooEditEngine.WPF
 
             if (this.Printing == false)
             {
+                int lineIndex = lti.GetIndexFromLineNumber(row);
+                int lineLength = lti.GetLengthFromLineNumber(row);
+                var SelectRanges = from s in doc.Selections.Get(lineIndex, lineLength)
+                                   let n = Util.ConvertAbsIndexToRelIndex(s, lineIndex, lineLength)
+                                   select n;
+
                 foreach (Selection sel in SelectRanges)
                 {
                     if (sel.length == 0 || sel.start == -1)
@@ -479,7 +478,7 @@ namespace FooEditEngine.WPF
 
                     foreach (TextBounds bound in layout.GetTextBounds(sel.start, sel.length))
                     {
-                        Rect rect = new Rect(x,y,bound.Rectangle.Width,bound.Rectangle.Height);
+                        Rect rect = new Rect(x, y, bound.Rectangle.Width, bound.Rectangle.Height);
                         this.Context.DrawRectangle(this.Brushes[this.Hilight], null, rect);
                     }
                 }
@@ -488,49 +487,29 @@ namespace FooEditEngine.WPF
             layout.Draw(this.Context, x, y);
         }
 
-        public List<LineToIndexTableData> BreakLine(Document doc, LineToIndexTable layoutLineCollection, int startIndex, int endIndex, double wrapwidth)
+        public void BeginClipRect(Rectangle rect)
         {
-            List<LineToIndexTableData> output = new List<LineToIndexTableData>();
-
-            foreach (string str in doc.GetLines(startIndex, endIndex))
-            {
-                TextLayout layout = new TextLayout(str, this.FontFamily, this.FontSize, this.Brushes[this.Foreground], wrapwidth);
-
-                int i = startIndex;
-                foreach (TextLine line in layout.Lines)
-                {
-                    if (line.Length == 0 && line.NewlineLength == 0)
-                        continue;
-
-                    int length = line.Length;
-
-                    IList<TextSpan<TextRun>> runs = line.GetTextRunSpans();
-                    if (runs.Last().Value is TextEndOfParagraph)
-                        length--;
-
-                    bool lineend = false;
-                    if (line.NewlineLength > 0)
-                        lineend = true;
-
-                    output.Add(layoutLineCollection.CreateLineToIndexTableData(i, length, lineend, null));
-                    i += line.Length;
-                }
-
-                layout.Dispose();
-
-                startIndex += str.Length;
-            }
-
-            if (output.Count > 0)
-                output.Last().LineEnd = true;
+            this.Context.PushClip(new RectangleGeometry(rect));
+        }
 
-            return output;
+        public void EndClipRect()
+        {
+            this.Context.Pop();
         }
 
-        public ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable<Marker> MarkerRanges)
+        public ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable<Marker> MarkerRanges, IEnumerable<Selection> SelectRanges, double wrapwidth)
         {
-            TextLayout layout = new TextLayout(str,this.FontFamily,this.FontSize,Brushes[this.Foreground],this.TextArea.Width);
-            layout.TextWarpping = TextWrapping.NoWrap;
+            TextLayout layout;
+            if(wrapwidth == LineToIndexTable.NONE_BREAK_LINE)
+            {
+                layout = new TextLayout(str, this.FontFamily, this.FontSize, Brushes[this.Foreground], this.TextArea.Width);
+                layout.TextWarpping = TextWrapping.NoWrap;
+            }
+            else
+            {
+                layout = new TextLayout(str, this.FontFamily, this.FontSize, Brushes[this.Foreground], wrapwidth);
+                layout.TextWarpping = TextWrapping.Wrap;
+            }
             layout.FlowDirection = this.RightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
 
             if (syntaxCollection != null)