protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { // Create a Font, Brush and TextFormat to draw our text. // For more information on drawing Text, please see the source code for the Text DrawingTool var font = new Gui.Tools.SimpleFont("Arial", 20); SharpDX.Direct2D1.Brush tmpBrush = Brushes.Red.ToDxBrush(RenderTarget); SharpDX.DirectWrite.TextFormat textFormat = font.ToDirectWriteTextFormat(); // Create a TextLayout for our text to draw. var cachedTextLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, "Hello, I am sideways text.", textFormat, 600, textFormat.FontSize); // Rotate the RenderTarget by setting the Matrix3x2 Transform property // Matrix3x2.Rotation() will return a rotated Matrix3x2 based off of the angle specified, and the center point where you draw the object RenderTarget.Transform = Matrix3x2.Rotation(1.5708f, new Vector2(100, 100)); // Draw the text on the rotated RenderTarget RenderTarget.DrawTextLayout(new SharpDX.Vector2(100, 100), cachedTextLayout, tmpBrush, SharpDX.Direct2D1.DrawTextOptions.NoSnap); // Dispose of resources textFormat.Dispose(); cachedTextLayout.Dispose(); tmpBrush.Dispose(); // Rotate the RenderTarget back RenderTarget.Transform = Matrix3x2.Identity; // Return rendering to base class base.OnRender(chartControl, chartScale); }
private void DrawString(string text, SimpleFont font, DXMediaBrush brush, double pointX, double pointY, DXMediaBrush areaBrush) { SharpDX.DirectWrite.TextFormat textFormat = font.ToDirectWriteTextFormat(); SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory, text, textFormat, ChartPanel.X + ChartPanel.W, textFormat.FontSize); float newW = textLayout.Metrics.Width; float newH = textLayout.Metrics.Height; SharpDX.Vector2 TextPlotPoint = new System.Windows.Point(pointX - newW, pointY - textLayout.Metrics.Height / 2 - 1).ToVector2(); SharpDX.RectangleF PLBoundRect = new SharpDX.RectangleF((float)pointX - newW - 4, (float)pointY - textLayout.Metrics.Height / 2 - 1, newW + 6, newH + 2); SharpDX.Direct2D1.RoundedRectangle PLRoundedRect = new SharpDX.Direct2D1.RoundedRectangle(); PLRoundedRect.RadiusX = newW / 4; PLRoundedRect.RadiusY = newH / 4; PLRoundedRect.Rect = PLBoundRect; RenderTarget.FillRoundedRectangle(PLRoundedRect, areaBrush.DxBrush); RenderTarget.DrawTextLayout(TextPlotPoint, textLayout, brush.DxBrush, SharpDX.Direct2D1.DrawTextOptions.NoSnap); textLayout.Dispose(); textLayout = null; textFormat.Dispose(); textFormat = null; }
/// <summary> /// Creates device-based resources to store a constant buffer, cube /// geometry, and vertex and pixel shaders. In some cases this will also /// store a geometry shader. /// </summary> public void CreateDeviceDependentResources() { ReleaseDeviceDependentResources(); // Create a default sampler state, which will use point sampling. pointSampler = ToDispose(new SamplerState(deviceResources.D3DDevice, new SamplerStateDescription() { AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp, AddressW = TextureAddressMode.Clamp, BorderColor = new RawColor4(0, 0, 0, 0), ComparisonFunction = Comparison.Never, Filter = Filter.MinMagMipLinear, MaximumAnisotropy = 16, MaximumLod = float.MaxValue, MinimumLod = 0, MipLodBias = 0.0f })); // Create the texture that will be used as the offscreen render target. var textureDesc = new Texture2DDescription { Format = SharpDX.DXGI.Format.B8G8R8A8_UNorm, Width = textureWidth, Height = textureHeight, MipLevels = 1, ArraySize = 1, BindFlags = BindFlags.ShaderResource | BindFlags.RenderTarget, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), OptionFlags = ResourceOptionFlags.None, Usage = ResourceUsage.Default, CpuAccessFlags = CpuAccessFlags.None }; texture2D = new Texture2D(deviceResources.D3DDevice, textureDesc); // Create read and write views for the offscreen render target. shaderResourceView = new ShaderResourceView(deviceResources.D3DDevice, texture2D); renderTargetView = new RenderTargetView(deviceResources.D3DDevice, texture2D); // In this example, we are using D2D and DirectWrite; so, we need to create a D2D render target as well. SharpDX.Direct2D1.RenderTargetProperties props = new SharpDX.Direct2D1.RenderTargetProperties( SharpDX.Direct2D1.RenderTargetType.Default, new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.Unknown, SharpDX.Direct2D1.AlphaMode.Premultiplied), 96, 96, SharpDX.Direct2D1.RenderTargetUsage.None, SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT); // The DXGI surface is used to create the render target. SharpDX.DXGI.Surface dxgiSurface = texture2D.QueryInterface <SharpDX.DXGI.Surface>(); d2dRenderTarget = new SharpDX.Direct2D1.RenderTarget(deviceResources.D2DFactory, dxgiSurface, props); // Create a solid color brush that will be used to render the text. whiteBrush = new SharpDX.Direct2D1.SolidColorBrush(d2dRenderTarget, new RawColor4(1f, 1f, 1f, 1f)); // This is where we format the text that will be written on the render target. textFormat = new SharpDX.DirectWrite.TextFormat(deviceResources.DWriteFactory, "Consolas", SharpDX.DirectWrite.FontWeight.Normal, SharpDX.DirectWrite.FontStyle.Normal, 64f); textFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Center; textFormat.ParagraphAlignment = SharpDX.DirectWrite.ParagraphAlignment.Center; }
private void UpdateTextLayout(float maxWidth) { if (!needsLayoutUpdate) { return; } needsLayoutUpdate = false; cachedTextLayout = null; if (Font == null) { return; } SharpDX.DirectWrite.TextFormat textFormat = Font.ToDirectWriteTextFormat(); cachedTextLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, DisplayText ?? string.Empty, textFormat, maxWidth, textFormat.FontSize); // again, make sure to chop max width/height to only amount actually needed cachedTextLayout.MaxWidth = cachedTextLayout.Metrics.Width; cachedTextLayout.MaxHeight = cachedTextLayout.Metrics.Height; // NOTE: always use leading alignment since our layout box will be the size of the text (http://i.msdn.microsoft.com/dynimg/IC520425.png) cachedTextLayout.TextAlignment = Alignment == TextAlignment.Center ? SharpDX.DirectWrite.TextAlignment.Center : Alignment == TextAlignment.Right ? SharpDX.DirectWrite.TextAlignment.Trailing : SharpDX.DirectWrite.TextAlignment.Leading; needsLayoutUpdate = false; textFormat.Dispose(); }
private void InitRender() { Factory factory = new Factory(FactoryType.MultiThreaded); RenderTargetProperties renderProps = new RenderTargetProperties { PixelFormat = new PixelFormat(), Usage = RenderTargetUsage.None, Type = RenderTargetType.Default }; HwndRenderTargetProperties hwndProps = new HwndRenderTargetProperties() { // 承载控件的句柄。 Hwnd = renderControl.Handle, // 控件的尺寸。 PixelSize = new Size2(renderControl.ClientSize.Width, renderControl.ClientSize.Height), PresentOptions = PresentOptions.None }; _renderTarget = new WindowRenderTarget(factory, renderProps, hwndProps) { AntialiasMode = AntialiasMode.PerPrimitive }; _blackBrush = new SolidColorBrush(_renderTarget, new RawColor4(0.0f, 0.0f, 0.0f, 0.9f)); //纯种黑 _blueBrush = new SolidColorBrush(_renderTarget, new RawColor4(0.3f, 0.6f, 1.0f, 0.5f)); //天依蓝 _greenBrush = new SolidColorBrush(_renderTarget, new RawColor4(0.0f, 0.8f, 0.0f, 0.9f)); //原谅绿 _redBrush = new SolidColorBrush(_renderTarget, new RawColor4(0.8f, 0.0f, 0.0f, 0.9f)); //姨妈红 _pinkBrush = new SolidColorBrush(_renderTarget, new RawColor4(1.0f, 0.3f, 0.3f, 0.9f)); //少女粉 SharpDX.DirectWrite.Factory fac = new SharpDX.DirectWrite.Factory(); _blackTextFormat = new SharpDX.DirectWrite.TextFormat(fac, "微软雅黑", 10.0f);//一个阿拉伯数字宽度6像素吧(大概....) }
public override void Draw(RenderTarget rt) { var b = ContentView.GetSBrush(0.8f, 0.2f, 0.5f); var b1 = ContentView.GetSBrush(0.4f, 0.4f, 0.4f); var b2 = ContentView.GetSBrush(0f, 0f, 0f); var b4 = ContentView.GetSBrush(0.1f, 0.1f, 0.1f); base.Draw(rt); rt.FillRectangle(ContentView.Scaled(ContentBounds), b1); rt.DrawRectangle(ContentView.Scaled(ContentBounds), b2, 1); rt.FillEllipse(new Ellipse(ContentView.Scaled(OUT.Position), ContentView.Scaled(0.1f), ContentView.Scaled(0.1f)), b); var DWFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared); SharpDX.DirectWrite.TextFormat tf = new SharpDX.DirectWrite.TextFormat(DWFactory, "Arial", ContentView.Scaled(0.6f)); var tg = ContentView.Scaled(ContentBounds); tg.Left += 2; tg.Top += 2; rt.DrawText(Name, tf, tg, b4); tg.Top += ContentView.Scaled(ContentBounds.Height / 2); rt.DrawText(Delay.ToString(), tf, tg, b4); tf.Dispose(); DWFactory.Dispose(); b.Dispose(); b1.Dispose(); b2.Dispose(); b4.Dispose(); }
/// <summary> /// 绘制标识 /// </summary> private void drawLegend() { var brush = new SharpDX.Direct2D1.SolidColorBrush(cp._renderTarget, new RawColor4(0, 0, 1, 1)); var textformat = new SharpDX.DirectWrite.TextFormat(cp.dwFactory, "Arial", 12); foreach (var item in coordianteParamList) { if (item.lineDirection == LineDireciton.Horizontal) { for (int i = 0; i < item.scalePointList.Count; i++) { cp._renderTarget.DrawText((item.MinValue + i * item.Interval).ToString(), textformat, new RawRectangleF(item.scalePointList[i].Item2.X - 5, item.scalePointList[i].Item2.Y, item.scalePointList[i].Item2.X + 200, item.scalePointList[i].Item2.Y + 200), brush); } } else { if (item.lineLocation == LineLocation.Right) { for (int i = 0; i < item.scalePointList.Count; i++) { cp._renderTarget.DrawText((item.MinValue + i * item.Interval).ToString(), textformat, new RawRectangleF(item.scalePointList[i].Item2.X, item.scalePointList[i].Item2.Y - 8, item.scalePointList[i].Item2.X + 200, item.scalePointList[i].Item2.Y + 200), brush); } } else { for (int i = 0; i < item.scalePointList.Count; i++) { cp._renderTarget.DrawText((item.MinValue + i * item.Interval).ToString(), textformat, new RawRectangleF(item.scalePointList[i].Item2.X - 15, item.scalePointList[i].Item2.Y - 8, item.scalePointList[i].Item2.X + 200, item.scalePointList[i].Item2.Y), brush); } } } } }
public TextElementState(TextElementState existing, TextElement element, RenderContext context) { props = element.Props; format = existing?.format ?? new SharpDX.DirectWrite.TextFormat(Renderer.AssertRendererType(context.Renderer).fontFactory, "Times New Roman", 18); layout = new SharpDX.DirectWrite.TextLayout(Renderer.AssertRendererType(context.Renderer).fontFactory, element.Props.Text, format, context.Bounds.Width, context.Bounds.Height); textBrush = existing?.textBrush ?? new SharpDX.Direct2D1.SolidColorBrush(Renderer.AssertRendererType(context.Renderer).d2dTarget, new RawColor4(1, 1, 1, 1)); BoundingBox = new Bounds(x: context.Bounds.X, y: context.Bounds.Y, width: (int)layout.Metrics.Width, height: (int)layout.Metrics.Height); context.Disposables.Add(format); context.Disposables.Add(layout); context.Disposables.Add(textBrush); var childStates = new List <IElementState>(); foreach (var child in element.Children) { var locations = layout.HitTestTextRange(child.Location.StartIndex, child.Location.EndIndex - child.Location.StartIndex, BoundingBox.X, BoundingBox.Y); if (locations.Length == 0) { continue; } var location = locations[0]; childStates.Add(child.Child.Update(null, context.WithBounds(new Bounds(x: (int)location.Left, y: (int)location.Top, width: (int)location.Width, height: (int)location.Height)))); } children = childStates; }
public override void Draw(RenderTarget rt) { base.Draw(rt); var b = new SolidColorBrush(rt, new Color4(0.2f, 0.2f, 0.2f, 1f)); var b2 = new SolidColorBrush(rt, new Color4(0f, 0f, 1f, 1f)); var b3 = new SolidColorBrush(rt, new Color4(0.3f, 0.3f, 0.3f, 1f)); var b4 = new SolidColorBrush(rt, new Color4(1f, 0.2f, 0.1f, 1f)); rt.DrawLine(ContentView.Scaled(Position), ContentView.Scaled(Pin.Position), b, ContentView.Scaled(0.1f)); rt.FillEllipse(new Ellipse(ContentView.Scaled(Position), ContentView.Scaled(0.5f), ContentView.Scaled(0.5f)), b3); rt.FillEllipse(new Ellipse(ContentView.Scaled(Position), ContentView.Scaled(0.1f), ContentView.Scaled(0.1f)), b2); var DWFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared); SharpDX.DirectWrite.TextFormat tf = new SharpDX.DirectWrite.TextFormat(DWFactory, "Arial", ContentView.Scaled(0.5f)); var tg = ContentView.Scaled(AreaBounds); tg.Left += ContentView.Scaled(Direction == Direction.Left ? 1.5f : 1f); tg.Top -= 1; rt.DrawText(Name, tf, tg, b4); tf.Dispose(); DWFactory.Dispose(); b.Dispose(); b2.Dispose(); b3.Dispose(); b4.Dispose(); }
private void HandleDrawString(RenderTarget target, String str, System.Drawing.Rectangle rect, int color, System.Drawing.Font font = null) { if (String.IsNullOrEmpty(str)) { return; } using (Brush brush = GetBrushFromColor(target, color)) { SharpDX.DirectWrite.FontWeight weight = WeightFromFontStyle(font.Style); SharpDX.DirectWrite.FontStyle style = StyleFromFontStyle(font.Style); SharpDX.DirectWrite.TextFormat stringFormat = new SharpDX.DirectWrite.TextFormat(this.FactoryDWrite, font.FontFamily.Name, weight, style, font.Size); stringFormat.TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading; stringFormat.WordWrapping = SharpDX.DirectWrite.WordWrapping.Wrap; if (font == null) { font = this.Font; } int maxsize = this.Width; if (pushedArgument.ContainsKey("TrimOutOfBounds") && ((bool)pushedArgument["TrimOutOfBounds"])) { using (SharpDX.DirectWrite.TextLayout layout = new SharpDX.DirectWrite.TextLayout(FactoryDWrite, str, stringFormat, maxsize, font.Height)) { var lines = layout.GetLineMetrics(); StringBuilder strb = new StringBuilder(); var hittests = layout.HitTestTextRange(0, str.Length, rect.X, rect.Y); int trimPos = -1; for (int i = 0; i < hittests.Length; ++i) { if (hittests[i].Top + hittests[i].Height > rect.Bottom) { trimPos = hittests[i].TextPosition; break; } } String trimmedStr = str; if (trimPos > -1) { trimmedStr = str.Substring(0, trimPos); } target.PushAxisAlignedClip(new RectangleF(rect.X, rect.Y, rect.Right, rect.Bottom), AntialiasMode.Aliased); target.DrawText(trimmedStr, stringFormat, new RawRectangleF(rect.X, rect.Y, rect.Right, rect.Bottom), brush, DrawTextOptions.EnableColorFont | DrawTextOptions.Clip); target.PopAxisAlignedClip(); } } else { target.PushAxisAlignedClip(new RectangleF(rect.X, rect.Y, rect.Right, rect.Bottom), AntialiasMode.Aliased); target.DrawText(str, stringFormat, new RawRectangleF(rect.X, rect.Y, rect.Right, rect.Bottom), brush, DrawTextOptions.EnableColorFont | DrawTextOptions.Clip); target.PopAxisAlignedClip(); } stringFormat.Dispose(); } }
void TextWriter_ChangeRenderTarget(RenderTarget newRenderTarget) { //throw new NotImplementedException(); renderTarget = device.renderTarget; brush = new SharpDX.Direct2D1.SolidColorBrush(renderTarget, xPFT.DrawingBase.Convertor.ColorConvertor(curentColor, opacity)); SharpDX.DirectWrite.Factory factory = new SharpDX.DirectWrite.Factory(); textFormat = new SharpDX.DirectWrite.TextFormat(factory, FontName, FontSize); }
public void DrawText() { //var sceneColorBrush = new SolidColorBrush(deviceManager.ContextDirect2D, Color.White); var textFormat = new SharpDX.DirectWrite.TextFormat(_deviceManager.FactoryDirectWrite, "Calibri", 20) { TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading, ParagraphAlignment = SharpDX.DirectWrite.ParagraphAlignment.Center }; }
public void DrawText(String message, String fontFamily, float fontSize, System.Drawing.Color clr, System.Drawing.Rectangle area) { SharpDX.DirectWrite.TextFormat fmt = new SharpDX.DirectWrite.TextFormat(dwFactory, fontFamily, fontSize); SharpDX.Mathematics.Interop.RawRectangleF rect = ToRectangle(area); SharpDX.Direct2D1.SolidColorBrush brush = new SharpDX.Direct2D1.SolidColorBrush(d2dRenderTarget, ToColor(clr)); d2dRenderTarget.DrawText(message, fmt, rect, brush); fmt.Dispose(); brush.Dispose(); }
protected override void OnFontChanged(EventArgs e) { base.OnFontChanged(e); if (m_TextFormat != null) { m_TextFormat.Dispose(); } m_TextFormat = new SharpDX.DirectWrite.TextFormat(FactoryDWrite, this.Font.FontFamily.Name, this.Font.Size); }
public void SetFont(Font f) { if (textFormat != null) { textFormat.Dispose(); } textFormat = new SharpDX.DirectWrite.TextFormat(dwFactory, "Segoe", f.Size); _fontSize = f.Size; }
public void LoadResources() { bsToolBarBox = D3DTextureLoader.LoadBitmap(new SharpDX.WIC.ImagingFactory2(), "Resources/GUI/ToolBarBox.jpg"); bsToolBarSelect = D3DTextureLoader.LoadBitmap(new SharpDX.WIC.ImagingFactory2(), "Resources/GUI/ToolBarSelect.png"); var textFactory = new SharpDX.DirectWrite.Factory(); textFormat = new SharpDX.DirectWrite.TextFormat(textFactory, "Consolas", 12.0f); textFactory.Dispose(); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { SharpDX.DirectWrite.Factory factory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Isolated); SharpDX.DirectWrite.TextFormat textFormat = new SharpDX.DirectWrite.TextFormat(factory, "Arial", 60); textLayout = new SharpDX.DirectWrite.TextLayout(factory, "Test", textFormat, 0, 0); MainWindow_SizeChanged(null, null); InteropImage.WindowOwner = (new System.Windows.Interop.WindowInteropHelper(this)).Handle; InteropImage.OnRender = OnRender; CompositionTarget.Rendering += CompositionTarget_Rendering; }
public SharpDX.DirectWrite.TextFormat Font2Raw(System.Drawing.Font Font) { SharpDX.DirectWrite.TextFormat ret; //new SharpDX.DirectWrite.TextFormat(FactoryDWrite, "Tahoma", 12) ret = new SharpDX.DirectWrite.TextFormat(DWrender, Font.FontFamily.Name, Font.Bold ? SharpDX.DirectWrite.FontWeight.Bold : SharpDX.DirectWrite.FontWeight.Normal, Font.Italic ? SharpDX.DirectWrite.FontStyle.Italic : SharpDX.DirectWrite.FontStyle.Normal, Font.Size); return(ret); }
public static void InitializeDirectX() { renderForm = new RenderForm(title); renderForm.Size = new System.Drawing.Size(800, 600); renderForm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; var swapChainDesc = new SwapChainDescription() { BufferCount = 4, Flags = SwapChainFlags.AllowModeSwitch, IsWindowed = true, ModeDescription = new ModeDescription(800, 600, new Rational(1, 60), Format.R8G8B8A8_UNorm), OutputHandle = renderForm.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; D3D.FeatureLevel[] featureLevels = { D3D.FeatureLevel.Level_9_3, D3D.FeatureLevel.Level_10_1 }; Device.CreateWithSwapChain(D3D.DriverType.Hardware, DeviceCreationFlags.BgraSupport, featureLevels, swapChainDesc, out device, out swapChain); Surface backBuffer = Surface.FromSwapChain(swapChain, 0); using (var factory2D = new Factory2D(FactoryType.MultiThreaded)) { var dpi = factory2D.DesktopDpi; InitializeRenderTarget(backBuffer, factory2D, dpi); renderForm.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; renderTarget.AntialiasMode = AntialiasMode.Aliased; renderTarget.TextAntialiasMode = TextAntialiasMode.Aliased; using (SharpDX.DirectWrite.Factory textFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared)) { textFormat = new Text(textFactory, "MS Sans Serif", SharpDX.DirectWrite.FontWeight.SemiBold, SharpDX.DirectWrite.FontStyle.Normal, SharpDX.DirectWrite.FontStretch.Medium, 16.0f ); } renderForm.KeyDown += (o, e) => { if (e.Alt && e.KeyCode == System.Windows.Forms.Keys.Enter) { swapChain.IsFullScreen = !swapChain.IsFullScreen; } }; } }
public static SharpDX.DirectWrite.TextLayout ToTextLayout(Font font, string text) { IntPtr hdc = Win32.NativeMethods.GetDC(IntPtr.Zero); int DpiX = Win32.NativeMethods.GetDeviceCaps(hdc, 88); Win32.NativeMethods.ReleaseDC(IntPtr.Zero, hdc); bool isPoint = font.Unit == GraphicsUnit.Point; float fontSize = isPoint ? font.Size * DpiX / 72 : font.Size; using (SharpDX.DirectWrite.TextFormat tf = new SharpDX.DirectWrite.TextFormat(directWriteFactory, font.FontFamily.Name, font.Bold ? SharpDX.DirectWrite.FontWeight.Bold : SharpDX.DirectWrite.FontWeight.Regular, font.Italic ? SharpDX.DirectWrite.FontStyle.Italic : SharpDX.DirectWrite.FontStyle.Normal, fontSize)) return(new SharpDX.DirectWrite.TextLayout(directWriteFactory, text, tf, float.MaxValue, 0)); }
public TextWriter(IDrawing.IDevice device, System.Drawing.Font font)// float FontSize = 10, String FontName = "Arial") { this.device = ((Device)device); this.FontName = font.Name; this.FontSize = font.Size; renderTarget =this.device.renderTarget; SharpDX.DirectWrite.Factory factory = new SharpDX.DirectWrite.Factory(); SharpDX.DirectWrite.FontWeight fontW = SharpDX.DirectWrite.FontWeight.Normal; if(font.Style==System.Drawing.FontStyle.Bold) fontW = SharpDX.DirectWrite.FontWeight.Heavy; textFormat = new SharpDX.DirectWrite.TextFormat(factory, FontName,fontW, SharpDX.DirectWrite.FontStyle.Normal, FontSize); // this.device.ChangeRenderTarget += TextWriter_ChangeRenderTarget; }
/// <summary> /// Draws text. /// </summary> /// <param name="foreground">The foreground brush.</param> /// <param name="rect">The output rectangle.</param> /// <param name="text">The text.</param> public void DrawText(Perspex.Media.Brush foreground, Rect rect, FormattedText text) { if (!string.IsNullOrEmpty(text.Text)) { using (SharpDX.Direct2D1.SolidColorBrush brush = this.Convert(foreground)) using (SharpDX.DirectWrite.TextFormat format = TextService.GetTextFormat(this.directWriteFactory, text)) { this.renderTarget.DrawText( text.Text, format, this.Convert(rect), brush); } } }
private void RenderText(float textX, float textY, string text, Brush brush) { if (ChartControl == null) { return; } using (SharpDX.DirectWrite.TextFormat textFormat = ChartControl.Properties.LabelFont.ToDirectWriteTextFormat()) { using (SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, text, textFormat, ChartPanel.W, 8f)) { SharpDX.Vector2 origin = new SharpDX.Vector2(textX, textY - (float)(textLayout.Metrics.Height * 2.5)); // bump above copyright RenderTarget.DrawTextLayout(origin, textLayout, brush.ToDxBrush(RenderTarget)); } } }
private void InitializeDirectXResources() { var clientSize = ClientSize; var backBufferDesc = new SharpDX.DXGI.ModeDescription(clientSize.Width, clientSize.Height, new SharpDX.DXGI.Rational(60, 1), SharpDX.DXGI.Format.R8G8B8A8_UNorm); var swapChainDesc = new SharpDX.DXGI.SwapChainDescription() { ModeDescription = backBufferDesc, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), Usage = SharpDX.DXGI.Usage.RenderTargetOutput, BufferCount = 1, OutputHandle = Handle, SwapEffect = SharpDX.DXGI.SwapEffect.Discard, IsWindowed = false }; SharpDX.Direct3D11.Device.CreateWithSwapChain(SharpDX.Direct3D.DriverType.Hardware, SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport, new[] { SharpDX.Direct3D.FeatureLevel.Level_10_0 }, swapChainDesc, out _d3DDevice, out var swapChain); _d3DDeviceContext = _d3DDevice.ImmediateContext; _swapChain = new SharpDX.DXGI.SwapChain1(swapChain.NativePointer); _d2DFactory = new SharpDX.Direct2D1.Factory(); using (var backBuffer = _swapChain.GetBackBuffer <SharpDX.Direct3D11.Texture2D>(0)) { _renderTargetView = new SharpDX.Direct3D11.RenderTargetView(_d3DDevice, backBuffer); _renderTarget = new SharpDX.Direct2D1.RenderTarget(_d2DFactory, backBuffer.QueryInterface <SharpDX.DXGI.Surface>(), new SharpDX.Direct2D1.RenderTargetProperties(new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.Unknown, SharpDX.Direct2D1.AlphaMode.Premultiplied))) { TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Cleartype }; } _solidColorBrush = new SharpDX.Direct2D1.SolidColorBrush(_renderTarget, Color.White); _dwFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared); _textFormat = new SharpDX.DirectWrite.TextFormat(_dwFactory, "Arial", SharpDX.DirectWrite.FontWeight.Bold, SharpDX.DirectWrite.FontStyle.Normal, SharpDX.DirectWrite.FontStretch.Normal, 84 * (float)GraphicsUtils.Scale) { TextAlignment = SharpDX.DirectWrite.TextAlignment.Center, ParagraphAlignment = SharpDX.DirectWrite.ParagraphAlignment.Center }; // var rectangleGeometry = new D2D1.RoundedRectangleGeometry(_d2DFactory, // new D2D1.RoundedRectangle() { RadiusX = 32, RadiusY = 32, Rect = new RectangleF(128, 128, Width - 128 * 2, Height - 128 * 2) }); }
} // Draw() /// <summary> /// desenha um texto. Há que ter os métodos Begin() e End() para efetivar a renderização. /// </summary> public void Draw(string texto, RectangleF rectDEstiny, Color cor, Font fonte) { // a coisa mais certa é setar a matriz transform do RenderTarget, e depois setar a transform para Identity. SetMatrixTranslation(new vetor2(rectDEstiny.Left, rectDEstiny.Top)); rectDEstiny.Left = 0; rectDEstiny.Top = 0; SharpDX.DirectWrite.TextFormat format = new SharpDX.DirectWrite.TextFormat(MyDevice2D.FactoryDirectWrite, "Arial", fonte.Size); // "formato" do texto a ser desenhado. SolidColorBrush brush = new SolidColorBrush(MyDevice2D.render[this.idRender], new RawColor(cor.R, cor.G, cor.B, cor.A)); // "brush" para o desenho. MyDevice2D.render[this.idRender].DrawText(texto, format, rectDEstiny, brush); // desenha o texto SetMatrixIdentity();// restaura a matriz identidade , para a matriz transform do RenderTarget. } // DrawText()
protected override void OnRender(ChartControl chartControl, ChartScale chartScale) { /// get the starting and ending bars from what is rendered on the chart float startX = chartControl.GetXByBarIndex(ChartBars, ChartBars.FromIndex); float endX = chartControl.GetXByBarIndex(ChartBars, ChartBars.ToIndex); /// Loop through each Plot Values on the chart for (int seriesCount = 0; seriesCount < Values.Length; seriesCount++) { /// get the value at the last bar on the chart (if it has been set) if (Values[seriesCount].IsValidDataPointAt(ChartBars.ToIndex)) { double plotValue = Values[seriesCount].GetValueAt(ChartBars.ToIndex); /// convert the plot value to the charts "Y" axis point float chartScaleYValue = chartScale.GetYByValue(plotValue); /// calculate the x and y values for the line to start and end SharpDX.Vector2 startPoint = new SharpDX.Vector2(startX, chartScaleYValue); SharpDX.Vector2 endPoint = new SharpDX.Vector2(endX, chartScaleYValue); /// draw a line between the start and end point at each plot using the plots SharpDX Brush color and style RenderTarget.DrawLine(startPoint, endPoint, Plots[seriesCount].BrushDX, Plots[seriesCount].Width, Plots[seriesCount].StrokeStyle); /// use the chart control text form to draw plot values along the line SharpDX.DirectWrite.TextFormat textFormat = chartControl.Properties.LabelFont.ToDirectWriteTextFormat(); /// calculate the which will be rendered at each plot using it the plot name and its price string textToRender = Plots[seriesCount].Name + ": " + plotValue; /// calculate the layout of the text to be drawn SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.DirectWriteFactory, textToRender, textFormat, 200, textFormat.FontSize); /// draw a line at each plot using the plots SharpDX Brush color at the calculated start point RenderTarget.DrawTextLayout(startPoint, textLayout, Plots[seriesCount].BrushDX); // /// dipose of the unmanaged resources used textLayout.Dispose(); textFormat.Dispose(); } } }
private void DrawString(string text, SimpleFont font, string brushName, double pointX, double pointY, string areaBrushName) { SharpDX.DirectWrite.TextFormat textFormat = font.ToDirectWriteTextFormat(); SharpDX.Vector2 TextPlotPoint = new System.Windows.Point(pointX, pointY).ToVector2(); SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory, text, textFormat, ChartPanel.X + ChartPanel.W, textFormat.FontSize); float newW = textLayout.Metrics.Width; float newH = textLayout.Metrics.Height; SharpDX.RectangleF PLBoundRect = new SharpDX.RectangleF((float)pointX + 2, (float)pointY, newW + 5, newH + 2); RenderTarget.FillRectangle(PLBoundRect, dxmBrushes[areaBrushName].DxBrush); RenderTarget.DrawTextLayout(TextPlotPoint, textLayout, dxmBrushes[brushName].DxBrush, SharpDX.Direct2D1.DrawTextOptions.NoSnap); textLayout.Dispose(); textFormat.Dispose(); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); try { if (textLayout != null) { textLayout.Dispose(); } textFormat = null; // this triggers native brush disposes textDeviceBrush.RenderTarget = null; textBackgroundDeviceBrush.RenderTarget = null; } catch { } finally { LineColor = null; } }
private void DrawLegend(float PointX, float PointY) { float unitX = 0; float unitY = 0; var unitbrush = new SharpDX.Direct2D1.SolidColorBrush(cp._renderTarget, new RawColor4(0, 0, 0, 1)); var textformat = new SharpDX.DirectWrite.TextFormat(cp.dwFactory, "Arial", 12); unitX = PointX; unitY = PointY; if (axislineparam.lineLocation == LineLocation.Left) { unitX = PointX - 30; unitY = PointY + 2; } if (axislineparam.Direction == LineDirection.Horizontal) { unitX = PointX - 20; unitY = PointY + 2; } cp._renderTarget.DrawText(axislineparam.Caption, textformat, new RawRectangleF(unitX, unitY, unitX + 200, unitY + 200), unitbrush); }
public System.Drawing.SizeF MeasureString(String s, System.Drawing.Font font = null, int maxsize = -1) { if (font == null) { font = this.Font; } using (SharpDX.DirectWrite.TextFormat format = new SharpDX.DirectWrite.TextFormat(FactoryDWrite, font.FontFamily.Name, WeightFromFontStyle(font.Style), StyleFromFontStyle(font.Style), font.Size)) { if (maxsize == -1) { maxsize = this.Width; } format.WordWrapping = SharpDX.DirectWrite.WordWrapping.Wrap; using (SharpDX.DirectWrite.TextLayout layout = new SharpDX.DirectWrite.TextLayout(FactoryDWrite, s, format, maxsize, font.Height)) { return(new System.Drawing.SizeF(layout.Metrics.Width, layout.Metrics.Height)); } } }
public override void Load( CanvasRenderArguments args ) { // dispose the old brush if (lineBrush != null && !lineBrush.IsDisposed) lineBrush.Dispose(); if (DW_textFormat != null && !DW_textFormat.IsDisposed) DW_textFormat.Dispose(); // init the lines brushs lineBrush = new SolidColorBrush( args.renderTarget, _AxesColor.ToColor4() ); _TextFormat.fontCollection = args.WriteFactory.GetSystemFontCollection(false); // init the text format DW_textFormat = new SharpDX.DirectWrite.TextFormat(args.WriteFactory, _TextFormat.familyName, _TextFormat.fontCollection, _TextFormat.weight, _TextFormat.fontStyle, _TextFormat.fontStretch, _TextFormat.fontSize, "en-us"); // get the size of the string SharpDX.DirectWrite.TextLayout textL = new SharpDX.DirectWrite.TextLayout(args.WriteFactory, "(0,0)", DW_textFormat, 1500, 1500); // init text rectangle textRectangle = new RectangleF(0, 0, textL.GetFontSize(0) * 10, textL.GetFontSize(0)); textL.Dispose(); // refresh the geometrys RefreshGeometry( args.renderTarget ); }
public override void Load( CanvasRenderArguments args ) { if ( lineBrush != null && !lineBrush.IsDisposed ) lineBrush.Dispose(); if (DW_textFormat != null && !DW_textFormat.IsDisposed) DW_textFormat.Dispose(); // init the lines brushs lineBrush = new SolidColorBrush( args.renderTarget, _FontColor ); _TextFormat.fontCollection = args.WriteFactory.GetSystemFontCollection(false); // init the text format DW_textFormat = new SharpDX.DirectWrite.TextFormat( args.WriteFactory, _TextFormat.familyName, _TextFormat.fontCollection, _TextFormat.weight, _TextFormat.fontStyle, _TextFormat.fontStretch, _TextFormat.fontSize, "en-us" ); // get the size of the string SharpDX.DirectWrite.TextLayout textL= new SharpDX.DirectWrite.TextLayout( args.WriteFactory, Internal_String, DW_textFormat, 1500, 1500 ); Size = new Vector.FxVector2f(textL.GetFontSize(0) * Internal_String.Length, textL.GetFontSize(0)); textL.Dispose(); // init text rectangle textRectangle = new RectangleF( 0, 0, Size.x, Size.y ); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); RenderForm form = new RenderForm("Kinect simple pilot sample"); RenderDevice device = new RenderDevice(SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport); RenderContext context = new RenderContext(device); DX11SwapChain swapChain = DX11SwapChain.FromHandle(device, form.Handle); //Allow to draw using direct2d on top of swapchain var context2d = new SharpDX.Direct2D1.DeviceContext(swapChain.Texture.QueryInterface<SharpDX.DXGI.Surface>()); //Call release on texture since queryinterface does an addref Marshal.Release(swapChain.Texture.NativePointer); var textFormat = new SharpDX.DirectWrite.TextFormat(device.DWriteFactory, "Arial", 16.0f); var blackBrush = new SharpDX.Direct2D1.SolidColorBrush(context2d, SharpDX.Color.Black); var whiteBrush = new SharpDX.Direct2D1.SolidColorBrush(context2d, SharpDX.Color.White); KinectSensor sensor = KinectSensor.GetDefault(); sensor.Open(); bool doQuit = false; KinectSensorColorRGBAFrameProvider provider = new KinectSensorColorRGBAFrameProvider(sensor); DynamicColorRGBATextureProcessor colorProcessor = new DynamicColorRGBATextureProcessor(provider, device); KinectPilotProcessor pilot = KinectPilotProcessor.Default; KinectSensorBodyFrameProvider bodyFrameProvider = new KinectSensorBodyFrameProvider(sensor); bodyFrameProvider.FrameReceived += (sender, args) => { var body = args.FrameData.TrackedOnly().ClosestBodies().FirstOrDefault(); if (body != null) { pilot.Process(body.GetJointTable()); } }; form.KeyDown += (sender, args) => { if (args.KeyCode == Keys.Escape) { doQuit = true; } }; RenderLoop.Run(form, () => { if (doQuit) { form.Dispose(); return; } colorProcessor.Update(context); context.RenderTargetStack.Push(swapChain); device.Primitives.ApplyFullTri(context, colorProcessor.Texture.ShaderView); device.Primitives.FullScreenTriangle.Draw(context); context.RenderTargetStack.Pop(); context2d.BeginDraw(); var rect = new SharpDX.RectangleF(0, 0, 200, 130); context2d.FillRectangle(rect, blackBrush); context2d.DrawText("Elevation: " + pilot.Elevation, textFormat, rect, whiteBrush); rect.Top += 30; context2d.DrawText("Steering Y: " + pilot.SteeringY, textFormat, rect, whiteBrush); rect.Top += 30; context2d.DrawText("Steering Z: " + pilot.SterringZ, textFormat, rect, whiteBrush); rect.Top += 30; context2d.DrawText("Push: " + pilot.Push, textFormat, rect, whiteBrush); context2d.EndDraw(); swapChain.Present(0, SharpDX.DXGI.PresentFlags.None); }); swapChain.Dispose(); context.Dispose(); device.Dispose(); colorProcessor.Dispose(); provider.Dispose(); sensor.Close(); }
private void Form1_Load(object sender, EventArgs e) { //Init Direct Draw //Set Rendering properties RenderTargetProperties renderProp = new RenderTargetProperties() { DpiX = 0, DpiY = 0, MinLevel = FeatureLevel.Level_10, PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied), Type = RenderTargetType.Hardware, Usage = RenderTargetUsage.None }; //set hwnd target properties (permit to attach Direct2D to window) HwndRenderTargetProperties winProp = new HwndRenderTargetProperties() { Hwnd = this.Handle, PixelSize = new DrawingSize(this.ClientSize.Width, this.ClientSize.Height), PresentOptions = PresentOptions.Immediately }; //target creation target = new WindowRenderTarget(factory, renderProp, winProp); //create red and white brushes redBrush = new SharpDX.Direct2D1.SolidColorBrush(target, SharpDX.Color.Red); whiteBrush = new SharpDX.Direct2D1.SolidColorBrush(target, SharpDX.Color.White); //create a linear gradient brush var grad = new LinearGradientBrushProperties() { StartPoint = new DrawingPointF(ClientSize.Width / 2, ClientSize.Height / 2), EndPoint = new DrawingPointF(ClientSize.Width, ClientSize.Height) }; var stopCollection = new GradientStopCollection(target, new GradientStop[] { new GradientStop(){Color=SharpDX.Color.Azure ,Position=0F}, new GradientStop(){Color=SharpDX.Color.Yellow,Position=0.2F}, new GradientStop(){Color=SharpDX.Color.Green,Position=0.4F}, new GradientStop(){Color=SharpDX.Color.Red,Position=1F}, }, ExtendMode.Mirror); gradient = new SharpDX.Direct2D1.LinearGradientBrush(target, grad, stopCollection); //create textformat textFormat = new SharpDX.DirectWrite.TextFormat(factoryWrite, "Arial", 36); //avoid artifacts this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); }
private void LoadPipeline(RenderForm form) { int width = form.ClientSize.Width; int height = form.ClientSize.Height; viewport.Width = width; viewport.Height = height; viewport.MaxDepth = 1.0f; scissorRect.Right = width; scissorRect.Bottom = height; #if DEBUG // Enable the D3D12 debug layer. { DebugInterface.Get().EnableDebugLayer(); } #endif device = new Device(null, SharpDX.Direct3D.FeatureLevel.Level_12_0); using (var factory = new Factory4()) { // Describe and create the command queue. CommandQueueDescription queueDesc = new CommandQueueDescription(CommandListType.Direct); commandQueue = device.CreateCommandQueue(queueDesc); // Describe and create the swap chain. SwapChainDescription swapChainDesc = new SwapChainDescription() { BufferCount = FrameCount, ModeDescription = new ModeDescription(width, height, new Rational(60, 1), Format.R8G8B8A8_UNorm), Usage = Usage.RenderTargetOutput, SwapEffect = SwapEffect.FlipDiscard, OutputHandle = form.Handle, //Flags = SwapChainFlags.None, SampleDescription = new SampleDescription(1, 0), IsWindowed = true }; SwapChain tempSwapChain = new SwapChain(factory, commandQueue, swapChainDesc); swapChain = tempSwapChain.QueryInterface<SwapChain3>(); tempSwapChain.Dispose(); frameIndex = swapChain.CurrentBackBufferIndex; } // Create descriptor heaps. // Describe and create a render target view (RTV) descriptor heap. DescriptorHeapDescription rtvHeapDesc = new DescriptorHeapDescription() { DescriptorCount = FrameCount, Flags = DescriptorHeapFlags.None, Type = DescriptorHeapType.RenderTargetView }; renderTargetViewHeap = device.CreateDescriptorHeap(rtvHeapDesc); rtvDescriptorSize = device.GetDescriptorHandleIncrementSize(DescriptorHeapType.RenderTargetView); //Init Direct3D11 device from Direct3D12 device device11 = SharpDX.Direct3D11.Device.CreateFromDirect3D12(device, SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport, null, null, commandQueue); deviceContext11 = device11.ImmediateContext; device11on12 = device11.QueryInterface<SharpDX.Direct3D11.ID3D11On12Device>(); var d2dFactory = new SharpDX.Direct2D1.Factory(SharpDX.Direct2D1.FactoryType.MultiThreaded); // Create frame resources. CpuDescriptorHandle rtvHandle = renderTargetViewHeap.CPUDescriptorHandleForHeapStart; for (int n = 0; n < FrameCount; n++) { renderTargets[n] = swapChain.GetBackBuffer<Resource>(n); device.CreateRenderTargetView(renderTargets[n], null, rtvHandle); rtvHandle += rtvDescriptorSize; //init Direct2D surfaces SharpDX.Direct3D11.D3D11ResourceFlags format = new SharpDX.Direct3D11.D3D11ResourceFlags() { BindFlags = (int)SharpDX.Direct3D11.BindFlags.RenderTarget, CPUAccessFlags = (int)SharpDX.Direct3D11.CpuAccessFlags.None }; device11on12.CreateWrappedResource( renderTargets[n], format, (int)ResourceStates.Present, (int)ResourceStates.RenderTarget, typeof(SharpDX.Direct3D11.Resource).GUID, out wrappedBackBuffers[n]); //Init direct2D surface var d2dSurface = wrappedBackBuffers[n].QueryInterface<Surface>(); direct2DRenderTarget[n] = new SharpDX.Direct2D1.RenderTarget(d2dFactory, d2dSurface, new SharpDX.Direct2D1.RenderTargetProperties(new SharpDX.Direct2D1.PixelFormat(Format.Unknown, SharpDX.Direct2D1.AlphaMode.Premultiplied))); d2dSurface.Dispose(); } commandAllocator = device.CreateCommandAllocator(CommandListType.Direct); d2dFactory.Dispose(); //Init font var directWriteFactory = new SharpDX.DirectWrite.Factory(); textFormat = new SharpDX.DirectWrite.TextFormat(directWriteFactory, "Arial", SharpDX.DirectWrite.FontWeight.Bold, SharpDX.DirectWrite.FontStyle.Normal, 48) { TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading, ParagraphAlignment = SharpDX.DirectWrite.ParagraphAlignment.Near }; textBrush = new SharpDX.Direct2D1.SolidColorBrush(direct2DRenderTarget[0], Color.White); directWriteFactory.Dispose(); }
public void Initialize(CommonDX.DeviceManager deviceManager) { _deviceManager = deviceManager; _d2dContext = deviceManager.ContextDirect2D; _generalGrayColor = new SharpDX.Direct2D1.SolidColorBrush(_deviceManager.ContextDirect2D, Color.Gray); _generalRedColor = new SharpDX.Direct2D1.SolidColorBrush(_deviceManager.ContextDirect2D, Color.Red); _generalLightGrayColor = new SharpDX.Direct2D1.SolidColorBrush(_deviceManager.ContextDirect2D, Color.LightGray); _generalLightWhiteColor = new SharpDX.Direct2D1.SolidColorBrush(_deviceManager.ContextDirect2D, Color.White); _generalTextFormat = new SharpDX.DirectWrite.TextFormat( _deviceManager.FactoryDirectWrite, "Segoe UI", SharpDX.DirectWrite.FontWeight.Light, SharpDX.DirectWrite.FontStyle.Normal, SharpDX.DirectWrite.FontStretch.Normal, 16f); _debugTextFormat = new SharpDX.DirectWrite.TextFormat( _deviceManager.FactoryDirectWrite, "Segoe UI", SharpDX.DirectWrite.FontWeight.Light, SharpDX.DirectWrite.FontStyle.Normal, SharpDX.DirectWrite.FontStretch.Normal, 20f); _layoutDetail = new LayoutDetail() { Width = this.State.DrawingSurfaceWidth, Height = this.State.DrawingSurfaceHeight }; _layoutDeviceScreenSize = new RectangleF(0, 0, (float)_layoutDetail.Width, (float)_layoutDetail.Height); _appWidth = (float)_layoutDetail.Width + 5; _appHeight = (float)_layoutDetail.Height; _updateScaleTranslate(1.0f); ////_drawTiles(0); if (State.DefaultBackgroundUri != string.Empty) { _clearRenderTree(); _changeBackgroundImpl(1, _appWidth, _appHeight, 0, 0, State.DefaultBackgroundFolder, State.DefaultBackgroundUri, "", Color.White, 0.7f, "", false); } //GestureService.OnGestureRaised += (o,a) => { // CustomGestureArgs gestureArgs = (CustomGestureArgs)a; // //NumberFramesToRender += 3; // if (gestureArgs.ManipulationStartedArgs != null) // { // _isInertialTranslationStaging = false; // _globalCameraTranslationStaging = _globalCameraTranslation; // } // else if (gestureArgs.ManipulationInertiaStartingArgs != null) // { // _isInertialTranslationStaging = true; // _globalCameraTranslationStaging = _globalCameraTranslation; // } // else if (gestureArgs.ManipulationUpdatedArgs != null) // { // if(_isInertialTranslationStaging) // _updateCameraTranslationStaging((float)gestureArgs.ManipulationUpdatedArgs.Velocities.Linear.X); // else // _updateCameraTranslationStaging((float)gestureArgs.ManipulationUpdatedArgs.Cumulative.Translation.X); // } // else if (gestureArgs.ManipulationCompletedArgs != null) // { // if (gestureArgs.ManipulationCompletedArgs.Cumulative.Scale < 1) // { // if (_globalScale.X != 0.9f) { _updateBackgroundTweener(1.0f, 0.9f, 1.2f); SendInformationNotification("zoom level at 90%", 3); } // //_updateScaleTranslate(0.9f); // } // else if (gestureArgs.ManipulationCompletedArgs.Cumulative.Scale > 1) // { // if (_globalScale.X != 1.0f) { _updateBackgroundTweener(0.9f, 1.0f, 1.2f); SendInformationNotification("zoom level at 100%", 3); } // //_updateScaleTranslate(1.0f); // } // _globalCameraTranslation = _globalCameraTranslation + _globalCameraTranslationStaging; // _globalCameraTranslationStaging = Vector3.Zero; // _isInertialTranslationStaging = false; // } // else if (gestureArgs.TappedEventArgs != null) // { // var x = gestureArgs.TappedEventArgs.Position.X - _globalCameraTranslation.X; // var y = gestureArgs.TappedEventArgs.Position.Y - _globalCameraTranslation.Y; // var found = _doTilesHitTest((float)x, (float)y); // if (found != null && found.Count > 0) // { // _selectedRect = found[0]; // } // else _selectedRect = null; // } //}; WindowLayoutService.OnWindowLayoutRaised += WindowLayoutService_OnWindowLayoutRaised; }