xw-devtool-cli 1.0.32 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xw-devtool-cli",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "type": "module",
5
5
  "description": "基于node的开发者助手cli",
6
6
  "main": "index.js",
@@ -25,6 +25,7 @@ public class DistanceForm : Form {
25
25
  private bool p1Set = false;
26
26
  private bool p2Set = false;
27
27
  private Bitmap screenCapture;
28
+ private Timer t;
28
29
 
29
30
  public DistanceForm() {
30
31
  this.FormBorderStyle = FormBorderStyle.None;
@@ -47,6 +48,11 @@ public class DistanceForm : Form {
47
48
  g.CopyFromScreen(totalBounds.Location, Point.Empty, totalBounds.Size);
48
49
  }
49
50
  this.BackgroundImage = screenCapture;
51
+
52
+ t = new Timer();
53
+ t.Interval = 33;
54
+ t.Tick += (s, e) => { this.Invalidate(); };
55
+ t.Start();
50
56
  }
51
57
 
52
58
  private Point GetSnappedPoint(Point current) {
@@ -95,9 +101,7 @@ public class DistanceForm : Form {
95
101
  }
96
102
 
97
103
  protected override void OnMouseMove(MouseEventArgs e) {
98
- if (p1Set && !p2Set) {
99
- this.Invalidate();
100
- }
104
+ this.Invalidate();
101
105
  }
102
106
 
103
107
  protected override void OnPaint(PaintEventArgs e) {
@@ -105,10 +109,18 @@ public class DistanceForm : Form {
105
109
  g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
106
110
 
107
111
  Pen pen = new Pen(Color.Red, 2);
112
+ Pen crossPen = new Pen(Color.Red, 1);
108
113
  Brush brush = Brushes.Red;
109
114
  Font font = new Font("Segoe UI", 12, FontStyle.Bold);
110
115
  Brush textBg = new SolidBrush(Color.FromArgb(180, 0, 0, 0));
111
116
 
117
+ Point cp = this.PointToClient(Cursor.Position);
118
+ int gap = 24;
119
+ g.DrawLine(crossPen, 0, cp.Y, Math.Max(0, cp.X - gap), cp.Y);
120
+ g.DrawLine(crossPen, Math.Min(this.ClientSize.Width, cp.X + gap), cp.Y, this.ClientSize.Width, cp.Y);
121
+ g.DrawLine(crossPen, cp.X, 0, cp.X, Math.Max(0, cp.Y - gap));
122
+ g.DrawLine(crossPen, cp.X, Math.Min(this.ClientSize.Height, cp.Y + gap), cp.X, this.ClientSize.Height);
123
+
112
124
  if (p1Set) {
113
125
  Point target = p2Set ? p2 : GetSnappedPoint(this.PointToClient(Cursor.Position));
114
126
 
@@ -123,14 +135,10 @@ public class DistanceForm : Form {
123
135
  double dist = Math.Sqrt(Math.Pow(target.X - p1.X, 2) + Math.Pow(target.Y - p1.Y, 2));
124
136
  string text = String.Format("{0:F2} px", dist);
125
137
 
126
- // Draw text at midpoint
127
- Point mid = new Point((p1.X + target.X) / 2, (p1.Y + target.Y) / 2);
128
138
  SizeF size = g.MeasureString(text, font);
129
-
130
- // Ensure text doesn't go off screen
131
- float txtX = mid.X + 10;
132
- float txtY = mid.Y + 10;
133
-
139
+ float pad = 16;
140
+ float txtX = this.ClientSize.Width - (float)size.Width - pad;
141
+ float txtY = this.ClientSize.Height - (float)size.Height - pad;
134
142
  g.FillRectangle(textBg, txtX - 2, txtY - 2, size.Width + 4, size.Height + 4);
135
143
  g.DrawString(text, font, Brushes.White, txtX, txtY);
136
144