Beispiel #1
0
        public void GraphicsInteropFromManaged()
        {
            //
            // This test interops a C# component (ie this one) with a C++/CX
            // component (GraphicsDeviceComponent) using Direct3DDevice and
            // Direct3DSurface to pass a IDXGIDevice and IDXGISurface between
            // them.
            //

            // Create a device.
            Direct3DDevice graphicsDevice = NativeComponent.DeviceCreator.CreateDevice();

            // We should be able to call Trim() without anything bad happening
            graphicsDevice.Trim();

            // Now create a surface using this device.
            int expectedWidth          = 128;
            int expectedHeight         = 256;
            var expectedGraphicsFormat = DirectXPixelFormat.R32Float;

            Direct3DSurface surface = NativeComponent.SurfaceCreator.CreateSurface(
                graphicsDevice,
                expectedWidth,
                expectedHeight,
                expectedGraphicsFormat);

            // Look at the surface description to make sure it seems valid.
            var desc = surface.Description;

            Assert.AreEqual(expectedWidth, desc.Width);
            Assert.AreEqual(expectedHeight, desc.Height);
            Assert.AreEqual(expectedGraphicsFormat, desc.Format);
            Assert.AreEqual(1, desc.MultisampleDescription.Count);
            Assert.AreEqual(0, desc.MultisampleDescription.Quality);
        }
