public TCM_DrawingObject(TCM_Graphics g, Color fillColor, Color outlineColor, float lineWidth) : base(g)
 {
     this.fillColor    = fillColor;
     this.outlineColor = outlineColor;
     this.lineWidth    = lineWidth;
     shape             = graphics.createGeometry(Shape.rectangle, 0, 0, 1, 1);
 }
Ejemplo n.º 2
0
        public static Color ToSeal(this D2D.RawColor4 color)
        {
            byte alpha = (byte)(color.A * 255);
            byte red   = (byte)(color.R * 255);
            byte green = (byte)(color.G * 255);
            byte blue  = (byte)(color.B * 255);

            return(Color.FromArgb(alpha, red, green, blue));
        }
 public void DrawLine(SharpDX.Mathematics.Interop.RawColor4 color, Point from, Point to, float strokeWidth = 5f)
 {
     if (device == null)
     {
         throw new SharpDXException("The device was not initialized yet");
     }
     using (SolidColorBrush brush = new SolidColorBrush(device, color))
     {
         device.DrawLine(new SharpDX.Mathematics.Interop.RawVector2(from.x, from.y), new SharpDX.Mathematics.Interop.RawVector2(to.x, to.y), brush, strokeWidth);
     }
 }
Ejemplo n.º 4
0
    void Draw()
    {
        m_d3d11DeviceContext.OutputMerger.SetRenderTargets(m_renderTargetView);
        SharpDX.Mathematics.Interop.RawColor4 color = new SharpDX.Mathematics.Interop.RawColor4(32 / (float)255, 103 / (float)255, 178 / (float)255, 1);
        m_d3d11DeviceContext.ClearRenderTargetView(m_renderTargetView, color);

        m_d3d11DeviceContext.InputAssembler.SetVertexBuffers(0, new D3D11.VertexBufferBinding(m_triangleVertexBuffer, SharpDX.Utilities.SizeOf <VertexPositionColor>(), 0));
        m_d3d11DeviceContext.Draw(m_vertices.Count(), 0);

        m_swapChain.Present(1, DXGI.PresentFlags.None);
    }
Ejemplo n.º 5
0
 public Board(int x, int y)
 {
     X            = x;
     Y            = y;
     VisibleBoard = new int[x, y];
     //Color = new Mathe.RawColor4[x, y];
     Color       = new Mathe.RawColor4[x, y];
     ImageNormal = new D2D.Bitmap[x, y];
     ImageActive = new D2D.Bitmap[x, y];
     IsActive    = new bool[x, y];
     VisibleBoard.Initialize();
     Color.Initialize();
 }
Ejemplo n.º 6
0
        public static void Initialize(string name, int width, int height, Color bgColor)
        {
            form            = new RenderForm(name);
            form.ClientSize = new System.Drawing.Size(width, height);
            screenFrame     = new Frame();
            screenFrame.setTransform(1, 0, 0, 1, 0, 0);
            screenFrame.addHitbox(new Hitbox(0, 0, width, height));
            TCM_Graphics.bgColor = bgColor;

            //overall begin drawing
            transformStack = new Stack <RawMatrix3x2>();
            var swapDescription = new SwapChainDescription()
            {
                BufferCount     = 1,
                ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height,
                                                      new Rational(60, 1), Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = form.Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput
            };

            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport,
                                       new SharpDX.Direct3D.FeatureLevel[] { SharpDX.Direct3D.FeatureLevel.Level_10_0 },
                                       swapDescription, out dev, out sc);

            d2dFactory = new SharpDX.Direct2D1.Factory();

            fact = sc.GetParent <Factory>();
            fact.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);

            backBuffer = Texture2D.FromSwapChain <Texture2D>(sc, 0);
            rtv        = new RenderTargetView(dev, backBuffer);
            Surface surf = backBuffer.QueryInterface <Surface>();


            rt = new RenderTarget(d2dFactory, surf,
                                  new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)));

            brush = new SolidColorBrush(rt, bgColor);
        }
