X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=Metro%2FFooEditEngine%2FDirect2D%2FD2DRenderBase.cs;h=709cd6d927056bce3e5a4a60f3761393996a4723;hb=a7c04797c6dc821b47ba103e60b12c38d1c572d1;hp=6a707206485f0c0e2cfcec001dabaf0894c1cf7d;hpb=18483bed5090af9f282b64e1645d2d8740389199;p=fooeditengine%2FFooEditEngine.git diff --git a/Metro/FooEditEngine/Direct2D/D2DRenderBase.cs b/Metro/FooEditEngine/Direct2D/D2DRenderBase.cs index 6a70720..709cd6d 100644 --- a/Metro/FooEditEngine/Direct2D/D2DRenderBase.cs +++ b/Metro/FooEditEngine/Direct2D/D2DRenderBase.cs @@ -24,14 +24,13 @@ using FooEditEngine.Metro; namespace FooEditEngine { - class D2DRenderBase: IDisposable + class D2DRenderBase: D2DRenderCommon,IDisposable { public const int MiniumeWidth = 40; //これ以上ないと誤操作が起こる protected DXGI.Device DXGIDevice; protected D3D11.Device1 D3DDevice; - D2DRenderCommon common = new D2DRenderCommon(); - Windows.UI.Color ForegroundColor, BackgroundColor, HilightColor, Keyword1Color, Keyword2Color, LiteralColor, UrlColor, ControlCharColor, CommentColor, InsertCaretColor, OverwriteCaretColor, LineMarkerColor; + Windows.UI.Color ForegroundColor, BackgroundColor, HilightColor, Keyword1Color, Keyword2Color, LiteralColor, UrlColor, ControlCharColor, CommentColor, InsertCaretColor, OverwriteCaretColor, LineMarkerColor,UpdateAreaColor; FontFamily fontFamily; FontStyle fontStyle = FontStyle.Normal; FontWeight fontWeigth; @@ -54,164 +53,26 @@ namespace FooEditEngine this.DXGIDevice = this.D3DDevice.QueryInterface(); } - public void ConstructDeviceResource(double width,double height) - { - this.common.ConstructDeviceResource(width,height); - } - - public void ReConstructDeviceResource(double width, double height) - { - this.common.ReConstructDeviceResource(width, height); - } - - public void DrawMarkerEffect(MyTextLayout layout, HilightType type, int start, int length, double x, double y, bool isBold, Windows.UI.Color? effectColor = null) - { - Color4? color4 = null; - if(effectColor != null) - color4 = this.ToColor4((Windows.UI.Color)effectColor); - this.common.DrawMarkerEffect(layout, type, start, length, x, y, isBold, color4); - } - public void InitTextFormat(string fontName, double size) { - this.common.InitTextFormat(fontName, (float)size); + base.InitTextFormat(fontName, (float)size); this.fontSize = size; } public void InitTextFormat(FontFamily font, double size) { - this.common.InitTextFormat(font.Source, (float)size); + base.InitTextFormat(font.Source, (float)size); this.fontFamily = font; this.fontSize = size; } - public System.Func ConstructRender - { - get - { - return this.common.ConstructRender; - } - set - { - this.common.ConstructRender = value; - } - } - - public System.Action ConstrctedResource - { - get - { - return this.common.ConstrctedResource; - } - set - { - this.common.ConstrctedResource = value; - } - } - - public GetDpiHandler GetDpi - { - get - { - return this.common.GetDpi; - } - set - { - this.common.GetDpi = value; - } - } - - public System.Action DestructRender - { - get - { - return this.common.DestructRender; - } - set - { - this.common.DestructRender = value; - } - } - - public System.Action ReCreateTarget - { - get - { - return this.common.ReCreateTarget; - } - set - { - this.common.ReCreateTarget = value; - } - } - - public void Dispose() + public override void Dispose() { if (this.DXGIDevice != null) this.DXGIDevice.Dispose(); if (this.D3DDevice != null) this.D3DDevice.Dispose(); - this.common.Dispose(); - } - - public TextAntialiasMode TextAntialiasMode - { - get - { - return this.common.TextAntialiasMode; - } - set - { - this.common.TextAntialiasMode = value; - } - } - - public bool ShowFullSpace - { - get - { - return this.common.ShowFullSpace; - } - set - { - this.common.ShowFullSpace = value; - } - } - - public bool ShowHalfSpace - { - get - { - return this.common.ShowHalfSpace; - } - set - { - this.common.ShowHalfSpace = value; - } - } - - public bool ShowTab - { - get - { - return this.common.ShowTab; - } - set - { - this.common.ShowTab = value; - } - } - - public bool ShowLineBreak - { - get - { - return this.common.ShowLineBreak; - } - set - { - this.common.ShowLineBreak = value; - } + base.Dispose(); } public FontFamily FontFamily @@ -220,7 +81,7 @@ namespace FooEditEngine set { this.fontFamily = value; - this.common.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle)); + this.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle)); this.TabWidthChar = this.TabWidthChar; } } @@ -231,7 +92,7 @@ namespace FooEditEngine set { this.fontSize = value; - this.common.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle)); + this.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle)); this.TabWidthChar = this.TabWidthChar; } } @@ -245,7 +106,7 @@ namespace FooEditEngine set { this.fontWeigth = value; - this.common.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(value), this.GetDWFontStyle(this.fontStyle)); + this.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(value), this.GetDWFontStyle(this.fontStyle)); } } @@ -258,7 +119,7 @@ namespace FooEditEngine set { this.fontStyle = value; - this.common.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle)); + this.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle)); } } @@ -275,325 +136,34 @@ namespace FooEditEngine return (DW.FontWeight)weigth.Weight; } - public bool RightToLeft - { - get - { - return this.common.RightToLeft; - } - set - { - this.common.RightToLeft = value; - } - } - - Color4 ToColor4(Windows.UI.Color color) + public static Color4 ToColor4(Windows.UI.Color color) { return new Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); } - public Windows.UI.Color Foreground - { - get - { - return this.ForegroundColor; - } - set - { - this.ForegroundColor = value; - this.common.Foreground = this.ToColor4(value); - } - } - - public Windows.UI.Color Background - { - get - { - return this.BackgroundColor; - } - set - { - this.BackgroundColor = value; - this.common.Background = this.ToColor4(value); - } - } - - public Windows.UI.Color InsertCaret - { - get - { - return this.InsertCaretColor; - } - set - { - this.InsertCaretColor = value; - this.common.InsertCaret = this.ToColor4(value); - } - } - - public Windows.UI.Color OverwriteCaret - { - get - { - return this.OverwriteCaretColor; - } - set - { - this.OverwriteCaretColor = value; - this.common.OverwriteCaret = this.ToColor4(value); - } - } - - public Windows.UI.Color LineMarker - { - get - { - return this.LineMarkerColor; - } - set - { - this.LineMarkerColor = value; - this.common.LineMarker = this.ToColor4(value); - } - } - - public Windows.UI.Color ControlChar - { - get - { - return this.ControlCharColor; - } - set - { - this.ControlCharColor = value; - this.common.ControlChar = this.ToColor4(value); - } - } - - public Windows.UI.Color Url - { - get - { - return this.UrlColor; - } - set - { - this.UrlColor = value; - this.common.Url = this.ToColor4(value); - } - } - - public Windows.UI.Color Hilight - { - get - { - return this.HilightColor; - } - set - { - this.HilightColor = value; - this.HilightColor.A = 50; - this.common.Hilight = this.ToColor4(this.HilightColor); - } - } - - public Windows.UI.Color Comment - { - get - { - return this.CommentColor; - } - set - { - this.CommentColor = value; - this.common.Comment = this.ToColor4(value); - } - } - - public Windows.UI.Color Literal - { - get - { - return this.LiteralColor; - } - set - { - this.LiteralColor = value; - this.common.Literal = this.ToColor4(value); - } - } - - public Windows.UI.Color Keyword1 - { - get - { - return this.Keyword1Color; - } - set - { - this.Keyword1Color = value; - this.common.Keyword1 = this.ToColor4(value); - } - } - - public Windows.UI.Color Keyword2 - { - get - { - return this.Keyword2Color; - } - set - { - this.Keyword2Color = value; - this.common.Keyword2 = this.ToColor4(value); - } - } - - public Rectangle TextArea - { - get { return this.common.ClipRect; } - set { this.common.ClipRect = value; } - } - - public double LineNemberWidth - { - get - { - return this.common.LineNemberWidth; - } - } - public double FoldingWidth - { - get - { - return Math.Max(D2DRender.MiniumeWidth, this.common.FoldingWidth); - } - } - - public Size emSize - { - get - { - return this.common.emSize; - } - } - - public int TabWidthChar - { - get { return this.common.TabWidthChar; } - set - { - if (value == 0) - return; - this.common.TabWidthChar = value; - } - } - - public event ChangedRenderResourceEventHandler ChangedRenderResource - { - add - { - this.common.ChangedRenderResource += value; - } - remove - { - this.common.ChangedRenderResource -= value; - } - } - - public event EventHandler ChangedRightToLeft - { - add - { - this.common.ChangedRightToLeft += value; - } - remove - { - this.common.ChangedRightToLeft -= value; - } - } - - public virtual void BeginDraw() - { - this.common.BegineDraw(); - } - - public virtual void EndDraw() - { - this.common.EndDraw(); - } - - public void DrawCachedBitmap(Rectangle rect) - { - //this.Common.DrawCachedBitmap(rect); - } + protected PreDrawOneLineHandler PreDrawOneLine; - public void DrawLine(Point from, Point to) + public override void CacheContent() { - this.common.DrawLine(from, to); } - public void CacheContent() + public override void DrawCachedBitmap(Rectangle rect) { - //this.Common.CacheContent(); } - public bool IsVaildCache() + public override bool IsVaildCache() { - //return this.Common.IsVaildCache(); return false; } - public void DrawString(string str, double x, double y, StringAlignment align, Size layoutRect) - { - this.common.DrawString(str, x, y, align, layoutRect); - } - - public void FillRectangle(Rectangle rect, FillRectType type) - { - this.common.FillRectangle(rect, type); - } - - public void DrawGripper(Point p, double radius) - { - this.common.DrawGripper(p, radius); - } - - public void DrawFoldingMark(bool expand, double x, double y) - { - string mark = expand ? "-" : "+"; - this.DrawString(mark, x, y, StringAlignment.Center, new Size(this.FoldingWidth, this.emSize.Height)); - } - - public void FillBackground(Rectangle rect) - { - this.common.FillBackground(rect); - } - - protected delegate void PreDrawOneLineHandler(MyTextLayout layout, LineToIndexTable lti, int row, double x, double y); - protected PreDrawOneLineHandler PreDrawOneLine; - - public void DrawOneLine(LineToIndexTable lti, int row, double x, double y, IEnumerable SelectRanges) + public void DrawOneLine(Document doc,LineToIndexTable lti, int row, double x, double y) { - this.common.DrawOneLine(lti, + this.DrawOneLine(doc, + lti, row, x, y, - SelectRanges, - (layout) =>{ - if(this.PreDrawOneLine !=null) - this.PreDrawOneLine(layout, lti, row, x, y); - }); - } - - public List BreakLine(Document doc,LineToIndexTable layoutLineCollection, int startIndex, int endIndex, double wrapwidth) - { - return this.common.BreakLine(doc,layoutLineCollection, startIndex, endIndex, wrapwidth); - } - - public ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable MarkerRanges) - { - return this.common.CreateLaytout(str, syntaxCollection, MarkerRanges); + this.PreDrawOneLine); } } }