示例#1
0
        public override void Render( CanvasRenderArguments args, System.Drawing.SizeF Zoom )
        {
            if ( IsGeomrtryDirty ) {
                Load( args );
            }

            // plot the mesh
            args.renderTarget.DrawGeometry( meshGeo, lineBrush, StrokeWidth );

            // plot the mesh
            args.renderTarget.DrawGeometry( meshGeo_Color, lineBrush_Color, StrokeWidth );
        }
示例#2
0
        public override void Render(CanvasRenderArguments args, SizeF Zoom)
        {
            lock (this)
            {
                // check if we have set the image
                if (mImageBitmap != null)
                {

                    var rect = new SharpDX.RectangleF(0, 0, Size.X, Size.Y);
                    // render the image
                    args.renderTarget.DrawBitmap(mImageBitmap, rect, 1, BitmapInterpolationMode.Linear);
                }
            }
        }
示例#3
0
        public override void Load( CanvasRenderArguments args )
        {
            // dispose the prev geometry
            if ( meshGeo != null )
                meshGeo.Dispose();
            if (meshGeo_Color != null)
                meshGeo_Color.Dispose();
            if (lineBrush_Color != null)
                lineBrush_Color.Dispose();
            if (lineBrush != null)
                lineBrush.Dispose();

            // init the lines brushs
            lineBrush = new SolidColorBrush(args.renderTarget, LineColor);

            // init the lines brushs
            lineBrush_Color = new SolidColorBrush(args.renderTarget, new Color4(0.98f, 0.99f, 0.09f, 1.0f));

            // init the geometryes
            meshGeo = new PathGeometry( args.factory );

            // fill the mesh geo
            meshGeo_Sink = meshGeo.Open();

            // init the geometryes
            meshGeo_Color = new PathGeometry(args.factory);

            // fill the mesh geo
            meshGeo_Sink_Color = meshGeo_Color.Open();

            // draw all the faces
            mesh.FaceFunctionExec(new FaceFunction(DrawFace));

            // close the geo
            meshGeo_Sink.Close();

            // free the memory for the sink
            meshGeo_Sink.Dispose();

            // close the geo
            meshGeo_Sink_Color.Close();

            // free the memory for the sink
            meshGeo_Sink_Color.Dispose();

            IsGeomrtryDirty = false;
        }
示例#4
0
        public override void Render( CanvasRenderArguments args, System.Drawing.SizeF Zoom )
        {
            if ( IsGeomrtryDirty ) {
                Load( args );
            }

            lock(listGeometry)
            {
                // plot the plots
                foreach (IBaseGeometry geo in listGeometry)
                {
                    newMAtrix = args.renderTarget.Transform;
                    newMAtrix.M31 += OriginPosition.x * Zoom.Width;
                    newMAtrix.M32 -= OriginPosition.y * Zoom.Height;
                    args.renderTarget.Transform = newMAtrix;

                    geo.Render2D(args.renderTarget, lineBrush);

                    newMAtrix.M31 -= OriginPosition.x * Zoom.Width;
                    newMAtrix.M32 += OriginPosition.y * Zoom.Height;
                    args.renderTarget.Transform = newMAtrix;

                }
            }

            // plot the axes
            args.renderTarget.DrawGeometry( Geo_Axes, lineBrush, 1 );
        }
示例#5
0
        public override void Load(CanvasRenderArguments args)
        {
            // set the properties of the image
            BitmapProperties bitmapProps = new BitmapProperties();
            bitmapProps.PixelFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied);

            if (mImageBitmap == null)
            {
                // make the bitmap for Direct2D1
                mImageBitmap = new SharpDX.Direct2D1.Bitmap(args.renderTarget,
                    new Size2(Width, Height),
                    bitmapProps);
            }

            // write to the specific bitmap not create a new one
            mImageBitmap.CopyFromMemory(internalImage, Pitch);
        }
示例#6
0
        public override void Render( CanvasRenderArguments args, System.Drawing.SizeF Zoom )
        {
            if ( IsGeomrtryDirty ) {
                Load( args );

                IsGeomrtryDirty = false;
            }

            args.renderTarget.DrawText( Internal_String, DW_textFormat, textRectangle, lineBrush );
        }
示例#7
0
        public override void Load( CanvasRenderArguments args )
        {
            // init the lines brushes
            if(lineBrush!=null)
                lineBrush.Dispose();
            lineBrush = new SolidColorBrush( args.renderTarget, new Color4( 0.08f, 0.40f, 0.93f, 1.0f) );

            // refresh the geometries
            RefreshGeometry( args.renderTarget );
        }
示例#8
0
        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 );
        }
示例#9
0
        public override void Render( CanvasRenderArguments args, System.Drawing.SizeF Zoom )
        {
            float maxValue = 0;
            float minValue = 0;
            float maxOrigValue = 0;

            if ( IsGeomrtryDirty ) {
                Load( args );
            }

            float maxSize = (Size.y - OriginPosition.y > OriginPosition.y) ? Size.y - OriginPosition.y : OriginPosition.y;

            int offset = (int)((Size.y) / 10.0);
            float PositiveMaxValue = (Size.y - OriginPosition.y) / _scale.y;

            // plot the plots
            foreach (PlotGeometry geo in listPlotsGeometry)
            {
                args.renderTarget.DrawGeometry(geo.Geometry, geo.Brush, 1);
            }

            // plot the axes
            args.renderTarget.DrawGeometry(Geo_Axes, lineBrush, 1);

            // draw possitive values
            for(int i=0;i<Size.y - OriginPosition.y;i+=offset)
            {
                textRectangle.X = OriginPosition.x;
                textRectangle.Y = (Size.y - OriginPosition.y) - i  - textRectangle.Height;

                if (textRectangle.X < 0 ||
                    textRectangle.Y < 0 ||
                    textRectangle.X > Size.x ||
                    textRectangle.Y > Size.y)
                    continue;

                args.renderTarget.DrawText(((float)i / _scale.y).ToString(), DW_textFormat, textRectangle, lineBrush);
            }

            // draw Negative values
            for (int i = offset; i < OriginPosition.y; i += offset)
            {
                textRectangle.X = OriginPosition.x;
                textRectangle.Y = (Size.y - OriginPosition.y) + i - textRectangle.Height;

                if (textRectangle.X < 0 ||
                    textRectangle.Y < 0 ||
                    textRectangle.X > Size.x ||
                    textRectangle.Y > Size.y)
                    continue;

                args.renderTarget.DrawText(((float)-i / _scale.y).ToString(), DW_textFormat, textRectangle, lineBrush);
            }
        }
示例#10
0
        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 );
        }
示例#11
0
 /// <summary>
 /// Render the element in the canva.
 /// </summary>
 /// <param name="renderTarget"></param>
 /// <param name="Zoom">The zoom factor for the internal state</param>
 public abstract void Render( CanvasRenderArguments renderTarget, SizeF Zoom );
示例#12
0
 /// <summary>
 /// Load the element to the canva
 /// </summary>
 /// <param name="renderTarget"></param>
 public abstract void Load( CanvasRenderArguments renderTarget );