Beispiel #2
0
 /// <summary>Create an indexed palette and linear brush for linear gradients.</summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> used for rendering.</param>
 /// <param name="gradientStops">Collection of gradient stops to use in brush and palette.</param>
 /// <param name="paletteSize">Number of indexed colors to create.</param>
 /// <param name="startPosition"><see cref="LinearGradientBrush"/> start vector.</param>
 /// <param name="endPosition"><see cref="LinearGradientBrush"/> end vector.</param>
 public LinearGradientPalette(Direct3DSurface surface, IEnumerable <GradientStop> gradientStops, RawVector2 startPosition, RawVector2 endPosition, int paletteSize = 256)
 {
     IsDisposed     = false;
     _surface       = surface;
     _paletteSize   = paletteSize;
     _startPosition = startPosition;
     _endPosition   = endPosition;
     _gradientStops = gradientStops.ToList();
     Update();
 }
        public MM_DX_Contouring(Direct3DSurface surface)
        {
            _surface = surface;
            _kdTree  = new KDTree.KDTree <MM_Substation>(2);

            if (featureEnableContour)
            {
                _redrawTimer = new Timer(AllowRedraw, null, Timeout.Infinite, Timeout.Infinite);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Create a new layer
        /// </summary>
        /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
        /// <param name="name">The name of the layer.</param>
        /// <param name="order">The order of the layer</param>
        public MinimapLayer(Direct3DSurface surface, MM_Violation_Viewer violationViewer) : base(surface, "Minimap", 99999)
        {
            _violationViewer = violationViewer;

            var map = this.Surface as MM_Network_Map_DX;

            _coordinates = map.Coordinates;
            violationViewer.ViolationsChanged += (s, e) => _isDirty = true;
            // Hook events to update render state
            MM_Repository.ViewChanged += v => _isDirty = true;
            _coordinates.Panned       += (center, newCenter) => _isDirty = true;
            _coordinates.Zoomed       += (zoom, newZoom) => _isDirty = true;
            _coordinates.LassoDrawing += () => _isDirty = true;
        }
Beispiel #5
0
        protected BaseContour(Direct3DSurface surface)
        {
            if (surface == null)
            {
                throw new ArgumentNullException("Surface", "Surface is null. Cannot create render target for contour.");
            }

            _surface = surface;

            var desc = new Texture2DDescription
            {
                BindFlags         = BindFlags.RenderTarget | BindFlags.ShaderResource,
                Format            = Format.R8G8B8A8_UNorm,
                Height            = MM_Repository.OverallDisplay.MapTileSize.Height,
                Width             = MM_Repository.OverallDisplay.MapTileSize.Width,
                MipLevels         = 1,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = ResourceUsage.Default,
                OptionFlags       = ResourceOptionFlags.None,
                CpuAccessFlags    = CpuAccessFlags.None,
                ArraySize         = 1
            };

            _tileTexture2D = new Texture2D(_surface.Device, desc);


            _dxgiSurface = _tileTexture2D.QueryInterface <Surface>();


            _renderTarget2D     = new RenderTarget(_surface.Factory2D, _dxgiSurface, new RenderTargetProperties(new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied)));
            _bitmapRenderTarget = new BitmapRenderTarget(_renderTarget2D, CompatibleRenderTargetOptions.None)
            {
                AntialiasMode = _surface.AntialiasMode
            };

            _renderTargetView = new RenderTargetView(_surface.Device, _tileTexture2D);

            InitializeShader();
        }
Beispiel #6
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 /// <param name="name">The name of the layer.</param>
 /// <param name="order">The order of the layer</param>
 public WeatherMapLayer(Direct3DSurface surface) : base(surface, "Weather", 20)
 {
 }
Beispiel #7
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 public DebugLayer(Direct3DSurface surface) : base(surface, "Debug Layer", 99999)
 {
 }
Beispiel #8
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 /// <param name="dataProvider">Data provider for the layer</param>
 /// <param name="name">The name of the layer.</param>
 /// <param name="order">The order of the layer</param>
 public ContourOverlayLayer(Direct3DSurface surface, string name = "Contour Layer", int order = 11) : base(surface, name, order)
 {
 }
Beispiel #9
0
 public TextFormatContainer(Direct3DSurface surface)
 {
     _surface = surface;
 }
Beispiel #10
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 public LineLayer(Direct3DSurface surface, MM_Violation_Viewer violationViewer) : base(surface, "LineLayer", 5)
 {
     _violationViewer = violationViewer;
 }
Beispiel #11
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 /// <param name="name">The name of the layer.</param>
 /// <param name="order">The order of the layer</param>
 public BaseMapLayer(Direct3DSurface surface) : base(surface, "BaseMap", 1)
 {
     tileLoadThread = new Thread(ProcessLoadQueueThread);
     tileLoadThread.Start();
 }
Beispiel #12
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 public TrainingGameLayer(Direct3DSurface surface) : base(surface, "Training Layer", 99999)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 /// <param name="order">The order of the layer</param>
 public SubstationLayer(Direct3DSurface surface, MM_Violation_Viewer violationViewer) : base(surface, "SubstationLayer", 10)
 {
     _violationViewer = violationViewer;
 }
Beispiel #14
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 /// <param name="name">The name of the layer.</param>
 /// <param name="order">The order of the layer</param>
 public DynamicRegionsLayer(Direct3DSurface surface) : base(surface, "DynamicRegions", 3)
 {
 }
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 /// <param name="name">The name of the layer.</param>
 /// <param name="order">The order of the layer</param>
 protected RenderLayer(Direct3DSurface surface, string name = null, int order = 0)
 {
     Surface = surface;
     Name    = name;
     Order   = order;
 }
Beispiel #16
0
 public BrushContainer(Direct3DSurface surface)
 {
     _surface = surface;
 }
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 /// <param name="name">The name of the layer.</param>
 /// <param name="order">The order of the layer</param>
 public StateRegionsLayer(Direct3DSurface surface) : base(surface, "RegionBorders", 2)
 {
 }
Beispiel #18
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 public ScreenLogLayer(Direct3DSurface surface) : base(surface, "Screen Logging Layer", 99)
 {
 }
Beispiel #19
0
 /// <summary>
 /// Create a new layer
 /// </summary>
 /// <param name="surface">The <see cref="Direct3DSurface"/> this layer belongs to.</param>
 /// <param name="name">The name of the layer.</param>
 /// <param name="order">The order of the layer</param>
 public LegendLayer(Direct3DSurface surface, string name = "Legend", int order = 9997) : base(surface, name, order)
 {
 }
Beispiel #20
0
 public KDTreeContour(Direct3DSurface surface) : base(surface)
 {
     _data = new KDTree <float>(2);
 }