⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diagnostic.cs

📁 功能:基于windows mobile 的地图查看器。使用vs2005开发
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
//using System.Collections;

using Microsoft.WindowsMobile.DirectX;
using Microsoft.WindowsMobile.DirectX.Direct3D;

namespace cfWorldWind
{
	class Diagnostic
	{
		private Microsoft.WindowsMobile.DirectX.Direct3D.Font dispFont = null;
		private Rectangle rect = new Rectangle(0, 0, 240, 320);
		private Dictionary<string, string> hashtable = new Dictionary<string, string>();
		private static Diagnostic instance;

		private Diagnostic(Device device)
		{
			System.Drawing.Font f = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular);
			dispFont = new Microsoft.WindowsMobile.DirectX.Direct3D.Font(device, f);
			rect.X = device.Viewport.X;
			rect.Y = device.Viewport.Y;
			rect.Width = device.Viewport.Width;
			rect.Height = device.Viewport.Height;
		}

		public static Diagnostic Instance(Device device)
		{
			if (instance == null)
			{
				instance = new Diagnostic(device);
			}
			return instance;
		}

		public Dictionary<string,string> Items
		{
			get
			{
				return hashtable;
			}
			set
			{
				hashtable = value;
			}
		}

		public void Add(string name, object value)
		{
			Add(name, value.ToString());
		}

		public void Add(string name, string value)
		{
			if (hashtable.ContainsKey(name) == true)
			{
				hashtable[name] = value;
			}
			else
			{
				hashtable.Add(name, value);
			}
		}

		public void Render()
		{
			DrawTextFormat textFormat = DrawTextFormat.Bottom | DrawTextFormat.Right;
			string val = String.Empty;
			int count = 1;
			foreach (string key in hashtable.Keys)
			{
				val = val + key + ": " + hashtable[key].ToString();
				if (count < hashtable.Count)
				{
					val = val + "\r\n";
				}
				count = count + 1;
			}
			dispFont.DrawText(null, val, rect, textFormat, System.Drawing.Color.Red);
		}

		public void Dispose()
		{
			if (dispFont != null)
			{
				dispFont.Dispose();
				dispFont = null;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -