星火微课系统客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

MainImage.cs 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. using ComeCapture.Helpers;
  2. using ComeCapture.Models;
  3. using Common.system;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Controls.Primitives;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Shapes;
  12. namespace ComeCapture.Controls
  13. {
  14. public class MainImage : Control
  15. {
  16. public Point point;
  17. private Rectangle _Rectangle = null;
  18. private Ellipse _Ellipse = null;
  19. private List<Point> points = null;
  20. private Path _Line = null;
  21. private readonly StreamGeometry geometry = new StreamGeometry();
  22. public TextBoxControl _Text = null;
  23. private Path _Arrow = null;
  24. static MainImage()
  25. {
  26. DefaultStyleKeyProperty.OverrideMetadata(typeof(MainImage), new FrameworkPropertyMetadata(typeof(MainImage)));
  27. }
  28. public MainImage()
  29. {
  30. _Current = this;
  31. AddHandler(Thumb.DragStartedEvent, new DragStartedEventHandler(OnDragStart));
  32. AddHandler(Thumb.DragCompletedEvent, new DragCompletedEventHandler(OnDragCompleted));
  33. AddHandler(Thumb.DragDeltaEvent, new DragDeltaEventHandler(OnDragDelta));
  34. AddHandler(MouseMoveEvent, new MouseEventHandler(OnMove));
  35. Limit = new Limit();
  36. }
  37. #region 属性 Current
  38. private static MainImage _Current = null;
  39. public static MainImage Current
  40. {
  41. get => _Current;
  42. set => _Current = value;
  43. }
  44. #endregion 属性 Current
  45. #region MoveCursor DependencyProperty
  46. public Cursor MoveCursor
  47. {
  48. get => (Cursor)GetValue(MoveCursorProperty);
  49. set => SetValue(MoveCursorProperty, value);
  50. }
  51. public static readonly DependencyProperty MoveCursorProperty =
  52. DependencyProperty.Register("MoveCursor", typeof(Cursor), typeof(MainImage),
  53. new PropertyMetadata(Cursors.SizeAll, new PropertyChangedCallback(MainImage.OnMoveCursorPropertyChanged)));
  54. private static void OnMoveCursorPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  55. {
  56. if (obj is MainImage)
  57. {
  58. (obj as MainImage).OnMoveCursorValueChanged();
  59. }
  60. }
  61. protected void OnMoveCursorValueChanged()
  62. {
  63. }
  64. #endregion MoveCursor DependencyProperty
  65. #region Direction DependencyProperty
  66. public Direction Direction
  67. {
  68. get => (Direction)GetValue(DirectionProperty);
  69. set => SetValue(DirectionProperty, value);
  70. }
  71. public static readonly DependencyProperty DirectionProperty =
  72. DependencyProperty.Register("Direction", typeof(Direction), typeof(MainImage),
  73. new PropertyMetadata(Direction.Null, new PropertyChangedCallback(MainImage.OnDirectionPropertyChanged)));
  74. private static void OnDirectionPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  75. {
  76. if (obj is MainImage)
  77. {
  78. (obj as MainImage).OnDirectionValueChanged();
  79. }
  80. }
  81. protected void OnDirectionValueChanged()
  82. {
  83. }
  84. #endregion Direction DependencyProperty
  85. #region Limit DependencyProperty
  86. public Limit Limit
  87. {
  88. get => (Limit)GetValue(LimitProperty);
  89. set => SetValue(LimitProperty, value);
  90. }
  91. public static readonly DependencyProperty LimitProperty =
  92. DependencyProperty.Register("Limit", typeof(Limit), typeof(MainImage),
  93. new PropertyMetadata(null, new PropertyChangedCallback(MainImage.OnLimitPropertyChanged)));
  94. private static void OnLimitPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  95. {
  96. if (obj is MainImage)
  97. {
  98. (obj as MainImage).OnLimitValueChanged();
  99. }
  100. }
  101. protected void OnLimitValueChanged()
  102. {
  103. }
  104. #endregion Limit DependencyProperty
  105. #region ZoomThumbVisibility DependencyProperty
  106. public Visibility ZoomThumbVisibility
  107. {
  108. get => (Visibility)GetValue(ZoomThumbVisibilityProperty);
  109. set => SetValue(ZoomThumbVisibilityProperty, value);
  110. }
  111. public static readonly DependencyProperty ZoomThumbVisibilityProperty =
  112. DependencyProperty.Register("ZoomThumbVisibility", typeof(Visibility), typeof(MainImage),
  113. new PropertyMetadata(Visibility.Visible, new PropertyChangedCallback(MainImage.OnZoomThumbVisibilityPropertyChanged)));
  114. private static void OnZoomThumbVisibilityPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
  115. {
  116. if (obj is MainImage)
  117. {
  118. (obj as MainImage).OnZoomThumbVisibilityValueChanged();
  119. }
  120. }
  121. protected void OnZoomThumbVisibilityValueChanged()
  122. {
  123. }
  124. #endregion ZoomThumbVisibility DependencyProperty
  125. #region 开始滑动事件
  126. private void OnDragStart(object sender, DragStartedEventArgs e)
  127. {
  128. Direction = (e.OriginalSource as ZoomThumb).Direction;
  129. if (SizeColorBar.Current.Selected != Tool.Null)
  130. {
  131. point = Mouse.GetPosition(this);
  132. if (SizeColorBar.Current.Selected == Tool.Text)
  133. {
  134. DrawText();
  135. }
  136. }
  137. }
  138. #endregion 开始滑动事件
  139. #region 滑动中事件
  140. private void OnDragDelta(object sender, DragDeltaEventArgs e)
  141. {
  142. double X = e.HorizontalChange;
  143. double Y = e.VerticalChange;
  144. switch (Direction)
  145. {
  146. case Direction.Move:
  147. if (SizeColorBar.Current.Selected == Tool.Null)
  148. {
  149. OnMove(X, Y);
  150. }
  151. else
  152. {
  153. switch (SizeColorBar.Current.Selected)
  154. {
  155. case Tool.Rectangle:
  156. DrawRectangle(X, Y);
  157. break;
  158. case Tool.Ellipse:
  159. DrawEllipse(X, Y);
  160. break;
  161. case Tool.Arrow:
  162. DrawArrow(X, Y);
  163. break;
  164. case Tool.Line:
  165. DrawLine(X, Y);
  166. break;
  167. case Tool.Text:
  168. break;
  169. default:
  170. break;
  171. }
  172. }
  173. break;
  174. case Direction.Null:
  175. break;
  176. default:
  177. string str = Direction.ToString();
  178. if (X != 0)
  179. {
  180. if (str.Contains("Left"))
  181. {
  182. Left(X);
  183. }
  184. if (str.Contains("Right"))
  185. {
  186. Right(X);
  187. }
  188. }
  189. if (Y != 0)
  190. {
  191. if (str.Contains("Top"))
  192. {
  193. Top(Y);
  194. }
  195. if (str.Contains("Bottom"))
  196. {
  197. Bottom(Y);
  198. }
  199. }
  200. AppModel.Current.ChangeShowSize();
  201. break;
  202. }
  203. ImageEditBar.Current.ResetCanvas();
  204. SizeColorBar.Current.ResetCanvas();
  205. }
  206. #endregion 滑动中事件
  207. #region 滑动结束事件
  208. private void OnDragCompleted(object sender, DragCompletedEventArgs e)
  209. {
  210. if (Direction == Direction.Move && SizeColorBar.Current.Selected != Tool.Null)
  211. {
  212. switch (SizeColorBar.Current.Selected)
  213. {
  214. case Tool.Rectangle:
  215. if (_Rectangle != null)
  216. {
  217. ResetLimit(Canvas.GetLeft(_Rectangle), Canvas.GetTop(_Rectangle), Canvas.GetLeft(_Rectangle) + _Rectangle.Width, Canvas.GetTop(_Rectangle) + _Rectangle.Height);
  218. JieTuWindow.Register(_Rectangle);
  219. _Rectangle = null;
  220. }
  221. break;
  222. case Tool.Ellipse:
  223. if (_Ellipse != null)
  224. {
  225. ResetLimit(Canvas.GetLeft(_Ellipse), Canvas.GetTop(_Ellipse), Canvas.GetLeft(_Ellipse) + _Ellipse.Width, Canvas.GetTop(_Ellipse) + _Ellipse.Height);
  226. JieTuWindow.Register(_Ellipse);
  227. _Ellipse = null;
  228. }
  229. break;
  230. case Tool.Arrow:
  231. if (_Arrow != null)
  232. {
  233. geometry.Clear();
  234. ResetLimit(points.Min(p => p.X), points.Min(p => p.Y), points.Max(p => p.X), points.Max(p => p.Y));
  235. points = null;
  236. JieTuWindow.Register(_Arrow);
  237. _Arrow = null;
  238. }
  239. break;
  240. case Tool.Line:
  241. if (_Line != null)
  242. {
  243. geometry.Clear();
  244. ResetLimit(points.Min(p => p.X), points.Min(p => p.Y), points.Max(p => p.X), points.Max(p => p.Y));
  245. points = null;
  246. JieTuWindow.Register(_Line);
  247. _Line = null;
  248. }
  249. break;
  250. case Tool.Text:
  251. break;
  252. default:
  253. break;
  254. }
  255. }
  256. Direction = Direction.Null;
  257. }
  258. #endregion 滑动结束事件
  259. #region 画矩形
  260. private void DrawRectangle(double X, double Y)
  261. {
  262. if (_Rectangle == null)
  263. {
  264. _Rectangle = new Rectangle()
  265. {
  266. Fill = new SolidColorBrush(Colors.Transparent),
  267. Stroke = RectangleTool.Current.LineBrush,
  268. StrokeThickness = RectangleTool.Current.LineThickness
  269. };
  270. Panel.SetZIndex(_Rectangle, -1);
  271. JieTuWindow.AddControl(_Rectangle);
  272. }
  273. if (X > 0)
  274. {
  275. Canvas.SetLeft(_Rectangle, point.X + AppModel.Current.MaskLeftWidth);
  276. _Rectangle.Width = X < Width - point.X ? X : Width - point.X;
  277. }
  278. else
  279. {
  280. Canvas.SetLeft(_Rectangle, -X < point.X ? point.X + X + AppModel.Current.MaskLeftWidth : AppModel.Current.MaskLeftWidth);
  281. _Rectangle.Width = -X < point.X ? -X : point.X;
  282. }
  283. if (Y > 0)
  284. {
  285. Canvas.SetTop(_Rectangle, point.Y + AppModel.Current.MaskTopHeight);
  286. _Rectangle.Height = Y < Height - point.Y ? Y : Height - point.Y;
  287. }
  288. else
  289. {
  290. Canvas.SetTop(_Rectangle, -Y < point.Y ? point.Y + Y + AppModel.Current.MaskTopHeight : AppModel.Current.MaskTopHeight);
  291. _Rectangle.Height = -Y < point.Y ? -Y : point.Y;
  292. }
  293. }
  294. #endregion 画矩形
  295. #region 画椭圆
  296. private void DrawEllipse(double X, double Y)
  297. {
  298. if (_Ellipse == null)
  299. {
  300. _Ellipse = new Ellipse()
  301. {
  302. Fill = new SolidColorBrush(Colors.Transparent),
  303. Stroke = EllipseTool.Current.LineBrush,
  304. StrokeThickness = EllipseTool.Current.LineThickness
  305. };
  306. Panel.SetZIndex(_Ellipse, -1);
  307. JieTuWindow.AddControl(_Ellipse);
  308. }
  309. if (X > 0)
  310. {
  311. Canvas.SetLeft(_Ellipse, point.X + AppModel.Current.MaskLeftWidth);
  312. _Ellipse.Width = X < Width - point.X ? X : Width - point.X;
  313. }
  314. else
  315. {
  316. Canvas.SetLeft(_Ellipse, -X < point.X ? point.X + X + AppModel.Current.MaskLeftWidth : AppModel.Current.MaskLeftWidth);
  317. _Ellipse.Width = -X < point.X ? -X : point.X;
  318. }
  319. if (Y > 0)
  320. {
  321. Canvas.SetTop(_Ellipse, point.Y + AppModel.Current.MaskTopHeight);
  322. _Ellipse.Height = Y < Height - point.Y ? Y : Height - point.Y;
  323. }
  324. else
  325. {
  326. Canvas.SetTop(_Ellipse, -Y < point.Y ? point.Y + Y + AppModel.Current.MaskTopHeight : AppModel.Current.MaskTopHeight);
  327. _Ellipse.Height = -Y < point.Y ? -Y : point.Y;
  328. }
  329. }
  330. #endregion 画椭圆
  331. #region 画箭头
  332. private void DrawArrow(double X, double Y)
  333. {
  334. Point screen = new Point(point.X + AppModel.Current.MaskLeftWidth, point.Y + AppModel.Current.MaskTopHeight);
  335. if (_Arrow == null)
  336. {
  337. _Arrow = new Path()
  338. {
  339. Fill = ArrowTool.Current.LineBrush,
  340. StrokeThickness = ArrowTool.Current.LineThickness
  341. };
  342. Panel.SetZIndex(_Arrow, -1);
  343. JieTuWindow.AddControl(_Arrow);
  344. }
  345. Point point2 = new Point(screen.X + X, screen.Y + Y);
  346. point2.X = point2.X < AppModel.Current.MaskLeftWidth ? AppModel.Current.MaskLeftWidth : point2.X > AppModel.Current.MaskLeftWidth + Width ? AppModel.Current.MaskLeftWidth + Width : point2.X;
  347. point2.Y = point2.Y < AppModel.Current.MaskTopHeight ? AppModel.Current.MaskTopHeight : point2.Y > AppModel.Current.MaskTopHeight + Height ? AppModel.Current.MaskTopHeight + Height : point2.Y;
  348. points = ArrowTool.Current.CreateArrow(screen, point2);
  349. using (StreamGeometryContext ctx = geometry.Open())
  350. {
  351. for (int i = 0; i < points.Count; i++)
  352. {
  353. if (i == 0)
  354. {
  355. ctx.BeginFigure(points[0], true, false);
  356. }
  357. else
  358. {
  359. ctx.LineTo(points[i], true, true);
  360. }
  361. }
  362. }
  363. _Arrow.Data = geometry.Clone();
  364. }
  365. #endregion 画箭头
  366. #region 画刷
  367. private void DrawLine(double X, double Y)
  368. {
  369. Point screen = new Point(point.X + AppModel.Current.MaskLeftWidth, point.Y + AppModel.Current.MaskTopHeight);
  370. if (_Line == null)
  371. {
  372. _Line = new Path()
  373. {
  374. Stroke = LineTool.Current.LineBrush,
  375. StrokeThickness = LineTool.Current.LineThickness
  376. };
  377. points = new List<Point>
  378. {
  379. screen
  380. };
  381. Panel.SetZIndex(_Line, -1);
  382. JieTuWindow.AddControl(_Line);
  383. }
  384. Point point2 = new Point(screen.X + X, screen.Y + Y);
  385. point2.X = point2.X < AppModel.Current.MaskLeftWidth ? AppModel.Current.MaskLeftWidth : point2.X > AppModel.Current.MaskLeftWidth + Width ? AppModel.Current.MaskLeftWidth + Width : point2.X;
  386. point2.Y = point2.Y < AppModel.Current.MaskTopHeight ? AppModel.Current.MaskTopHeight : point2.Y > AppModel.Current.MaskTopHeight + Height ? AppModel.Current.MaskTopHeight + Height : point2.Y;
  387. points.Add(point2);
  388. using (StreamGeometryContext ctx = geometry.Open())
  389. {
  390. for (int i = 0; i < points.Count; i++)
  391. {
  392. if (i == 0)
  393. {
  394. ctx.BeginFigure(points[0], true, false);
  395. }
  396. else
  397. {
  398. ctx.LineTo(points[i], true, true);
  399. }
  400. }
  401. }
  402. _Line.Data = geometry.Clone();
  403. }
  404. #endregion 画刷
  405. #region 添加输入框
  406. private void DrawText()
  407. {
  408. if (_Text != null)
  409. {
  410. Focus();
  411. }
  412. else
  413. {
  414. _Text = new TextBoxControl()
  415. {
  416. FontSize = TextTool.Current.FontSize,
  417. Foreground = TextTool.Current.LineBrush
  418. };
  419. if (point.X > Width - 36)
  420. {
  421. point.X = Width - 36;
  422. }
  423. if (point.Y > Height - 22)
  424. {
  425. point.Y = Height - 22;
  426. }
  427. Point screen = new Point(point.X + AppModel.Current.MaskLeftWidth, point.Y + AppModel.Current.MaskTopHeight);
  428. Canvas.SetLeft(_Text, screen.X);
  429. Canvas.SetTop(_Text, screen.Y);
  430. JieTuWindow.AddControl(_Text);
  431. }
  432. }
  433. #endregion 添加输入框
  434. #region 拖动截图区域
  435. private void OnMove(double X, double Y)
  436. {
  437. #region X轴移动
  438. if (X > 0)
  439. {
  440. double max = AppModel.Current.MaskRightWidth > Limit.Left - AppModel.Current.MaskLeftWidth ? Limit.Left - AppModel.Current.MaskLeftWidth : AppModel.Current.MaskRightWidth;
  441. if (X > max)
  442. {
  443. X = max;
  444. }
  445. }
  446. else
  447. {
  448. double max = AppModel.Current.MaskLeftWidth > AppModel.Current.MaskLeftWidth + Width - Limit.Right ? AppModel.Current.MaskLeftWidth + Width - Limit.Right : AppModel.Current.MaskLeftWidth;
  449. if (-X > max)
  450. {
  451. X = -max;
  452. }
  453. }
  454. if (X != 0)
  455. {
  456. AppModel.Current.MaskLeftWidth += X;
  457. AppModel.Current.MaskRightWidth -= X;
  458. Canvas.SetLeft(this, Canvas.GetLeft(this) + X);
  459. }
  460. #endregion X轴移动
  461. #region Y轴移动
  462. if (Y > 0)
  463. {
  464. double max = AppModel.Current.MaskBottomHeight > Limit.Top - AppModel.Current.MaskTopHeight ? Limit.Top - AppModel.Current.MaskTopHeight : AppModel.Current.MaskBottomHeight;
  465. if (Y > max)
  466. {
  467. Y = max;
  468. }
  469. }
  470. else
  471. {
  472. double max = AppModel.Current.MaskTopHeight > AppModel.Current.MaskTopHeight + Height - Limit.Bottom ? AppModel.Current.MaskTopHeight + Height - Limit.Bottom : AppModel.Current.MaskTopHeight;
  473. if (-Y > max)
  474. {
  475. Y = -max;
  476. }
  477. }
  478. if (Y != 0)
  479. {
  480. AppModel.Current.MaskTopHeight += Y;
  481. AppModel.Current.MaskBottomHeight -= Y;
  482. Canvas.SetTop(this, Canvas.GetTop(this) + Y);
  483. }
  484. #endregion Y轴移动
  485. }
  486. #endregion 拖动截图区域
  487. #region 左缩放
  488. private void Left(double X)
  489. {
  490. if (X > 0)
  491. {
  492. double max = JieTuWindow.Current.list.Count == 0 ? Width - JieTuWindow.MinSize
  493. : Limit.Left - AppModel.Current.MaskLeftWidth < Width - JieTuWindow.MinSize ? Limit.Left - AppModel.Current.MaskLeftWidth
  494. : Width - JieTuWindow.MinSize;
  495. if (X > max)
  496. {
  497. X = max;
  498. }
  499. }
  500. else
  501. {
  502. double max = AppModel.Current.MaskLeftWidth;
  503. if (-X > max)
  504. {
  505. X = -max;
  506. }
  507. }
  508. if (X != 0)
  509. {
  510. Width -= X;
  511. Canvas.SetLeft(this, Canvas.GetLeft(this) + X);
  512. AppModel.Current.MaskLeftWidth += X;
  513. AppModel.Current.MaskTopWidth -= X;
  514. }
  515. }
  516. #endregion 左缩放
  517. #region 右缩放
  518. private void Right(double X)
  519. {
  520. if (X > 0)
  521. {
  522. double max = AppModel.Current.MaskRightWidth;
  523. if (X > max)
  524. {
  525. X = max;
  526. }
  527. }
  528. else
  529. {
  530. double max = JieTuWindow.Current.list.Count == 0 ? Width - JieTuWindow.MinSize
  531. : AppModel.Current.MaskLeftWidth + Width - Limit.Right < Width - JieTuWindow.MinSize ? AppModel.Current.MaskLeftWidth + Width - Limit.Right
  532. : Width - JieTuWindow.MinSize;
  533. if (-X > max)
  534. {
  535. X = -max;
  536. }
  537. }
  538. if (X != 0)
  539. {
  540. Width += X;
  541. AppModel.Current.MaskRightWidth -= X;
  542. AppModel.Current.MaskTopWidth += X;
  543. }
  544. }
  545. #endregion 右缩放
  546. #region 上缩放
  547. private void Top(double Y)
  548. {
  549. if (Y > 0)
  550. {
  551. double max = JieTuWindow.Current.list.Count == 0 ? Height - JieTuWindow.MinSize
  552. : Limit.Top - AppModel.Current.MaskTopHeight < Height - JieTuWindow.MinSize ? Limit.Top - AppModel.Current.MaskTopHeight
  553. : Height - JieTuWindow.MinSize;
  554. if (Y > max)
  555. {
  556. Y = max;
  557. }
  558. }
  559. else
  560. {
  561. double max = AppModel.Current.MaskLeftWidth;
  562. if (-Y > max)
  563. {
  564. Y = -max;
  565. }
  566. }
  567. if (Y != 0)
  568. {
  569. Height -= Y;
  570. Canvas.SetTop(this, Canvas.GetTop(this) + Y);
  571. AppModel.Current.MaskTopHeight += Y;
  572. }
  573. }
  574. #endregion 上缩放
  575. #region 下缩放
  576. private void Bottom(double Y)
  577. {
  578. if (Y > 0)
  579. {
  580. double max = AppModel.Current.MaskBottomHeight;
  581. if (Y > max)
  582. {
  583. Y = max;
  584. }
  585. }
  586. else
  587. {
  588. double max = JieTuWindow.Current.list.Count == 0 ? Height - JieTuWindow.MinSize
  589. : AppModel.Current.MaskTopHeight + Height - Limit.Bottom < Height - JieTuWindow.MinSize ? AppModel.Current.MaskTopHeight + Height - Limit.Bottom
  590. : Height - JieTuWindow.MinSize;
  591. if (-Y > max)
  592. {
  593. Y = -max;
  594. }
  595. }
  596. if (Y != 0)
  597. {
  598. Height += Y;
  599. AppModel.Current.MaskBottomHeight -= Y;
  600. }
  601. }
  602. #endregion 下缩放
  603. #region 刷新RGB
  604. private void OnMove(object sender, MouseEventArgs e)
  605. {
  606. Point point = PointToScreen(e.GetPosition(this));
  607. AppModel.Current.ShowRGB = ImageHelper.GetRGB((int)point.X, (int)point.Y);
  608. }
  609. #endregion 刷新RGB
  610. #region 计算图片移动的极限值
  611. public void ResetLimit(double left, double top, double right, double bottom)
  612. {
  613. ResetLeft(left);
  614. ResetTop(top);
  615. ResetRight(right);
  616. ResetButtom(bottom);
  617. }
  618. private void ResetLeft(double value)
  619. {
  620. if (value < Limit.Left)
  621. {
  622. Limit.Left = value;
  623. }
  624. }
  625. private void ResetTop(double value)
  626. {
  627. if (value < Limit.Top)
  628. {
  629. Limit.Top = value;
  630. }
  631. }
  632. private void ResetRight(double value)
  633. {
  634. if (value > Limit.Right)
  635. {
  636. Limit.Right = value;
  637. }
  638. }
  639. private void ResetButtom(double value)
  640. {
  641. if (value > Limit.Bottom)
  642. {
  643. Limit.Bottom = value;
  644. }
  645. }
  646. #endregion 计算图片移动的极限值
  647. }
  648. }