fork download
  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Imaging;
  4. using System.Drawing.Drawing2D;
  5. using System.Windows.Forms;
  6.  
  7. namespace anclock
  8. {
  9. public partial class anclock : Form
  10. {
  11. bool pb = false;
  12. private System.ComponentModel.IContainer components = null;
  13. private System.Windows.Forms.PictureBox pictureBox1;
  14. private System.Windows.Forms.Timer timer1;
  15. private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
  16. private System.Windows.Forms.ToolStripMenuItem tsmi1;
  17. private System.Windows.Forms.ToolStripMenuItem tsmi2;
  18.  
  19. protected override void Dispose(bool disposing)
  20. {
  21. if (disposing && (components != null)) { components.Dispose(); }
  22. base.Dispose(disposing);
  23. }
  24. private void InitializeComponent()
  25. {
  26.  
  27. }
  28. public anclock()
  29. {
  30. this.components = new System.ComponentModel.Container();
  31. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  32. this.timer1 = new System.Windows.Forms.Timer(this.components);
  33. this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
  34. this.tsmi1 = new System.Windows.Forms.ToolStripMenuItem();
  35. this.tsmi2 = new System.Windows.Forms.ToolStripMenuItem();
  36. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  37. this.contextMenuStrip1.SuspendLayout();
  38. this.SuspendLayout();
  39. this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
  40. this.pictureBox1.Location = new System.Drawing.Point(0, 0);
  41. this.pictureBox1.Margin = new System.Windows.Forms.Padding(0);
  42. this.pictureBox1.Name = "pictureBox1";
  43. this.pictureBox1.Size = new System.Drawing.Size(300, 300);
  44. this.pictureBox1.TabIndex = 0;
  45. this.pictureBox1.TabStop = false;
  46. this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);
  47. this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
  48. this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);
  49. this.timer1.Interval = 500;
  50. this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
  51. this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tsmi1, this.tsmi2 });
  52. this.contextMenuStrip1.Name = "contextMenuStrip1";
  53. this.contextMenuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
  54. this.contextMenuStrip1.ShowImageMargin = false;
  55. this.contextMenuStrip1.Size = new System.Drawing.Size(74, 48);
  56. this.tsmi1.Name = "tsmi1";
  57. this.tsmi1.Size = new System.Drawing.Size(73, 22);
  58. this.tsmi1.Text = "time";
  59. this.tsmi2.Name = "tsmi2";
  60. this.tsmi2.Size = new System.Drawing.Size(73, 22);
  61. this.tsmi2.Text = "Close";
  62. this.tsmi2.Click += new System.EventHandler(this.tsmi2_Click);
  63. this.FormBorderStyle = FormBorderStyle.None;
  64. this.AllowDrop = true;
  65. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  66. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  67. this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
  68. this.ClientSize = new System.Drawing.Size(300, 300);
  69. this.ContextMenuStrip = this.contextMenuStrip1;
  70. this.Controls.Add(this.pictureBox1);
  71. this.Name = "Form1";
  72. this.ShowIcon = false;
  73. this.ShowInTaskbar = false;
  74. this.Load += new System.EventHandler(this.Form1_Load);
  75. this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
  76. this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter);
  77. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  78. this.contextMenuStrip1.ResumeLayout(false);
  79. this.ResumeLayout(false);
  80. Setbrd();
  81. timer1.Start();
  82. }
  83. private void Form1_Load(object sender, EventArgs e)
  84. {
  85. this.SetBounds(this.Left, this.Top, 301, 301, BoundsSpecified.Size);
  86. GraphicsPath path = new GraphicsPath();
  87. path.AddEllipse(new Rectangle(0, 0, 300, 300));
  88. this.Region = new Region(path);
  89. this.TopMost = true;
  90. }
  91. private void Setbrd()
  92. {
  93. Bitmap img = this.BackgroundImage == null ? new Bitmap(300, 300) : (Bitmap)this.BackgroundImage;
  94. Graphics g = Graphics.FromImage(img);
  95. int i = 12, l = 130;
  96. for (; i > 0; i--)
  97. {
  98. string st = i.ToString();
  99. Font fn = new Font("Arial Bold", 25);
  100. SizeF f = g.MeasureString(st, fn, 50);
  101. double rd = - i * Math.PI / 6;
  102. PointF p = new PointF((float)(150 - l * Math.Sin(rd) - f.Width / 2), (float)(150 - l * Math.Cos(rd) - f.Height / 2));
  103. g.DrawString(st, fn, Brushes.Black, p);
  104. }
  105. this.BackgroundImage = img;
  106. g.Dispose();
  107. }
  108. private Point[] Setneedle(int l, double rd, double r)
  109. {
  110. rd = -rd;
  111. double r1 = rd - r, r2 = rd + r;
  112. Point[] p = new Point[3];
  113. p[0] = new Point((int)(150 - l * Math.Sin(rd)), (int)(150 - l * Math.Cos(rd)));
  114. p[1] = new Point((int)(150 - 15 * Math.Sin(r1)), (int)(150 - 15 * Math.Cos(r1)));
  115. p[2] = new Point((int)(150 - 15 * Math.Sin(r2)), (int)(150 - 15 * Math.Cos(r2)));
  116. return p;
  117. }
  118. private void timer1_Tick(object sender, EventArgs e)
  119. {
  120. Bitmap img = new Bitmap(300, 300);
  121. Graphics g = Graphics.FromImage(img);
  122. DateTime d = DateTime.Now;
  123. tsmi1.Text = d.ToString();
  124. double rd = (d.Hour % 12) * Math.PI / 6 + d.Minute * Math.PI / 360, r = Math.PI / 4; int l = 80;
  125. Point[] p = Setneedle(l, rd, r);
  126. g.FillPolygon(Brushes.Black, p);
  127. rd = d.Minute * Math.PI / 30; r = Math.PI / 8; l = 110;
  128. p = Setneedle(l, rd, r);
  129. g.FillPolygon(Brushes.Black, p);
  130. rd = d.Second * Math.PI / 30; r = Math.PI / 18; l = 140;
  131. p = Setneedle(l, rd, r);
  132. g.FillPolygon(Brushes.Black, p);
  133. g.FillEllipse(Brushes.Black, 134, 134, 32, 32);
  134. pictureBox1.Image = img;
  135. g.Dispose(); g = null; GC.Collect();
  136. }
  137. private void tsmi2_Click(object sender, EventArgs e)
  138. { this.Close(); }
  139. private void Form1_DragEnter(object sender, DragEventArgs e)
  140. {
  141. if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None;
  142. }
  143. private void Form1_DragDrop(object sender, DragEventArgs e)
  144. {
  145. string[] fp;
  146. fp = (string[])e.Data.GetData(DataFormats.FileDrop, false);
  147. if (fp.Length == 0) return;
  148. timer1.Stop();
  149. Bitmap img = null;Graphics g = null;
  150. try
  151. {
  152. img = new Bitmap(@fp[0]);
  153. g = Graphics.FromImage((Bitmap)this.BackgroundImage);
  154. g.DrawImage(img, this.ClientRectangle);
  155. Setbrd();
  156. }
  157. catch { }
  158. finally
  159. {
  160. if (g != null) g.Dispose();
  161. if (img != null) img.Dispose();
  162. timer1.Start();
  163. }
  164. }
  165. private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
  166. {
  167. if (!pb) return;
  168. Point p = Cursor.Position;
  169. this.Location = new Point(p.X - 150, p.Y - 150);
  170. }
  171. private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
  172. { if (e.Button == MouseButtons.Left) pb = true; }
  173. private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
  174. { pb = false;}
  175.  
  176. }
  177. static class Program
  178. {
  179. [STAThread]
  180. static void Main()
  181. {
  182. Application.EnableVisualStyles();
  183. Application.SetCompatibleTextRenderingDefault(false);
  184. Application.Run(new anclock());
  185. }
  186. }
  187. }
  188.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(5,22): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
prog.cs(9,32): error CS0246: The type or namespace name `Form' could not be found. Are you missing an assembly reference?
prog.cs(13,24): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
prog.cs(14,24): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
prog.cs(15,24): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
prog.cs(16,24): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
prog.cs(17,24): error CS0234: The type or namespace name `Forms' does not exist in the namespace `System.Windows'. Are you missing `System.Windows.Forms' assembly reference?
prog.cs(19,25): error CS0115: `anclock.anclock.Dispose(bool)' is marked as an override but no suitable method found to override
prog.cs(139,45): error CS0246: The type or namespace name `DragEventArgs' could not be found. Are you missing an assembly reference?
prog.cs(143,44): error CS0246: The type or namespace name `DragEventArgs' could not be found. Are you missing an assembly reference?
prog.cs(165,51): error CS0246: The type or namespace name `MouseEventArgs' could not be found. Are you missing an assembly reference?
prog.cs(171,51): error CS0246: The type or namespace name `MouseEventArgs' could not be found. Are you missing an assembly reference?
prog.cs(173,49): error CS0246: The type or namespace name `MouseEventArgs' could not be found. Are you missing an assembly reference?
Compilation failed: 13 error(s), 0 warnings
stdout
Standard output is empty