You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6 KiB

3 years ago
  1. using Apewer.Surface;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Text;
  6. using System.Windows.Forms;
  7. namespace Apewer.Tray
  8. {
  9. class MainForm : Form
  10. {
  11. private void InitializeComponent()
  12. {
  13. SuspendLayout();
  14. AutoScaleMode = AutoScaleMode.None;
  15. StartPosition = FormStartPosition.CenterScreen;
  16. ClientSize = new Size(900, 600);
  17. Font = FormsUtility.DefaultFont;
  18. Text = "MainForm";
  19. ResumeLayout(false);
  20. }
  21. public MainForm()
  22. {
  23. Load += (s, e) => Init();
  24. }
  25. ListBox _listbox;
  26. void Init()
  27. {
  28. Padding = new Padding(30, 30, 30, 30);
  29. _listbox = new ListBox();
  30. _listbox.Dock = DockStyle.Fill;
  31. Controls.Add(_listbox);
  32. Resize += (s, e) => Log(nameof(Resize), Width, Height);
  33. ResizeBegin += (s, e) => Log(nameof(ResizeBegin), Width, Height);
  34. ResizeEnd += (s, e) => Log(nameof(ResizeEnd), Width, Height);
  35. Paint += (s, e) => Log(nameof(ResizeBegin), $"X={e.ClipRectangle.X}", $"Y={e.ClipRectangle.Y}", $"Width={e.ClipRectangle.Width}", $"X={e.ClipRectangle.Height}");
  36. }
  37. void Log(params object[] segs)
  38. {
  39. var text = TextUtility.Join("|", segs);
  40. Logger.Write(text);
  41. if (_listbox != null)
  42. {
  43. _listbox.Items.Add(text);
  44. _listbox.TopIndex = _listbox.Items.Count - (int)(_listbox.Height / _listbox.ItemHeight);
  45. }
  46. }
  47. }
  48. }