Ejemplo n.º 7
0
        private void LoadTarget(object sender, EventArgs e)
        {
            // Initial settings
            var pixelFormat = new D2D.PixelFormat(DXGI.Format.B8G8R8A8_UNorm, D2D.AlphaMode.Premultiplied);
            var winProp     = new D2D.HwndRenderTargetProperties
            {
                Hwnd           = Handle,
                PixelSize      = new DX.Size2(ClientSize.Width, ClientSize.Height),
                PresentOptions = Program.MainSettings.LimitFps ? D2D.PresentOptions.None : D2D.PresentOptions.Immediately
            };
            var renderProp = new D2D.RenderTargetProperties(D2D.RenderTargetType.Default, pixelFormat, 96, 96,
                                                            D2D.RenderTargetUsage.None, D2D.FeatureLevel.Level_DEFAULT);

            RenderTarget = new D2D.WindowRenderTarget(Factory, renderProp, winProp)
            {
                AntialiasMode     = D2D.AntialiasMode.PerPrimitive,
                TextAntialiasMode = D2D.TextAntialiasMode.Grayscale,
                Transform         = new Mathe.RawMatrix3x2 {
                    M11 = 1f, M12 = 0f, M21 = 0f, M22 = 1f, M31 = 0, M32 = 0
                }
            };

            // Create colors
            _colorBack = new Mathe.RawColor4(0, 0, 0, 1);

            LayerList = new Dictionary <string, ILayer>();
            LayerList.Add("back", new Background());
            if (Program.MainSettings.UseParticle)
            {
                LayerList.Add("particle", new Particle(500));
            }
            LayerList.Add("chess", new Chessboard());

            // Create brushes
            _whiteBrush = new D2D.SolidColorBrush(RenderTarget, new Mathe.RawColor4(1, 1, 1, 1));

            // Create text formats
            _textFormat = new DW.TextFormat(FactoryWrite, "Microsoft YaHei", 12);

            // Avoid artifacts
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
        }
Ejemplo n.º 8
0
		private void InitializeGraphics()
		{
			factory = new Factory(FactoryType.SingleThreaded, DebugLevel.None);

			renderTargetProperties = new RenderTargetProperties(new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied));

			hwndRenderTargetProperties = new HwndRenderTargetProperties();
			hwndRenderTargetProperties.Hwnd = this.Handle;
			hwndRenderTargetProperties.PixelSize = new SharpDX.Size2(Width, Height);
			hwndRenderTargetProperties.PresentOptions = PresentOptions.None;

			windowRenderTarget = new WindowRenderTarget(factory, renderTargetProperties, hwndRenderTargetProperties);

			backgroundColor = new RawColor4(BackColor.R, BackColor.G, BackColor.B, BackColor.A);

			borderColor = new SolidColorBrush(windowRenderTarget, new RawColor4(0.5f, 0.5f, 0.5f, 1));
			wayColor = new SolidColorBrush(windowRenderTarget, new RawColor4(0, 0, 1, 0.3f));
			currentPositionColor = new SolidColorBrush(windowRenderTarget, new RawColor4(0, 0, 1, 1));

			graphicsInitialized = true;
		}
Ejemplo n.º 9
0
        private void LoadTarget(object sender, EventArgs e)
        {
            var pixelFormat = new D2D.PixelFormat(DXGI.Format.B8G8R8A8_UNorm, D2D.AlphaMode.Premultiplied);

            var winProp = new D2D.HwndRenderTargetProperties
            {
                Hwnd           = this.Handle,
                PixelSize      = new DX.Size2(this.ClientSize.Width, this.ClientSize.Height),
                PresentOptions = D2D.PresentOptions.Immediately
            };

            var renderProp = new D2D.RenderTargetProperties(D2D.RenderTargetType.Default, pixelFormat,
                                                            96, 96, D2D.RenderTargetUsage.None, D2D.FeatureLevel.Level_DEFAULT);

            RenderTarget = new D2D.WindowRenderTarget(Factory, renderProp, winProp)
            {
                AntialiasMode     = D2D.AntialiasMode.PerPrimitive,
                TextAntialiasMode = D2D.TextAntialiasMode.Grayscale,
                Transform         = new Mathe.RawMatrix3x2
                {
                    M11 = 1,
                    M12 = 0,
                    M21 = 0,
                    M22 = 1,
                    M31 = 0,
                    M32 = 0
                }
            };

            // Create colors
            colorBack = new Mathe.RawColor4(0, 0, 0, 1);

            // Initialize layers
            layerClock    = new Layer.Clock(this.ClientSize);
            layerParticle = new Layer.Particles(500, 200);
            layerBack     = new Layer.Background();

            // Avoid artifacts
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
        }
