Credits.cs
上传用户:szltgg
上传日期:2019-05-16
资源大小:604k
文件大小:8k
源码类别:

Telnet服务器

开发平台:

C#

  1. /*
  2. * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
  3. * $Id: Credits.cs,v 1.3 2005/04/27 23:27:18 okajima Exp $
  4. */
  5. using System;
  6. using System.Drawing;
  7. using System.Collections;
  8. using System.ComponentModel;
  9. using System.Windows.Forms;
  10. using Poderosa.UI;
  11. using Poderosa.Config;
  12. namespace Poderosa.Forms
  13. {
  14. /// <summary>
  15. /// Credits 偺奣梫偺愢柧偱偡丅
  16. /// </summary>
  17. internal class Credits : System.Windows.Forms.Form
  18. {
  19. private System.Windows.Forms.PictureBox _pictureBox;
  20. private System.Windows.Forms.Label _subtitle;
  21. private System.Windows.Forms.Button _okButton;
  22. private System.Windows.Forms.Label _mainPanel;
  23. /// <summary>
  24. /// 昁梫側僨僓僀僫曄悢偱偡丅
  25. /// </summary>
  26. private System.ComponentModel.Container components = null;
  27. public Credits()
  28. {
  29. //
  30. // Windows 僼僅乕儉 僨僓僀僫 僒億乕僩偵昁梫偱偡丅
  31. //
  32. InitializeComponent();
  33. _okButton.Text = GApp.Strings.GetString("Common.OK");
  34. //
  35. // TODO: InitializeComponent 屇傃弌偟偺屻偵丄僐儞僗僩儔僋僞 僐乕僪傪捛壛偟偰偔偩偝偄丅
  36. //
  37. //AboutBox偐傜庁傝傞
  38. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(AboutBox));
  39. this._pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("_pictureBox.Image")));
  40. }
  41. /// <summary>
  42. /// 巊梡偝傟偰偄傞儕僜乕僗偵屻張棟傪幚峴偟傑偡丅
  43. /// </summary>
  44. protected override void Dispose( bool disposing )
  45. {
  46. if( disposing )
  47. {
  48. if(components != null)
  49. {
  50. components.Dispose();
  51. }
  52. _timer.Dispose();
  53. }
  54. base.Dispose( disposing );
  55. }
  56. #region Windows 僼僅乕儉 僨僓僀僫偱惗惉偝傟偨僐乕僪 
  57. /// <summary>
  58. /// 僨僓僀僫 僒億乕僩偵昁梫側儊僜僢僪偱偡丅偙偺儊僜僢僪偺撪梕傪
  59. /// 僐乕僪 僄僨傿僞偱曄峏偟側偄偱偔偩偝偄丅
  60. /// </summary>
  61. private void InitializeComponent()
  62. {
  63. this._pictureBox = new System.Windows.Forms.PictureBox();
  64. this._subtitle = new System.Windows.Forms.Label();
  65. this._okButton = new System.Windows.Forms.Button();
  66. this._mainPanel = new System.Windows.Forms.Label();
  67. this.SuspendLayout();
  68. // 
  69. // _pictureBox
  70. // 
  71. this._pictureBox.BackColor = System.Drawing.SystemColors.Window;
  72. this._pictureBox.Location = new System.Drawing.Point(0, 0);
  73. this._pictureBox.Name = "_pictureBox";
  74. this._pictureBox.Size = new System.Drawing.Size(288, 80);
  75. this._pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
  76. this._pictureBox.TabIndex = 0;
  77. this._pictureBox.TabStop = false;
  78. // 
  79. // _subtitle
  80. // 
  81. this._subtitle.BackColor = System.Drawing.SystemColors.Window;
  82. this._subtitle.Font = new System.Drawing.Font("Arial", 11.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  83. this._subtitle.Location = new System.Drawing.Point(0, 80);
  84. this._subtitle.Name = "_subtitle";
  85. this._subtitle.Size = new System.Drawing.Size(288, 24);
  86. this._subtitle.TabIndex = 1;
  87. this._subtitle.Text = "The Terminal, Reloaded";
  88. this._subtitle.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  89. // 
  90. // _okButton
  91. // 
  92. this._okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
  93. this._okButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  94. this._okButton.Location = new System.Drawing.Point(104, 240);
  95. this._okButton.Name = "_okButton";
  96. this._okButton.TabIndex = 2;
  97. // 
  98. // _mainPanel
  99. // 
  100. this._mainPanel.BackColor = System.Drawing.SystemColors.Window;
  101. this._mainPanel.Font = new System.Drawing.Font("MS UI Gothic", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(128)));
  102. this._mainPanel.Location = new System.Drawing.Point(0, 104);
  103. this._mainPanel.Name = "_mainPanel";
  104. this._mainPanel.Size = new System.Drawing.Size(288, 128);
  105. this._mainPanel.TabIndex = 3;
  106. this._mainPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.OnPaintCredit);
  107. // 
  108. // Credits
  109. // 
  110. this.AcceptButton = this._okButton;
  111. this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
  112. this.BackColor = System.Drawing.SystemColors.Control;
  113. this.ClientSize = new System.Drawing.Size(290, 266);
  114. this.ControlBox = false;
  115. this.Controls.Add(this._mainPanel);
  116. this.Controls.Add(this._okButton);
  117. this.Controls.Add(this._subtitle);
  118. this.Controls.Add(this._pictureBox);
  119. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  120. this.Name = "Credits";
  121. this.ShowInTaskbar = false;
  122. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  123. this.Text = "Poderosa";
  124. this.ResumeLayout(false);
  125. }
  126. #endregion
  127. private class Entry {
  128. public string _en_name;
  129. public string _ja_name;
  130. public Entry(string en, string ja) {
  131. _en_name = en;
  132. _ja_name = ja;
  133. }
  134. }
  135. private class CreditGroup {
  136. public string _name;
  137. public Entry[] _credits;
  138. public CreditGroup(string name, params Entry[] credits) {
  139. _name = name;
  140. _credits = credits;
  141. }
  142. }
  143. private ArrayList _creditGroups;
  144. private void CreateCreditData() {
  145. _creditGroups = new ArrayList();
  146. _creditGroups.Add(new CreditGroup(
  147. "",
  148. new Entry[0]));
  149. _creditGroups.Add(new CreditGroup(
  150.                 "Project Leader & Chief Developer",
  151. new Entry("Daisuke OKAJIMA", "壀搱 戝夘")));
  152. _creditGroups.Add(new CreditGroup(
  153.                 "Website Manager",
  154. new Entry("Hiroshi Taketazu", "Hiroshi Taketazu"),
  155. new Entry("Tadashi "ELF" Jokagi", "Tadashi "ELF" Jokagi")));
  156. _creditGroups.Add(new CreditGroup(
  157.                 "Server Administrator",
  158. new Entry("yuk@lavans", "yuk@lavans")));
  159. _creditGroups.Add(new CreditGroup(
  160. "Developer",
  161. new Entry("Shintaro UNO", "塅栰 怣懢榊")));
  162. _creditGroups.Add(new CreditGroup(
  163. "Special Thanks To",
  164. new Entry("Routrek Networks, Inc.", "(姅)儖乕僩儗僢僋丒僱僢僩儚乕僋僗")));
  165. _creditGroups.Add(new CreditGroup(
  166. "Poderosa Project",
  167. new Entry("http://www.poderosa.org/", "http://www.poderosa.org/")));
  168. }
  169. protected override void OnLoad(EventArgs e) {
  170. base.OnLoad (e);
  171. if(!this.DesignMode) {
  172. CreateCreditData();
  173. _creditIndex = 0;
  174. _creditStep = 0;
  175. _boldFont = new Font(_mainPanel.Font, FontStyle.Bold);
  176. _timer = new Timer();
  177. _timer.Tick += new EventHandler(OnTimer);
  178. _timer.Interval = 50;
  179. _timer.Start();
  180. }
  181. }
  182. private Font _boldFont;
  183. private int _creditIndex;
  184. private int _creditStep;
  185. private const int STEPS_PER_GROUP = 60;
  186. private Timer _timer;
  187. private void OnTimer(object sender, EventArgs args) {
  188. if(_creditIndex==0) {
  189. //嵟弶偺昞帵傪弌偡傑偱偵傗傗娫傪嬻偗傞
  190. if(++_creditStep==30) {
  191. _creditIndex++;
  192. _creditStep = 0;
  193. }
  194. }
  195. else if(_creditIndex==_creditGroups.Count-1) {
  196. if(++_creditStep==20) {
  197. _timer.Stop();
  198. }
  199. }
  200. else if(++_creditStep==STEPS_PER_GROUP) {
  201. _creditIndex++;
  202. _creditStep = 0;
  203. }
  204. _mainPanel.Invalidate(true);
  205. }
  206. private void OnPaintCredit(object sender, PaintEventArgs args) {
  207. if(_creditIndex==_creditGroups.Count) return;
  208. CreditGroup grp = (CreditGroup)_creditGroups[_creditIndex];
  209. Color col;
  210. if(_creditStep < 10)
  211. col = ColorUtil.CalculateColor(SystemColors.WindowText, SystemColors.Window, _creditStep*(255/10));
  212. else if(_creditStep < 40)
  213. col = SystemColors.WindowText;
  214. else if(_creditStep < 50)
  215. col = ColorUtil.CalculateColor(SystemColors.WindowText, SystemColors.Window, (50-_creditStep)*(255/10));
  216. else
  217. return; //no draw
  218. Graphics g = args.Graphics;
  219. SizeF name_size = g.MeasureString(grp._name, _boldFont);
  220. Brush br = new SolidBrush(col);
  221. float y = (_mainPanel.Height - (name_size.Height*(1+grp._credits.Length))) / 2;
  222. float width = this.Width;
  223. DrawString(g, grp._name, _boldFont, br, y);
  224. y += name_size.Height;
  225. foreach(Entry e in grp._credits) {
  226. DrawString(g, GEnv.Options.Language==Language.English? e._en_name : e._ja_name, _mainPanel.Font, br, y);
  227. y += name_size.Height;
  228. }
  229. br.Dispose();
  230. }
  231. private void DrawString(Graphics g, string text, Font font, Brush br, float y) {
  232. SizeF sz = g.MeasureString(text, font);
  233. g.DrawString(text, font, br, (_mainPanel.Width-sz.Width)/2, y);
  234. }
  235. }
  236. }