Form1.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System.Globalization;
  2. using System.Reflection.Emit;
  3. using System.Runtime.InteropServices;
  4. using System.Windows.Forms;
  5. namespace data_displayer
  6. {
  7. public partial class Form1 : Form
  8. {
  9. [DllImport("user32.dll", SetLastError = true)]
  10. private static extern bool SetWindowPos(
  11. IntPtr hWnd,
  12. IntPtr hWndInsertAfter,
  13. int x,
  14. int y,
  15. int cx,
  16. int cy,
  17. uint uFlags
  18. );
  19. // ¶¨ÒåSetWindowPosµÄһЩ³£Á¿
  20. private static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
  21. private const uint SWP_NOMOVE = 0x0002;
  22. private const uint SWP_NOSIZE = 0x0001;
  23. public Form1()
  24. {
  25. SetWindowPos(this.Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  26. InitializeComponent();
  27. BackColor = Color.White;
  28. TransparencyKey = Color.White;
  29. }
  30. private void timer1_Tick(object sender, EventArgs e)
  31. {
  32. label1.Text = DateTime.Now.ToString("O");
  33. GregorianCalendar WgregorianCalendar = new GregorianCalendar();
  34. int WweekOfYear = WgregorianCalendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
  35. string Wtime = WweekOfYear.ToString();
  36. GregorianCalendar SgregorianCalendar = new GregorianCalendar();
  37. int SweekOfYear = SgregorianCalendar.GetWeekOfYear(Settings1.Default.Start_of_school_week, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
  38. int SWeek = WweekOfYear - SweekOfYear + 1;
  39. label2.Text = "W" + Wtime + "|" + "S" + SWeek.ToString();
  40. label3.Text = Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d")).ToString();
  41. }
  42. private void Form1_Load(object sender, EventArgs e)
  43. {
  44. int ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width;
  45. int x = ScreenWidth - Width - 5;
  46. int y = 5;
  47. Location = new Point(x, y);
  48. }
  49. private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
  50. {
  51. Form2 form2 = new Form2();
  52. form2.ShowDialog();
  53. }
  54. private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
  55. {
  56. AboutBox1 aboutBox1 = new AboutBox1();
  57. aboutBox1.ShowDialog();
  58. }
  59. }
  60. }