}
}
- sealed class D2DRenderCommon : IDisposable
+ class D2DRenderCommon : IDisposable
{
ColorBrushCollection Brushes = new ColorBrushCollection();
StrokeCollection Strokes = new StrokeCollection();
public event EventHandler ChangedRightToLeft;
+ public const int MiniumeWidth = 40; //これ以上ないと誤操作が起こる
+
public void InitTextFormat(string fontName, float fontSize, DW.FontWeight fontWeigth = DW.FontWeight.Normal,DW.FontStyle fontStyle = DW.FontStyle.Normal)
{
if(this.format != null)
layout = new MyTextLayout(this.DWFactory, "+", this.format, float.MaxValue, float.MaxValue, dpix, false);
layout.RightToLeft = false;
+#if METRO
+ this.FoldingWidth = Math.Max(D2DRenderCommon.MiniumeWidth, layout.Width);
+#else
this.FoldingWidth = layout.Width;
+#endif
layout.Dispose();
this.ChangedRenderResource(this,new ChangedRenderRsourceEventArgs(ResourceType.Font));
}
}
- public Rectangle ClipRect
+ public Rectangle TextArea
{
get;
set;
get { return this.tabLength; }
set
{
+ if (value == 0)
+ return;
this.tabLength = value;
DW.TextLayout layout = new DW.TextLayout(this.DWFactory, "0", this.format, float.MaxValue, float.MaxValue);
float width = (float)(layout.Metrics.Width * value);
this.ConstructDeviceResource(width, height);
}
- public void DrawCachedBitmap(Rectangle rect)
+ public virtual void DrawCachedBitmap(Rectangle rect)
{
if (this.render == null || this.render.IsDisposed)
return;
render.DrawBitmap(this.bitmap, rect, 1.0f, D2D.BitmapInterpolationMode.Linear, rect);
}
- public void CacheContent()
+ public virtual void CacheContent()
{
if (this.render == null || this.bitmap == null || this.bitmap.IsDisposed || this.render.IsDisposed)
return;
this.hasCache = true;
}
- public bool IsVaildCache()
+ public virtual bool IsVaildCache()
{
return this.hasCache;
}
- public void BegineDraw()
+ public virtual void BegineDraw()
{
if (this.render == null || this.render.IsDisposed)
return;
this.render.AntialiasMode = D2D.AntialiasMode.Aliased;
}
- public void EndDraw()
+ public virtual void EndDraw()
{
if (this.render == null || this.render.IsDisposed)
return;
MyTextLayout layout = (MyTextLayout)lti.GetLayout(row);
- this.render.PushAxisAlignedClip(this.ClipRect, D2D.AntialiasMode.Aliased);
+ this.render.PushAxisAlignedClip(this.TextArea, D2D.AntialiasMode.Aliased);
if(PreDrawOneLine != null)
PreDrawOneLine(layout);
MyTextLayout newLayout = new MyTextLayout(this.DWFactory,
str,
this.format,
- this.ClipRect.Width,
- this.ClipRect.Height,
+ this.TextArea.Width,
+ this.TextArea.Height,
dpiy,
hasNewLine && this._ShowLineBreak);
ParseLayout(newLayout, str);
return output;
}
- public void Dispose()
+ public virtual void Dispose()
{
this.DestructDeviceResource();
this.HiddenChars.Clear();
}
#if METRO
- public System.Func<D2D.Factory1,D2D.RenderTargetProperties,double,double,D2D.RenderTarget> ConstructRender;
+ protected virtual D2D.RenderTarget ConstructRender(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
#else
- public System.Func<D2D.Factory,D2D.RenderTargetProperties,double,double,D2D.RenderTarget> ConstructRender;
+ protected virtual D2D.RenderTarget ConstructRender(D2D.Factory factory, D2D.RenderTargetProperties prop, double width, double height)
#endif
- public System.Action ConstrctedResource;
+ {
+ throw new NotImplementedException();
+ }
- public GetDpiHandler GetDpi;
+ protected virtual void ConstrctedResource()
+ {
+ throw new NotImplementedException();
+ }
- public System.Action DestructRender;
+ public virtual void GetDpi(out float dpix,out float dpiy)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected virtual void DestructRender()
+ {
+ throw new NotImplementedException();
- public System.Action ReCreateTarget;
+ }
+
+ protected virtual void ReCreateTarget()
+ {
+ throw new NotImplementedException();
+ }
public void DestructDeviceResource()
{
public void AddSymbol(char c, char alt)
{
- D2D.SolidColorBrush brush = this.Brushes.Get(this.Fore);
if (c == '\t')
{
this.InlineTabs = new MultiSet<double,InlineTab>();
}
else
{
+ D2D.SolidColorBrush brush = this.Brushes.Get(this.Fore);
for (int i = 0; i < DuplicateCount; i++)
{
this.InlineChars.Add(c, new InlineChar(this.Factory, this.Format, brush, alt));
public D2DRender(FooTextBox textbox,Windows.UI.Xaml.Shapes.Rectangle rect,TextStore2 store)
: base()
{
- base.ConstructRender = this.ConstructRenderHandler;
- base.ConstrctedResource = this.ConstructedResourceHandler;
- base.DestructRender = this.DestructRenderHandler;
- base.ReCreateTarget = this.ReCreateTargetHandler;
- base.GetDpi = this.GetDpiHandler;
this.ConstructDeviceResource(rect.ActualWidth,rect.ActualHeight);
this.InitTextFormat(textbox.FontFamily, textbox.FontSize);
base.PreDrawOneLine = D2DRender_PreDrawOneLine;
- this.Foreground = textbox.Foreground;
- this.Background = textbox.Background;
- this.Hilight = textbox.Hilight;
- this.Keyword1 = textbox.Keyword1;
- this.Keyword2 = textbox.Keyword2;
- this.Literal = textbox.Literal;
- this.Url = textbox.URL;
- this.ControlChar = textbox.ControlChar;
- this.Comment = textbox.Comment;
- this.InsertCaret = textbox.InsertCaret;
- this.OverwriteCaret = textbox.OverwriteCaret;
- this.LineMarker = textbox.LineMarker;
- this.UpdateArea = textbox.UpdateArea;
+ this.Foreground = D2DRenderBase.ToColor4( textbox.Foreground);
+ this.Background = D2DRenderBase.ToColor4(textbox.Background);
+ this.Hilight = D2DRenderBase.ToColor4(textbox.Hilight);
+ this.Keyword1 = D2DRenderBase.ToColor4(textbox.Keyword1);
+ this.Keyword2 = D2DRenderBase.ToColor4(textbox.Keyword2);
+ this.Literal = D2DRenderBase.ToColor4(textbox.Literal);
+ this.Url = D2DRenderBase.ToColor4(textbox.URL);
+ this.ControlChar = D2DRenderBase.ToColor4(textbox.ControlChar);
+ this.Comment = D2DRenderBase.ToColor4(textbox.Comment);
+ this.InsertCaret = D2DRenderBase.ToColor4(textbox.InsertCaret);
+ this.OverwriteCaret = D2DRenderBase.ToColor4(textbox.OverwriteCaret);
+ this.LineMarker = D2DRenderBase.ToColor4(textbox.LineMarker);
+ this.UpdateArea = D2DRenderBase.ToColor4(textbox.UpdateArea);
}
void D2DRender_PreDrawOneLine(MyTextLayout layout,LineToIndexTable lti, int row, double x, double y)
int start = attr.startIndex - lineIndex;
HilightType type = HilightType.None;
- Windows.UI.Color? color = null;
+ Color4? color = null;
switch (attr.attribute.lsStyle)
{
case TF_DA_LINESTYLE.TF_LS_DOT:
}
}
- void GetDpiHandler(out float dpix, out float dpiy)
+ public override void GetDpi(out float dpix, out float dpiy)
{
dpix = DisplayInformation.GetForCurrentView().LogicalDpi;
dpiy = DisplayInformation.GetForCurrentView().LogicalDpi;
return this.Size.Height != 0 && this.Size.Width != 0;
}
- public override void BeginDraw()
+ public override void BegineDraw()
{
SharpDX.Point offset;
this.Surface = this.SurfaceImageNative.BeginDraw(
new SharpDX.Rectangle(0, 0, (int)this.Size.Width, (int)this.Size.Height), out offset);
float dpix, dpiy;
- this.GetDpiHandler(out dpix, out dpiy);
+ this.GetDpi(out dpix, out dpiy);
D2D.BitmapProperties1 prop = new D2D.BitmapProperties1(new D2D.PixelFormat(DXGI.Format.B8G8R8A8_UNorm, D2D.AlphaMode.Premultiplied),
dpix, dpiy, D2D.BitmapOptions.Target | D2D.BitmapOptions.CannotDraw);
this.Bitmap = new D2D.Bitmap1(this.D2DContext, this.Surface, prop);
this.D2DContext.Target = this.Bitmap;
this.D2DContext.Transform = Matrix3x2.Translation(offset.X,offset.Y);
- base.BeginDraw();
+ base.BegineDraw();
}
public override void EndDraw()
rect.Fill = brush;
}
-
- D2D.RenderTarget ConstructRenderHandler(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
+ protected override D2D.RenderTarget ConstructRender(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
{
this.D2DDevice = new D2D.Device(factory,this.DXGIDevice);
this.D2DContext = new D2D.DeviceContext(this.D2DDevice, D2D.DeviceContextOptions.None);
return this.D2DContext;
}
- void ConstructedResourceHandler()
+ protected override void ConstrctedResource()
{
}
- void DestructRenderHandler()
+ protected override void DestructRender()
{
if (this.D2DDevice != null)
this.D2DDevice.Dispose();
this.D2DContext.Dispose();
}
- void ReCreateTargetHandler()
+ protected override void ReCreateTarget()
{
}
}
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,UpdateAreaColor;
FontFamily fontFamily;
FontStyle fontStyle = FontStyle.Normal;
this.DXGIDevice = this.D3DDevice.QueryInterface<DXGI.Device>();
}
- 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<D2D.Factory1, D2D.RenderTargetProperties, double, double, D2D.RenderTarget> 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
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;
}
}
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;
}
}
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));
}
}
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));
}
}
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 UpdateArea
- {
- get
- {
- return this.UpdateAreaColor;
- }
- set
- {
- this.UpdateAreaColor = value;
- this.common.UpdateArea = 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 delegate void PreDrawOneLineHandler(MyTextLayout layout, LineToIndexTable lti, int row, double x, double y);
+ 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<Selection> SelectRanges)
{
- this.common.DrawOneLine(lti,
+ this.DrawOneLine(lti,
row,
x,
y,
this.PreDrawOneLine(layout, lti, row, x, y);
});
}
-
- public List<LineToIndexTableData> 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<Marker> MarkerRanges)
- {
- return this.common.CreateLaytout(str, syntaxCollection, MarkerRanges);
- }
}
}
if (this.rectangle.ActualWidth == 0 || this.rectangle.ActualHeight == 0/* || !this.Render.IsCanDraw()*/)\r
return;\r
\r
- this.Render.BeginDraw();\r
+ this.Render.BegineDraw();\r
if (this.IsEnabled)\r
this.View.Draw(updateRect);\r
else\r
if (e.Property.Equals(FontSizeProperty))\r
source.Render.FontSize = source.FontSize;\r
if (e.Property.Equals(ForegroundProperty))\r
- source.Render.Foreground = source.Foreground;\r
+ source.Render.Foreground = D2DRenderBase.ToColor4(source.Foreground);\r
if (e.Property.Equals(BackgroundProperty))\r
- source.Render.Background = source.Background;\r
+ source.Render.Background = D2DRenderBase.ToColor4(source.Background);\r
if (e.Property.Equals(ControlCharProperty))\r
- source.Render.ControlChar = source.ControlChar;\r
+ source.Render.ControlChar = D2DRenderBase.ToColor4(source.ControlChar);\r
if (e.Property.Equals(HilightProperty))\r
- source.Render.Hilight = source.Hilight;\r
+ source.Render.Hilight = D2DRenderBase.ToColor4(source.Hilight);\r
if (e.Property.Equals(Keyword1Property))\r
- source.Render.Keyword1 = source.Keyword1;\r
+ source.Render.Keyword1 = D2DRenderBase.ToColor4(source.Keyword1);\r
if (e.Property.Equals(Keyword2Property))\r
- source.Render.Keyword2 = source.Keyword2;\r
+ source.Render.Keyword2 = D2DRenderBase.ToColor4(source.Keyword2);\r
if (e.Property.Equals(CommentProperty))\r
- source.Render.Comment = source.Comment;\r
+ source.Render.Comment = D2DRenderBase.ToColor4(source.Comment);\r
if (e.Property.Equals(LiteralProperty))\r
- source.Render.Literal = source.Literal;\r
+ source.Render.Literal = D2DRenderBase.ToColor4(source.Literal);\r
if (e.Property.Equals(URLProperty))\r
- source.Render.Url = source.URL;\r
+ source.Render.Url = D2DRenderBase.ToColor4(source.URL);\r
if (e.Property.Equals(InsertCaretProperty))\r
- source.Render.InsertCaret = source.InsertCaret;\r
+ source.Render.InsertCaret = D2DRenderBase.ToColor4(source.InsertCaret);\r
if (e.Property.Equals(OverwriteCaretProperty))\r
- source.Render.OverwriteCaret = source.OverwriteCaret;\r
+ source.Render.OverwriteCaret = D2DRenderBase.ToColor4(source.OverwriteCaret);\r
if (e.Property.Equals(PaddingProperty))\r
source.View.Padding = new Padding((int)source.Padding.Left, (int)source.Padding.Top, (int)source.Padding.Right, (int)source.Padding.Bottom);\r
if (e.Property.Equals(LineMarkerProperty))\r
- source.Render.LineMarker = source.LineMarker;\r
+ source.Render.LineMarker = D2DRenderBase.ToColor4(source.LineMarker);\r
if (e.Property.Equals(MarkURLProperty))\r
source.View.UrlMark = source.MarkURL;\r
if (e.Property.Equals(ShowFullSpaceProperty))\r
if (e.Property.Equals(LineBreakCharCountProperty))\r
source.View.LineBreakCharCount = source.LineBreakCharCount;\r
if (e.Property.Equals(UpdateAreaProperty))\r
- source.Render.UpdateArea = source.UpdateArea;\r
+ source.Render.UpdateArea = D2DRenderBase.ToColor4(source.UpdateArea);\r
if (e.Property.Equals(FlowDirectionProperty))\r
{\r
source.Render.RightToLeft = source.FlowDirection == Windows.UI.Xaml.FlowDirection.RightToLeft;\r
this.Size = size;
this.dpi = dpi;
- base.ConstructRender = this.ConstructRenderHandler;
- base.ConstrctedResource = this.ConstructedResourceHandler;
- base.DestructRender = this.DestructRenderHandler;
- base.ReCreateTarget = this.ReCreateTargetHandler;
- base.GetDpi = this.GetDpi;
base.ConstructDeviceResource(size.Width, size.Height);
base.InitTextFormat(fontName, (float)fontSize);
}
- new void GetDpi(out float dpix, out float dpiy)
+ public override void GetDpi(out float dpix, out float dpiy)
{
dpix = this.dpi;
dpiy = this.dpi;
}
- public override void BeginDraw()
+ public override void BegineDraw()
{
- base.BeginDraw();
+ base.BegineDraw();
}
public void Resize(float width,float height)
this.D2DContext.Transform = Matrix3x2.Scaling(1/scale);
}
- D2D.RenderTarget ConstructRenderHandler(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
+ protected override D2D.RenderTarget ConstructRender(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
{
D3D11.Texture2DDescription desc = new D3D11.Texture2DDescription();
desc.Width = (int)(width * this.dpi / 96);
return this.D2DContext;
}
- void ConstructedResourceHandler()
+ protected override void ConstrctedResource()
{
}
- void DestructRenderHandler()
+ protected override void DestructRender()
{
if (this.Texture != null)
this.Texture.Dispose();
this.D2DContext.Dispose();
}
- void ReCreateTargetHandler()
+ protected override void ReCreateTarget()
{
}
public D2DPrintRender(string fontName,double fontSize, Size size, uint dpi, IPrintDocumentPackageTarget docPackageTarget)
: base()
{
- base.ConstructRender = this.ConstructRenderHandler;
- base.ConstrctedResource = this.ConstructedResourceHandler;
- base.DestructRender = this.DestructRenderHandler;
- base.ReCreateTarget = this.ReCreateTargetHandler;
- base.GetDpi = this.GetDpi;
base.ConstructDeviceResource(size.Width, size.Height);
base.InitTextFormat(fontName, (float)fontSize);
this.CreateSurface(size,dpi,docPackageTarget);
}
- new void GetDpi(out float dpix, out float dpiy)
+ public override void GetDpi(out float dpix, out float dpiy)
{
dpix = this.dpi;
dpiy = this.dpi;
}
- public override void BeginDraw()
+ public override void BegineDraw()
{
this.CommandList = new D2D.CommandList(this.D2DContext);
this.D2DContext.Target = this.CommandList;
- base.BeginDraw();
+ base.BegineDraw();
}
public override void EndDraw()
this.dpi = (int)dpi;
}
- D2D.RenderTarget ConstructRenderHandler(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
+ protected override D2D.RenderTarget ConstructRender(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
{
this.D2DDevice = new D2D.Device(factory,this.DXGIDevice);
this.D2DContext = new D2D.DeviceContext(this.D2DDevice, D2D.DeviceContextOptions.None);
return this.D2DContext;
}
- void ConstructedResourceHandler()
+ protected override void ConstrctedResource()
{
}
- void DestructRenderHandler()
+ protected override void DestructRender()
{
if (this.Control != null)
{
this.D2DContext.Dispose();
}
- void ReCreateTargetHandler()
+ protected override void ReCreateTarget()
{
}
D2DRenderBase render;\r
Size size = new Size(pagedesc.ImageableRect.Width, pagedesc.ImageableRect.Height);\r
render = new D2DPrintRender(this.fontName, this.fontSize, size, Math.Min(pagedesc.DpiX, pagedesc.DpiY), docPackageTarget);\r
- render.Foreground = this.foreground;\r
- render.Comment = this.comment;\r
- render.Keyword1 = this.keyword1;\r
- render.Keyword2 = this.keyword2;\r
- render.Literal = this.literal;\r
- render.Url = this.url;\r
+ render.Foreground = D2DRenderBase.ToColor4(this.foreground);\r
+ render.Comment = D2DRenderBase.ToColor4(this.comment);\r
+ render.Keyword1 = D2DRenderBase.ToColor4(this.keyword1);\r
+ render.Keyword2 = D2DRenderBase.ToColor4(this.keyword2);\r
+ render.Literal = D2DRenderBase.ToColor4(this.literal);\r
+ render.Url = D2DRenderBase.ToColor4(this.url);\r
return render;\r
}\r
public D2DPrintPreviewRender CreateRender(PrintPageDescription pagedesc)\r
D2DPrintPreviewRender render;\r
Size size = new Size(pagedesc.ImageableRect.Width, pagedesc.ImageableRect.Height);\r
render = new D2DPrintPreviewRender(this.fontName, this.fontSize, size, this.displayDpi);\r
- render.Foreground = this.foreground;\r
- render.Comment = this.comment;\r
- render.Keyword1 = this.keyword1;\r
- render.Keyword2 = this.keyword2;\r
- render.Literal = this.literal;\r
- render.Url = this.url;\r
+ render.Foreground = D2DRenderBase.ToColor4(this.foreground);\r
+ render.Comment = D2DRenderBase.ToColor4(this.comment);\r
+ render.Keyword1 = D2DRenderBase.ToColor4(this.keyword1);\r
+ render.Keyword2 = D2DRenderBase.ToColor4(this.keyword2);\r
+ render.Literal = D2DRenderBase.ToColor4(this.literal);\r
+ render.Url = D2DRenderBase.ToColor4(this.url);\r
return render;\r
}\r
public PrintableView CreateView(PrintPageDescription pagedesc, D2DRenderBase render, string header, string footer)\r
if (!string.IsNullOrEmpty(this.Fotter))\r
view.Footer = this.ParseHF(this, new ParseCommandEventArgs(currentPage, this.maxPreviePageCount, this.Fotter));\r
\r
- render.BeginDraw();\r
+ render.BegineDraw();\r
view.Draw(view.PageBound);\r
render.EndDraw();\r
result = view.TryPageDown();\r
this.previewRender.Resize(width, height);\r
this.previewRender.SetScale((float)(this.previewView.PageBound.Width / width)); //BeginDraw()で倍率が1に戻る\r
\r
- this.previewRender.BeginDraw();\r
+ this.previewRender.BegineDraw();\r
this.previewView.Draw(this.previewView.PageBound);\r
this.previewRender.EndDraw(this.dxgiPreviewTarget,desiredJobPage);\r
}\r
namespace FooEditEngine.WPF
{
- class D2DRender : IEditorRender, IDisposable
+ class D2DRender : D2DRenderCommon,IEditorRender
{
- D2DRenderCommon common;
- System.Windows.Media.Color ForegroundColor, BackgroundColor, HilightColor, Keyword1Color, Keyword2Color, LiteralColor, UrlColor, ControlCharColor, CommentColor, InsertCaretColor,OverwriteCaretColor,LineMarkerColor,UpdateAreaColor;
DotNetTextStore.TextStore store;
D3D10.Texture2D texture;
DXGI.Surface surface;
this.fontSize = textbox.FontSize;
this.fontWeigth = textbox.FontWeight;
this.fontStyle = textbox.FontStyle;
- this.ForegroundColor = textbox.Foreground;
- this.BackgroundColor = textbox.Background;
- this.ControlCharColor = textbox.ControlChar;
- this.HilightColor = textbox.Hilight;
- this.CommentColor = textbox.Comment;
- this.UrlColor = textbox.URL;
- this.Keyword1Color = textbox.Keyword1;
- this.Keyword2Color = textbox.Keyword2;
- this.LiteralColor = textbox.Literal;
- this.InsertCaretColor = textbox.InsertCaret;
- this.OverwriteCaretColor = textbox.OverwriteCaret;
- this.LineMarkerColor = textbox.LineMarker;
- this.UpdateAreaColor = textbox.UpdateArea;
+ this.Foreground = ToColor4(textbox.Foreground);
+ this.Background = ToColor4(textbox.Background);
+ this.ControlChar = ToColor4(textbox.ControlChar);
+ this.Hilight = ToColor4(textbox.Hilight);
+ this.Comment = ToColor4(textbox.Comment);
+ this.Url = ToColor4(textbox.URL);
+ this.Keyword1 = ToColor4(textbox.Keyword1);
+ this.Keyword2 = ToColor4(textbox.Keyword2);
+ this.Literal = ToColor4(textbox.Literal);
+ this.InsertCaret = ToColor4(textbox.InsertCaret);
+ this.OverwriteCaret = ToColor4(textbox.OverwriteCaret);
+ this.LineMarker = ToColor4(textbox.LineMarker);
+ this.UpdateArea = ToColor4(textbox.UpdateArea);
this.store = textbox.TextStore;
this.CreateDevice();
- this.common = new D2DRenderCommon();
- this.common.ConstructRender = ConstructRenderHandler;
- this.common.ConstrctedResource = ConstructedResourceHandler;
- this.common.DestructRender = this.DestructRenderHandler;
- this.common.ReCreateTarget = this.ReCreateTarget;
- this.common.GetDpi = this.GetDpi;
- this.common.ConstructDeviceResource(width, height);
- this.common.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle));
+ this.ConstructDeviceResource(width, height);
+ this.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle));
this.imageSource = new D3DImage();
this.imageSource.Lock();
image.Source = this.imageSource;
}
- public void GetDpi(out float dpix, out float dpiy)
- {
- IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
- dpix = NativeMethods.GetDeviceCaps(hDc, NativeMethods.LOGPIXELSX);
- dpiy = NativeMethods.GetDeviceCaps(hDc, NativeMethods.LOGPIXELSY);
- NativeMethods.ReleaseDC(IntPtr.Zero, hDc);
- }
-
- 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;
- }
- }
-
public FontFamily FontFamily
{
get { return this.fontFamily; }
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;
}
}
set
{
this.fontSize = value;
- this.common.InitTextFormat(this.fontFamily.Source, (float)value, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle));
+ this.InitTextFormat(this.fontFamily.Source, (float)value, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle));
this.TabWidthChar = this.TabWidthChar;
}
}
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));
}
}
set
{
this.fontStyle = value;
- this.common.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle));
- }
- }
-
- public bool RightToLeft
- {
- get
- {
- return this.common.RightToLeft;
- }
- set
- {
- this.common.RightToLeft = value;
+ this.InitTextFormat(this.fontFamily.Source, (float)this.fontSize, this.GetDWFontWeigth(this.fontWeigth), this.GetDWFontStyle(this.fontStyle));
}
}
- Color4 ToColor4(System.Windows.Media.Color color)
+ public static Color4 ToColor4(System.Windows.Media.Color color)
{
return new Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
}
- public System.Windows.Media.Color Foreground
- {
- get
- {
- return this.ForegroundColor;
- }
- set
- {
- this.ForegroundColor = value;
- this.common.Foreground = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color Background
- {
- get
- {
- return this.BackgroundColor;
- }
- set
- {
- this.BackgroundColor = value;
- this.common.Background = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color InsertCaret
- {
- get
- {
- return this.InsertCaretColor;
- }
- set
- {
- this.InsertCaretColor = value;
- this.common.InsertCaret = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color OverwriteCaret
- {
- get
- {
- return this.OverwriteCaretColor;
- }
- set
- {
- this.OverwriteCaretColor = value;
- this.common.OverwriteCaret = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color UpdateArea
- {
- get
- {
- return this.UpdateAreaColor;
- }
- set
- {
- this.UpdateAreaColor = value;
- this.common.UpdateArea = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color LineMarker
- {
- get
- {
- return this.LineMarkerColor;
- }
- set
- {
- this.LineMarkerColor = value;
- this.common.LineMarker = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color ControlChar
- {
- get
- {
- return this.ControlCharColor;
- }
- set
- {
- this.ControlCharColor = value;
- this.common.ControlChar = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color Url
- {
- get
- {
- return this.UrlColor;
- }
- set
- {
- this.UrlColor = value;
- this.common.Url = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color Hilight
- {
- get
- {
- return this.HilightColor;
- }
- set
- {
- this.HilightColor = value;
- this.common.Hilight = this.ToColor4(this.HilightColor);
- }
- }
-
- public System.Windows.Media.Color Comment
- {
- get
- {
- return this.CommentColor;
- }
- set
- {
- this.CommentColor = value;
- this.common.Comment = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color Literal
- {
- get
- {
- return this.LiteralColor;
- }
- set
- {
- this.LiteralColor = value;
- this.common.Literal = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.Color Keyword1
- {
- get
- {
- return this.Keyword1Color;
- }
- set
- {
- this.Keyword1Color = value;
- this.common.Keyword1 = this.ToColor4(value);
- }
- }
-
- public System.Windows.Media.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 this.common.FoldingWidth;
- }
- }
-
- public int TabWidthChar
- {
- get { return this.common.TabWidthChar; }
- set
- {
- if (value == 0)
- return;
- this.common.TabWidthChar = value;
- }
- }
-
- public Size emSize
- {
- get
- {
- return this.common.emSize;
- }
- }
-
- 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 bool Resize(double width, double height)
{
if (width != this.imageSource.Width || height != this.imageSource.Height)
{
- this.common.ReConstructDeviceResource(width, height);
+ this.ReConstructDeviceResource(width, height);
this.imageSource.Lock();
this.imageSource.SetBackBuffer(D3DResourceType.IDirect3DSurface9, this.surface9.NativePointer);
this.imageSource.Unlock();
return false;
}
- public void DrawCachedBitmap(Rectangle rect)
+ public override void BegineDraw()
{
- this.common.DrawCachedBitmap(rect);
+ base.BegineDraw();
}
- public void CacheContent()
+ public override void EndDraw()
{
- this.common.CacheContent();
- }
-
- public bool IsVaildCache()
- {
- return this.common.IsVaildCache();
- }
-
- public void BegineDraw()
- {
- this.common.BegineDraw();
- }
-
- public void EndDraw()
- {
- this.common.EndDraw();
+ base.EndDraw();
this.device.Flush();
if (this.imageSource.IsFrontBufferAvailable)
}
}
- 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 DrawFoldingMark(bool expand, double x, double y)
- {
- this.common.DrawFoldingMark(expand, x, y);
- }
-
- public void FillBackground(Rectangle rect)
- {
- this.common.FillBackground(rect);
- }
-
- public void DrawLine(Point from, Point to)
- {
- this.common.DrawLine(from, to);
- }
-
public void DrawOneLine(LineToIndexTable lti, int row, double x, double y, IEnumerable<Selection> SelectRanges)
{
PreDrawOneLineHandler PreDrawOneLine = (layout) => {
color = this.GetColor4(attr.attribute.crBk);
}
- this.common.DrawMarkerEffect(layout, type, start, length,x,y,attr.attribute.fBoldLine,color);
+ this.DrawMarkerEffect(layout, type, start, length,x,y,attr.attribute.fBoldLine,color);
color = this.GetColor4(attr.attribute.crText);
if (color != null)
{
- this.common.SetTextColor(layout, start, length, color);
+ this.SetTextColor(layout, start, length, color);
layout.Invaild = true;
}
}
}
};
- this.common.DrawOneLine(lti,
+ this.DrawOneLine(lti,
row,
x,
y,
return new Color4(colorref.R / 255.0f, colorref.G / 255.0f, colorref.B / 255.0f, 1);
}
- public ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable<Marker> MarkerRanges)
+ public override void Dispose()
{
- return this.common.CreateLaytout(str,syntaxCollection,MarkerRanges);
- }
-
- public List<LineToIndexTableData> BreakLine(Document doc,LineToIndexTable layoutLineCollection, int startIndex, int endIndex, double wrapwidth)
- {
- return this.common.BreakLine(doc,layoutLineCollection, startIndex, endIndex, wrapwidth);
- }
-
- public void Dispose()
- {
- //CA2213が表示されるが、DestructRenderHandlerで破棄しているので問題はない
- this.common.Dispose();
+ base.Dispose();
this.DestructDevice();
}
- void ReCreateTarget()
- {
- System.Diagnostics.Debug.WriteLine("ReCreatedDevice");
- this.DestructDevice();
- this.CreateDevice();
- this.common.ReConstructDeviceResource();
- }
-
DW.FontStyle GetDWFontStyle(FontStyle style)
{
return (DW.FontStyle)Enum.Parse(typeof(DW.FontStyle), style.ToString());
}
}
- D2D.RenderTarget ConstructRenderHandler(D2D.Factory factory, D2D.RenderTargetProperties prop, double width, double height)
+ protected override void ReCreateTarget()
+ {
+ System.Diagnostics.Debug.WriteLine("ReCreatedDevice");
+ this.DestructDevice();
+ this.CreateDevice();
+ this.ReConstructDeviceResource();
+ }
+
+ protected override D2D.RenderTarget ConstructRender(D2D.Factory factory, D2D.RenderTargetProperties prop, double width, double height)
{
D3D10.Texture2DDescription desc = new D3D10.Texture2DDescription();
desc.Width = (int)width;
return this.render;
}
- void ConstructedResourceHandler()
+ protected override void ConstrctedResource()
+ {
+ }
+
+ public override void GetDpi(out float dpix, out float dpiy)
{
- this.common.Foreground = this.ToColor4(this.ForegroundColor);
- this.common.Background = this.ToColor4(this.BackgroundColor);
- this.common.ControlChar = this.ToColor4(this.ControlCharColor);
- this.common.Url = this.ToColor4(this.UrlColor);
- this.common.Keyword1 = this.ToColor4(this.Keyword1Color);
- this.common.Keyword2 = this.ToColor4(this.Keyword2Color);
- this.common.Literal = this.ToColor4(this.LiteralColor);
- this.common.Comment = this.ToColor4(this.CommentColor);
- this.common.Hilight = this.ToColor4(this.HilightColor);
- this.common.LineMarker = this.ToColor4(this.LineMarkerColor);
- this.common.InsertCaret = this.ToColor4(this.InsertCaretColor);
- this.common.OverwriteCaret = this.ToColor4(this.OverwriteCaretColor);
- this.common.UpdateArea = this.ToColor4(this.UpdateAreaColor);
+ IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
+ dpix = NativeMethods.GetDeviceCaps(hDc, NativeMethods.LOGPIXELSX);
+ dpiy = NativeMethods.GetDeviceCaps(hDc, NativeMethods.LOGPIXELSY);
+ NativeMethods.ReleaseDC(IntPtr.Zero, hDc);
}
- void DestructRenderHandler()
+ protected override void DestructRender()
{
if (this.texture != null)
this.texture.Dispose();
this.Render.FontWeigth = this.FontWeight;\r
break;\r
case "Foreground":\r
- this.Render.Foreground = this.Foreground;\r
+ this.Render.Foreground = D2DRender.ToColor4(this.Foreground);\r
break;\r
case "Background":\r
- this.Render.Background = this.Background;\r
+ this.Render.Background = D2DRender.ToColor4(this.Background);\r
break;\r
case "ControlChar":\r
- this.Render.ControlChar = this.ControlChar;\r
+ this.Render.ControlChar =D2DRender.ToColor4( this.ControlChar);\r
break;\r
case "Hilight":\r
- this.Render.Hilight = this.Hilight;\r
+ this.Render.Hilight = D2DRender.ToColor4(this.Hilight);\r
break;\r
case "Keyword1":\r
- this.Render.Keyword1 = this.Keyword1;\r
+ this.Render.Keyword1 = D2DRender.ToColor4(this.Keyword1);\r
break;\r
case "Keyword2":\r
- this.Render.Keyword2 = this.Keyword2;\r
+ this.Render.Keyword2 = D2DRender.ToColor4(this.Keyword2);\r
break;\r
case "Comment":\r
- this.Render.Comment = this.Comment;\r
+ this.Render.Comment = D2DRender.ToColor4(this.Comment);\r
break;\r
case "Literal":\r
- this.Render.Literal = this.Literal;\r
+ this.Render.Literal = D2DRender.ToColor4(this.Literal);\r
break;\r
case "URL":\r
- this.Render.Url = this.URL;\r
+ this.Render.Url = D2DRender.ToColor4(this.URL);\r
break;\r
case "InsertCaret":\r
- this.Render.InsertCaret = this.InsertCaret;\r
+ this.Render.InsertCaret = D2DRender.ToColor4(this.InsertCaret);\r
break;\r
case "OverwriteCaret":\r
- this.Render.OverwriteCaret = this.OverwriteCaret;\r
+ this.Render.OverwriteCaret = D2DRender.ToColor4(this.OverwriteCaret);\r
break;\r
case "Padding":\r
this.View.Padding = new Padding((int)this.Padding.Left, (int)this.Padding.Top, (int)this.Padding.Right, (int)this.Padding.Bottom);\r
break;\r
case "LineMarker":\r
- this.Render.LineMarker = this.LineMarker;\r
+ this.Render.LineMarker = D2DRender.ToColor4(this.LineMarker);\r
break;\r
case "MarkURL":\r
this.View.UrlMark = this.MarkURL;\r
this._Controller.JumpCaret(this.View.CaretPostion.row, this.View.CaretPostion.col);\r
break;\r
case "UpdateArea":\r
- this.Render.UpdateArea = this.UpdateArea;\r
+ this.Render.UpdateArea = D2DRender.ToColor4(this.UpdateArea);\r
break;\r
}\r
base.OnPropertyChanged(e);\r
namespace FooEditEngine.Windows
{
- class D2DTextRender : IEditorRender, IDisposable
+ class D2DTextRender : D2DRenderCommon,IEditorRender, IDisposable
{
- D2DRenderCommon common;
FooTextBox TextBox;
- System.Drawing.Color ForegroundColor = SystemColors.ControlText,
- BackgroundColor = SystemColors.Control,
- HilightColor = System.Drawing.Color.DeepSkyBlue,
- Keyword1Color = System.Drawing.Color.Blue,
- Keyword2Color = System.Drawing.Color.DarkCyan,
- LiteralColor = System.Drawing.Color.Brown,
- UrlColor = System.Drawing.Color.Blue,
- ControlCharColor = System.Drawing.Color.Gray,
- CommentColor = System.Drawing.Color.Green,
- InsertCaretColor = System.Drawing.Color.Black,
- OverwriteCaretColor = System.Drawing.Color.Black,
- LineMarkerColor = System.Drawing.Color.WhiteSmoke,
- UpdateAreaColor = System.Drawing.Color.MediumSeaGreen;
string fontName;
float fontSize;
textbox.HandleDestroyed += new EventHandler(textbox_HandleDestroyed);
Size size = textbox.Size;
- this.common = new D2DRenderCommon();
- this.common.ConstructRender = ConstructRenderHandler;
- this.common.ConstrctedResource = ConstructedResourceHandler;
- this.common.DestructRender = this.DestructRenderHandler;
- this.common.GetDpi = this.GetDpiHandler;
- this.common.ConstructDeviceResource(size.Width, size.Height);
this.fontName = textbox.Font.Name;
this.fontSize = textbox.Font.Size;
- this.common.InitTextFormat(textbox.Font.Name, (float)textbox.Font.Size);
+ this.InitTextFormat(textbox.Font.Name, (float)textbox.Font.Size);
}
- public void GetDpiHandler(out float dpix, out float dpiy)
+ public override void GetDpi(out float dpix, out float dpiy)
{
IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
dpix = NativeMethods.GetDeviceCaps(hDc, NativeMethods.LOGPIXELSX);
NativeMethods.ReleaseDC(IntPtr.Zero, hDc);
}
- public event EventHandler ChangedRightToLeft;
-
void textbox_HandleDestroyed(object sender, EventArgs e)
{
- this.common.DestructDeviceResource();
+ this.DestructDeviceResource();
}
void textbox_HandleCreated(object sender, EventArgs e)
{
FooTextBox textbox = (FooTextBox)sender;
this.TextBox = textbox;
- this.common.ConstructDeviceResource(textbox.Width, textbox.Height);
+ this.ConstructDeviceResource(textbox.Width, textbox.Height);
}
void textbox_FontChanged(object sender, EventArgs e)
this.fontSize = font.Size;
DW.FontWeight weigth = font.Bold ? DW.FontWeight.Bold : DW.FontWeight.Normal;
DW.FontStyle style = font.Italic ? DW.FontStyle.Italic : DW.FontStyle.Normal;
- this.common.InitTextFormat(font.Name, font.Size,weigth,style);
+ this.InitTextFormat(font.Name, font.Size,weigth,style);
}
void textbox_SizeChanged(object sender, EventArgs e)
{
FooTextBox textbox = (FooTextBox)sender;
- this.common.ReConstructDeviceResource(this.TextBox.Width, this.TextBox.Height);
+ this.ReConstructDeviceResource(this.TextBox.Width, this.TextBox.Height);
}
- Color4 ToColor4(System.Drawing.Color color)
+ public static Color4 ToColor4(System.Drawing.Color color)
{
return new Color4(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f);
}
- public bool RightToLeft
- {
- get
- {
- return this.common.RightToLeft;
- }
- set
- {
- this.common.RightToLeft = value;
- this.ChangedRightToLeft(this, null);
- }
- }
-
- public TextAntialiasMode TextAntialiasMode
- {
- get
- {
- return this.common.TextAntialiasMode;
- }
- set
- {
- this.common.TextAntialiasMode = value;
- }
- }
-
- public System.Drawing.Color Foreground
- {
- get
- {
- return this.ForegroundColor;
- }
- set
- {
- this.ForegroundColor = value;
- this.common.Foreground = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color UpdateArea
- {
- get
- {
- return this.UpdateArea;
- }
- set
- {
- this.UpdateArea = value;
- this.common.UpdateArea = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color Background
- {
- get
- {
- return this.BackgroundColor;
- }
- set
- {
- this.BackgroundColor = value;
- this.common.Background = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color InsertCaret
- {
- get
- {
- return this.InsertCaretColor;
- }
- set
- {
- this.InsertCaretColor = value;
- this.common.InsertCaret = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color OverwriteCaret
- {
- get
- {
- return this.OverwriteCaretColor;
- }
- set
- {
- this.OverwriteCaretColor = value;
- this.common.OverwriteCaret = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color LineMarker
- {
- get
- {
- return this.LineMarkerColor;
- }
- set
- {
- this.LineMarkerColor = value;
- this.common.LineMarker = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color ControlChar
- {
- get
- {
- return this.ControlCharColor;
- }
- set
- {
- this.ControlCharColor = value;
- this.common.ControlChar = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color Url
- {
- get
- {
- return this.UrlColor;
- }
- set
- {
- this.UrlColor = value;
- this.common.Url = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color Hilight
- {
- get
- {
- return this.HilightColor;
- }
- set
- {
- this.HilightColor = value;
- this.common.Hilight = this.ToColor4(this.HilightColor);
- }
- }
-
- public System.Drawing.Color Comment
- {
- get
- {
- return this.CommentColor;
- }
- set
- {
- this.CommentColor = value;
- this.common.Comment = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color Literal
- {
- get
- {
- return this.LiteralColor;
- }
- set
- {
- this.LiteralColor = value;
- this.common.Literal = this.ToColor4(value);
- }
- }
-
- public System.Drawing.Color Keyword1
- {
- get
- {
- return this.Keyword1Color;
- }
- set
- {
- this.Keyword1Color = value;
- this.common.Keyword1 = this.ToColor4(value);
- }
- }
-
- public System.Drawing.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 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 double FoldingWidth
- {
- get
- {
- return this.common.FoldingWidth;
- }
- }
-
- 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;
- }
- }
-
- public event ChangedRenderResourceEventHandler ChangedRenderResource
- {
- add
- {
- this.common.ChangedRenderResource += value;
- }
- remove
- {
- this.common.ChangedRenderResource -= value;
- }
- }
-
- public void DrawLine(Point from, Point to)
- {
- this.common.DrawLine(from, to);
- }
-
- public void DrawCachedBitmap(Rectangle rect)
- {
- this.common.DrawCachedBitmap(rect);
- }
-
- public void CacheContent()
- {
- this.common.CacheContent();
- }
-
- public bool IsVaildCache()
- {
- return this.common.IsVaildCache();
- }
-
- public void BeginDraw()
- {
- this.common.BegineDraw();
- }
-
- public void EndDraw()
- {
- this.common.EndDraw();
- }
-
- 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 DrawFoldingMark(bool expand, double x, double y)
- {
- this.common.DrawFoldingMark(expand, x, y);
- }
-
- public void FillBackground(Rectangle rect)
- {
- this.common.FillBackground(rect);
- }
public void DrawOneLine(LineToIndexTable lti, int row, double x, double y, IEnumerable<Selection> SelectRanges)
{
- this.common.DrawOneLine(lti,
+ this.DrawOneLine(lti,
row,
x,
y,
null);
}
- public ITextLayout CreateLaytout(string str, SyntaxInfo[] syntaxCollection, IEnumerable<Marker> MarkerRanges)
- {
- return this.common.CreateLaytout(str,syntaxCollection,MarkerRanges);
- }
-
- public List<LineToIndexTableData> BreakLine(Document doc, LineToIndexTable layoutLineCollection, int startIndex, int endIndex, double wrapwidth)
- {
- return this.common.BreakLine(doc,layoutLineCollection, startIndex, endIndex, wrapwidth);
- }
-
- public void Dispose()
- {
- this.common.Dispose();
- }
-
D2D.WindowRenderTarget WindowRender;
- D2D.RenderTarget ConstructRenderHandler(D2D.Factory factory, D2D.RenderTargetProperties prop, double width, double height)
+ protected override D2D.RenderTarget ConstructRender(D2D.Factory factory, D2D.RenderTargetProperties prop, double width, double height)
{
D2D.HwndRenderTargetProperties hwndProp = new D2D.HwndRenderTargetProperties();
hwndProp.Hwnd = this.TextBox.Handle;
return this.WindowRender;
}
- void ConstructedResourceHandler()
+ protected override void ConstrctedResource()
{
- this.common.Foreground = this.ToColor4(this.ForegroundColor);
- this.common.Background = this.ToColor4(this.BackgroundColor);
- this.common.ControlChar = this.ToColor4(this.ControlCharColor);
- this.common.Url = this.ToColor4(this.UrlColor);
- this.common.Keyword1 = this.ToColor4(this.Keyword1Color);
- this.common.Keyword2 = this.ToColor4(this.Keyword2Color);
- this.common.Literal = this.ToColor4(this.LiteralColor);
- this.common.Comment = this.ToColor4(this.CommentColor);
- this.common.Hilight = this.ToColor4(this.HilightColor);
- this.common.LineMarker = this.ToColor4(this.LineMarkerColor);
- this.common.InsertCaret = this.ToColor4(this.InsertCaretColor);
- this.common.OverwriteCaret = this.ToColor4(this.OverwriteCaretColor);
- this.common.UpdateArea = this.ToColor4(this.UpdateAreaColor);
+ this.Foreground = ToColor4(this.TextBox.Foreground);
+ this.Background = ToColor4(this.TextBox.Background);
+ this.ControlChar = ToColor4(this.TextBox.ControlChar);
+ this.Url = ToColor4(this.TextBox.Url);
+ this.Keyword1 = ToColor4(this.TextBox.Keyword1);
+ this.Keyword2 = ToColor4(this.TextBox.Keyword2);
+ this.Literal = ToColor4(this.TextBox.Literal);
+ this.Comment = ToColor4(this.TextBox.Comment);
+ this.Hilight = ToColor4(this.TextBox.Hilight);
+ this.LineMarker = ToColor4(this.TextBox.LineMarker);
+ this.InsertCaret = ToColor4(this.TextBox.InsertCaret);
+ this.OverwriteCaret = ToColor4(this.TextBox.OverwriteCaret);
+ this.UpdateArea = ToColor4(this.TextBox.UpdateArea);
}
- void DestructRenderHandler()
+ protected override void DestructRender()
{
if (this.WindowRender != null)
this.WindowRender.Dispose();
set { this.Controller.RectSelection = value; }\r
}\r
\r
+ System.Drawing.Color ForegroundColor = SystemColors.ControlText,\r
+ BackgroundColor = SystemColors.Control,\r
+ HilightColor = System.Drawing.Color.DeepSkyBlue,\r
+ Keyword1Color = System.Drawing.Color.Blue,\r
+ Keyword2Color = System.Drawing.Color.DarkCyan,\r
+ LiteralColor = System.Drawing.Color.Brown,\r
+ UrlColor = System.Drawing.Color.Blue,\r
+ ControlCharColor = System.Drawing.Color.Gray,\r
+ CommentColor = System.Drawing.Color.Green,\r
+ InsertCaretColor = System.Drawing.Color.Black,\r
+ OverwriteCaretColor = System.Drawing.Color.Black,\r
+ LineMarkerColor = System.Drawing.Color.WhiteSmoke,\r
+ UpdateAreaColor = System.Drawing.Color.MediumSeaGreen;\r
+\r
/// <summary>\r
/// 前景色\r
/// </summary>\r
{\r
get\r
{\r
- return this.render.Foreground;\r
+ return this.ForegroundColor;\r
}\r
set\r
{\r
- this.render.Foreground = value;\r
+ this.render.Foreground = D2DTextRender.ToColor4(value);\r
+ this.ForegroundColor = value;\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.Background;\r
+ return this.BackgroundColor;\r
}\r
set\r
{\r
- this.render.Background = value;\r
+ this.render.Background = D2DTextRender.ToColor4(value);\r
+ this.BackgroundColor = value;\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.InsertCaret;\r
+ return this.InsertCaretColor;\r
}\r
set\r
{\r
- this.render.InsertCaret = value;\r
+ this.InsertCaretColor = value;\r
+ this.render.InsertCaret = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.OverwriteCaret;\r
+ return this.OverwriteCaretColor;\r
}\r
set\r
{\r
- this.render.OverwriteCaret = value;\r
+ this.OverwriteCaretColor = value;\r
+ this.render.OverwriteCaret = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.LineMarker;\r
+ return this.LineMarkerColor;\r
}\r
set\r
{\r
- this.render.LineMarker = value;\r
+ this.LineMarkerColor = value;\r
+ this.render.LineMarker = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.ControlChar;\r
+ return this.ControlCharColor;\r
}\r
set\r
{\r
- this.render.ControlChar = value;\r
+ this.ControlCharColor = value;\r
+ this.render.ControlChar = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
+ /// <summary>\r
+ /// 編集行フラグの色\r
+ /// </summary>\r
public System.Drawing.Color UpdateArea\r
{\r
- get;\r
- set;\r
+ get\r
+ {\r
+ return this.UpdateAreaColor;\r
+ }\r
+ set\r
+ {\r
+ this.UpdateAreaColor = value;\r
+ this.render.UpdateArea = D2DTextRender.ToColor4(value);\r
+ }\r
}\r
\r
/// <summary>\r
{\r
get\r
{\r
- return this.render.Url;\r
+ return this.UrlColor;\r
}\r
set\r
{\r
- this.render.Url = value;\r
+ this.UrlColor = value;\r
+ this.render.Url = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.Hilight;\r
+ return this.HilightColor;\r
}\r
set\r
{\r
- this.render.Hilight = value;\r
+ this.HilightColor = value;\r
+ this.render.Hilight = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.Comment;\r
+ return this.CommentColor;\r
}\r
set\r
{\r
- this.render.Comment = value;\r
+ this.CommentColor = value;\r
+ this.render.Comment = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.Literal;\r
+ return this.LiteralColor;\r
}\r
set\r
{\r
- this.render.Literal = value;\r
+ this.LiteralColor = value;\r
+ this.render.Literal = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.Keyword1;\r
+ return this.Keyword1Color;\r
}\r
set\r
{\r
- this.render.Keyword1 = value;\r
+ this.Keyword1Color = value;\r
+ this.render.Keyword1 = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
{\r
get\r
{\r
- return this.render.Keyword2;\r
+ return this.Keyword2Color;\r
}\r
set\r
{\r
- this.render.Keyword2 = value;\r
+ this.Keyword2Color = value;\r
+ this.render.Keyword2 = D2DTextRender.ToColor4(value);\r
}\r
}\r
\r
e.Graphics.FillRectangle(brush, this.ClientRectangle);\r
brush.Dispose();\r
}else if (this.Document.FireUpdateEvent){\r
- this.render.BeginDraw();\r
+ this.render.BegineDraw();\r
this.View.Draw(e.ClipRectangle);\r
this.render.EndDraw();\r
}\r
this.Ime.Font = this.Font;\r
System.Drawing.Point p = this.GetPostionFromIndex(this.Controller.SelectionStart);\r
float dpi;\r
- this.render.GetDpiHandler(out dpi, out dpi);\r
+ this.render.GetDpi(out dpi, out dpi);\r
p.X = (int)(p.X * dpi / 96);\r
p.Y = (int)(p.X * dpi / 96);\r
this.Ime.Location = p;\r
if (CaretBlinkTime == -1)\r
{\r
this.View.CaretBlink = false;\r
- this.BeginInvoke(new Action(() => {\r
+ if (this.IsHandleCreated)\r
+ this.BeginInvoke(new Action(() =>\r
+ {\r
this.Timer.Stop();\r
- }));\r
+ }));\r
}\r
else\r
{\r
this.View.CaretBlink = true;\r
this.View.CaretBlinkTime = CaretBlinkTime * 2;\r
- this.BeginInvoke(new Action(() =>\r
- {\r
- this.Timer.Start();\r
- }));\r
+ if(this.IsHandleCreated)\r
+ this.BeginInvoke(new Action(() =>\r
+ {\r
+ this.Timer.Start();\r
+ }));\r
}\r
this.View.CaretWidthOnInsertMode = SystemInformation.CaretWidth;\r
}\r