LayoutItem.cs 24 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. /*******************************************************************************
  2. * Copyright(c) 2012 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:LayoutItem.cs
  5. * 2.功能描述:全部LayoutItem的基类(定义为abstract)
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 欧阳涛 2012/09/14 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Drawing;
  12. namespace Dongke.WinForm.Controls.InvoiceLayout
  13. {
  14. [Serializable]
  15. public abstract class LayoutItem //: ICloneable, IDisposable
  16. {
  17. #region 成员变量
  18. private int _id; // ID
  19. private object _tag; // 扩展
  20. private readonly ItemType _type; // Item类别
  21. // 位置
  22. protected float _top; // 上位置X (mm単位)
  23. protected float _left; // 左位置Y (mm単位)
  24. protected float _width; // 宽 (mm単位)
  25. protected float _height; // 高 (mm単位)
  26. protected float _right; // 右位置 (mm単位)
  27. protected float _bottom; // 下位置 (mm単位)
  28. protected bool _sideRatioFixed = false; // 横纵比例是否固定
  29. private ItemLock _lock = ItemLock.None; // Item锁定
  30. #endregion 成员变量
  31. #region 属性
  32. /// <summary>
  33. /// LayoutBox内使用的Item标识。
  34. /// </summary>
  35. /// <remarks>
  36. /// </remarks>
  37. public int ID
  38. {
  39. get
  40. {
  41. return _id;
  42. }
  43. }
  44. /// <summary>
  45. /// 获取或设置Item类别。
  46. /// </summary>
  47. public ItemType ItemType
  48. {
  49. get
  50. {
  51. return _type;
  52. }
  53. }
  54. /// <summary>
  55. /// 获取或设置Item在LayoutBox内的X坐标 mm单位。
  56. /// </summary>
  57. public float Top
  58. {
  59. get
  60. {
  61. return _top;
  62. }
  63. set
  64. {
  65. if (value != _top)
  66. {
  67. SetTop(value);
  68. }
  69. }
  70. }
  71. /// <summary>
  72. /// 获取或设置Item在LayoutBox内的Y坐标 mm单位。
  73. /// </summary>
  74. public float Left
  75. {
  76. get
  77. {
  78. return _left;
  79. }
  80. set
  81. {
  82. if (value != _left)
  83. {
  84. SetLeft(value);
  85. }
  86. }
  87. }
  88. /// <summary>
  89. /// 获取或设置Item在LayoutBox内的宽 mm单位。
  90. /// </summary>
  91. public float Width
  92. {
  93. get
  94. {
  95. return _width;
  96. }
  97. set
  98. {
  99. if (value != _width)
  100. {
  101. SetWidth(value);
  102. }
  103. }
  104. }
  105. /// <summary>
  106. /// 获取或设置Item在LayoutBox内的高 mm单位。
  107. /// </summary>
  108. public float Height
  109. {
  110. get
  111. {
  112. return _height;
  113. }
  114. set
  115. {
  116. if (value != _height)
  117. {
  118. SetHeight(value);
  119. }
  120. }
  121. }
  122. /// <summary>
  123. /// 获取Item在LayoutBox内的右位置 mm单位。
  124. /// </summary>
  125. public float Right
  126. {
  127. get
  128. {
  129. return _left + _width;
  130. //return _right;
  131. }
  132. //set
  133. //{
  134. // if (value != _right)
  135. // {
  136. // if (SetRight(value) && _owner != null)
  137. // {
  138. // _owner.SetItemChangedArgs(this, ItemChangeType.Change);
  139. // }
  140. // }
  141. //}
  142. }
  143. /// <summary>
  144. /// 获取Item在LayoutBox内的下位置 mm单位。
  145. /// </summary>
  146. public float Bottom
  147. {
  148. get
  149. {
  150. return _top + _height;
  151. //return _bottom;
  152. }
  153. //set
  154. //{
  155. // if (value != _bottom)
  156. // {
  157. // if (SetBottom(value) && _owner != null)
  158. // {
  159. // _owner.SetItemChangedArgs(this, ItemChangeType.Change);
  160. // }
  161. // }
  162. //}
  163. }
  164. /// <summary>
  165. /// 获取或设置图片横纵比例是否固定
  166. /// </summary>
  167. public bool SideRatioFixed
  168. {
  169. get
  170. {
  171. return _sideRatioFixed;
  172. }
  173. set
  174. {
  175. if (value != _sideRatioFixed)
  176. {
  177. _sideRatioFixed = value;
  178. //if (Owner != null)
  179. //{
  180. // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  181. //}
  182. }
  183. }
  184. }
  185. /// <summary>
  186. /// 获取或设置Item锁定
  187. /// </summary>
  188. internal ItemLock ItemLockType
  189. {
  190. get
  191. {
  192. return _lock;
  193. }
  194. set
  195. {
  196. if (value != _lock)
  197. {
  198. _lock = value;
  199. //ResetItemFrame();
  200. }
  201. }
  202. }
  203. ///// <summary>
  204. ///// 获取Item是否是选择状态。
  205. ///// </summary>
  206. //public bool Selected
  207. //{
  208. // get
  209. // {
  210. // return false;
  211. // }
  212. // //internal set
  213. // //{
  214. // // if (value != _isSelected)
  215. // // {
  216. // // _isSelected = value;
  217. // // }
  218. // //}
  219. //}
  220. ///// <summary>
  221. ///// 获取或设置是否是新追加的Item。
  222. ///// </summary>
  223. //internal bool IsNew
  224. //{
  225. // get
  226. // {
  227. // return false;
  228. // }
  229. // //set
  230. // //{
  231. // // _isNew = value;
  232. // //}
  233. //}
  234. ///// <summary>
  235. ///// Item对应的图形
  236. ///// </summary>
  237. //internal Shape Shape
  238. //{
  239. // get
  240. // {
  241. // return _shape;
  242. // }
  243. // private set
  244. // {
  245. // if (_shape != value)
  246. // {
  247. // if (_shape != null)
  248. // {
  249. // _shape.Dispose();
  250. // }
  251. // _shape = value;
  252. // if (_shape != null)
  253. // {
  254. // if (_shape is SimpleShape)
  255. // {
  256. // _simpleShape = _shape as SimpleShape;
  257. // }
  258. // else if (_shape is LineShape)
  259. // {
  260. // _lineShape = _shape as LineShape;
  261. // }
  262. // SetShapeProperty(GetZoom());
  263. // if (_owner != null && !_owner.ItemShapes.Contains(_shape))
  264. // {
  265. // _owner.ItemShapes.Add(_shape);
  266. // _shape.BringToFront();
  267. // }
  268. // _shape.DoubleClick += new EventHandler(OnDoubleClickControl);
  269. // _shape.MouseDown += new MouseEventHandler(OnMouseDownControl);
  270. // _shape.PreviewKeyDown += new PreviewKeyDownEventHandler(OnPreviewKeyDown);
  271. // _shape.MouseMove += new MouseEventHandler(OnMouseMove);
  272. // _shape.Paint += new PaintEventHandler(OnPaint);
  273. // ResetShapeLocationAndSize(false);
  274. // }
  275. // }
  276. // }
  277. //}
  278. //protected SimpleShape SimpleShape
  279. //{
  280. // get
  281. // {
  282. // return _simpleShape;
  283. // }
  284. //}
  285. //protected LineShape LineShape
  286. //{
  287. // get
  288. // {
  289. // return _lineShape;
  290. // }
  291. //}
  292. ///// <summary>
  293. ///// 图形范围
  294. ///// </summary>
  295. //internal protected virtual Rectangle ShapeBounds
  296. //{
  297. // get
  298. // {
  299. // return _simpleShape != null ? _simpleShape.Bounds : Rectangle.Empty;
  300. // }
  301. //}
  302. ///// <summary>
  303. /////
  304. ///// </summary>
  305. //internal protected virtual Rectangle ShapeVirtualBounds
  306. //{
  307. // get
  308. // {
  309. // return ShapeBounds;
  310. // }
  311. //}
  312. ///// <summary>
  313. ///// 获取或设置Item的选中边框
  314. ///// </summary>
  315. //internal ItemFrame Frame
  316. //{
  317. // get
  318. // {
  319. // return _frame;
  320. // }
  321. // set
  322. // {
  323. // if (_frame != value)
  324. // {
  325. // _frame = value;
  326. // }
  327. // }
  328. //}
  329. ///// <summary>
  330. ///// 获取或设置Item的范围 - 绘制用 (mm単位)
  331. ///// </summary>
  332. //protected virtual RectangleF RectangleFDraw
  333. //{
  334. // get
  335. // {
  336. // return _rectangleFDraw;
  337. // }
  338. // set
  339. // {
  340. // _rectangleFDraw = value;
  341. // }
  342. //}
  343. #endregion 属性
  344. #region 构造函数
  345. /// <summary>
  346. /// 构造函数
  347. /// </summary>
  348. /// <param name="box">Layoutbox</param>
  349. /// <param name="itemType">item类别</param>
  350. internal LayoutItem(/*LayoutBox box, */ItemType itemType)
  351. {
  352. //_rectangleFDraw = RectangleF.Empty;
  353. //_top = LayoutConsts.ITEM_LOCATION_DEF;
  354. //_left = LayoutConsts.ITEM_LOCATION_DEF;
  355. _width = 0f;
  356. _height = 0f;
  357. _right = _left + _width;
  358. _bottom = _top + _height;
  359. _id = 0;
  360. _type = itemType;
  361. //Owner = box;
  362. //if (_owner != null)
  363. //{
  364. // _id = _owner.NewItemID;
  365. // Shape = LayoutUtility.GetNewShape(this);
  366. // //SetShapeProperty();
  367. // SetDrawProperty();
  368. //}
  369. }
  370. #endregion 构造函数
  371. #region 事件处理
  372. ///// <summary>
  373. ///// Item图形上的OnPaint事件
  374. ///// </summary>
  375. ///// <param name="sender">指定的对象</param>
  376. ///// <param name="e">提供的事件数据</param>
  377. //protected virtual void OnPaint(object sender, PaintEventArgs e)
  378. //{
  379. //}
  380. #endregion 事件处理
  381. #region 函数
  382. /// <summary>
  383. /// Item初始化
  384. /// </summary>
  385. /// <param name="box">LayoutBox</param>
  386. /// <param name="isNewID">是否生成新ID</param>
  387. /// <returns>是否成功</returns>
  388. internal virtual bool Init(/*LayoutBox box, bool isNewID*/)
  389. {
  390. //Owner = box;
  391. //if (_owner == null)
  392. //{
  393. // return false;
  394. //}
  395. //if (isNewID)
  396. //{
  397. // _id = _owner.NewItemID;
  398. //}
  399. //Shape = LayoutUtility.GetNewShape(this);
  400. ////SetShapeProperty();
  401. //SetDrawProperty();
  402. return true;
  403. }
  404. ///// <summary>
  405. ///// 刷新显示
  406. ///// </summary>
  407. //public virtual void Refresh()
  408. //{
  409. // if (_shape != null)
  410. // {
  411. // _shape.Refresh();
  412. // }
  413. //}
  414. ///// <summary>
  415. ///// 显示Item属性设置画面
  416. ///// </summary>
  417. ///// <returns>
  418. ///// DialogResult.OK:选中的Item有效,设置成功<br/>
  419. ///// DialogResult.Cancel:选中的Item有效,取消设置<br/>
  420. ///// DialogResult.None:LayoutBox不是编辑模式,或选中的Item不是一个
  421. ///// </returns>
  422. //public DialogResult ShowItemPropertyDialog()
  423. //{
  424. // if (_owner != null && _owner.LayoutMode == LayoutMode.Edit)
  425. // {
  426. // // 显示Item属性设置画面
  427. // DialogResult dialogResult = ShowItemPropertyDialogInner();
  428. // if (dialogResult == DialogResult.OK)
  429. // {
  430. // //_owner.PaperArea.Refresh();
  431. // }
  432. // return dialogResult;
  433. // }
  434. // return DialogResult.None;
  435. //}
  436. ///// <summary>
  437. ///// 显示Item属性设置画面 - 子类实例化用
  438. ///// </summary>
  439. ///// <returns>
  440. ///// DialogResult.OK:选中的Item有效,设置成功<br/>
  441. ///// DialogResult.Cancel:选中的Item有效,取消设置<br/>
  442. ///// DialogResult.None:LayoutBox不是编辑模式,或选中的Item不是一个
  443. ///// </returns>
  444. //protected virtual DialogResult ShowItemPropertyDialogInner()
  445. //{
  446. // throw new NotImplementedException();
  447. //}
  448. ///// <summary>
  449. ///// 改变Item的选择状态
  450. ///// </summary>
  451. ///// <param name="value">选中:true,取消选择:false</param>
  452. //public void Select(bool value)
  453. //{
  454. // if (_owner.LayoutMode != LayoutMode.Edit)
  455. // {
  456. // return;
  457. // }
  458. // if (_owner != null)
  459. // {
  460. // _owner.SelectItemMultiple(this, value);
  461. // }
  462. //}
  463. ///// <summary>
  464. ///// 刷新显示Item选择边框
  465. ///// </summary>
  466. //internal void ResetItemFrame()
  467. //{
  468. // if (_isSelected && _frame != null)
  469. // {
  470. // _frame.CreateFrame();
  471. // }
  472. //}
  473. ///// <summary>
  474. ///// 改变Item图形的位置和大小
  475. ///// </summary>
  476. //protected virtual bool ResetShapeLocationAndSize(int left, int top, int width, int height)
  477. //{
  478. // if (_simpleShape != null)
  479. // {
  480. // _simpleShape.Location = new Point(left, top);
  481. // _simpleShape.Size = new Size(width, height);
  482. // return true;
  483. // }
  484. // return false;
  485. //}
  486. //protected virtual bool ResetShapeLocation(int left, int top)
  487. //{
  488. // if (_simpleShape != null)
  489. // {
  490. // _simpleShape.Location = new Point(left, top);
  491. // return true;
  492. // }
  493. // return false;
  494. //}
  495. //protected virtual bool ResetShapeSize(int width, int height)
  496. //{
  497. // if (_simpleShape != null)
  498. // {
  499. // _simpleShape.Size = new Size(width, height);
  500. // return true;
  501. // }
  502. // return false;
  503. //}
  504. ///// <summary>
  505. ///// 根据zoom改变Item与Item图形的位置和大小
  506. ///// </summary>
  507. //protected virtual bool ResetItemLocationAndSize(int left, int top, int width, int height)
  508. //{
  509. // bool l = ResetItemLocation(left, top);
  510. // bool s = ResetItemSize(width, height);
  511. // return l && s;
  512. //}
  513. //protected virtual bool ResetItemLocation(int left, int top)
  514. //{
  515. // if (_lock == ItemLock.LockLocationAndSize)
  516. // {
  517. // return false;
  518. // }
  519. // int zoom = 100;
  520. // if (_owner != null)
  521. // {
  522. // zoom = _owner.Zoom;
  523. // }
  524. // if (_simpleShape != null && 0 < zoom)
  525. // {
  526. // if (_simpleShape.Top != top || _simpleShape.Left != left)
  527. // {
  528. // if (_simpleShape.Top != top)
  529. // {
  530. // _top = LayoutCommon.PixelToMillimeter(top, zoom);
  531. // _bottom = _top + _height;
  532. // }
  533. // if (_simpleShape.Left != left)
  534. // {
  535. // _left = LayoutCommon.PixelToMillimeter(left, zoom);
  536. // _right = _left + _width;
  537. // }
  538. // _simpleShape.Location = new Point(left, top);
  539. // SetRectangleF();
  540. // if (_owner != null)
  541. // {
  542. // _owner.SetItemChangedArgs(this, ItemChangeType.Moved);
  543. // }
  544. // }
  545. // }
  546. // return true;
  547. //}
  548. //protected virtual bool ResetItemSize(int width, int height)
  549. //{
  550. // if (_lock != ItemLock.None)
  551. // {
  552. // return false;
  553. // }
  554. // int zoom = 100;
  555. // if (_owner != null)
  556. // {
  557. // zoom = _owner.Zoom;
  558. // }
  559. // if (_simpleShape != null && 0 < zoom)
  560. // {
  561. // if (_simpleShape.Width != width || _simpleShape.Height != height)
  562. // {
  563. // if (_simpleShape.Width != width)
  564. // {
  565. // _width = LayoutCommon.PixelToMillimeter(width, zoom);
  566. // _right = _left + _width;
  567. // }
  568. // if (_simpleShape.Height != height)
  569. // {
  570. // _height = LayoutCommon.PixelToMillimeter(height, zoom);
  571. // _bottom = _top + _height;
  572. // }
  573. // _simpleShape.Size = new Size(width, height);
  574. // SetRectangleF();
  575. // if (_owner != null)
  576. // {
  577. // _owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  578. // }
  579. // }
  580. // }
  581. // return true;
  582. //}
  583. ///// <summary>
  584. ///// 根据zoom与Item图形的位置和大小,改变Item的位置和大小
  585. ///// </summary>
  586. //protected virtual bool ResetItemLocationAndSize()
  587. //{
  588. // bool l = ResetItemLocation();
  589. // bool s = ResetItemSize();
  590. // return l && s;
  591. //}
  592. //protected virtual bool ResetItemLocation()
  593. //{
  594. // if (_lock == ItemLock.LockLocationAndSize)
  595. // {
  596. // return false;
  597. // }
  598. // int zoom = 100;
  599. // if (_owner != null)
  600. // {
  601. // zoom = _owner.Zoom;
  602. // }
  603. // if (_simpleShape != null && 0 < zoom)
  604. // {
  605. // float top = LayoutCommon.PixelToMillimeter(_simpleShape.Top, zoom);
  606. // float left = LayoutCommon.PixelToMillimeter(_simpleShape.Left, zoom);
  607. // if (_top != top || _left != left)
  608. // {
  609. // if (_top != top)
  610. // {
  611. // _top = top;
  612. // _bottom = _top + _height;
  613. // }
  614. // if (_left != left)
  615. // {
  616. // _left = left;
  617. // _right = _left + _width;
  618. // }
  619. // SetRectangleF();
  620. // if (_owner != null)
  621. // {
  622. // _owner.SetItemChangedArgs(this, ItemChangeType.Moved);
  623. // }
  624. // }
  625. // }
  626. // return true;
  627. //}
  628. //protected virtual bool ResetItemSize()
  629. //{
  630. // if (_lock != ItemLock.None)
  631. // {
  632. // return false;
  633. // }
  634. // int zoom = 100;
  635. // if (_owner != null)
  636. // {
  637. // zoom = _owner.Zoom;
  638. // }
  639. // if (_simpleShape != null && 0 < zoom)
  640. // {
  641. // float width = LayoutCommon.PixelToMillimeter(_simpleShape.Width, zoom);
  642. // float height = LayoutCommon.PixelToMillimeter(_simpleShape.Height, zoom);
  643. // if (_width != width || _height != height)
  644. // {
  645. // if (_width != width)
  646. // {
  647. // _width = width;
  648. // _right = _left + _width;
  649. // }
  650. // if (_height != height)
  651. // {
  652. // _height = height;
  653. // _bottom = _top + _height;
  654. // }
  655. // SetRectangleF();
  656. // if (_owner != null)
  657. // {
  658. // _owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  659. // }
  660. // }
  661. // }
  662. // return true;
  663. //}
  664. /// <summary>
  665. /// 设置Item的X坐标
  666. /// </summary>
  667. /// <param name="value">X坐标</param>
  668. protected virtual bool SetTop(float value)
  669. {
  670. //if (_lock == ItemLock.LockLocationAndSize)
  671. //{
  672. // return false;
  673. //}
  674. //if (value < LayoutConsts.ITEM_LOCATION_MIN
  675. // || LayoutConsts.ITEM_LOCATION_MAX < value
  676. // || _owner.PaperHeight <= value)
  677. //{
  678. // return false;
  679. //}
  680. //_top = value;
  681. //_bottom = _top + _height;
  682. //SetRectangleF();
  683. //if (_simpleShape != null && _owner != null)
  684. //{
  685. // _simpleShape.Top = LayoutCommon.MillimeterToPixel(_top, _owner.Zoom);
  686. // ResetItemFrame();
  687. //}
  688. return true;
  689. }
  690. /// <summary>
  691. /// 设置Item的Y坐标
  692. /// </summary>
  693. /// <param name="value">Y坐标</param>
  694. protected virtual bool SetLeft(float value)
  695. {
  696. //if (_lock == ItemLock.LockLocationAndSize)
  697. //{
  698. // return false;
  699. //}
  700. //if (value < LayoutConsts.ITEM_LOCATION_MIN
  701. // || LayoutConsts.ITEM_LOCATION_MAX < value
  702. // || _owner.PaperWidth <= value)
  703. //{
  704. // return false;
  705. //}
  706. //_left = value;
  707. //_right = _left + _width;
  708. //SetRectangleF();
  709. //if (_simpleShape != null && _owner != null)
  710. //{
  711. // _simpleShape.Left = LayoutCommon.MillimeterToPixel(_left, _owner.Zoom);
  712. // ResetItemFrame();
  713. //}
  714. return true;
  715. }
  716. /// <summary>
  717. /// 设置Item的宽度
  718. /// </summary>
  719. /// <param name="value">宽</param>
  720. protected virtual bool SetWidth(float value)
  721. {
  722. //if (_lock != ItemLock.None)
  723. //{
  724. // return false;
  725. //}
  726. //if (value < LayoutConsts.ITEM_SIZE_MIN
  727. // || LayoutConsts.ITEM_SIZE_WIDTH_MAX < value)
  728. //{
  729. // return false;
  730. //}
  731. //float hValue = _height;
  732. //if (_sideRatioFixed)
  733. //{
  734. // hValue = _height / _width * value;
  735. // if (hValue < LayoutConsts.ITEM_SIZE_MIN
  736. // || LayoutConsts.ITEM_SIZE_WIDTH_MAX < hValue)
  737. // {
  738. // return false;
  739. // }
  740. // _height = hValue;
  741. // _bottom = _top + _height;
  742. //}
  743. //_width = value;
  744. //_right = _left + _width;
  745. //SetRectangleF();
  746. //if (_simpleShape != null && _owner != null)
  747. //{
  748. // if (_sideRatioFixed)
  749. // {
  750. // _simpleShape.Size = new Size(
  751. // LayoutCommon.MillimeterToPixel(_width, _owner.Zoom),
  752. // LayoutCommon.MillimeterToPixel(_height, _owner.Zoom));
  753. // }
  754. // else
  755. // {
  756. // _simpleShape.Width = LayoutCommon.MillimeterToPixel(_width, _owner.Zoom);
  757. // }
  758. // ResetItemFrame();
  759. //}
  760. return true;
  761. }
  762. /// <summary>
  763. /// 设置Item的高度
  764. /// </summary>
  765. /// <param name="value">高</param>
  766. protected virtual bool SetHeight(float value)
  767. {
  768. //if (_lock != ItemLock.None)
  769. //{
  770. // return false;
  771. //}
  772. //if (value < LayoutConsts.ITEM_SIZE_MIN
  773. // || LayoutConsts.ITEM_SIZE_HEIGHT_MAX < value)
  774. //{
  775. // return false;
  776. //}
  777. //float wValue = _height;
  778. //if (_sideRatioFixed)
  779. //{
  780. // wValue = _width / _height * value;
  781. // if (wValue < LayoutConsts.ITEM_SIZE_MIN
  782. // || LayoutConsts.ITEM_SIZE_WIDTH_MAX < wValue)
  783. // {
  784. // return false;
  785. // }
  786. // _width = wValue;
  787. // _right = _left + _width;
  788. //}
  789. //_height = value;
  790. //_bottom = _top + _height;
  791. //SetRectangleF();
  792. //if (_simpleShape != null && _owner != null)
  793. //{
  794. // if (_sideRatioFixed)
  795. // {
  796. // _simpleShape.Size = new Size(
  797. // LayoutCommon.MillimeterToPixel(_width, _owner.Zoom),
  798. // LayoutCommon.MillimeterToPixel(_height, _owner.Zoom));
  799. // }
  800. // else
  801. // {
  802. // _simpleShape.Height = LayoutCommon.MillimeterToPixel(_height, _owner.Zoom);
  803. // }
  804. // ResetItemFrame();
  805. //}
  806. return true;
  807. }
  808. ///// <summary>
  809. ///// 移动Item
  810. ///// </summary>
  811. //public virtual bool LeftItem(int value)
  812. //{
  813. // //if (_lock == ItemLock.LockLocationAndSize)
  814. // //{
  815. // // return false;
  816. // //}
  817. // //if (_simpleShape != null && value <= _simpleShape.Left)
  818. // //{
  819. // // int left = _simpleShape.Left - value;
  820. // // if (_frame != null)
  821. // // {
  822. // // _frame.Left -= value;
  823. // // }
  824. // // ResetItemLocation(left, _simpleShape.Top);
  825. // // return true;
  826. // //}
  827. // return false;
  828. //}
  829. //public virtual bool UpItem(int value)
  830. //{
  831. // if (_lock == ItemLock.LockLocationAndSize)
  832. // {
  833. // return false;
  834. // }
  835. // if (_simpleShape != null && value <= _simpleShape.Top)
  836. // {
  837. // int top = _simpleShape.Top - value;
  838. // if (_frame != null)
  839. // {
  840. // _frame.Top -= value;
  841. // }
  842. // ResetItemLocation(_simpleShape.Left, top);
  843. // return true;
  844. // }
  845. // return false;
  846. //}
  847. //public virtual bool RightItem(int value)
  848. //{
  849. // if (_lock == ItemLock.LockLocationAndSize)
  850. // {
  851. // return false;
  852. // }
  853. // if (_simpleShape != null)
  854. // {
  855. // int left = _simpleShape.Left + value;
  856. // if (_owner != null
  857. // && left < _owner.PaperArea.Width
  858. // && left <= _owner.MaxItemLeft)
  859. // {
  860. // if (_frame != null)
  861. // {
  862. // _frame.Left += value;
  863. // }
  864. // ResetItemLocation(left, _simpleShape.Top);
  865. // return true;
  866. // }
  867. // }
  868. // return false;
  869. //}
  870. //public virtual bool DownItem(int value)
  871. //{
  872. // if (_lock == ItemLock.LockLocationAndSize)
  873. // {
  874. // return false;
  875. // }
  876. // if (_simpleShape != null)
  877. // {
  878. // int top = _simpleShape.Top + value;
  879. // if (_owner != null
  880. // && top < _owner.PaperArea.Height
  881. // && top <= _owner.MaxItemTop)
  882. // {
  883. // if (_frame != null)
  884. // {
  885. // _frame.Top += value;
  886. // }
  887. // ResetItemLocation(_simpleShape.Left, top);
  888. // return true;
  889. // }
  890. // }
  891. // return false;
  892. //}
  893. //public virtual bool MoveItem(int left, int top)
  894. //{
  895. // if (_lock == ItemLock.LockLocationAndSize)
  896. // {
  897. // return false;
  898. // }
  899. // return ResetItemLocation(left, top);
  900. //}
  901. //public virtual bool ChangeItemSize(int width, int height)
  902. //{
  903. // if (_lock != ItemLock.None)
  904. // {
  905. // return false;
  906. // }
  907. // return ResetItemSize(width, height);
  908. //}
  909. ///// <summary>
  910. ///// 根据zom与Item,改变Item图形的位置和大小
  911. ///// </summary>
  912. //internal virtual bool ResetShapeLocationAndSize(bool isCheck)
  913. //{
  914. // int zoom = 100;
  915. // if (_owner != null)
  916. // {
  917. // zoom = _owner.Zoom;
  918. // }
  919. // if (_shape != null)
  920. // {
  921. // int top = LayoutCommon.MillimeterToPixel(_top, zoom);
  922. // int left = LayoutCommon.MillimeterToPixel(_left, zoom);
  923. // int width = LayoutCommon.MillimeterToPixel(_width, zoom);
  924. // int height = LayoutCommon.MillimeterToPixel(_height, zoom);
  925. // ResetShapeLocationAndSize(left, top, width, height);
  926. // ResetItemFrame();
  927. // return true;
  928. // }
  929. // return false;
  930. //}
  931. ///// <summary>
  932. ///// 初始化Item图形属性
  933. ///// </summary>
  934. //internal virtual void SetShapeProperty(float zoom)
  935. //{
  936. //}
  937. //internal virtual float GetZoom()
  938. //{
  939. // float zoom = 1;
  940. // if (Owner != null)
  941. // {
  942. // zoom = Owner.Zoom / 100f;
  943. // }
  944. // return (0 < zoom) ? zoom : 1;
  945. //}
  946. ///// <summary>
  947. ///// 初始化Item绘制用属性
  948. ///// </summary>
  949. //internal virtual float SetDrawProperty()
  950. //{
  951. // float zoom = GetZoom();
  952. // _rectangleFDraw.X = Left * zoom;
  953. // _rectangleFDraw.Y = Top * zoom;
  954. // _rectangleFDraw.Width = Width * zoom;
  955. // _rectangleFDraw.Height = (Height - LayoutConsts.TEXT_MARGIN) * zoom;
  956. // return zoom;
  957. //}
  958. ///// <summary>
  959. ///// 初始化Item绘制用范围属性
  960. ///// </summary>
  961. //internal virtual float SetRectangleF()
  962. //{
  963. // float zoom = GetZoom();
  964. // _rectangleFDraw.X = Left * zoom;
  965. // _rectangleFDraw.Y = Top * zoom;
  966. // _rectangleFDraw.Width = Width * zoom;
  967. // _rectangleFDraw.Height = (Height - LayoutConsts.TEXT_MARGIN) * zoom;
  968. // return zoom;
  969. //}
  970. ///// <summary>
  971. ///// Item图形是否被此范围包含
  972. ///// </summary>
  973. ///// <param name="rect"></param>
  974. ///// <returns></returns>
  975. //internal protected virtual bool BoundsContainsBy(Rectangle rect)
  976. //{
  977. // return _simpleShape != null ? rect.Contains(_simpleShape.Bounds) : false;
  978. //}
  979. //internal protected virtual bool BoundsContains(Rectangle rect)
  980. //{
  981. // return _simpleShape != null ? _simpleShape.Bounds.Contains(rect) : false;
  982. //}
  983. //internal protected virtual bool BoundsContains(Point pt)
  984. //{
  985. // return _simpleShape != null ? _simpleShape.Bounds.Contains(pt) : false;
  986. //}
  987. //#region ICloneable
  988. ///// <summary>
  989. ///// Creates a new object that is a copy of the current instance.
  990. ///// </summary>
  991. ///// <returns>A new object that is a copy of this instance.</returns>
  992. //public virtual object Clone()
  993. //{
  994. // return MemberwiseClone();
  995. //}
  996. //#endregion ICloneable
  997. //#region IDisposable
  998. ///// <summary>
  999. ///// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  1000. ///// </summary>
  1001. //public void Dispose()
  1002. //{
  1003. // Dispose(true);
  1004. // GC.SuppressFinalize(this);
  1005. //}
  1006. ///// <summary>
  1007. ///// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  1008. ///// </summary>
  1009. ///// <param name="disposing"></param>
  1010. //protected virtual void Dispose(bool disposing)
  1011. //{
  1012. // if (disposing)
  1013. // {
  1014. // lock (this)
  1015. // {
  1016. // if (_shape != null)
  1017. // {
  1018. // _shape.Dispose();
  1019. // _shape = null;
  1020. // }
  1021. // _owner = null;
  1022. // }
  1023. // }
  1024. //}
  1025. //#endregion IDisposable
  1026. #endregion 函数
  1027. }
  1028. }