Ejemplo n.º 10
0
 /// <summary>	
 /// Creates a new <see cref="SharpDX.Direct2D1.SolidColorBrush"/> that has the specified color and opacity. 	
 /// </summary>	
 /// <param name="renderTarget">an instance of <see cref = "SharpDX.Direct2D1.RenderTarget" /></param>
 /// <param name="color">The red, green, blue, and alpha values of the brush's color.</param>
 /// <param name="brushProperties">The base opacity of the brush.</param>
 public SolidColorBrush(RenderTarget renderTarget, RawColor4 color, SharpDX.Direct2D1.BrushProperties? brushProperties)
     : base(IntPtr.Zero)
 {
     renderTarget.CreateSolidColorBrush(color, brushProperties, this);
 }
Ejemplo n.º 11
0
        public Chessboard()
        {
            _centerPointF = new PointF(RenderForm.Width / 2f, RenderForm.Height / 2f);

            // Create colors
            var cRed     = new Mathe.RawColor4(237 / 255f, 28 / 255f, 36 / 255f, 1);
            var cGreen   = new Mathe.RawColor4(34 / 255f, 177 / 255f, 76 / 255f, 1);
            var cYellow  = new Mathe.RawColor4(255 / 255f, 243 / 255f, 0 / 255f, 1);
            var cPirple  = new Mathe.RawColor4(163 / 255f, 72 / 255f, 165 / 255f, 1);
            var cBlue    = new Mathe.RawColor4(0 / 255f, 163 / 255f, 233 / 255f, 1);
            var cGrey    = new Mathe.RawColor4(195 / 255f, 195 / 255f, 195 / 255f, 1);
            var cWhite   = new Mathe.RawColor4(1, 1, 1, 1);
            var cYellow2 = new Mathe.RawColor4(226 / 255f, 234 / 255f, 152 / 255f, 0.8f);

            // Create brushes
            _yellowBrush = new D2D.SolidColorBrush(RenderForm.RenderTarget, cYellow2);
            _blueBrush   = new D2D.SolidColorBrush(RenderForm.RenderTarget, cBlue);
            _redBrush    = new D2D.SolidColorBrush(RenderForm.RenderTarget, cRed);
            _maskBrush   = new D2D.SolidColorBrush(RenderForm.RenderTarget, new Mathe.RawColor4(0, 0, 0, 0.5f));

            LoadSettings();
            int intI = 0;

            // Create rectangles
            for (var index = 0; index < Boards.Count; index++)
            {
                var item = Boards[index];
                _rectangles.Add(new Mathe.RawRectangleF[item.X, item.Y]);
                _brushes.Add(new D2D.Brush[item.X, item.Y]);
                const float recWidth = 51, margin = 5;

                float widthC  = recWidth * item.X + margin * (item.X - 1),
                      heightC = recWidth * item.Y + margin * (item.Y - 1),
                      leftC   = _centerPointF.X - widthC / 2,
                      topC    = _centerPointF.Y - heightC / 2;

                for (var i = 0; i < item.X; i++)
                {
                    for (var j = 0; j < item.Y; j++)
                    {
                        if (item.VisibleBoard[i, j] == 0)
                        {
                            continue;
                        }
                        float left = leftC + i * (recWidth + margin), top = topC + j * (recWidth + margin);
                        _rectangles[index][i, j] = new Mathe.RawRectangleF(left, top, left + recWidth, top + recWidth);
                        _brushes[index][i, j]    = new D2D.SolidColorBrush(RenderForm.RenderTarget, item.Color[i, j]);
                        Rectangles.Add(_rectangles[index][i, j]);
                        _boardMap.Add(_rectangles[index][i, j], intI);
                        intI++;
                    }
                }
            }

            #region ImageNormal settings
            //_boardCentre.SetNormalImage(0, 2, LoadFromFile(Path.Combine(_resPath, "13.png")));

            //_boardCentre.SetNormalImage(1, 1, LoadFromFile(Path.Combine(_resPath, "1A.png")));
            //_boardCentre.SetNormalImage(1, 2, LoadFromFile(Path.Combine(_resPath, "6.png")));
            //_boardCentre.SetNormalImage(1, 3, LoadFromFile(Path.Combine(_resPath, "9.png")));

            //_boardCentre.SetNormalImage(2, 0, LoadFromFile(Path.Combine(_resPath, "12.png")));
            //_boardCentre.SetNormalImage(2, 1, LoadFromFile(Path.Combine(_resPath, "2.png")));
            //_boardCentre.SetNormalImage(2, 2, LoadFromFile(Path.Combine(_resPath, "7C.png")));
            //_boardCentre.SetNormalImage(2, 3, LoadFromFile(Path.Combine(_resPath, "8.png")));
            //_boardCentre.SetNormalImage(2, 4, LoadFromFile(Path.Combine(_resPath, "10.png")));

            //_boardCentre.SetNormalImage(3, 1, LoadFromFile(Path.Combine(_resPath, "3.png")));
            //_boardCentre.SetNormalImage(3, 2, LoadFromFile(Path.Combine(_resPath, "4.png")));
            //_boardCentre.SetNormalImage(3, 3, LoadFromFile(Path.Combine(_resPath, "5.png")));

            //_boardCentre.SetNormalImage(4, 2, LoadFromFile(Path.Combine(_resPath, "11.png")));
            #endregion
        }
