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


C# DrawArgs.CreateFont方法代码示例

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


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

示例1: RenderContents

		public override void RenderContents(DrawArgs drawArgs)
		{
			m_DrawArgs = drawArgs;
			try
			{
				if(itemFont == null)
				{
					itemFont = drawArgs.CreateFont( World.Settings.LayerManagerFontName, 
						World.Settings.LayerManagerFontSize, World.Settings.LayerManagerFontStyle );

					// TODO: Fix wingdings menu problems
					System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold);
					headerFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);

					System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f);
					wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings);

					AddFontResource(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
					System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection();
					fpc.AddFontFile(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
					System.Drawing.Font worldwinddings = new System.Drawing.Font(fpc.Families[0], 12.0f);
					worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, worldwinddings);
				}

				this.updateList();
				
				this.worldwinddingsFont.DrawText(
					null,
					"E",
					new System.Drawing.Rectangle(this.Right - 16, this.Top + 2, 20, topBorder),
					DrawTextFormat.None,
					TextColor);

				int numItems = GetNumberOfUncollapsedItems();
				int totalHeight = GetItemsHeight(drawArgs);//numItems * ItemHeight;
				showScrollbar = totalHeight > ClientHeight;
				if(showScrollbar)
				{
					double percentHeight = (double)ClientHeight / totalHeight;
					int scrollbarHeight = (int)(ClientHeight * percentHeight);

					int maxScroll = totalHeight-ClientHeight;

					if(scrollBarPosition < 0)
						scrollBarPosition = 0;
					else if(scrollBarPosition > maxScroll)
						scrollBarPosition = maxScroll;

					// Smooth scroll
					const float scrollSpeed = 0.3f;
					float smoothScrollDelta = (scrollBarPosition - scrollSmoothPosition)*scrollSpeed;
					float absDelta = Math.Abs(smoothScrollDelta);
					if(absDelta > 100f || absDelta < 3f) 
						// Scroll > 100 pixels and < 1.5 pixels faster
						smoothScrollDelta = (scrollBarPosition - scrollSmoothPosition)*(float)Math.Sqrt(scrollSpeed);
					
					scrollSmoothPosition += smoothScrollDelta;

					if(scrollSmoothPosition > maxScroll)
						scrollSmoothPosition = maxScroll;

					int scrollPos = (int)((float)percentHeight * scrollBarPosition );

					int color = isScrolling ? World.Settings.scrollbarHotColor : World.Settings.scrollbarColor;
					MenuUtils.DrawBox(
						Right - ScrollBarSize + 2,
						ClientTop + scrollPos,
						ScrollBarSize - 3,
						scrollbarHeight + 1,
						0.0f,
						color,
						drawArgs.device);

					scrollbarLine[0].X = this.Right - ScrollBarSize;
					scrollbarLine[0].Y = this.ClientTop;
					scrollbarLine[1].X = this.Right - ScrollBarSize;
					scrollbarLine[1].Y = this.Bottom;
					MenuUtils.DrawLine(scrollbarLine, 
						DialogColor,
						drawArgs.device);
				}

				this.headerFont.DrawText(
					null, "Layer Manager",
					new System.Drawing.Rectangle( Left+5, Top+1, Width, topBorder-2 ),
					DrawTextFormat.VerticalCenter, TextColor);

				Microsoft.DirectX.Vector2[] headerLinePoints = new Microsoft.DirectX.Vector2[2];
				headerLinePoints[0].X = this.Left;
				headerLinePoints[0].Y = this.Top + topBorder - 1;

				headerLinePoints[1].X = this.Right;
				headerLinePoints[1].Y = this.Top + topBorder - 1;

				MenuUtils.DrawLine(headerLinePoints, DialogColor, drawArgs.device);

				int runningItemHeight = 0;
				if( showScrollbar )
					runningItemHeight = -(int)Math.Round(scrollSmoothPosition);

//.........这里部分代码省略.........
开发者ID:jpespartero,项目名称:WorldWind,代码行数:101,代码来源:Menu.cs

示例2: Initialize

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

            m_drawingFont = drawArgs.CreateFont(m_fontDescription);
            if (!File.Exists(m_placenameListFilePath)) {
                this.Inited = true;
                Log.Write("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 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, Encoding.UTF8)) {
                    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:beginor,项目名称:WorldWind,代码行数:37,代码来源:TiledPlacenameSet.cs


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