using System.Globalization; using System.Reflection.Emit; using System.Runtime.InteropServices; using System.Windows.Forms; namespace data_displayer { public partial class Form1 : Form { [DllImport("user32.dll", SetLastError = true)] private static extern bool SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags ); // 定义SetWindowPos的一些常量 private static readonly IntPtr HWND_BOTTOM = new IntPtr(1); private const uint SWP_NOMOVE = 0x0002; private const uint SWP_NOSIZE = 0x0001; public Form1() { SetWindowPos(this.Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); InitializeComponent(); BackColor = Color.White; TransparencyKey = Color.White; } private void timer1_Tick(object sender, EventArgs e) { label1.Text = DateTime.Now.ToString("O"); GregorianCalendar WgregorianCalendar = new GregorianCalendar(); int WweekOfYear = WgregorianCalendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); string Wtime = WweekOfYear.ToString(); GregorianCalendar SgregorianCalendar = new GregorianCalendar(); int SweekOfYear = SgregorianCalendar.GetWeekOfYear(Settings1.Default.Start_of_school_week, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); int SWeek = WweekOfYear - SweekOfYear + 1; label2.Text = "W" + Wtime + "|" + "S" + SWeek.ToString(); label3.Text = Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d")).ToString(); } private void Form1_Load(object sender, EventArgs e) { int ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width; int x = ScreenWidth - Width - 5; int y = 5; Location = new Point(x, y); } private void settingsToolStripMenuItem_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); form2.ShowDialog(); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { AboutBox1 aboutBox1 = new AboutBox1(); aboutBox1.ShowDialog(); } } }