Ejemplo n.º 12
0
 public void SetColor(int x, int y, Mathe.RawColor4 color) => Color[x, y]         = color;
 public TCM_TextObject(TCM_Graphics g, string text, Color color) : base(g)
 {
     this.text = text;
     setFormat("Arial", 18);
     this.color = color;
 }
Ejemplo n.º 14
0
 public SharpDX.Direct2D1.SolidColorBrush CreateSolidColorBrush(SharpDX.Mathematics.Interop.RawColor4 color)
 {
     return(new SolidColorBrush(_renderTarget, color));
 }
Ejemplo n.º 15
0
 public unsafe static Color4 Convert(RawColor4 color)
 {
     return *(Color4*)&color;
 }
 /// <summary>	
 /// Set the blend state of the output-merger stage.	
 /// </summary>	
 /// <param name="blendStateRef"><para>Pointer to a blend-state interface (see <see cref="SharpDX.Direct3D11.BlendState"/>). Passing in <c>null</c> implies a default blend state. See remarks for further details.</para></param>	
 /// <param name="blendFactor"><para>Array of blend factors, one for each RGBA component. This requires a blend state object that specifies the <see cref="SharpDX.Direct3D11.BlendOption.BlendFactor"/> option.</para></param>	
 /// <param name="sampleMask"><para>32-bit sample coverage. The default value is 0xffffffff. See remarks.</para></param>	
 /// <remarks>	
 /// Blend state is used by the output-merger stage to determine how to blend together two pixel values. The two values are commonly the current pixel value and the pixel value already in the output render target. Use the blend operation to control where the two pixel values come from and how they are mathematically combined.To create a blend-state interface, call <see cref="SharpDX.Direct3D11.Device.CreateBlendState"/>.Passing in <c>null</c> for the blend-state interface indicates to the runtime to set a default blending state.  The following table indicates the default blending parameters.StateDefault Value AlphaToCoverageEnableFALSE BlendEnableFALSE[8] SrcBlendD3D11_BLEND_ONE DstBlendD3D11_BLEND_ZERO BlendOpD3D11_BLEND_OP_ADD SrcBlendAlphaD3D11_BLEND_ONE DstBlendAlphaD3D11_BLEND_ZERO BlendOpAlphaD3D11_BLEND_OP_ADD RenderTargetWriteMask[8]<see cref="SharpDX.Direct3D11.ColorWriteMaskFlags.All"/>[8]?A sample mask determines which samples get updated in all the active render targets. The mapping of bits in a sample mask to samples in a multisample render target is the responsibility of an individual application. A sample mask is always applied; it is independent of whether multisampling is enabled, and does not depend on whether an application uses multisample render targets.The method will hold a reference to the interfaces passed in. This differs from the device state behavior in Direct3D 10.	
 /// </remarks>	
 /// <unmanaged>void ID3D11DeviceContext::OMSetBlendState([In, Optional] ID3D11BlendState* pBlendState,[In, Optional] const SHARPDX_COLOR4* BlendFactor,[In] unsigned int SampleMask)</unmanaged>	
 public void SetBlendState(SharpDX.Direct3D11.BlendState blendStateRef, RawColor4? blendFactor, uint sampleMask)
 {
     SetBlendState(blendStateRef, blendFactor, unchecked((int)sampleMask));
 }
