• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DrawArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DrawArgs的典型用法代码示例。如果您正苦于以下问题:C# DrawArgs类的具体用法?C# DrawArgs怎么用?C# DrawArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DrawArgs类属于命名空间,在下文中一共展示了DrawArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Initialize

		public override void Initialize(DrawArgs drawArgs)
		{
			try
			{
				GraphicsStream adj;
				this.mesh = Mesh.FromFile(this.meshFilePath, MeshFlags.Managed, drawArgs.device, out adj, out this.materials );
				this.meshMaterials = new Material[this.materials.Length];
				//using(StreamWriter sw = new StreamWriter("mat.txt", true, System.Text.Encoding.ASCII))
			{
				//sw.WriteLine(this.meshMaterials.Length.ToString());
				for(int i = 0; i < this.materials.Length; i++)
				{
					this.meshMaterials[i] = this.materials[i].Material3D;
					this.meshMaterials[i].Ambient = this.meshMaterials[i].Diffuse;
				}
			}

				//this.mesh.ComputeNormals();
			}
			catch(Exception caught)
			{
				Log.Write( caught );
			}
			this.isInitialized = true;
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:25,代码来源:MeshLayer.cs


示例2: Initialize

        public override void Initialize(DrawArgs drawArgs)
        {
            FileInfo boundaryFileInfo = new FileInfo(this._boundaryFilePath);
            if (!boundaryFileInfo.Exists) {
                this.Inited = true;
                return;
            }

            using (FileStream boundaryFileStream = boundaryFileInfo.OpenRead()) {
                using (BinaryReader boundaryFileReader = new BinaryReader(boundaryFileStream, Encoding.ASCII)) {
                    int count = boundaryFileReader.ReadInt32();
                    this.vertices = new CustomVertex.PositionColored[count];

                    for (int i = 0; i < count; i++) {
                        double lat = boundaryFileReader.ReadDouble();
                        double lon = boundaryFileReader.ReadDouble();
                        Vector3 v = MathEngine.SphericalToCartesian((float) lat, (float) lon, (float) (this._parentWorld.EquatorialRadius + this._distanceAboveSurface));
                        this.vertices[i].X = v.X;
                        this.vertices[i].Y = v.Y;
                        this.vertices[i].Z = v.Z;
                        this.vertices[i].Color = this._color;
                    }
                }
            }
            this.Inited = true;
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:26,代码来源:BoundaryLayer.cs


示例3: Render

 public override void Render(DrawArgs drawArgs)
 {
     if (!m_widget.Visible)
     {
         SetPushed(false);
     }
 }
开发者ID:jpespartero,项目名称:WorldWind,代码行数:7,代码来源:WidgetMenuButton.cs


示例4: Render

 public override void Render(DrawArgs drawArgs)
 {
     if (this.Inited) {
         drawArgs.Device.VertexFormat = CustomVertex.PositionColored.Format;
         drawArgs.Device.TextureState[0].ColorOperation = TextureOperation.Disable;
         drawArgs.Device.DrawUserPrimitives(PrimitiveType.LineStrip, this.vertices.Length - 1, this.vertices);
     }
 }
开发者ID:beginor,项目名称:WorldWind,代码行数:8,代码来源:BoundaryLayer.cs


示例5: DownloadableImageFromIconSet

 /// <summary>
 /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.DownloadableImageFromIconSet"/> class.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="drawArgs"></param>
 /// <param name="terrainAccessor"></param>
 public DownloadableImageFromIconSet(string name, World parentWorld, float distanceAboveSurface, DrawArgs drawArgs, TerrainAccessor terrainAccessor)
     : base(name, parentWorld.Position, parentWorld.Orientation)
 {
     this.m_ParentWorld = parentWorld;
     this.layerRadius = (float) parentWorld.EquatorialRadius + distanceAboveSurface;
     this.IsSelectable = true;
     this.drawArgs = drawArgs;
     this._terrainAccessor = terrainAccessor;
 }
开发者ID:beginor,项目名称:WorldWind,代码行数:15,代码来源:DownloadableImageFromIconSet.cs


示例6: Draw

        public void Draw(DrawArgs args)
        {
            //_gameZonePanel.Draw(args);

            foreach (var panel in _panels)
            {
                panel.Draw(args);
            }
            //todo draw other
        }
开发者ID:BradArmstrong06,项目名称:rogueloise,代码行数:10,代码来源:UI.cs


示例7: Tree

 public Tree(Vector3 position, float treeHeight, float angleClamp, float dropOff, int number, 
     int depth, Billboard b)
 {
     args = new DrawArgs(null, new Color4(0, .5f, 0, 1f));
     Root = new TreeBranch();
     Root.Position = position;
     var subr = new TreeBranch(treeHeight * dropOff, angleClamp, dropOff, number, new Vector3(0,1,0),
         position + new Vector3(0, treeHeight, 0), depth, b, Root, this);
     Root.Children.Add(subr);
     Position = position;
 }
开发者ID:lvarvel,项目名称:aura,代码行数:11,代码来源:Tree.cs


示例8: Render

		public void Render(DrawArgs drawArgs)
		{
			for(int index = m_ChildWidgets.Count - 1; index >= 0; index--)
			{
				IWidget currentWidget = m_ChildWidgets[index] as IWidget;
				if(currentWidget != null)
				{
					if(currentWidget.ParentWidget == null || currentWidget.ParentWidget != this)
						currentWidget.ParentWidget = this;

					currentWidget.Render(drawArgs);
				}
			}
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:14,代码来源:WorldWind.Widgets.RootWidget.cs


示例9: Initialize

		public override void Initialize(DrawArgs drawArgs)
		{
			FileInfo polygonFileInfo = new FileInfo(this._polygonFilePath);
			if(!polygonFileInfo.Exists)
			{
				this.isInitialized = true;
				return;
			}

			using( FileStream polygonFileStream = polygonFileInfo.OpenRead() )
			using( BinaryReader polygonFileReader = new BinaryReader(polygonFileStream, System.Text.Encoding.ASCII) ) {
				int nodeCount = polygonFileReader.ReadInt32();
				int edgeCount = polygonFileReader.ReadInt32();

				this._vertices = new CustomVertex.PositionColored[nodeCount];
				this._indices = new int[edgeCount * 3];

				for(int i = 0; i < nodeCount; i++) {
					double lat = polygonFileReader.ReadDouble();
					double lon = polygonFileReader.ReadDouble();

					Vector3 curNode = MathEngine.SphericalToCartesian((float)lat, (float)lon, (float)(this._parentWorld.EquatorialRadius + this._distanceAboveSurface));
					this._vertices[i].X = curNode.X;
					this._vertices[i].Y = curNode.Y;
					this._vertices[i].Z = curNode.Z;
					this._vertices[i].Color = this._color.ToArgb();
				}

				for(int i = 0; i < edgeCount; i++) {
					int e0 = polygonFileReader.ReadInt32();
					int e1 = polygonFileReader.ReadInt32();
					int e2 = polygonFileReader.ReadInt32();

					this._indices[i*3] = e0;
					this._indices[i*3 + 1] = e1;
					this._indices[i*3 + 2] = e2;
				}
			}
			this.isInitialized = true;
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:40,代码来源:PolygonLayer.cs


示例10: DrawBorders

        private void DrawBorders(DrawArgs args)
        {
            Vector topLeftCorner = AbsolutePosition;
            Vector bottomRightCorner = AbsolutePosition + Size;

            for (int y = topLeftCorner.Y; y <= bottomRightCorner.Y; y++)
            {
                if (y == topLeftCorner.Y || y == bottomRightCorner.Y)
                {
                    for (int x = topLeftCorner.X; x <= bottomRightCorner.X; x++)
                    {
                        var point = new Vector(x, y);

                        if (x == topLeftCorner.X)
                        {
                            if (y == topLeftCorner.Y)
                                args.DrawAtAbsolutePoint(point, _leftTopCorner);
                            if (y == bottomRightCorner.Y)
                                args.DrawAtAbsolutePoint(point, _leftBottomCorner);
                        }
                        else if (x == bottomRightCorner.X)
                        {
                            if (y == topLeftCorner.Y)
                                args.DrawAtAbsolutePoint(point, _rightTopCorner);
                            if (y == bottomRightCorner.Y)
                                args.DrawAtAbsolutePoint(point, _rightBottomCorner);
                        }
                        else
                            args.DrawAtAbsolutePoint(point, _topBottonBorder);
                    }
                }
                else
                {
                    args.DrawAtAbsolutePoint(topLeftCorner.X, y, _sideBorders);
                    args.DrawAtAbsolutePoint(bottomRightCorner.X, y, _sideBorders);
                }
            }
        }
开发者ID:BradArmstrong06,项目名称:rogueloise,代码行数:38,代码来源:Panel.cs


示例11: Render

		public override void Render(DrawArgs drawArgs)
		{
//			Vector3 here = MathEngine.SphericalToCartesian(drawArgs.WorldCamera.Latitude, drawArgs.WorldCamera.Longitude, this.layerRadius);
			Matrix currentWorld = drawArgs.device.Transform.World;
			drawArgs.device.RenderState.Lighting = true;
			drawArgs.device.RenderState.ZBufferEnable = true;
			drawArgs.device.Lights[0].Diffuse = System.Drawing.Color.White; 
			drawArgs.device.Lights[0].Type = LightType.Point; 
			drawArgs.device.Lights[0].Range = 100000;
			drawArgs.device.Lights[0].Position = new Vector3(this.layerRadius, 0, 0);
			drawArgs.device.Lights[0].Enabled = true ; 

			drawArgs.device.RenderState.CullMode = Cull.None;
			drawArgs.device.Transform.World = Matrix.Identity;
			drawArgs.device.Transform.World *= Matrix.Scaling(this.scaleFactor, this.scaleFactor, this.scaleFactor);
			//drawArgs.device.Transform.World *= Matrix.RotationX(MathEngine.RadiansToDegrees(90));
			drawArgs.device.Transform.World *= Matrix.Translation(0,0,-this.layerRadius);
			
			drawArgs.device.Transform.World *= Matrix.RotationY((float)MathEngine.DegreesToRadians(90-this.lat));
			drawArgs.device.Transform.World *= Matrix.RotationZ((float)MathEngine.DegreesToRadians(180+this.lon));
			
			//drawArgs.device.Transform.World *= Matrix.RotationQuaternion(drawArgs.WorldCamera.CurrentOrientation);
		
			drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable;
			drawArgs.device.RenderState.NormalizeNormals = true;
		
			
			for( int i = 0; i < this.meshMaterials.Length; i++ )
			{
				drawArgs.device.Material = this.meshMaterials[i];
				this.mesh.DrawSubset(i);
			}
			
			drawArgs.device.Transform.World = currentWorld;
			drawArgs.device.RenderState.CullMode = Cull.Clockwise;
			drawArgs.device.RenderState.Lighting = false;
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:37,代码来源:MeshLayer.cs


示例12: Draw

        /// <summary>
        /// Draws the progress bar
        /// </summary>
        /// <param name="x">Center X position of progress.</param>
        /// <param name="y">Center Y position of progress.</param>
        /// <param name="progress">Progress vale, in the range 0..1</param>
        public void Draw(DrawArgs drawArgs, float x, float y, float progress, int color)
        {
            if (x != this.x
                || y != this.y) {
                Initalize(x, y);
            }
            int barlength = (int) (progress*2*halfWidth);

            progressBar[0].X = x - halfWidth;
            progressBar[0].Y = y - halfHeight;
            progressBar[0].Color = color;
            progressBar[1].X = x - halfWidth;
            progressBar[1].Y = y + halfHeight;
            progressBar[1].Color = color;
            progressBar[2].X = x - halfWidth + barlength;
            progressBar[2].Y = y - halfHeight;
            progressBar[2].Color = color;
            progressBar[3].Y = y + halfHeight;
            progressBar[3].X = x - halfWidth + barlength;
            progressBar[3].Color = color;

            progressRight[0].X = x - halfWidth + barlength;
            progressRight[0].Y = y - halfHeight;
            progressRight[1].X = x - halfWidth + barlength;
            progressRight[1].Y = y + halfHeight;
            progressRight[2].X = x + halfWidth;
            progressRight[2].Y = y - halfHeight;
            progressRight[3].X = x + halfWidth;
            progressRight[3].Y = y + halfHeight;

            drawArgs.Device.VertexFormat = CustomVertex.TransformedColored.Format;
            drawArgs.Device.TextureState[0].ColorOperation = TextureOperation.Disable;
            drawArgs.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, progressBar);
            drawArgs.Device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, progressRight);
            drawArgs.Device.DrawUserPrimitives(PrimitiveType.LineStrip, 4, progressBarOutline);
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:42,代码来源:ProgressBar.cs


示例13: ComputeGridValues

        /// <summary>
        /// Recalculates the grid bounds + interval values
        /// </summary>
        public void ComputeGridValues(DrawArgs drawArgs)
        {
            double vr = drawArgs.WorldCamera.TrueViewRange.Radians;

            // Compensate for closer grid towards poles
            vr *= 1 + Math.Abs(Math.Sin(drawArgs.WorldCamera.Latitude.Radians));

            if (vr < 0.17) {
                LatitudeInterval = 1;
            }
            else if (vr < 0.6) {
                LatitudeInterval = 2;
            }
            else if (vr < 1.0) {
                LatitudeInterval = 5;
            }
            else {
                LatitudeInterval = 10;
            }

            LongitudeInterval = LatitudeInterval;

            if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(MathEngine.SphericalToCartesian(90, 0, radius))
                || drawArgs.WorldCamera.ViewFrustum.ContainsPoint(MathEngine.SphericalToCartesian(-90, 0, radius))) {
                // Pole visible, 10 degree longitude spacing forced
                LongitudeInterval = 10;
            }

            MinVisibleLongitude = LongitudeInterval >= 10 ? -180 : (int) drawArgs.WorldCamera.Longitude.Degrees/LongitudeInterval*LongitudeInterval - 18*LongitudeInterval;
            MaxVisibleLongitude = LongitudeInterval >= 10 ? 180 : (int) drawArgs.WorldCamera.Longitude.Degrees/LongitudeInterval*LongitudeInterval + 18*LongitudeInterval;
            MinVisibleLatitude = (int) drawArgs.WorldCamera.Latitude.Degrees/LatitudeInterval*LatitudeInterval - 9*LatitudeInterval;
            MaxVisibleLatitude = (int) drawArgs.WorldCamera.Latitude.Degrees/LatitudeInterval*LatitudeInterval + 9*LatitudeInterval;

            if (MaxVisibleLatitude - MinVisibleLatitude >= 180
                || LongitudeInterval == 10) {
                MinVisibleLatitude = -90;
                MaxVisibleLatitude = 90;
            }
            LongitudePointCount = (MaxVisibleLongitude - MinVisibleLongitude)/LongitudeInterval + 1;
            LatitudePointCount = (MaxVisibleLatitude - MinVisibleLatitude)/LatitudeInterval + 1;
            int vertexPointCount = Math.Max(LatitudePointCount, LongitudePointCount);
            if (lineVertices == null
                || vertexPointCount > lineVertices.Length) {
                lineVertices = new CustomVertex.PositionColored[Math.Max(LatitudePointCount, LongitudePointCount)];
            }

            radius = WorldRadius;
            if (drawArgs.WorldCamera.Altitude
                < 0.10f*WorldRadius) {
                useZBuffer = false;
            }
            else {
                useZBuffer = true;
                double bRadius = WorldRadius*1.01f;
                double nRadius = WorldRadius + 0.015f*drawArgs.WorldCamera.Altitude;

                radius = Math.Min(nRadius, bRadius);
            }
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:62,代码来源:LatLongGrid.cs


示例14: Update

        public override void Update(DrawArgs drawArgs)
        {
            if (drawArgs.WorldCamera.AltitudeAboveTerrain >= m_MinimumViewingAltitude
                && drawArgs.WorldCamera.AltitudeAboveTerrain <= m_MaximumViewingAltitude) {
                if (!Inited) {
                    Initialize(drawArgs);
                }

                foreach (ShapeTile shapeTile in m_RootTiles) {
                    if (shapeTile != null
                        && (shapeTile.m_GeoBB.North - shapeTile.m_GeoBB.South) <= m_lztsd) {
                        shapeTile.Update(drawArgs);
                    }
                }
            }
            else {
                if (Inited) {
                    Dispose();
                }
            }
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:21,代码来源:ShapeFileLayer.cs


示例15: Render

        public override void Render(DrawArgs drawArgs)
        {
            if (!Inited || drawArgs.WorldCamera.AltitudeAboveTerrain < m_MinimumViewingAltitude
                || drawArgs.WorldCamera.AltitudeAboveTerrain > m_MaximumViewingAltitude) {
                return;
            }

            try {
                foreach (ShapeTile shapeTile in m_RootTiles) {
                    if (shapeTile != null
                        && (shapeTile.m_GeoBB.North - shapeTile.m_GeoBB.South) <= m_lztsd) {
                        shapeTile.Render(drawArgs);
                    }
                }

                Vector3 referenceCenter = new Vector3((float) drawArgs.WorldCamera.ReferenceCenter.X, (float) drawArgs.WorldCamera.ReferenceCenter.Y, (float) drawArgs.WorldCamera.ReferenceCenter.Z);

                if (m_PointList.Count > 0) {
                    drawArgs.Device.VertexFormat = CustomVertex.PositionColored.Format;

                    float curPointSize = drawArgs.Device.RenderState.PointSize;

                    drawArgs.Device.RenderState.PointSize = 5.0f;
                    drawArgs.Device.RenderState.ZBufferEnable = false;
                    CustomVertex.PositionColored[] verts = new CustomVertex.PositionColored[1];
                    Vector3 camPoint = MathEngine.SphericalToCartesian(drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees, m_ShapeTileArgs.LayerRadius);

                    drawArgs.Device.Transform.World = Matrix.Translation(-referenceCenter);

                    foreach (Vector3 v in m_PointList) {
                        if (Vector3.Subtract(v, camPoint).Length()
                            < m_ShapeTileArgs.LayerRadius) {
                            verts[0].Color = m_ShapeTileArgs.LabelColor.ToArgb();
                            verts[0].X = v.X;
                            verts[0].Y = v.Y;
                            verts[0].Z = v.Z;

                            drawArgs.Device.TextureState[0].ColorOperation = TextureOperation.Disable;
                            drawArgs.Device.DrawUserPrimitives(PrimitiveType.PointList, 1, verts);
                        }
                    }

                    drawArgs.Device.Transform.World = drawArgs.WorldCamera.WorldMatrix;

                    drawArgs.Device.RenderState.PointSize = curPointSize;
                    drawArgs.Device.RenderState.ZBufferEnable = true;
                }

                if (m_LabelList.Count > 0) {
                    Color iconColor = Color.FromArgb(m_IconOpacity, 255, 255, 255);
                    foreach (Shapefile_Point p in m_LabelList) {
                        Vector3 cartesianPoint = MathEngine.SphericalToCartesian(p.Y, p.X, drawArgs.WorldCamera.WorldRadius + drawArgs.WorldCamera.TerrainElevation);

                        if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(cartesianPoint)
                            || MathEngine.SphericalDistanceDegrees(p.Y, p.X, drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees) > 90.0) {
                            continue;
                        }

                        Vector3 projectedPoint = drawArgs.WorldCamera.Project(cartesianPoint - referenceCenter);

                        /*if(isMouseOver)
                        {
                            // Mouse is over
                            isMouseOver = true;

                            if(icon.isSelectable)
                                DrawArgs.MouseCursor = CursorType.Hand;

                            string description = icon.Description;
                            if(description==null)
                                description = icon.ClickableActionURL;
                            if(description!=null)
                            {
                                // Render description field
                                DrawTextFormat format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak | DrawTextFormat.Bottom;
                                int left = 10;
                                if(World.Settings.showLayerManager)
                                    left += World.Settings.layerManagerWidth;
                                Rectangle rect = Rectangle.FromLTRB(left, 10, drawArgs.ScreenWidth - 10, drawArgs.ScreenHeight - 10 );

                                // Draw outline
                                drawArgs.DefaultDrawingFont.DrawText(
                                    m_sprite, description,
                                    rect,
                                    format, 0xb0 << 24 );

                                rect.Offset(2,0);
                                drawArgs.DefaultDrawingFont.DrawText(
                                    m_sprite, description,
                                    rect,
                                    format, 0xb0 << 24 );

                                rect.Offset(0,2);
                                drawArgs.DefaultDrawingFont.DrawText(
                                    m_sprite, description,
                                    rect,
                                    format, 0xb0 << 24 );

                                rect.Offset(-2,0);
                                drawArgs.DefaultDrawingFont.DrawText(
//.........这里部分代码省略.........
开发者ID:beginor,项目名称:WorldWind,代码行数:101,代码来源:ShapeFileLayer.cs


示例16: Initialize

        public override void Initialize(DrawArgs drawArgs)
        {
            try {
                m_Sprite = new Sprite(drawArgs.Device);
                if (m_IconFilePath != null
                    && File.Exists(m_IconFilePath)) {
                    m_IconTexture = ImageHelper.LoadIconTexture(m_IconFilePath);
                    m_IconTextureDescription = m_IconTexture.GetLevelDescription(0);
                }
                loadShapeFile(m_ShapeFilePath);

                if ((m_ShapeTileArgs.ShowLabels && m_ShapeTileArgs.DataKey != null)
                    || m_IconTexture != null) {
                    foreach (ShapeFileRecord record in m_ShapeTileArgs.ShapeRecords) {
                        if (record.Value != null) {
                            if (record.Point != null) {
                                Shapefile_Point p = new Shapefile_Point();
                                p.X = record.Point.X;
                                p.Y = record.Point.Y;
                                p.Tag = record.Value;
                                m_LabelList.Add(p);
                            }
                            else if (record.MultiPoint != null) {
                                Shapefile_Point p = new Shapefile_Point();
                                p.X = 0.5*(record.MultiPoint.BoundingBox.West + record.MultiPoint.BoundingBox.East);
                                p.Y = 0.5*(record.MultiPoint.BoundingBox.North + record.MultiPoint.BoundingBox.South);
                                p.Tag = record.Value;
                                m_LabelList.Add(p);
                            }
                            else if (record.PolyLine != null) {
                                Shapefile_Point p = new Shapefile_Point();
                                p.X = 0.5*(record.PolyLine.BoundingBox.West + record.PolyLine.BoundingBox.East);
                                p.Y = 0.5*(record.PolyLine.BoundingBox.North + record.PolyLine.BoundingBox.South);
                                p.Tag = record.Value;
                                m_LabelList.Add(p);
                            }
                            else if (record.Polygon != null) {
                                Shapefile_Point p = new Shapefile_Point();
                                p.X = 0.5*(record.Polygon.BoundingBox.West + record.Polygon.BoundingBox.East);
                                p.Y = 0.5*(record.Polygon.BoundingBox.North + record.Polygon.BoundingBox.South);
                                p.Tag = record.Value;
                                m_LabelList.Add(p);
                            }
                        }
                    }
                }
            }
            catch (Exception ex) {
                Log.Write(ex);
            }
            finally {
                Inited = true;
            }
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:54,代码来源:ShapeFileLayer.cs


示例17: CreateImageLayer

        private ImageLayer CreateImageLayer(double north, double south, double west, double east, DrawArgs drawArgs, string imagePath)
        {
            Bitmap b = null;
            Graphics g = null;
            ImageLayer imageLayer = null;
            GeographicBoundingBox geoBB = new GeographicBoundingBox(north, south, west, east);

            int numberPolygonsInTile = 0;

            FileInfo imageFile = new FileInfo(imagePath);
            FileInfo shapeFile = new FileInfo(m_ShapeTileArgs.ParentShapeFileLayer.ShapeFilePath);
            FileInfo shapeXmlFile = null;
            if (m_ShapeTileArgs.ParentShapeFileLayer.MetaData.Contains("SourceXml")) {
                string sourceXml = (string) m_ShapeTileArgs.ParentShapeFileLayer.MetaData["SourceXml"];
                if (!sourceXml.ToLower().StartsWith("http://")) {
                    shapeXmlFile = new FileInfo(sourceXml);
                }
            }

            if (!m_ShapeTileArgs.ParentShapeFileLayer.EnableCaching || !imageFile.Exists || shapeXmlFile == null || shapeXmlFile.LastWriteTimeUtc > imageFile.LastWriteTimeUtc
                || shapeFile.LastWriteTimeUtc > imageFile.LastWriteTimeUtc) {
                for (int i = 0; i < m_ShapeTileArgs.ShapeRecords.Count; i++) {
                    ShapeFileRecord currentRecord = (ShapeFileRecord) m_ShapeTileArgs.ShapeRecords[i];

                    if (currentRecord.Null != null || currentRecord.Point != null || currentRecord.MultiPoint != null
                        || !isShapeRecordInBounds(geoBB, currentRecord)) {
                        continue;
                    }
                    else {
                        if (b == null) {
                            b = new Bitmap(m_ShapeTileArgs.TilePixelSize.Width, m_ShapeTileArgs.TilePixelSize.Height, PixelFormat.Format32bppArgb);
                        }

                        if (g == null) {
                            g = Graphics.FromImage(b);
                        }

                        Color color = m_ShapeTileArgs.PolygonColor;

                        //Fix Black Tiles
                        g.DrawLine(new Pen(color), 0, 0, 1, 1);

                        if (m_ShapeTileArgs.UseScalar
                            && m_ShapeTileArgs.ScaleColors) {
                            double red = 1.0;
                            double green = 1.0;
                            double blue = 1.0;

                            try {
                                //TODO: make this a function and abstract to allow multiple gradient mappings
                                double dv;

                                double curScalar = double.Parse(currentRecord.Value.ToString());

                                if (curScalar < m_ShapeTileArgs.ScaleMin) {
                                    curScalar = m_ShapeTileArgs.ScaleMin;
                                }
                                if (curScalar > m_ShapeTileArgs.ScaleMax) {
                                    curScalar = m_ShapeTileArgs.ScaleMax;
                                }

                                dv = m_ShapeTileArgs.ScaleMax - m_ShapeTileArgs.ScaleMin;

                                if (curScalar < (m_ShapeTileArgs.ScaleMin + 0.25*dv)) {
                                    red = 0;
                                    green = 4*(curScalar - m_ShapeTileArgs.ScaleMin)/dv;
                                }
                                else if (curScalar < (m_ShapeTileArgs.ScaleMin + 0.5*dv)) {
                                    red = 0;
                                    blue = 1 + 4*(m_ShapeTileArgs.ScaleMin + 0.25*dv - curScalar)/dv;
                                }
                                else if (curScalar < (m_ShapeTileArgs.ScaleMin + 0.75*dv)) {
                                    red = 4*(curScalar - m_ShapeTileArgs.ScaleMin - 0.5*dv)/dv;
                                    blue = 0;
                                }
                                else {
                                    green = 1 + 4*(m_ShapeTileArgs.ScaleMin + 0.75*dv - curScalar)/dv;
                                    blue = 0;
                                }

                                color = Color.FromArgb((int) (255*red), (int) (255*green), (int) (255*blue));
                            }
                            catch (Exception) {
                                //	Utility.Log.Write((string)currentPoly.ScalarHash[m_ShapeTileArgs.ColorKey]);
                                //	Utility.Log.Write(String.Format("Min: {0}, Max: {1}", m_ShapeTileArgs.ScaleMin, m_ShapeTileArgs.ScaleMax));
                                //	Utility.Log.Write(String.Format("{0},{1},{2}", red, green, blue));
                                //	Utility.Log.Write(ex);
                            }
                        }
                        else {
                            if (m_ShapeTileArgs.ColorAssignments.Count > 0
                                && m_ShapeTileArgs.ScaleColors) {
                                try {
                                    string colorAssignmentKey = (string) currentRecord.Value;
                                    foreach (string cak in m_ShapeTileArgs.ColorAssignments.Keys) {
                                        if (String.Compare(cak, colorAssignmentKey, true) == 0) {
                                            color = (Color) m_ShapeTileArgs.ColorAssignments[cak];
                                            break;
                                        }
                                    }
//.........这里部分代码省略.........
开发者ID:beginor,项目名称:WorldWind,代码行数:101,代码来源:ShapeFileLayer.cs


示例18: ComputeChild

        private ShapeTile ComputeChild(DrawArgs drawArgs, double childSouth, double childNorth, double childWest, double childEast, double tileSize)
        {
            ShapeTile child = new ShapeTile(new GeographicBoundingBox(childNorth, childSouth, childWest, childEast), m_ShapeTileArgs);

            return child;
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:6,代码来源:ShapeFileLayer.cs


示例19: Draw

        public void Draw(Graphics g, Rectangle rcClient, DrawArgs drwa, Point ptOffset)
        {
            int xCenter = rcClient.Width / 2;
            int yCenter = rcClient.Height / 2;

            int cxT = ((rcClient.Width + drwa.nScale - 1) / drwa.nScale) + 2;
            int cyT = ((rcClient.Height + drwa.nScale - 1) / drwa.nScale) + 2;
            int xCenterT = cxT / 2;
            int yCenterT = cyT / 2;

            // NOTE: these 'using' statements (a 'shortcut' for calling .Dispose()) are
            // absolutely necessary or we chew up all virtual memory while animating

            // Create a temporary bitmap for compositing the grid, frames, origin indicator, etc into

            using (Bitmap bmT = new Bitmap(cxT, cyT)) {

                // Draw the frame and its indicators (grid, center point, special point, etc)

                DrawUnscaled(bmT, cxT, cyT, drwa, ptOffset);

                // Force a nice simple fast old-school stretchblt

                InterpolationMode imOld = g.InterpolationMode;
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                // NOTE: _without_ this the first row and column are only scaled by half!

                PixelOffsetMode pomOld = g.PixelOffsetMode;
                g.PixelOffsetMode = PixelOffsetMode.Half;

                // StretchBlt the temporary composite to the passed-in Graphic

                g.DrawImage(bmT, rcClient.Left - ((xCenterT * drwa.nScale) - xCenter),
                        rcClient.Top - ((yCenterT * drwa.nScale) - yCenter),
                        cxT * drwa.nScale, cyT * drwa.nScale);

                g.PixelOffsetMode = pomOld;
                g.InterpolationMode = imOld;
            }
        }
开发者ID:RusselRains,项目名称:hostile-takeover,代码行数:41,代码来源:Frame.cs


示例20: RenderTropicLine

        /// <summary>
        /// Draws a tropic line at specified latitude with specified label
        /// </summary>
        /// <param name="drawArgs"></param>
        /// <param name="latitude">Latitude in degrees</param>
        /// <param name="label"></param>
        private void RenderTropicLine(DrawArgs drawArgs, float latitude, string label)
        {
            int vertexIndex = 0;
            Vector3 referenceCenter = new Vector3((float) drawArgs.WorldCamera.ReferenceCenter.X, (float) drawArgs.WorldCamera.ReferenceCenter.Y, (float) drawArgs.WorldCamera.ReferenceCenter.Z);

            for (float longitude = MinVisibleLongitude; longitude <= MaxVisibleLongitude; longitude = longitude + LongitudeInterval) {
                Vector3 pointXyz = MathEngine.SphericalToCartesian(latitude, longitude, radius);

                lineVertices[vertexIndex].X = pointXyz.X;
                lineVertices[vertexIndex].Y = pointXyz.Y;
                lineVertices[vertexIndex].Z = pointXyz.Z;
                lineVertices[vertexIndex].Color = World.Settings.tropicLinesColor;
                vertexIndex++;
            }
            drawArgs.Device.DrawUserPrimitives(PrimitiveType.LineStrip, LongitudePointCount - 1, lineVertices);

            Vector3 t1 = MathEngine.SphericalToCartesian(Angle.FromDegrees(latitude), drawArgs.WorldCamera.Longitude - drawArgs.WorldCamera.TrueViewRange*0.3f*0.5f, radius);
            if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(t1)) {
                t1 = drawArgs.WorldCamera.Project(t1 - referenceCenter);
                drawArgs.DefaultDrawingFont.DrawText(null, label, new Rectangle((int) t1.X, (int) t1.Y, drawArgs.ScreenWidth, drawArgs.ScreenHeight), DrawTextFormat.NoClip, World.Settings.tropicLinesColor);
            }
        }
开发者ID:beginor,项目名称:WorldWind,代码行数:28,代码来源:LatLongGrid.cs



注:本文中的DrawArgs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DrawContext类代码示例发布时间:2022-05-24
下一篇:
C# Draw类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap