WalkLtDemoHelp.cpp 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531
  1. //Download by http://www.NewXing.com
  2. // WalkLtDemoHelp.cpp
  3. //
  4. #include "stdafx.h"
  5. #include "WalkLtDemo.h"
  6. #include "WalkLtDemoHelp.h"
  7. #include "GdiplusDemoFuns.h"
  8. #include <math.h>
  9. #include <io.h>
  10. //屏蔽 4244 编译警告
  11. #pragma warning( disable : 4244 )
  12. CWideCharString::CWideCharString()
  13. {
  14. m_nBufferLen=0;
  15. m_pBuffer=new WCHAR [m_nBufferLen+1];
  16. m_pBuffer[0]=0;
  17. }
  18. CWideCharString::CWideCharString(LPCWSTR widestring, int len)
  19. {
  20. if(widestring)
  21. m_nBufferLen=wcslen(widestring);
  22. else
  23. m_nBufferLen=0;
  24. if(len<m_nBufferLen && len>=0){
  25. m_nBufferLen=len;
  26. }
  27. m_pBuffer=new WCHAR [m_nBufferLen+1];
  28. if(widestring)
  29. wcsncpy(m_pBuffer, widestring,m_nBufferLen);
  30. m_pBuffer[m_nBufferLen]=0;
  31. }
  32. CWideCharString::CWideCharString(const CWideCharString& wcString)
  33. {
  34. m_nBufferLen=wcString.m_nBufferLen;
  35. m_pBuffer=new WCHAR [m_nBufferLen+1];
  36. wcscpy(m_pBuffer,wcString.m_pBuffer);
  37. }
  38. CWideCharString::CWideCharString(const char* lpszString, int len)
  39. {
  40. if(!lpszString){
  41. m_nBufferLen=0;
  42. m_pBuffer=new WCHAR [1];
  43. m_pBuffer[0]=0;
  44. return;
  45. }
  46. int srclen=strlen(lpszString);
  47. if(len < srclen && len >=0){
  48. srclen=len;
  49. }
  50. m_nBufferLen=srclen;
  51. m_pBuffer=new WCHAR[m_nBufferLen+1];
  52. m_nBufferLen=MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpszString,srclen,m_pBuffer,m_nBufferLen+1);
  53. m_pBuffer[m_nBufferLen]=0;
  54. }
  55. CWideCharString::~CWideCharString()
  56. {
  57. if(m_pBuffer)
  58. delete[] m_pBuffer;
  59. }
  60. CWideCharString& CWideCharString::operator=(const CWideCharString& wcString)
  61. {
  62. if(this == &wcString)
  63. return *this;
  64. if(m_pBuffer)
  65. delete[] m_pBuffer;
  66. m_nBufferLen=wcString.m_nBufferLen;
  67. m_pBuffer=new WCHAR [m_nBufferLen+1];
  68. wcscpy(m_pBuffer,wcString.m_pBuffer);
  69. return *this;
  70. }
  71. CWideCharString& CWideCharString::operator =(const char* lpszString)
  72. {
  73. if(lpszString==NULL){
  74. m_nBufferLen=0;
  75. if(!m_pBuffer){
  76. m_pBuffer=new WCHAR [m_nBufferLen+1];
  77. }
  78. m_pBuffer[0]=0;
  79. return *this;
  80. }
  81. int srclen=strlen(lpszString);
  82. m_nBufferLen=srclen;
  83. if(m_pBuffer)
  84. delete[] m_pBuffer;
  85. m_pBuffer=new WCHAR[m_nBufferLen+1];
  86. m_nBufferLen=MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpszString,srclen,m_pBuffer,m_nBufferLen+1);
  87. m_pBuffer[m_nBufferLen]=0;
  88. return *this;
  89. }
  90. CWideCharString CWideCharString::Mid(int begin,int len)
  91. {
  92. if (len<0) len=GetLength();
  93. if(begin+len>m_nBufferLen)
  94. len=m_nBufferLen-begin;
  95. return CWideCharString(m_pBuffer+begin,len);
  96. }
  97. BOOL CWideCharString::operator == (const CWideCharString& wcString)
  98. {
  99. return (wcscmp(m_pBuffer,wcString.m_pBuffer)==0);
  100. }
  101. BOOL CWideCharString::operator != (const CWideCharString& wcString)
  102. {
  103. return (wcscmp(m_pBuffer,wcString.m_pBuffer)!=0);
  104. }
  105. WCHAR CWideCharString::operator[] (int index) const
  106. {
  107. if(index<0 || index>=m_nBufferLen)
  108. return 0;
  109. return m_pBuffer[index];
  110. }
  111. WCHAR& CWideCharString::operator[] (int index)
  112. {
  113. if(index<0 || index>=m_nBufferLen){
  114. static WCHAR w=0;
  115. return w;
  116. }
  117. return m_pBuffer[index];
  118. }
  119. CWideCharString CWideCharString::operator + (const CWideCharString& wcString)
  120. {
  121. int totalLen=m_nBufferLen+wcString.m_nBufferLen;
  122. WCHAR* pBuf=new WCHAR[totalLen+1];
  123. wcscpy(pBuf,m_pBuffer);
  124. wcscat(pBuf+m_nBufferLen,wcString.m_pBuffer);
  125. CWideCharString ret(pBuf);
  126. delete[] pBuf;
  127. return ret;
  128. }
  129. CWideCharString& CWideCharString::operator += (const CWideCharString& wcString)
  130. {
  131. int totalLen=m_nBufferLen+wcString.m_nBufferLen;
  132. WCHAR* pTempBuf=new WCHAR[totalLen+1];
  133. wcscpy(pTempBuf,m_pBuffer);
  134. wcscat(pTempBuf+m_nBufferLen,wcString.m_pBuffer);
  135. delete[] m_pBuffer;
  136. m_pBuffer=pTempBuf;
  137. m_nBufferLen=totalLen;
  138. return *this;
  139. }
  140. Status MyDrawString(Graphics &graphics, const TCHAR *str, const Font &font, const Brush &brush, const PointF &origin)
  141. {
  142. CWideCharString string(str, strlen(str));
  143. return graphics.DrawString(string, wcslen(string), &font, origin, &brush);
  144. }
  145. Status MyDrawString(Graphics &graphics, const TCHAR *str, const Font &font, const Brush &brush, const PointF &origin, StringFormat &fmt)
  146. {
  147. CWideCharString string(str, strlen(str));
  148. return graphics.DrawString(string, wcslen(string), &font, origin, &fmt, &brush);
  149. }
  150. Status MyDrawString(Graphics &graphics, const TCHAR *str, const Font &font, const Brush &brush, const Point &origin)
  151. {
  152. CWideCharString string(str, strlen(str));
  153. return graphics.DrawString(string, wcslen(string), &font, PointF(origin.X,origin.Y), &brush);
  154. }
  155. Status MyDrawString(Graphics &graphics, const TCHAR *str, const Font &font, const Brush &brush, const RectF &rect, StringFormat &fmt)
  156. {
  157. CWideCharString string(str, strlen(str));
  158. return graphics.DrawString(string, wcslen(string), &font, rect, &fmt, &brush);
  159. }
  160. Status MyDrawString(Graphics &graphics, const TCHAR *str, const Font &font, const Brush &brush, const Rect &rect, StringFormat &fmt)
  161. {
  162. CWideCharString string(str, strlen(str));
  163. RectF r(rect.X, rect.Y, rect.Width, rect.Height);
  164. return graphics.DrawString(string, wcslen(string), &font, r, &fmt, &brush);
  165. }
  166. void MyImageSave(Bitmap &im, const WCHAR* filename, const GUID* clsid, const EncoderParameters *en)
  167. {
  168. CString file= filename;
  169. if (0==::_access(file, 0))
  170. ::DeleteFile(file);
  171. im.Save(filename, clsid, en);
  172. }
  173. Color _MakeA_RGB(int a, Color cl)
  174. {
  175. return Color(a, cl.GetR(), cl.GetG(), cl.GetB());
  176. }
  177. Color _MakeA_RGB(int r, int g, int b)
  178. {
  179. return Color(255, r, g, b);
  180. }
  181. int rand_Next(int bound)
  182. {
  183. ::srand( (unsigned)time( NULL ) );
  184. return ::rand()/bound;
  185. }
  186. void FillGdiplusFuns(CTreeCtrl &tree)
  187. {
  188. HTREEITEM ch1, ch2, ch, ch0=TVI_ROOT;
  189. CString txt0, txt1, txt2;
  190. int index1=0, index2=0;
  191. tree.SetItemText(ch0, "Gdi+演示");
  192. //-------------------------------------------------------------
  193. txt1 = "画笔";
  194. ch1 = tree.InsertItem(txt1, ch0);
  195. index1 = 0x0100;
  196. txt2 = "从画刷中构造画笔";
  197. ch2 = tree.InsertItem(txt2, ch1);
  198. index2 = 1; //CreatePenFromBrush_Click;
  199. tree.SetItemData(ch2, index1+index2);
  200. txt2 = "自定义线型";
  201. ch2 = tree.InsertItem(txt2, ch1);
  202. index2 = 2; //DashStyle_Custom_Click
  203. tree.SetItemData(ch2, index1+index2);
  204. txt2 = "画笔的对齐方式";
  205. ch2 = tree.InsertItem(txt2, ch1);
  206. index2 = 3; //Pen_Align_Click);
  207. tree.SetItemData(ch2, index1+index2);
  208. txt2 = "画笔的缩放与旋转";
  209. ch2 = tree.InsertItem(txt2, ch1);
  210. index2 = 4; //Pen_Tranform_Click);
  211. tree.SetItemData(ch2, index1+index2);
  212. txt2 = "画笔的线帽属性";
  213. ch2 = tree.InsertItem(txt2, ch1);
  214. index2 = 5; //Pen_LineCap_Click);
  215. tree.SetItemData(ch2, index1+index2);
  216. txt2 = "画笔的透明度支持";
  217. ch2 = tree.InsertItem(txt2, ch1);
  218. index2 = 6; //Pen_TransColor_Click);
  219. tree.SetItemData(ch2, index1+index2);
  220. //-------------------------------------------------------------
  221. txt1 = "画刷";
  222. ch = tree.InsertItem(txt1, ch0);
  223. index1 = 0x0200;
  224. ch1 = tree.InsertItem("单色画刷的使用", ch);
  225. txt2 = "简单的单色画刷";
  226. ch2 = tree.InsertItem(txt2, ch1);
  227. index2 = 1; //Brush_SolidBrush_Click);
  228. tree.SetItemData(ch2, index1+index2);
  229. txt2 = "填充正叶曲线";
  230. ch2 = tree.InsertItem(txt2, ch1);
  231. index2 = 2; //Brush_FillVurve_Click);
  232. tree.SetItemData(ch2, index1+index2);
  233. ch1 = tree.InsertItem("影线画刷的使用", ch);
  234. txt2 = "影线画刷";
  235. ch2 = tree.InsertItem(txt2, ch1);
  236. index2 = 3; //Brush_HatchBrush_Click);
  237. tree.SetItemData(ch2, index1+index2);
  238. txt2 = "枚举所有影线画刷风格";
  239. ch2 = tree.InsertItem(txt2, ch1);
  240. index2 = 4; //Brush_EnumAllStyle_Click);
  241. tree.SetItemData(ch2, index1+index2);
  242. txt2 = "设置绘制原点";
  243. ch2 = tree.InsertItem(txt2, ch1);
  244. index2 = 5; //Brush_SetRenderingOrigin_Click);
  245. tree.SetItemData(ch2, index1+index2);
  246. ch1 = tree.InsertItem("纹理画刷", ch);
  247. txt2 = "纹理画刷的基本使用";
  248. ch2 = tree.InsertItem(txt2, ch1);
  249. index2 = 6; //Brush_Texture_Click);
  250. tree.SetItemData(ch2, index1+index2);
  251. txt2 = "纹理画刷的排列方式";
  252. ch2 = tree.InsertItem(txt2, ch1);
  253. index2 = 7; //Brush_Texture_WrapMode_Click);
  254. tree.SetItemData(ch2, index1+index2);
  255. txt2 = "纹理画刷的变换";
  256. ch2 = tree.InsertItem(txt2, ch1);
  257. index2 = 8; //Brush_TextureTransform_Click);
  258. tree.SetItemData(ch2, index1+index2);
  259. txt2 = "查询画刷的变换信息";
  260. ch2 = tree.InsertItem(txt2, ch1);
  261. index2 = 9; //Brush_GetTextureMatrix_Click);
  262. tree.SetItemData(ch2, index1+index2);
  263. ch1 = tree.InsertItem("线性渐变画刷的使用", ch);
  264. txt2 = "线性渐变画刷";
  265. ch2 = tree.InsertItem(txt2, ch1);
  266. index2 = 10; //Brush_LinearGradientBrush_Click);
  267. tree.SetItemData(ch2, index1+index2);
  268. txt2 = "渐变画刷的不同填充方式";
  269. ch2 = tree.InsertItem(txt2, ch1);
  270. index2 = 11; //Brush_LinearArrange_Click);
  271. tree.SetItemData(ch2, index1+index2);
  272. txt2 = "多色渐变画刷";
  273. ch2 = tree.InsertItem(txt2, ch1);
  274. index2 = 12; //Brush_LinearInterpolation_Click);
  275. tree.SetItemData(ch2, index1+index2);
  276. txt2 = "使用渐变画刷的渐变模式";
  277. ch2 = tree.InsertItem(txt2, ch1);
  278. index2 = 13; //Brush_LinearGradientMode_Click);
  279. tree.SetItemData(ch2, index1+index2);
  280. txt2 = "调整渐变线偏转角度";
  281. ch2 = tree.InsertItem(txt2, ch1);
  282. index2 = 14; //Brush_LinearAngle_Click);
  283. tree.SetItemData(ch2, index1+index2);
  284. txt2 = "自定义线性渐变画刷的渐变过程";
  285. ch2 = tree.InsertItem(txt2, ch1);
  286. index2 = 15; //Brush_LinearCustomize_Click);
  287. tree.SetItemData(ch2, index1+index2);
  288. txt2 = "钟形曲线渐变";
  289. ch2 = tree.InsertItem(txt2, ch1);
  290. index2 = 16; //Brush_LinearGradientBrush_BellShape_Click);
  291. tree.SetItemData(ch2, index1+index2);
  292. txt2 = "启用Gamma校正";
  293. ch2 = tree.InsertItem(txt2, ch1);
  294. index2 = 17; //Brsuh_LinearGradientBrush_UsingGamma_Click);
  295. tree.SetItemData(ch2, index1+index2);
  296. ch1 = tree.InsertItem("路径渐变画刷", ch);
  297. txt2 = "构造五星";
  298. ch2 = tree.InsertItem(txt2, ch1);
  299. index2 = 18; //Brush_PathGradientBrush_Star_Click);
  300. tree.SetItemData(ch2, index1+index2);
  301. txt2 = "构造五星(2)";
  302. ch2 = tree.InsertItem(txt2, ch1);
  303. index2 = 19; //Brush_PathGradientBrush_Star2_Click);
  304. tree.SetItemData(ch2, index1+index2);
  305. txt2 = "使用不同的路径渐变画刷";
  306. ch2 = tree.InsertItem(txt2, ch1);
  307. index2 = 20; //Brush_Using_MorePathGradientBrush_Click);
  308. tree.SetItemData(ch2, index1+index2);
  309. txt2 = "路径渐变画刷的排列方式";
  310. ch2 = tree.InsertItem(txt2, ch1);
  311. index2 = 21; //Brush_PathGradientBrush_WrapMode_Click);
  312. tree.SetItemData(ch2, index1+index2);
  313. txt2 = "更改路径渐变画刷的中心点";
  314. ch2 = tree.InsertItem(txt2, ch1);
  315. index2 = 22; //Brush_PathGradientBrush_CenterPoint_Click);
  316. tree.SetItemData(ch2, index1+index2);
  317. txt2 = "使用多色渐变";
  318. ch2 = tree.InsertItem(txt2, ch1);
  319. index2 = 23; //Brush_PathGradientBrush_InterpolationColors_Click);
  320. tree.SetItemData(ch2, index1+index2);
  321. txt2 = "更改画刷的焦点缩放比例";
  322. ch2 = tree.InsertItem(txt2, ch1);
  323. index2 = 24; //Brsuh_PathGradietBrush_Focus_Click);
  324. tree.SetItemData(ch2, index1+index2);
  325. txt2 = "路径渐变画刷的变换";
  326. ch2 = tree.InsertItem(txt2, ch1);
  327. index2 = 25; //Brush_PathGradientBrush_Transform_Click);
  328. tree.SetItemData(ch2, index1+index2);
  329. //-------------------------------------------------------------
  330. txt1 = "文本与字体";
  331. ch1 = tree.InsertItem(txt1, ch0);
  332. index1 = 0x0300;
  333. txt2 = "在GDI+中使用字体(&A)";
  334. ch2 = tree.InsertItem(txt2, ch1);
  335. index2 = 1; //Font_UsingFontInGDIPlus_Click);
  336. tree.SetItemData(ch2, index1+index2);
  337. txt2 = "获取已安装的字体";
  338. ch2 = tree.InsertItem(txt2, ch1);
  339. index2 = 2; //Font_EnumAllFonts_Click);
  340. tree.SetItemData(ch2, index1+index2);
  341. txt2 = "增强型字体选择对话框";
  342. ch2 = tree.InsertItem(txt2, ch1);
  343. index2 = 3; //Font_EnhanceFontDialog_Click);
  344. tree.SetItemData(ch2, index1+index2);
  345. txt2 = "设置字体的边缘处理方式";
  346. ch2 = tree.InsertItem(txt2, ch1);
  347. index2 = 4; //Font_UsingTextRenderHint_Click);
  348. tree.SetItemData(ch2, index1+index2);
  349. txt2 = "使用私有字体集合";
  350. ch2 = tree.InsertItem(txt2, ch1);
  351. index2 = 5; //Font_Privatefontcollection_Click);
  352. tree.SetItemData(ch2, index1+index2);
  353. txt2 = "在私有字体集合中使用多个字体";
  354. ch2 = tree.InsertItem(txt2, ch1);
  355. index2 = 6; //Font_Privatefontcollection2_Click);
  356. tree.SetItemData(ch2, index1+index2);
  357. txt2 = "在私有字体集合中检查字体信息的可用性";
  358. ch2 = tree.InsertItem(txt2, ch1);
  359. index2 = 7; //Font_IsStyleAvailable_Click);
  360. tree.SetItemData(ch2, index1+index2);
  361. txt2 = "在程序中访问字体(系列)的大小信息";
  362. ch2 = tree.InsertItem(txt2, ch1);
  363. index2 = 8; //Font_Size_Click);
  364. tree.SetItemData(ch2, index1+index2);
  365. txt2 = "设置文本输出的基线";
  366. ch2 = tree.InsertItem(txt2, ch1);
  367. index2 = 9; //Font_BaseLine_Click);
  368. tree.SetItemData(ch2, index1+index2);
  369. txt2 = "使用GDI+绘制文本";
  370. ch2 = tree.InsertItem(txt2, ch1);
  371. index2 = 10; //Font_DrawString_Click);
  372. tree.SetItemData(ch2, index1+index2);
  373. txt2 = "测量文本";
  374. ch2 = tree.InsertItem(txt2, ch1);
  375. index2 = 11; //Font_MeasureString_Click);
  376. tree.SetItemData(ch2, index1+index2);
  377. txt2 = "计算指定区域中能够显示的字符总数及行数";
  378. ch2 = tree.InsertItem(txt2, ch1);
  379. index2 = 12; //Font_MeasureString2_Click);
  380. tree.SetItemData(ch2, index1+index2);
  381. txt2 = "实现文件的分栏显示";
  382. ch2 = tree.InsertItem(txt2, ch1);
  383. index2 = 13; //Font_ColumnTextOut_Click);
  384. tree.SetItemData(ch2, index1+index2);
  385. txt2 = "字符串的去尾";
  386. ch2 = tree.InsertItem(txt2, ch1);
  387. index2 = 14; //Font_StirngTrimming_Click);
  388. tree.SetItemData(ch2, index1+index2);
  389. txt2 = "文本输出的剪裁修正";
  390. ch2 = tree.InsertItem(txt2, ch1);
  391. index2 = 15; //Font_TextOutClip_Click);
  392. tree.SetItemData(ch2, index1+index2);
  393. txt2 = "测量文本的局部输出区域";
  394. ch2 = tree.InsertItem(txt2, ch1);
  395. index2 = 16; //Font_MeasureCharacterRanges_Click);
  396. tree.SetItemData(ch2, index1+index2);
  397. txt2 = "控制文本输出方向";
  398. ch2 = tree.InsertItem(txt2, ch1);
  399. index2 = 17; //Font_TextoutDirection_Click);
  400. tree.SetItemData(ch2, index1+index2);
  401. txt2 = "设置文本对齐方式";
  402. ch2 = tree.InsertItem(txt2, ch1);
  403. index2 = 18; //Font_TextAlignment_Click);
  404. tree.SetItemData(ch2, index1+index2);
  405. txt2 = "设置文本对齐方式(2)";
  406. ch2 = tree.InsertItem(txt2, ch1);
  407. index2 = 19; //Font_TextAlignment2_Click);
  408. tree.SetItemData(ch2, index1+index2);
  409. txt2 = "设置和获取制表符信息";
  410. ch2 = tree.InsertItem(txt2, ch1);
  411. index2 = 20; //Font_TextoutUsingTabs_Click);
  412. tree.SetItemData(ch2, index1+index2);
  413. txt2 = "使用制表位进行表格输出";
  414. ch2 = tree.InsertItem(txt2, ch1);
  415. index2 = 21; //Font_UsingTabs_Click);
  416. tree.SetItemData(ch2, index1+index2);
  417. txt2 = "快捷键前导字符显示";
  418. ch2 = tree.InsertItem(txt2, ch1);
  419. index2 = 22; //Font_TextoutHotkeyPrefix_Click);
  420. tree.SetItemData(ch2, index1+index2);
  421. txt2 = "阴影字特效";
  422. ch2 = tree.InsertItem(txt2, ch1);
  423. index2 = 23; //Font_TextoutShadow_Click);
  424. tree.SetItemData(ch2, index1+index2);
  425. txt2 = "使用影线画刷绘制文本";
  426. ch2 = tree.InsertItem(txt2, ch1);
  427. index2 = 24; //Font_TextoutHashline_Click);
  428. tree.SetItemData(ch2, index1+index2);
  429. txt2 = "绘制纹理字";
  430. ch2 = tree.InsertItem(txt2, ch1);
  431. index2 = 25; //Font_TextoutTexture_Click);
  432. tree.SetItemData(ch2, index1+index2);
  433. txt2 = "使用渐变画刷绘制文本";
  434. ch2 = tree.InsertItem(txt2, ch1);
  435. index2 = 26; //Font_TextoutGradient_Click);
  436. tree.SetItemData(ch2, index1+index2);
  437. //-------------------------------------------------------------
  438. txt1 = "路径和区域";
  439. ch1 = tree.InsertItem(txt1, ch0);
  440. index1 = 0x0400;
  441. txt2 = "构造路径";
  442. ch2 = tree.InsertItem(txt2, ch1);
  443. index2 = 1; //Path_Construct_Click);
  444. tree.SetItemData(ch2, index1+index2);
  445. txt2 = "在路径中添加多条线段";
  446. ch2 = tree.InsertItem(txt2, ch1);
  447. index2 = 2; //Path_AddLines_Click);
  448. tree.SetItemData(ch2, index1+index2);
  449. txt2 = "封闭图形";
  450. ch2 = tree.InsertItem(txt2, ch1);
  451. index2 = 3; //Path_CloseFigure_Click);
  452. tree.SetItemData(ch2, index1+index2);
  453. txt2 = "路径的填充";
  454. ch2 = tree.InsertItem(txt2, ch1);
  455. index2 = 4; //Path_FillPath_Click);
  456. tree.SetItemData(ch2, index1+index2);
  457. txt2 = "添加子路径";
  458. ch2 = tree.InsertItem(txt2, ch1);
  459. index2 = 5; //Path_AddSubPath_Click);
  460. tree.SetItemData(ch2, index1+index2);
  461. txt2 = "GraphicsPathIterator的基本使用";
  462. ch2 = tree.InsertItem(txt2, ch1);
  463. index2 = 6; //Path_GetSubPath_Click);
  464. tree.SetItemData(ch2, index1+index2);
  465. txt2 = "访问路径的点信息";
  466. ch2 = tree.InsertItem(txt2, ch1);
  467. index2 = 7; //Path_GetPoints_Click);
  468. tree.SetItemData(ch2, index1+index2);
  469. txt2 = "同时获取端点坐标及类型信息";
  470. ch2 = tree.InsertItem(txt2, ch1);
  471. index2 = 8; //Path_PathData_Click);
  472. tree.SetItemData(ch2, index1+index2);
  473. txt2 = "查看路径端点的标记信息";
  474. ch2 = tree.InsertItem(txt2, ch1);
  475. index2 = 9; //Path_ViewPointFLAG_Click);
  476. tree.SetItemData(ch2, index1+index2);
  477. txt2 = "标记路径区间";
  478. ch2 = tree.InsertItem(txt2, ch1);
  479. index2 = 10; //Path_SubPathRange_Click);
  480. tree.SetItemData(ch2, index1+index2);
  481. txt2 = "路径的展平";
  482. ch2 = tree.InsertItem(txt2, ch1);
  483. index2 = 11; //Path_Flatten_Click);
  484. tree.SetItemData(ch2, index1+index2);
  485. txt2 = "路径的扭曲";
  486. ch2 = tree.InsertItem(txt2, ch1);
  487. index2 = 12; //Path_Warp_Click);
  488. tree.SetItemData(ch2, index1+index2);
  489. txt2 = "路径的线性变换";
  490. ch2 = tree.InsertItem(txt2, ch1);
  491. index2 = 13; //Path_Transform_Click);
  492. tree.SetItemData(ch2, index1+index2);
  493. txt2 = "路径的拓宽";
  494. ch2 = tree.InsertItem(txt2, ch1);
  495. index2 = 14; //Path_Widen_Click);
  496. tree.SetItemData(ch2, index1+index2);
  497. txt2 = "路径的拓宽处理原理演示";
  498. ch2 = tree.InsertItem(txt2, ch1);
  499. index2 = 15; //Path_WidenDemo_Click);
  500. tree.SetItemData(ch2, index1+index2);
  501. txt2 = "从路径中创建文本区域";
  502. ch2 = tree.InsertItem(txt2, ch1);
  503. index2 = 16; //Region_FromPath_Click);
  504. tree.SetItemData(ch2, index1+index2);
  505. txt2 = "区域的运算";
  506. ch2 = tree.InsertItem(txt2, ch1);
  507. index2 = 17; //Region_Calculate_Click);
  508. tree.SetItemData(ch2, index1+index2);
  509. txt2 = "获取区域的组成矩形集";
  510. ch2 = tree.InsertItem(txt2, ch1);
  511. index2 = 18; //Region_GetRects_Click);
  512. tree.SetItemData(ch2, index1+index2);
  513. //-------------------------------------------------------------
  514. txt1 = "GDI+的坐标变换";
  515. ch1 = tree.InsertItem(txt1, ch0);
  516. index1 = 0x0500;
  517. txt2 = "在GDI+使用坐标变换";
  518. ch2 = tree.InsertItem(txt2, ch1);
  519. index2 = 1; //Transform_Click);
  520. tree.SetItemData(ch2, index1+index2);
  521. txt2 = "平移变换的实现";
  522. ch2 = tree.InsertItem(txt2, ch1);
  523. index2 = 2; //TranslateTransform_Click);
  524. tree.SetItemData(ch2, index1+index2);
  525. txt2 = "旋转图片";
  526. ch2 = tree.InsertItem(txt2, ch1);
  527. index2 = 3; //RotateTransform_Click);
  528. tree.SetItemData(ch2, index1+index2);
  529. txt2 = "汽车里程表的绘制";
  530. ch2 = tree.InsertItem(txt2, ch1);
  531. index2 = 4; //DrawWatch_Click);
  532. tree.SetItemData(ch2, index1+index2);
  533. txt2 = "缩放变换的使用";
  534. ch2 = tree.InsertItem(txt2, ch1);
  535. index2 = 5; //ScaleTransform_Click);
  536. tree.SetItemData(ch2, index1+index2);
  537. txt2 = "矩形对象的缩放";
  538. ch2 = tree.InsertItem(txt2, ch1);
  539. index2 = 6; //RectScale_Click);
  540. tree.SetItemData(ch2, index1+index2);
  541. txt2 = "在GDI+中旋转输出文本";
  542. ch2 = tree.InsertItem(txt2, ch1);
  543. index2 = 7; //FontRotate_Click);
  544. tree.SetItemData(ch2, index1+index2);
  545. txt2 = "查看矩阵的组成元素";
  546. ch2 = tree.InsertItem(txt2, ch1);
  547. index2 = 8; //Matrix_ListElements_Click_1);
  548. tree.SetItemData(ch2, index1+index2);
  549. txt2 = "使用矩阵的前置与后缀";
  550. ch2 = tree.InsertItem(txt2, ch1);
  551. index2 = 9; //MatrixPos_Click);
  552. tree.SetItemData(ch2, index1+index2);
  553. txt2 = "逆矩阵在变换中的运用";
  554. ch2 = tree.InsertItem(txt2, ch1);
  555. index2 = 10; //Martrix_Invert_Click);
  556. tree.SetItemData(ch2, index1+index2);
  557. txt2 = "使用复合变换";
  558. ch2 = tree.InsertItem(txt2, ch1);
  559. index2 = 11; //Matrix_Multiply_Click);
  560. tree.SetItemData(ch2, index1+index2);
  561. txt2 = "使用矩阵批量修改点信息";
  562. ch2 = tree.InsertItem(txt2, ch1);
  563. index2 = 12; //Matrix_TransformPoints_Click);
  564. tree.SetItemData(ch2, index1+index2);
  565. txt2 = "使用TransformPoints函数实现路径的变换";
  566. ch2 = tree.InsertItem(txt2, ch1);
  567. index2 = 13; //Matrix_TransformPoints2_Click);
  568. tree.SetItemData(ch2, index1+index2);
  569. txt2 = "普通矩阵运算与二维向量的矩阵运算";
  570. ch2 = tree.InsertItem(txt2, ch1);
  571. index2 = 14; //Matrix_TransformVectors_Click);
  572. tree.SetItemData(ch2, index1+index2);
  573. txt2 = "使用RotateAt函数";
  574. ch2 = tree.InsertItem(txt2, ch1);
  575. index2 = 15; //Matrix_RotateAt_Click);
  576. tree.SetItemData(ch2, index1+index2);
  577. txt2 = "使用不同的投射变换显示图片";
  578. ch2 = tree.InsertItem(txt2, ch1);
  579. index2 = 16; //Matrix_Shear_Click);
  580. tree.SetItemData(ch2, index1+index2);
  581. txt2 = "投影字的特效输出";
  582. ch2 = tree.InsertItem(txt2, ch1);
  583. index2 = 17; //Matrix_TextoutShear_Click);
  584. tree.SetItemData(ch2, index1+index2);
  585. txt2 = "文字大小渐变输出特效";
  586. ch2 = tree.InsertItem(txt2, ch1);
  587. index2 = 18; //Matrix_ChangeFontHeight_Click);
  588. tree.SetItemData(ch2, index1+index2);
  589. //-------------------------------------------------------------
  590. txt1 = "GDI+的色彩变换";
  591. ch1 = tree.InsertItem(txt1, ch0);
  592. index1 = 0x0600;
  593. txt2 = "启用色彩变换矩阵";
  594. ch2 = tree.InsertItem(txt2, ch1);
  595. index2 = 1; //ColorMatrix_Start_Click);
  596. tree.SetItemData(ch2, index1+index2);
  597. txt2 = "色彩平移运算";
  598. ch2 = tree.InsertItem(txt2, ch1);
  599. index2 = 2; //TranslateColor_Click);
  600. tree.SetItemData(ch2, index1+index2);
  601. txt2 = "色彩的缩放运算";
  602. ch2 = tree.InsertItem(txt2, ch1);
  603. index2 = 3; //ScaleColor_Click);
  604. tree.SetItemData(ch2, index1+index2);
  605. txt2 = "色彩的三种旋转方式";
  606. ch2 = tree.InsertItem(txt2, ch1);
  607. index2 = 4; //RotateColor_Click);
  608. tree.SetItemData(ch2, index1+index2);
  609. txt2 = "色彩的投射变换";
  610. ch2 = tree.InsertItem(txt2, ch1);
  611. index2 = 5; //ColorShear_Click);
  612. tree.SetItemData(ch2, index1+index2);
  613. txt2 = "色彩映射的程序实现";
  614. ch2 = tree.InsertItem(txt2, ch1);
  615. index2 = 6; //ColorRemap_Click);
  616. tree.SetItemData(ch2, index1+index2);
  617. txt2 = "使用色彩变换矩阵实现色彩输出通道";
  618. ch2 = tree.InsertItem(txt2, ch1);
  619. index2 = 7; //SetRGBOutputChannel_Click);
  620. tree.SetItemData(ch2, index1+index2);
  621. //-------------------------------------------------------------
  622. txt1 = "图像的基本处理";
  623. ch1 = tree.InsertItem(txt1, ch0);
  624. index1 = 0x0700;
  625. txt2 = "图元文件中的记录与回放";
  626. ch2 = tree.InsertItem(txt2, ch1);
  627. index2 = 1; //Metafile_Click);
  628. tree.SetItemData(ch2, index1+index2);
  629. txt2 = "图形的剪裁与缩放";
  630. ch2 = tree.InsertItem(txt2, ch1);
  631. index2 = 2; //CroppingAndScaling_Click);
  632. tree.SetItemData(ch2, index1+index2);
  633. txt2 = "使用不同的插值模式控制图形缩放质量";
  634. ch2 = tree.InsertItem(txt2, ch1);
  635. index2 = 3; //UsingInterpolationMode_Click);
  636. tree.SetItemData(ch2, index1+index2);
  637. txt2 = "绘制镜像图片示例";
  638. ch2 = tree.InsertItem(txt2, ch1);
  639. index2 = 4; //RotateFlip_Click);
  640. tree.SetItemData(ch2, index1+index2);
  641. txt2 = "绘制映射图片";
  642. ch2 = tree.InsertItem(txt2, ch1);
  643. index2 = 5; //ImageSkewing_Click);
  644. tree.SetItemData(ch2, index1+index2);
  645. txt2 = "立方体贴图";
  646. ch2 = tree.InsertItem(txt2, ch1);
  647. index2 = 6; //Cubeimage_Click);
  648. tree.SetItemData(ch2, index1+index2);
  649. txt2 = "GDI+中处理缩略图";
  650. ch2 = tree.InsertItem(txt2, ch1);
  651. index2 = 7; //ThumbnailImage_Click);
  652. tree.SetItemData(ch2, index1+index2);
  653. txt2 = "分块显示图片";
  654. ch2 = tree.InsertItem(txt2, ch1);
  655. index2 = 8; //Clone_Click);
  656. tree.SetItemData(ch2, index1+index2);
  657. txt2 = "图片局部放大(缩小)显示";
  658. ch2 = tree.InsertItem(txt2, ch1);
  659. index2 = 9; //Picturescale_Click);
  660. tree.SetItemData(ch2, index1+index2);
  661. //-------------------------------------------------------------
  662. txt1 = "图像色彩信息的调整";
  663. ch1 = tree.InsertItem(txt1, ch0);
  664. index1 = 0x0800;
  665. txt2 = "色彩校正的启用与禁用";
  666. ch2 = tree.InsertItem(txt2, ch1);
  667. index2 = 1; //ImageAttributesSetNoOp_Click);
  668. tree.SetItemData(ch2, index1+index2);
  669. txt2 = "设置不同的色彩调整对象";
  670. ch2 = tree.InsertItem(txt2, ch1);
  671. index2 = 2; //SetColorMatrices_Click);
  672. tree.SetItemData(ch2, index1+index2);
  673. txt2 = "使用色彩配置文件进行色彩校正";
  674. ch2 = tree.InsertItem(txt2, ch1);
  675. index2 = 3; //SetOutputChannelColorProfile_Click);
  676. tree.SetItemData(ch2, index1+index2);
  677. txt2 = "修改Gamma值进行图片输出";
  678. ch2 = tree.InsertItem(txt2, ch1);
  679. index2 = 4; //Gammaadjust_Click);
  680. tree.SetItemData(ch2, index1+index2);
  681. txt2 = "设置色彩输出通道";
  682. ch2 = tree.InsertItem(txt2, ch1);
  683. index2 = 5; //SetOutputChannel_Click);
  684. tree.SetItemData(ch2, index1+index2);
  685. txt2 = "使用关键色";
  686. ch2 = tree.InsertItem(txt2, ch1);
  687. index2 = 6; //Colorkey_Click);
  688. tree.SetItemData(ch2, index1+index2);
  689. txt2 = "阈值运用演示程序";
  690. ch2 = tree.InsertItem(txt2, ch1);
  691. index2 = 7; //Setthreshold_Click);
  692. tree.SetItemData(ch2, index1+index2);
  693. txt2 = "获取色彩校正调色板";
  694. ch2 = tree.InsertItem(txt2, ch1);
  695. index2 = 8; //AdjustedPalette_Click);
  696. tree.SetItemData(ch2, index1+index2);
  697. txt2 = "设置色彩校正的环绕模式和颜色";
  698. ch2 = tree.InsertItem(txt2, ch1);
  699. index2 = 9; //SetWrapMode_Click);
  700. tree.SetItemData(ch2, index1+index2);
  701. //-------------------------------------------------------------
  702. txt1 = "图形的编码与解码";
  703. ch1 = tree.InsertItem(txt1, ch0);
  704. index1 = 0x0900;
  705. txt2 = "输出编码器信息";
  706. ch2 = tree.InsertItem(txt2, ch1);
  707. index2 = 1; //ListAllImageEncoders_Click);
  708. tree.SetItemData(ch2, index1+index2);
  709. txt2 = "输出编码器信息";
  710. ch2 = tree.InsertItem(txt2, ch1);
  711. index2 = 2; //ListImageEncoder_Detail_Click);
  712. tree.SetItemData(ch2, index1+index2);
  713. txt2 = "列出系统可用的解码器信息";
  714. ch2 = tree.InsertItem(txt2, ch1);
  715. index2 = 3; //ListImageDecoder_Click);
  716. tree.SetItemData(ch2, index1+index2);
  717. txt2 = "查看将位图保存为JPEG时需要设置的参数信息";
  718. ch2 = tree.InsertItem(txt2, ch1);
  719. index2 = 4; //GetEncoderParameter_Click);
  720. tree.SetItemData(ch2, index1+index2);
  721. txt2 = "查看所有的编码信息所需的参数列表";
  722. ch2 = tree.InsertItem(txt2, ch1);
  723. index2 = 5; //GetAllEncoderParameter_Click);
  724. tree.SetItemData(ch2, index1+index2);
  725. txt2 = "将BMP文件另存为PNG格式的文件";
  726. ch2 = tree.InsertItem(txt2, ch1);
  727. index2 = 6; //menuItem17_Click);
  728. tree.SetItemData(ch2, index1+index2);
  729. txt2 = "将BMP文件保存为TIF文件";
  730. ch2 = tree.InsertItem(txt2, ch1);
  731. index2 = 7; //SaveBmp2tif_Click);
  732. tree.SetItemData(ch2, index1+index2);
  733. txt2 = "使用不同的压缩质量保存JPEG文件";
  734. ch2 = tree.InsertItem(txt2, ch1);
  735. index2 = 8; //SaveBMP2JPG_Click);
  736. tree.SetItemData(ch2, index1+index2);
  737. txt2 = "JPEG文件的保存与变换";
  738. ch2 = tree.InsertItem(txt2, ch1);
  739. index2 = 9; //TransformingJPEG_Click);
  740. tree.SetItemData(ch2, index1+index2);
  741. txt2 = "保存多帧图片";
  742. ch2 = tree.InsertItem(txt2, ch1);
  743. index2 = 10; //MultipleFrameImage_Click);
  744. tree.SetItemData(ch2, index1+index2);
  745. txt2 = "读取多帧图片的子图片";
  746. ch2 = tree.InsertItem(txt2, ch1);
  747. index2 = 11; //GetImageFromMultyFrame_Click);
  748. tree.SetItemData(ch2, index1+index2);
  749. txt2 = "获取图像属性列表";
  750. ch2 = tree.InsertItem(txt2, ch1);
  751. index2 = 12; //QueryImage_Click);
  752. tree.SetItemData(ch2, index1+index2);
  753. txt2 = "修改图片属性";
  754. ch2 = tree.InsertItem(txt2, ch1);
  755. index2 = 13; //SetProp_Click);
  756. tree.SetItemData(ch2, index1+index2);
  757. //-------------------------------------------------------------
  758. txt1 = "图形特技处理";
  759. ch1 = tree.InsertItem(txt1, ch0);
  760. index1 = 0x0A00;
  761. txt2 = "淡入浅出";
  762. ch2 = tree.InsertItem(txt2, ch1);
  763. index2 = 1; //menuItem2_Click);
  764. tree.SetItemData(ch2, index1+index2);
  765. txt2 = "灰度处理与还原";
  766. ch2 = tree.InsertItem(txt2, ch1);
  767. index2 = 2; //GrayScale_Click);
  768. tree.SetItemData(ch2, index1+index2);
  769. txt2 = "底片(负片)滤镜";
  770. ch2 = tree.InsertItem(txt2, ch1);
  771. index2 = 3; //Inverse_Click);
  772. tree.SetItemData(ch2, index1+index2);
  773. txt2 = "浮雕及雕刻";
  774. ch2 = tree.InsertItem(txt2, ch1);
  775. index2 = 4; //Emboss_Click);
  776. tree.SetItemData(ch2, index1+index2);
  777. txt2 = "油画效果的制作";
  778. ch2 = tree.InsertItem(txt2, ch1);
  779. index2 = 5; //OnCanvas_Click);
  780. tree.SetItemData(ch2, index1+index2);
  781. txt2 = "木刻滤镜";
  782. ch2 = tree.InsertItem(txt2, ch1);
  783. index2 = 6; //OnWood_Click);
  784. tree.SetItemData(ch2, index1+index2);
  785. txt2 = "强光照射滤镜";
  786. ch2 = tree.InsertItem(txt2, ch1);
  787. index2 = 7; //Flashligt_Click);
  788. tree.SetItemData(ch2, index1+index2);
  789. txt2 = "柔化与锐化滤镜";
  790. ch2 = tree.InsertItem(txt2, ch1);
  791. index2 = 8; //BlurAndSharpen_Click);
  792. tree.SetItemData(ch2, index1+index2);
  793. }
  794. void DoGdiplusFuns(int index1, int index2)
  795. {
  796. switch (index1)
  797. {
  798. //-------------------------------------------------------------
  799. //txt1 = "画笔";
  800. case 0x01:
  801. switch (index2)
  802. {
  803. case 1: CreatePenFromBrush_Click(); break;
  804. case 2: DashStyle_Custom_Click(); break;
  805. case 3: Pen_Align_Click(); break;
  806. case 4: Pen_Tranform_Click(); break;
  807. case 5: Pen_LineCap_Click(); break;
  808. case 6: Pen_TransColor_Click(); break;
  809. }
  810. break;
  811. //-------------------------------------------------------------
  812. //txt1 = "画刷";
  813. case 0x02:
  814. switch (index2)
  815. {
  816. case 1: Brush_SolidBrush_Click(); break;
  817. case 2: Brush_FillVurve_Click(); break;
  818. case 3: Brush_HatchBrush_Click(); break;
  819. case 4: Brush_EnumAllStyle_Click(); break;
  820. case 5: Brush_SetRenderingOrigin_Click(); break;
  821. case 6: Brush_Texture_Click(); break;
  822. case 7: Brush_Texture_WrapMode_Click(); break;
  823. case 8: Brush_TextureTransform_Click(); break;
  824. case 9: Brush_GetTextureMatrix_Click(); break;
  825. case 10: Brush_LinearGradientBrush_Click(); break;
  826. case 11: Brush_LinearArrange_Click(); break;
  827. case 12: Brush_LinearInterpolation_Click(); break;
  828. case 13: Brush_LinearGradientMode_Click(); break;
  829. case 14: Brush_LinearAngle_Click(); break;
  830. case 15: Brush_LinearCustomize_Click(); break;
  831. case 16: Brush_LinearGradientBrush_BellShape_Click(); break;
  832. case 17: Brsuh_LinearGradientBrush_UsingGamma_Click(); break;
  833. case 18: Brush_PathGradientBrush_Star_Click(); break;
  834. case 19: Brush_PathGradientBrush_Star2_Click(); break;
  835. case 20: Brush_Using_MorePathGradientBrush_Click(); break;
  836. case 21: Brush_PathGradientBrush_WrapMode_Click(); break;
  837. case 22: Brush_PathGradientBrush_CenterPoint_Click(); break;
  838. case 23: Brush_PathGradientBrush_InterpolationColors_Click(); break;
  839. case 24: Brsuh_PathGradietBrush_Focus_Click(); break;
  840. case 25: Brush_PathGradientBrush_Transform_Click(); break;
  841. }
  842. break;
  843. //-------------------------------------------------------------
  844. //txt1 = "文本与字体";
  845. case 0x03:
  846. switch (index2)
  847. {
  848. case 1: Font_UsingFontInGDIPlus_Click(); break;
  849. case 2: Font_EnumAllFonts_Click(); break;
  850. case 3: Font_EnhanceFontDialog_Click(); break;
  851. case 4: Font_UsingTextRenderHint_Click(); break;
  852. case 5: Font_Privatefontcollection_Click(); break;
  853. case 6: Font_Privatefontcollection2_Click(); break;
  854. case 7: Font_IsStyleAvailable_Click(); break;
  855. case 8: Font_Size_Click(); break;
  856. case 9: Font_BaseLine_Click(); break;
  857. case 10: Font_DrawString_Click(); break;
  858. case 11: Font_MeasureString_Click(); break;
  859. case 12: Font_MeasureString2_Click(); break;
  860. case 13: Font_ColumnTextOut_Click(); break;
  861. case 14: Font_StirngTrimming_Click(); break;
  862. case 15: Font_TextOutClip_Click(); break;
  863. case 16: Font_MeasureCharacterRanges_Click(); break;
  864. case 17: Font_TextoutDirection_Click(); break;
  865. case 18: Font_TextAlignment_Click(); break;
  866. case 19: Font_TextAlignment2_Click(); break;
  867. case 20: Font_TextoutUsingTabs_Click(); break;
  868. case 21: Font_UsingTabs_Click(); break;
  869. case 22: Font_TextoutHotkeyPrefix_Click(); break;
  870. case 23: Font_TextoutShadow_Click(); break;
  871. case 24: Font_TextoutHashline_Click(); break;
  872. case 25: Font_TextoutTexture_Click(); break;
  873. case 26: Font_TextoutGradient_Click(); break;
  874. }
  875. break;
  876. //-------------------------------------------------------------
  877. //txt1 = "路径和区域";
  878. case 0x04:
  879. switch (index2)
  880. {
  881. case 1: Path_Construct_Click(); break;
  882. case 2: Path_AddLines_Click(); break;
  883. case 3: Path_CloseFigure_Click(); break;
  884. case 4: Path_FillPath_Click(); break;
  885. case 5: Path_AddSubPath_Click(); break;
  886. case 6: Path_GetSubPath_Click(); break;
  887. case 7: Path_GetPoints_Click(); break;
  888. case 8: Path_PathData_Click(); break;
  889. case 9: Path_ViewPointFLAG_Click(); break;
  890. case 10: Path_SubPathRange_Click(); break;
  891. case 11: Path_Flatten_Click(); break;
  892. case 12: Path_Warp_Click(); break;
  893. case 13: Path_Transform_Click(); break;
  894. case 14: Path_Widen_Click(); break;
  895. case 15: Path_WidenDemo_Click(); break;
  896. case 16: Region_FromPath_Click(); break;
  897. case 17: Region_Calculate_Click(); break;
  898. case 18: Region_GetRects_Click(); break;
  899. }
  900. break;
  901. //-------------------------------------------------------------
  902. //txt1 = "GDI+的坐标变换";
  903. case 0x05:
  904. switch (index2)
  905. {
  906. case 1: Transform_Click(); break;
  907. case 2: TranslateTransform_Click(); break;
  908. case 3: RotateTransform_Click(); break;
  909. case 4: DrawWatch_Click(); break;
  910. case 5: ScaleTransform_Click(); break;
  911. case 6: RectScale_Click(); break;
  912. case 7: FontRotate_Click(); break;
  913. case 8: Matrix_ListElements_Click_1(); break;
  914. case 9: MatrixPos_Click(); break;
  915. case 10: Martrix_Invert_Click(); break;
  916. case 11: Matrix_Multiply_Click(); break;
  917. case 12: Matrix_TransformPoints_Click(); break;
  918. case 13: Matrix_TransformPoints2_Click(); break;
  919. case 14: Matrix_TransformVectors_Click(); break;
  920. case 15: Matrix_RotateAt_Click(); break;
  921. case 16: Matrix_Shear_Click(); break;
  922. case 17: Matrix_TextoutShear_Click(); break;
  923. case 18: Matrix_ChangeFontHeight_Click(); break;
  924. }
  925. break;
  926. //-------------------------------------------------------------
  927. //txt1 = "GDI+的色彩变换";
  928. case 0x06:
  929. switch (index2)
  930. {
  931. case 1: ColorMatrix_Start_Click(); break;
  932. case 2: TranslateColor_Click(); break;
  933. case 3: ScaleColor_Click(); break;
  934. case 4: RotateColor_Click(); break;
  935. case 5: ColorShear_Click(); break;
  936. case 6: ColorRemap_Click(); break;
  937. case 7: SetRGBOutputChannel_Click(); break;
  938. }
  939. break;
  940. //-------------------------------------------------------------
  941. //txt1 = "图像的基本处理";
  942. case 0x07:
  943. switch (index2)
  944. {
  945. case 1: Metafile_Click(); break;
  946. case 2: CroppingAndScaling_Click(); break;
  947. case 3: UsingInterpolationMode_Click(); break;
  948. case 4: RotateFlip_Click(); break;
  949. case 5: ImageSkewing_Click(); break;
  950. case 6: Cubeimage_Click(); break;
  951. case 7: ThumbnailImage_Click(); break;
  952. case 8: Clone_Click(); break;
  953. case 9: Picturescale_Click(); break;
  954. }
  955. break;
  956. //-------------------------------------------------------------
  957. //txt1 = "图像色彩信息的调整";
  958. case 0x08:
  959. switch (index2)
  960. {
  961. case 1: ImageAttributesSetNoOp_Click(); break;
  962. case 2: SetColorMatrices_Click(); break;
  963. case 3: SetOutputChannelColorProfile_Click(); break;
  964. case 4: Gammaadjust_Click(); break;
  965. case 5: SetOutputChannel_Click(); break;
  966. case 6: Colorkey_Click(); break;
  967. case 7: Setthreshold_Click(); break;
  968. case 8: AdjustedPalette_Click(); break;
  969. case 9: SetWrapMode_Click(); break;
  970. }
  971. break;
  972. //-------------------------------------------------------------
  973. //txt1 = "图形的编码与解码";
  974. case 0x09:
  975. switch (index2)
  976. {
  977. case 1: ListAllImageEncoders_Click(); break;
  978. case 2: ListImageEncoder_Detail_Click(); break;
  979. case 3: ListImageDecoder_Click(); break;
  980. case 4: GetEncoderParameter_Click(); break;
  981. case 5: GetAllEncoderParameter_Click(); break;
  982. case 6: menuItem17_Click(); break;
  983. case 7: SaveBmp2tif_Click(); break;
  984. case 8: SaveBMP2JPG_Click(); break;
  985. case 9: TransformingJPEG_Click(); break;
  986. case 10: MultipleFrameImage_Click(); break;
  987. case 11: GetImageFromMultyFrame_Click(); break;
  988. case 12: QueryImage_Click(); break;
  989. case 13: SetProp_Click(); break;
  990. }
  991. break;
  992. //-------------------------------------------------------------
  993. //txt1 = "图形特技处理";
  994. case 0x0A:
  995. switch (index2)
  996. {
  997. case 1: menuItem2_Click(); break;
  998. case 2: GrayScale_Click(); break;
  999. case 3: Inverse_Click(); break;
  1000. case 4: Emboss_Click(); break;
  1001. case 5: OnCanvas_Click(); break;
  1002. case 6: OnWood_Click(); break;
  1003. case 7: Flashligt_Click(); break;
  1004. case 8: BlurAndSharpen_Click(); break;
  1005. }
  1006. break;
  1007. }
  1008. }
  1009. //
  1010. CString GetGdiplusFunsName(int index1, int index2)
  1011. {
  1012. CString s;
  1013. switch (index1)
  1014. {
  1015. //-------------------------------------------------------------
  1016. //txt1 = "画笔";
  1017. case 0x01:
  1018. switch (index2)
  1019. {
  1020. case 1: s="CreatePenFromBrush_Click()"; break;
  1021. case 2: s="DashStyle_Custom_Click()"; break;
  1022. case 3: s="Pen_Align_Click()"; break;
  1023. case 4: s="Pen_Tranform_Click()"; break;
  1024. case 5: s="Pen_LineCap_Click()"; break;
  1025. case 6: s="Pen_TransColor_Click()"; break;
  1026. }
  1027. break;
  1028. //-------------------------------------------------------------
  1029. //txt1 = "画刷";
  1030. case 0x02:
  1031. switch (index2)
  1032. {
  1033. case 1: s="Brush_SolidBrush_Click()"; break;
  1034. case 2: s="Brush_FillVurve_Click()"; break;
  1035. case 3: s="Brush_HatchBrush_Click()"; break;
  1036. case 4: s="Brush_EnumAllStyle_Click()"; break;
  1037. case 5: s="Brush_SetRenderingOrigin_Click()"; break;
  1038. case 6: s="Brush_Texture_Click()"; break;
  1039. case 7: s="Brush_Texture_WrapMode_Click()"; break;
  1040. case 8: s="Brush_TextureTransform_Click()"; break;
  1041. case 9: s="Brush_GetTextureMatrix_Click()"; break;
  1042. case 10: s="Brush_LinearGradientBrush_Click()"; break;
  1043. case 11: s="Brush_LinearArrange_Click()"; break;
  1044. case 12: s="Brush_LinearInterpolation_Click()"; break;
  1045. case 13: s="Brush_LinearGradientMode_Click()"; break;
  1046. case 14: s="Brush_LinearAngle_Click()"; break;
  1047. case 15: s="Brush_LinearCustomize_Click()"; break;
  1048. case 16: s="Brush_LinearGradientBrush_BellShape_Click()"; break;
  1049. case 17: s="Brsuh_LinearGradientBrush_UsingGamma_Click()"; break;
  1050. case 18: s="Brush_PathGradientBrush_Star_Click()"; break;
  1051. case 19: s="Brush_PathGradientBrush_Star2_Click()"; break;
  1052. case 20: s="Brush_Using_MorePathGradientBrush_Click()"; break;
  1053. case 21: s="Brush_PathGradientBrush_WrapMode_Click()"; break;
  1054. case 22: s="Brush_PathGradientBrush_CenterPoint_Click()"; break;
  1055. case 23: s="Brush_PathGradientBrush_InterpolationColors_Click()"; break;
  1056. case 24: s="Brsuh_PathGradietBrush_Focus_Click()"; break;
  1057. case 25: s="Brush_PathGradientBrush_Transform_Click()"; break;
  1058. }
  1059. break;
  1060. //-------------------------------------------------------------
  1061. //txt1 = "文本与字体";
  1062. case 0x03:
  1063. switch (index2)
  1064. {
  1065. case 1: s="Font_UsingFontInGDIPlus_Click()"; break;
  1066. case 2: s="Font_EnumAllFonts_Click()"; break;
  1067. case 3: s="Font_EnhanceFontDialog_Click()"; break;
  1068. case 4: s="Font_UsingTextRenderHint_Click()"; break;
  1069. case 5: s="Font_Privatefontcollection_Click()"; break;
  1070. case 6: s="Font_Privatefontcollection2_Click()"; break;
  1071. case 7: s="Font_IsStyleAvailable_Click()"; break;
  1072. case 8: s="Font_Size_Click()"; break;
  1073. case 9: s="Font_BaseLine_Click()"; break;
  1074. case 10: s="Font_DrawString_Click()"; break;
  1075. case 11: s="Font_MeasureString_Click()"; break;
  1076. case 12: s="Font_MeasureString2_Click()"; break;
  1077. case 13: s="Font_ColumnTextOut_Click()"; break;
  1078. case 14: s="Font_StirngTrimming_Click()"; break;
  1079. case 15: s="Font_TextOutClip_Click()"; break;
  1080. case 16: s="Font_MeasureCharacterRanges_Click()"; break;
  1081. case 17: s="Font_TextoutDirection_Click()"; break;
  1082. case 18: s="Font_TextAlignment_Click()"; break;
  1083. case 19: s="Font_TextAlignment2_Click()"; break;
  1084. case 20: s="Font_TextoutUsingTabs_Click()"; break;
  1085. case 21: s="Font_UsingTabs_Click()"; break;
  1086. case 22: s="Font_TextoutHotkeyPrefix_Click()"; break;
  1087. case 23: s="Font_TextoutShadow_Click()"; break;
  1088. case 24: s="Font_TextoutHashline_Click()"; break;
  1089. case 25: s="Font_TextoutTexture_Click()"; break;
  1090. case 26: s="Font_TextoutGradient_Click()"; break;
  1091. }
  1092. break;
  1093. //-------------------------------------------------------------
  1094. //txt1 = "路径和区域";
  1095. case 0x04:
  1096. switch (index2)
  1097. {
  1098. case 1: s="Path_Construct_Click()"; break;
  1099. case 2: s="Path_AddLines_Click()"; break;
  1100. case 3: s="Path_CloseFigure_Click()"; break;
  1101. case 4: s="Path_FillPath_Click()"; break;
  1102. case 5: s="Path_AddSubPath_Click()"; break;
  1103. case 6: s="Path_GetSubPath_Click()"; break;
  1104. case 7: s="Path_GetPoints_Click()"; break;
  1105. case 8: s="Path_PathData_Click()"; break;
  1106. case 9: s="Path_ViewPointFLAG_Click()"; break;
  1107. case 10: s="Path_SubPathRange_Click()"; break;
  1108. case 11: s="Path_Flatten_Click()"; break;
  1109. case 12: s="Path_Warp_Click()"; break;
  1110. case 13: s="Path_Transform_Click()"; break;
  1111. case 14: s="Path_Widen_Click()"; break;
  1112. case 15: s="Path_WidenDemo_Click()"; break;
  1113. case 16: s="Region_FromPath_Click()"; break;
  1114. case 17: s="Region_Calculate_Click()"; break;
  1115. case 18: s="Region_GetRects_Click()"; break;
  1116. }
  1117. break;
  1118. //-------------------------------------------------------------
  1119. //txt1 = "GDI+的坐标变换";
  1120. case 0x05:
  1121. switch (index2)
  1122. {
  1123. case 1: s="Transform_Click()"; break;
  1124. case 2: s="TranslateTransform_Click()"; break;
  1125. case 3: s="RotateTransform_Click()"; break;
  1126. case 4: s="DrawWatch_Click()"; break;
  1127. case 5: s="ScaleTransform_Click()"; break;
  1128. case 6: s="RectScale_Click()"; break;
  1129. case 7: s="FontRotate_Click()"; break;
  1130. case 8: s="Matrix_ListElements_Click_1()"; break;
  1131. case 9: s="MatrixPos_Click()"; break;
  1132. case 10: s="Martrix_Invert_Click()"; break;
  1133. case 11: s="Matrix_Multiply_Click()"; break;
  1134. case 12: s="Matrix_TransformPoints_Click()"; break;
  1135. case 13: s="Matrix_TransformPoints2_Click()"; break;
  1136. case 14: s="Matrix_TransformVectors_Click()"; break;
  1137. case 15: s="Matrix_RotateAt_Click()"; break;
  1138. case 16: s="Matrix_Shear_Click()"; break;
  1139. case 17: s="Matrix_TextoutShear_Click()"; break;
  1140. case 18: s="Matrix_ChangeFontHeight_Click()"; break;
  1141. }
  1142. break;
  1143. //-------------------------------------------------------------
  1144. //txt1 = "GDI+的色彩变换";
  1145. case 0x06:
  1146. switch (index2)
  1147. {
  1148. case 1: s="ColorMatrix_Start_Click()"; break;
  1149. case 2: s="TranslateColor_Click()"; break;
  1150. case 3: s="ScaleColor_Click()"; break;
  1151. case 4: s="RotateColor_Click()"; break;
  1152. case 5: s="ColorShear_Click()"; break;
  1153. case 6: s="ColorRemap_Click()"; break;
  1154. case 7: s="SetRGBOutputChannel_Click()"; break;
  1155. }
  1156. break;
  1157. //-------------------------------------------------------------
  1158. //txt1 = "图像的基本处理";
  1159. case 0x07:
  1160. switch (index2)
  1161. {
  1162. case 1: s="Metafile_Click()"; break;
  1163. case 2: s="CroppingAndScaling_Click()"; break;
  1164. case 3: s="UsingInterpolationMode_Click()"; break;
  1165. case 4: s="RotateFlip_Click()"; break;
  1166. case 5: s="ImageSkewing_Click()"; break;
  1167. case 6: s="Cubeimage_Click()"; break;
  1168. case 7: s="ThumbnailImage_Click()"; break;
  1169. case 8: s="Clone_Click()"; break;
  1170. case 9: s="Picturescale_Click()"; break;
  1171. }
  1172. break;
  1173. //-------------------------------------------------------------
  1174. //txt1 = "图像色彩信息的调整";
  1175. case 0x08:
  1176. switch (index2)
  1177. {
  1178. case 1: s="ImageAttributesSetNoOp_Click()"; break;
  1179. case 2: s="SetColorMatrices_Click()"; break;
  1180. case 3: s="SetOutputChannelColorProfile_Click()"; break;
  1181. case 4: s="Gammaadjust_Click()"; break;
  1182. case 5: s="SetOutputChannel_Click()"; break;
  1183. case 6: s="Colorkey_Click()"; break;
  1184. case 7: s="Setthreshold_Click()"; break;
  1185. case 8: s="AdjustedPalette_Click()"; break;
  1186. case 9: s="SetWrapMode_Click()"; break;
  1187. }
  1188. break;
  1189. //-------------------------------------------------------------
  1190. //txt1 = "图形的编码与解码";
  1191. case 0x09:
  1192. switch (index2)
  1193. {
  1194. case 1: s="ListAllImageEncoders_Click()"; break;
  1195. case 2: s="ListImageEncoder_Detail_Click()"; break;
  1196. case 3: s="ListImageDecoder_Click()"; break;
  1197. case 4: s="GetEncoderParameter_Click()"; break;
  1198. case 5: s="GetAllEncoderParameter_Click()"; break;
  1199. case 6: s="menuItem17_Click()"; break;
  1200. case 7: s="SaveBmp2tif_Click()"; break;
  1201. case 8: s="SaveBMP2JPG_Click()"; break;
  1202. case 9: s="TransformingJPEG_Click()"; break;
  1203. case 10: s="MultipleFrameImage_Click()"; break;
  1204. case 11: s="GetImageFromMultyFrame_Click()"; break;
  1205. case 12: s="QueryImage_Click()"; break;
  1206. case 13: s="SetProp_Click()"; break;
  1207. }
  1208. break;
  1209. //-------------------------------------------------------------
  1210. //txt1 = "图形特技处理";
  1211. case 0x0A:
  1212. switch (index2)
  1213. {
  1214. case 1: s="menuItem2_Click()"; break;
  1215. case 2: s="GrayScale_Click()"; break;
  1216. case 3: s="Inverse_Click()"; break;
  1217. case 4: s="Emboss_Click()"; break;
  1218. case 5: s="OnCanvas_Click()"; break;
  1219. case 6: s="OnWood_Click()"; break;
  1220. case 7: s="Flashligt_Click()"; break;
  1221. case 8: s="BlurAndSharpen_Click()"; break;
  1222. }
  1223. break;
  1224. }
  1225. return s;
  1226. }
  1227. //获取函数的源代码
  1228. CString GetGdiplusFunsCode(int index1, int index2)
  1229. {
  1230. CString key=GetGdiplusFunsName(index1, index2);
  1231. if (key.IsEmpty())
  1232. return "未找到函数";
  1233. //假设原代码在 <exePath> ../WalkLtDemo/WalkLtDemo设计实例.cpp
  1234. TCHAR ModuleDirectory[_MAX_PATH];
  1235. ::GetModuleFileName(NULL, ModuleDirectory, _MAX_PATH);
  1236. TCHAR *p=::_tcsrchr(ModuleDirectory, '\\');
  1237. if (p)
  1238. {
  1239. *p=0;
  1240. p=::_tcsrchr(ModuleDirectory, '\\'); *p=0;
  1241. ::_tcscat(ModuleDirectory, "\\WalkLtDemo\\WalkLtDemo设计实例.cpp");
  1242. }
  1243. CString fname=ModuleDirectory;
  1244. FILE *pf = ::fopen(fname, "rt");
  1245. if (!pf)
  1246. return "打开文件失败";
  1247. CString res;
  1248. char buf[1024];
  1249. while (!feof(pf))
  1250. {
  1251. ::fgets(buf, 1024, pf);
  1252. if (strstr(buf, key))
  1253. {
  1254. CString s=buf; s.TrimRight(); s+="\r\n";
  1255. res = s;
  1256. while (!feof(pf))
  1257. {
  1258. ::fgets(buf, 1024, pf);
  1259. s=buf; s.TrimRight(); s+="\r\n";
  1260. res += s;
  1261. if (buf[0]=='}')
  1262. {
  1263. ::fclose(pf);
  1264. return res;
  1265. }
  1266. }
  1267. }
  1268. }
  1269. ::fclose(pf);
  1270. return res;
  1271. }
  1272. ////////////////////////////////////////////////////////////////
  1273. Graphics *gz_graphics;
  1274. Graphics &GetGraphics()
  1275. {
  1276. return *gz_graphics;
  1277. }
  1278. Rect MyClient;
  1279. extern void DoGdiplusFuns(int index1, int index2);
  1280. void DoGdiplusDemo(Graphics &gc, CView *pView, int index1, int index2)
  1281. {
  1282. //------------- 全局变量的初始化 -------------------------
  1283. gz_graphics = &gc;
  1284. CRect rect;
  1285. pView->GetClientRect(&rect);
  1286. MyClient.X=rect.left; MyClient.Y=rect.top;
  1287. MyClient.Width=rect.Width(); MyClient.Height=rect.Height();
  1288. //------------ Action ------------------------------------
  1289. DoGdiplusFuns(index1, index2);
  1290. }