Ejemplo n.º 17
0
		/// <summary>
		/// SetupBlendState
		/// </summary>
		void SetupBlendState ()
		{
			var	rtbd	=	new RenderTargetBlendDescription();

			bool enabled	=	true;

			if ( BlendState.DstAlpha==Blend.Zero && BlendState.SrcAlpha==Blend.One &&
				 BlendState.DstColor==Blend.Zero && BlendState.SrcColor==Blend.One ) {

				 enabled = false;
			}

			rtbd.IsBlendEnabled			=	enabled	;
			rtbd.BlendOperation			=	Converter.Convert( BlendState.ColorOp );
			rtbd.AlphaBlendOperation	=	Converter.Convert( BlendState.AlphaOp );
			rtbd.RenderTargetWriteMask	=	(ColorWriteMaskFlags)(int)BlendState.WriteMask;
			rtbd.DestinationBlend		=	Converter.Convert( BlendState.DstColor );
			rtbd.SourceBlend			=	Converter.Convert( BlendState.SrcColor );
			rtbd.DestinationAlphaBlend	=	Converter.Convert( BlendState.DstAlpha );
			rtbd.SourceAlphaBlend		=	Converter.Convert( BlendState.SrcAlpha );
				
			var	bsd		=	new BlendStateDescription();
			bsd.AlphaToCoverageEnable	=	false;
			bsd.IndependentBlendEnable	=	false;
			bsd.RenderTarget[0]			=	rtbd;

			blendFactor	=	SharpDXHelper.Convert( BlendState.BlendFactor );
			blendMsaaMask	=	BlendState.MultiSampleMask;

			blendState	=	new D3DBlendState( device.Device, bsd );
		}
Ejemplo n.º 18
0
 /// <unmanaged>HRESULT ID2D1CommandSink::Clear([In, Optional] const D2D_COLOR_F* color)</unmanaged>	
 public void Clear(RawColor4? color = null)
 {
     Clear_(color);
 }
Ejemplo n.º 19
0
 /// <summary>	
 /// Creates a new <see cref="SharpDX.Direct2D1.SolidColorBrush"/> that has the specified color and opacity. 	
 /// </summary>	
 /// <param name="renderTarget">an instance of <see cref = "SharpDX.Direct2D1.RenderTarget" /></param>
 /// <param name="color">The red, green, blue, and alpha values of the brush's color.</param>
 public SolidColorBrush(RenderTarget renderTarget, RawColor4 color) : this(renderTarget, color, null)
 {
 }
Ejemplo n.º 20
0
 public TextVisual(string text, Color color) : base()
 {
     this.text = text;
     setFormat("Arial", 18);
     this.color = color;
 }
Ejemplo n.º 21
0
 public void setColor(Color color)
 {
     this.color = color;
 }
Ejemplo n.º 22
0
 /// <summary>	
 /// Draws a run of glyphs to a bitmap target at the specified position.	
 /// </summary>	
 /// <remarks>	
 /// You can use the IDWriteBitmapRenderTarget::DrawGlyphRun to render to a bitmap from a custom text renderer that you implement.  The custom text renderer should call this method from within the <see cref="M:SharpDX.DirectWrite.TextRenderer.DrawGlyphRun(System.IntPtr,System.Single,System.Single,SharpDX.DirectWrite.MeasuringMode,SharpDX.DirectWrite.GlyphRun,SharpDX.DirectWrite.GlyphRunDescription,SharpDX.ComObject)" /> callback method as shown in the following code. 	
 /// <code> STDMETHODIMP GdiTextRenderer::DrawGlyphRun( __maybenull void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, __in DWRITE_GLYPH_RUN const* glyphRun, __in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription, IUnknown* clientDrawingEffect )	
 /// { HRESULT hr = S_OK; // Pass on the drawing call to the render target to do the real work. RECT dirtyRect = {0}; hr = pRenderTarget_-&gt;DrawGlyphRun( baselineOriginX, baselineOriginY, measuringMode, glyphRun, pRenderingParams_, RGB(0,200,255), &amp;dirtyRect ); return hr;	
 /// } </code>	
 /// 
 /// The baselineOriginX, baslineOriginY, measuringMethod, and glyphRun parameters are provided (as arguments) when the callback method is invoked.  The renderingParams, textColor and blackBoxRect are not. Default rendering params can be retrieved by using the <see cref="M:SharpDX.DirectWrite.Factory.CreateMonitorRenderingParams(System.IntPtr,SharpDX.DirectWrite.RenderingParams@)" /> method.  	
 /// </remarks>	
 /// <param name="baselineOriginX">The horizontal position of the baseline origin, in DIPs, relative to the upper-left corner of the DIB. </param>
 /// <param name="baselineOriginY">The vertical position of the baseline origin, in DIPs, relative to the upper-left corner of the DIB. </param>
 /// <param name="measuringMode">The measuring method for glyphs in the run, used with the other properties to determine the rendering mode. </param>
 /// <param name="glyphRun">The structure containing the properties of the glyph run. </param>
 /// <param name="renderingParams">The object that controls rendering behavior. </param>
 /// <param name="textColor">The foreground color of the text. </param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. </returns>
 /// <unmanaged>HRESULT IDWriteBitmapRenderTarget::DrawGlyphRun([None] float baselineOriginX,[None] float baselineOriginY,[None] DWRITE_MEASURING_MODE measuringMode,[In] const DWRITE_GLYPH_RUN* glyphRun,[None] IDWriteRenderingParams* renderingParams,[None] COLORREF textColor,[Out, Optional] RECT* blackBoxRect)</unmanaged>
 public void DrawGlyphRun(float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, RenderingParams renderingParams, RawColor4 textColor)
 {
     RawRectangle temp;
     DrawGlyphRun(baselineOriginX, baselineOriginY, measuringMode, glyphRun, renderingParams, textColor, out temp);
 }
