当前位置: 首页>>代码示例>>C#>>正文


C# DrawArgs.CreateFont方法代码示例

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


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

示例1: ComputeAutoSize

		public void ComputeAutoSize (DrawArgs drawArgs)
		{
			Microsoft.DirectX.Direct3D.Font font = drawArgs.defaultDrawingFont;
			if(font==null)
				font = drawArgs.CreateFont( "", 10 );
			Rectangle bounds = font.MeasureString(null, m_Text, m_Format, 0);
			if(m_useParentWidth)
			{
				m_size.Width = this.WidgetSize.Width - m_location.X;
				m_size.Height = bounds.Height * ( (int)(bounds.Width/m_size.Width) + 1);
			}
			else
			{
				m_size.Width = bounds.Width + m_borderWidth;
				m_size.Height = bounds.Height + m_borderWidth;
			}

			if(m_useParentHeight)
				m_size.Height = this.WidgetSize.Height - m_location.Y;

			// This code is iffy - no idea why Y is offset by more than specified.
			if (m_location.X == 0)
			{
				m_location.X = m_borderWidth;
				m_size.Width += m_borderWidth;
			}
			if (m_location.Y == 0)
			{
				m_location.Y = m_borderWidth;
				m_size.Height += m_borderWidth;
			}
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:32,代码来源:LabelWidget.cs

示例2: Initialize

		public override void Initialize(DrawArgs drawArgs)
		{
			this.isInitialized = true;

			m_drawingFont = drawArgs.CreateFont(m_fontDescription);

            //Validate URL
            /*
            if(System.Text.RegularExpressions.Regex.IsMatch(m_placenameBaseUrl, "(http|ftp|https)://([/w-]+/.)+(/[/w- ./?%&=]*)?"))
            {
                this.isInitialized = true;
            }
            */
            //Generate Initial File List
            //WorldWindWFSPlacenameFile root_file = new WorldWindWFSPlacenameFile(m_placenameBaseUrl, m_typename, m_labelfield);
            //m_placenameFileList = new ArrayList(root_file.SplitPlacenameFiles());

            //TODO:Download and validate capabitilities

			if(m_iconFilePath!=null)
			{
				m_iconTexture = ImageHelper.LoadIconTexture( m_iconFilePath );
			
				using(Surface s = m_iconTexture.GetSurfaceLevel(0))
				{
					SurfaceDescription desc = s.Description;
					m_spriteSize = new System.Drawing.Rectangle(0,0, desc.Width, desc.Height);
				}

				m_sprite = new Sprite(drawArgs.device);
			}
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:32,代码来源:TiledWFSPlacenameSet.cs

示例3: Initialize

        public override void Initialize(DrawArgs drawArgs)
        {
            this.isInitialized = true;

            FontDescription scaledDescription = m_fontDescription;
            scaledDescription.Height = (int)(m_fontDescription.Height * m_fontScaling);

            m_drawingFont = drawArgs.CreateFont(scaledDescription);

            if (m_iconFilePath != null)
            {
                m_iconTexture = ImageHelper.LoadIconTexture(m_iconFilePath);

                using (Surface s = m_iconTexture.GetSurfaceLevel(0))
                {
                }

                m_sprite = new Sprite(drawArgs.device);
            }
        }
开发者ID:paladin74,项目名称:Dapple,代码行数:20,代码来源:TiledWFSPlacenameSet.cs

示例4: Render

        public override void Render(DrawArgs drawArgs)
        {
            try
            {
                lock (this)
                {
                    m_renderColor = m_defaultColor;

                    if (WFSNameSizeMultiplier != m_fontScaling)
                    {
                        m_fontScaling = WFSNameSizeMultiplier;
                        // scale font size based on settings
                        FontDescription scaledDescription = m_fontDescription;
                        scaledDescription.Height = (int)(m_fontDescription.Height * m_fontScaling);
                        m_drawingFont = drawArgs.CreateFont(scaledDescription);
                    }

                    Point3d cameraPosition = drawArgs.WorldCamera.Position;
                    if (m_placeNames == null)
                        return;

                    if (m_sprite != null)
                        m_sprite.Begin(SpriteFlags.AlphaBlend);
                    int count = 0;
                    Point3d referenceCenter = new Point3d(
                        drawArgs.WorldCamera.ReferenceCenter.X,
                        drawArgs.WorldCamera.ReferenceCenter.Y,
                        drawArgs.WorldCamera.ReferenceCenter.Z);

                    for (int index = 0; index < m_placeNames.Length; index++)
                    {
                        Point3d v = m_placeNames[index].cartesianPoint;
                        double distanceSquared = (v - cameraPosition).LengthSq;
                        if (distanceSquared > m_maximumDistanceSq)
                            continue;

                        if (distanceSquared < m_minimumDistanceSq)
                            continue;

                        if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(v))
                            continue;

                        Point3d pv = drawArgs.WorldCamera.Project(v - referenceCenter);

                        // Render text only
                        string label = m_placeNames[index].Name;

                        /*
                        if(m_sprite != null && 1==0)
                        {
                            m_sprite.Draw(m_iconTexture,
                                m_spriteSize,
                                new Vector3(m_spriteSize.Width/2,m_spriteSize.Height/2,0),
                                new Vector3(pv.X, pv.Y, 0),
                                System.Drawing.Color.White);
                            pv.X += m_spriteSize.Width/2 + 4;
                        }
                        */

                        System.Drawing.Rectangle rect = m_drawingFont.MeasureString(null, label, m_textFormat, m_renderColor);

                        pv.Y -= rect.Height / 2;
                        if (m_sprite == null)
                            // Center horizontally
                            pv.X -= rect.Width / 2;

                        rect.Inflate(3, 1);
                        int x = (int)Math.Round(pv.X);
                        int y = (int)Math.Round(pv.Y);

                        rect.Offset(x, y);

                        m_drawingFont.DrawText(null, label, x, y, m_renderColor);

                        count++;
                        if (count > 30)
                            break;
                    }

                    if (m_sprite != null)
                        m_sprite.End();

                }
            }
            catch (Exception caught)
            {
                Log.Write(caught);
            }
        }
开发者ID:paladin74,项目名称:Dapple,代码行数:89,代码来源:TiledWFSPlacenameSet.cs

示例5: Initialize

		public override void Initialize(DrawArgs drawArgs)
		{
			this.isInitialized = true;

			m_drawingFont = drawArgs.CreateFont(m_fontDescription);
			if(!File.Exists(m_placenameListFilePath))
			{
				this.isInitialized = true;
				Log.Write(Log.Levels.Error, "PLACE", m_placenameListFilePath + " not found.");
				return;
			}

			if(m_iconFilePath!=null)
			{
				m_iconTexture = ImageHelper.LoadIconTexture( m_iconFilePath );
			
				using(Surface s = m_iconTexture.GetSurfaceLevel(0))
				{
					SurfaceDescription desc = s.Description;
					m_spriteSize = new System.Drawing.Rectangle(0,0, desc.Width, desc.Height);
				}

				m_sprite = new Sprite(drawArgs.device);
			}

			using( BufferedStream placenameFileListStream = new BufferedStream(File.Open(m_placenameListFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)))
			using( BinaryReader placenameFileListReader = new BinaryReader(placenameFileListStream, System.Text.Encoding.ASCII))
			{
				int count = placenameFileListReader.ReadInt32();
				for (int i = 0; i < count; i++)
				{
					WorldWindPlacenameFile wwpf = new WorldWindPlacenameFile();
					wwpf.dataFilename = placenameFileListReader.ReadString();
					wwpf.west = placenameFileListReader.ReadSingle();
					wwpf.south = placenameFileListReader.ReadSingle();
					wwpf.east = placenameFileListReader.ReadSingle();
					wwpf.north = placenameFileListReader.ReadSingle();
					m_placenameFileList.Add(wwpf);
				}
			}
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:41,代码来源:TiledPlacenameSet.cs


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