Ejemplo n.º 23
0
 /// <summary>	
 /// Get the {{blend state}} of the output-merger stage.	
 /// </summary>	
 /// <remarks>	
 /// The reference count of the returned interface will be incremented by one when the blend state is retrieved. Applications must release returned reference(s) when they are no longer needed, or else there will be a memory leak. 	
 /// </remarks>	
 /// <param name="blendFactor">Array of blend factors, one for each RGBA component. </param>
 /// <param name="sampleMaskRef">Pointer to a {{sample mask}}. </param>
 /// <returns>a reference to a blend-state interface (see <see cref="SharpDX.Direct3D10.BlendState"/>).</returns>
 /// <unmanaged>void OMGetBlendState([Out, Optional] ID3D10BlendState** ppBlendState,[Out, Optional] float BlendFactor[4],[Out, Optional] int* pSampleMask)</unmanaged>
 public SharpDX.Direct3D10.BlendState GetBlendState(out RawColor4 blendFactor, out int sampleMaskRef)
 {
     BlendState blendState;
     GetBlendState(out blendState, out blendFactor, out sampleMaskRef);
     return blendState;
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Draw formatted text at the specified position.
 /// </summary>
 /// <param name="sprite">Reference to an ID3DX10Sprite object that contains the string you wish to draw. Can be NULL, in which case Direct3D will render the string with its own sprite object. To improve efficiency, a sprite object should be specified if ID3DX10Font::DrawText is to be called more than once in a row.</param>
 /// <param name="text">Pointer to a string to draw. If UNICODE is defined, this parameter type resolves to an LPCWSTR, otherwise, the type resolves to an LPCSTR. If the Count parameter is -1, the string must be NULL terminated.</param>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="color">Color of the text. See <see cref="RawColor4"/>.</param>
 /// <returns>
 /// If the function succeeds, the return value is the height of the text in logical units. If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from pRect (top to the bottom) of the drawn text. If the function fails, the return value is zero.
 /// </returns>
 /// <unmanaged>int ID3DX10Font::DrawTextW([None] LPD3DX10SPRITE pSprite,[None] const wchar_t* pString,[None] int Count,[None] RECT* pRect,[None] int Format,[None] D3DXCOLOR Color)</unmanaged>
 /// <remarks>
 /// The parameters of this method are very similar to those of the {{GDI DrawText}} function. This method supports both ANSI and Unicode strings. Unless the DT_NOCLIP format is used, this method clips the text so that it does not appear outside the specified rectangle. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is specified. If the selected font is too large for the rectangle, this method does not attempt to substitute a smaller font. This method supports only fonts whose escapement and orientation are both zero.
 /// </remarks>
 /// <unmanaged>int ID3DX10Font::DrawTextW([In] ID3DX10Sprite* pSprite,[In] const wchar_t* pString,[In] int Count,[In] RECT* pRect,[In] unsigned int Format,[In] D3DXCOLOR Color)</unmanaged>	
 public int DrawText(Sprite sprite, string text, int x, int y, RawColor4 color)
 {
     return DrawText(sprite, text, new RawRectangle(x, y, 0, 0), FontDrawFlags.NoClip, color);
 }
Ejemplo n.º 25
-1
 /// <summary>	
 /// Draw formatted text.
 /// </summary>	
 /// <remarks>	
 /// The parameters of this method are very similar to those of the {{GDI DrawText}} function. This method supports both ANSI and Unicode strings. Unless the DT_NOCLIP format is used, this method clips the text so that it does not appear outside the specified rectangle. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is specified. If the selected font is too large for the rectangle, this method does not attempt to substitute a smaller font. This method supports only fonts whose escapement and orientation are both zero. 	
 /// </remarks>	
 /// <param name="sprite">Reference to an ID3DX10Sprite object that contains the string you wish to draw. Can be NULL, in which case Direct3D will render the string with its own sprite object. To improve efficiency, a sprite object should be specified if ID3DX10Font::DrawText is to be called more than once in a row. </param>
 /// <param name="text">Pointer to a string to draw. If UNICODE is defined, this parameter type resolves to an LPCWSTR, otherwise, the type resolves to an LPCSTR. If the Count parameter is -1, the string must be NULL terminated. </param>
 /// <param name="rect">Pointer to a <see cref="RawRectangle"/> structure that contains the rectangle, in logical coordinates, in which the text is to be formatted. As with any RECT object, the coordinate value of the rectangle's right side must be greater than that of its left side. Likewise, the coordinate value of the bottom must be greater than that of the top. </param>
 /// <param name="drawFlags">Specify the method of formatting the text. It can be any combination of the following values:    ItemDescription  DT_BOTTOM  Justify the text to the bottom of the rectangle. This value must be combined with DT_SINGLELINE.   DT_CALCRECT  Tell DrawText to automatically calculate the width and height of the rectangle based on the length of the string you tell it to draw. If there are multiple lines of text, ID3DX10Font::DrawText uses the width of the rectangle pointed to by the pRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, ID3DX10Font::DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, ID3DX10Font::DrawText returns the height of the formatted text but does not draw the text.   DT_CENTER  Center text horizontally in the rectangle.   DT_EXPANDTABS  Expand tab characters. The default number of characters per tab is eight.   DT_LEFT  Align text to the left.   DT_NOCLIP  Draw without clipping. ID3DX10Font::DrawText is somewhat faster when DT_NOCLIP is used.   DT_RIGHT  Align text to the right.   DT_RTLREADING  Display text in right-to-left reading order for bidirectional text when a Hebrew or Arabic font is selected. The default reading order for all text is left-to-right.   DT_SINGLELINE  Display text on a single line only. Carriage returns and line feeds do not break the line.   DT_TOP  Top-justify text.   DT_VCENTER  Center text vertically (single line only).   DT_WORDBREAK  Break words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the pRect parameter. A carriage return/line feed sequence also breaks the line.   ? </param>
 /// <param name="color">Color of the text. See <see cref="RawColor4"/>. </param>
 /// <returns>If the function succeeds, the return value is the height of the text in logical units. If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from pRect (top to the bottom) of the drawn text. If the function fails, the return value is zero. </returns>
 /// <unmanaged>int ID3DX10Font::DrawTextW([None] LPD3DX10SPRITE pSprite,[None] const wchar_t* pString,[None] int Count,[None] RECT* pRect,[None] int Format,[None] D3DXCOLOR Color)</unmanaged>
 public unsafe int DrawText(SharpDX.Direct3D10.Sprite sprite, string text, RawRectangle rect, FontDrawFlags drawFlags, RawColor4 color)
 {
     int value = DrawText(sprite, text, text.Length, new IntPtr(&rect), (int) drawFlags, color);
     if (value == 0)
         throw new SharpDXException("Draw failed");
     return value;
 }
Ejemplo n.º 26
-1
 public static Color4 Convert(RawColor4 color)
 {
     var temp = new Color4();
     unsafe
     {
         *((RawColor4*)&temp) = color;
     }
     return temp;
 }
Ejemplo n.º 27
-1
 private static unsafe Result Fill2DCallbackImpl(RawColor4* outVector, RawVector2* textCoord, RawVector2* textelSize, IntPtr data)
 {
     try
     {
         var handle = GCHandle.FromIntPtr(data);
         *outVector = ((Fill2DCallback)handle.Target)(*textCoord, *textelSize);
     }
     catch (SharpDXException exception)
     {
         return exception.ResultCode.Code;
     }
     catch (Exception)
     {
         return Result.Fail.Code;
     }
     return Result.Ok.Code;
 }