DocumentWorkspaceWindow.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. using SmartCoalApplication.Base.Enum;
  2. using SmartCoalApplication.Core;
  3. using SmartCoalApplication.Measure;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Drawing;
  9. using System.Drawing.Imaging;
  10. using System.Reflection;
  11. using System.Threading;
  12. using System.Windows.Forms;
  13. namespace SmartCoalApplication
  14. {
  15. /// <summary>
  16. /// 抽出来在各种弹窗里面使用
  17. /// </summary>
  18. internal class DocumentWorkspaceWindow : DocumentView
  19. {
  20. private ZoomBasis zoomBasis;
  21. private ZoomBasis savedZb;
  22. private ScaleFactor savedSf;
  23. public TreeView oldDrawTreeView;
  24. private AppWorkspace appWorkspace1;
  25. protected override void OnSizeChanged(EventArgs e)
  26. {
  27. PerformLayout();
  28. base.OnSizeChanged(e);
  29. }
  30. protected override void OnLayout(LayoutEventArgs e)
  31. {
  32. if (this.zoomBasis == ZoomBasis.FitToWindow)
  33. {
  34. ZoomToWindow();
  35. // This bizarre ordering of setting PanelAutoScroll prevents some very weird layout/scroll-without-scrollbars stuff.
  36. PanelAutoScroll = true;
  37. PanelAutoScroll = false;
  38. }
  39. base.OnLayout(e);
  40. }
  41. protected override void OnResize(EventArgs e)
  42. {
  43. if (this.zoomBasis == ZoomBasis.FitToWindow)
  44. {
  45. PerformLayout();
  46. }
  47. base.OnResize(e);
  48. }
  49. public DocumentWorkspaceWindow(AppWorkspace appWorkspace, int type = 2)
  50. {
  51. this.AppWorkspaceTop = appWorkspace;
  52. this.appWorkspace1 = appWorkspace;
  53. this.InitToolsAndManager();
  54. this.RulersEnabled = false;
  55. this.rightDown = false;
  56. InitializeComponent();
  57. this.zoomBasis = ZoomBasis.FitToWindow;
  58. InitializeBottomEvent();
  59. if (type == 1)
  60. {
  61. this.ShowContextMenuStrip1();
  62. this.panel.MouseDown += new MouseEventHandler(this.ShowContextMenuStrip2);
  63. }
  64. }
  65. private void ShowContextMenuStrip2(object sender, MouseEventArgs e)
  66. {
  67. if (e.Button == MouseButtons.Right)
  68. this.ShowContextMenuStrip1();
  69. }
  70. public override void ToolStripMenuItem1_Click(object sender, EventArgs e)
  71. {
  72. //using (MeasureSettingDialog af = new MeasureSettingDialog(this.appWorkspace1))
  73. //{
  74. // af.StartPosition = FormStartPosition.CenterScreen;
  75. // af.ShowDialog();
  76. //}
  77. for (int i = 0; i < this.GraphicsList.Count; i++)
  78. {
  79. if (GraphicsList[i].Selected)
  80. {
  81. MeasurementPropertiesDialog measurementPropertiesDialog = new MeasurementPropertiesDialog(this.appWorkspace1, this.GraphicsList[i], this);
  82. measurementPropertiesDialog.StartPosition = FormStartPosition.CenterScreen;
  83. measurementPropertiesDialog.ShowDialog();
  84. }
  85. }
  86. }
  87. public override void ToolStripMenuItem2_Click(object sender, EventArgs e)
  88. {
  89. using (MeasureAreaDialog af = new MeasureAreaDialog(this.appWorkspace1, this))
  90. {
  91. af.StartPosition = FormStartPosition.CenterScreen;
  92. af.ShowDialog();
  93. }
  94. }
  95. public DocumentWorkspaceWindow()
  96. {
  97. this.RulersEnabled = false;
  98. this.rightDown = false;
  99. InitializeComponent();
  100. this.zoomBasis = ZoomBasis.FitToWindow;
  101. InitializeBottomEvent();
  102. }
  103. protected override void OnUnitsChanged()
  104. {
  105. base.OnUnitsChanged();
  106. }
  107. private void InitializeComponent()
  108. {
  109. }
  110. protected override void Dispose(bool disposing)
  111. {
  112. base.Dispose(disposing);
  113. }
  114. public override void ZoomIn()
  115. {
  116. this.ZoomBasis = ZoomBasis.ScaleFactor;
  117. base.ZoomIn();
  118. }
  119. public override void ZoomIn(double factor)
  120. {
  121. this.ZoomBasis = ZoomBasis.ScaleFactor;
  122. base.ZoomIn(factor);
  123. }
  124. public override void ZoomOut()
  125. {
  126. this.ZoomBasis = ZoomBasis.ScaleFactor;
  127. base.ZoomOut();
  128. }
  129. public override void ZoomOut(double factor)
  130. {
  131. this.ZoomBasis = ZoomBasis.ScaleFactor;
  132. base.ZoomOut(factor);
  133. }
  134. public event EventHandler ZoomBasisChanging;
  135. protected virtual void OnZoomBasisChanging()
  136. {
  137. if (ZoomBasisChanging != null)
  138. {
  139. ZoomBasisChanging(this, EventArgs.Empty);
  140. }
  141. }
  142. public event EventHandler ZoomBasisChanged;
  143. protected virtual void OnZoomBasisChanged()
  144. {
  145. if (ZoomBasisChanged != null)
  146. {
  147. ZoomBasisChanged(this, EventArgs.Empty);
  148. }
  149. }
  150. public ZoomBasis ZoomBasis
  151. {
  152. get
  153. {
  154. return this.zoomBasis;
  155. }
  156. set
  157. {
  158. if (this.zoomBasis != value)
  159. {
  160. OnZoomBasisChanging();
  161. this.zoomBasis = value;
  162. switch (this.zoomBasis)
  163. {
  164. case ZoomBasis.FitToWindow:
  165. ZoomToWindow();
  166. // Enable PanelAutoScroll only long enough to recenter the view
  167. PanelAutoScroll = true;
  168. PanelAutoScroll = false;
  169. // this would be unset by the scalefactor changes in ZoomToWindow
  170. this.zoomBasis = ZoomBasis.FitToWindow;
  171. break;
  172. case ZoomBasis.ScaleFactor:
  173. PanelAutoScroll = true;
  174. break;
  175. default:
  176. throw new InvalidEnumArgumentException();
  177. }
  178. OnZoomBasisChanged();
  179. }
  180. }
  181. }
  182. protected override void HandleMouseWheel(Control sender, MouseEventArgs e)
  183. {
  184. //1判断滚动条是否显示
  185. //2判断鼠标位置是否在滚动条上
  186. Rectangle rectangle = this.panel.ClientRectangle;
  187. rectangle.X += rectangle.Width;
  188. rectangle.Width = 25;
  189. if (this.panel.VerticalScroll.Visible && rectangle.Contains(e.Location))
  190. {
  191. base.HandleMouseWheel(sender, e);
  192. }
  193. else
  194. {
  195. double mouseDelta = (double)e.Delta / 120.0f;
  196. Rectangle visibleDocBoundsStart = this.VisibleDocumentBounds;
  197. System.Drawing.Point mouseDocPt = this.MouseToDocument(sender, new System.Drawing.Point(e.X, e.Y));
  198. RectangleF visibleDocDocRect1 = this.VisibleDocumentRectangleF;
  199. PointF mouseNPt = new PointF(
  200. (mouseDocPt.X - visibleDocDocRect1.X) / visibleDocDocRect1.Width,
  201. (mouseDocPt.Y - visibleDocDocRect1.Y) / visibleDocDocRect1.Height);
  202. Rectangle rc = this.PanelClientRectangle;
  203. int width = this.SurfaceScrollableWidth;
  204. int height = this.SurfaceScrollableHeight;
  205. //获取鼠标在图像中的坐标定位
  206. double originX = 0.5;
  207. double originY = 0.5;
  208. double ptxInDoc = mouseDocPt.X * this.ScaleRatio;
  209. double ptyInDoc = mouseDocPt.Y * this.ScaleRatio;
  210. if (rc.Width < width)
  211. {
  212. originX = (ptxInDoc + this.PanelScrollPosition.X - 0.0) / width;
  213. }
  214. if (rc.Height < height)
  215. {
  216. originY = (ptyInDoc + this.PanelScrollPosition.Y - 0.0) / height;
  217. }
  218. const double factor = 1.12;
  219. double mouseFactor = Math.Pow(factor, Math.Abs(mouseDelta));
  220. if (e.Delta > 0)
  221. {
  222. this.ZoomIn(mouseFactor);
  223. }
  224. else if (e.Delta < 0)
  225. {
  226. this.ZoomOut(mouseFactor);
  227. }
  228. RectangleF visibleDocDocRect2 = this.VisibleDocumentRectangleF;
  229. PointF scrollPt2 = new PointF(
  230. mouseDocPt.X - visibleDocDocRect2.Width * mouseNPt.X,
  231. mouseDocPt.Y - visibleDocDocRect2.Height * mouseNPt.Y);
  232. this.DocumentScrollPositionF = scrollPt2;
  233. int width2 = this.SurfaceScrollableWidth;
  234. int height2 = this.SurfaceScrollableHeight;
  235. if ((rc.Width < width2 || rc.Height < height2) && (rc.Width < width || rc.Height < height))
  236. {
  237. //根据鼠标在图像中的坐标重新定位放大后的图像
  238. this.PanelScrollPosition = new System.Drawing.Point(
  239. (int)(width2 * originX - ptxInDoc + 0),
  240. (int)(height2 * originY - ptyInDoc + 0));
  241. }
  242. else if (rc.Width < width2 || rc.Height < height2)
  243. {
  244. this.PanelScrollPosition = new System.Drawing.Point((int)(width2 - rc.Width) / 2 + 0, (int)(height2 - rc.Height) / 2 + 0);
  245. }
  246. else
  247. {
  248. this.PanelScrollPosition = new System.Drawing.Point((int)(width2 - rc.Width) / 2 + 0, (int)(height2 - rc.Height) / 2 + 0);
  249. }
  250. Rectangle visibleDocBoundsEnd = this.VisibleDocumentBounds;
  251. if (visibleDocBoundsEnd != visibleDocBoundsStart)
  252. {
  253. // Make sure the screen updates, otherwise it can get a little funky looking
  254. this.Update();
  255. }
  256. /*double mouseDelta = (double)e.Delta / 120.0f;
  257. Rectangle visibleDocBoundsStart = this.VisibleDocumentBounds;
  258. Point mouseDocPt = this.MouseToDocument(sender, new Point(e.X, e.Y));
  259. RectangleF visibleDocDocRect1 = this.VisibleDocumentRectangleF;
  260. PointF mouseNPt = new PointF(
  261. (mouseDocPt.X - visibleDocDocRect1.X) / visibleDocDocRect1.Width,
  262. (mouseDocPt.Y - visibleDocDocRect1.Y) / visibleDocDocRect1.Height);
  263. const double factor = 1.12;
  264. double mouseFactor = Math.Pow(factor, Math.Abs(mouseDelta));
  265. if (e.Delta > 0)
  266. {
  267. this.ZoomIn(mouseFactor);
  268. }
  269. else if (e.Delta < 0)
  270. {
  271. this.ZoomOut(mouseFactor);
  272. }
  273. RectangleF visibleDocDocRect2 = this.VisibleDocumentRectangleF;
  274. PointF scrollPt2 = new PointF(
  275. mouseDocPt.X - visibleDocDocRect2.Width * mouseNPt.X,
  276. mouseDocPt.Y - visibleDocDocRect2.Height * mouseNPt.Y);
  277. this.DocumentScrollPositionF = scrollPt2;
  278. Rectangle visibleDocBoundsEnd = this.VisibleDocumentBounds;
  279. if (visibleDocBoundsEnd != visibleDocBoundsStart)
  280. {
  281. // Make sure the screen updates, otherwise it can get a little funky looking
  282. this.Update();
  283. }*/
  284. }
  285. }
  286. protected override void OnLoad(EventArgs e)
  287. {
  288. base.OnLoad(e);
  289. }
  290. public event EventHandler ActiveLayerChanged;
  291. protected void OnLayerChanged()
  292. {
  293. this.Focus();
  294. if (ActiveLayerChanged != null)
  295. {
  296. ActiveLayerChanged(this, EventArgs.Empty);
  297. }
  298. }
  299. /// <summary>
  300. /// 初始化底部按钮的各种事件
  301. /// </summary>
  302. private void InitializeBottomEvent()
  303. {
  304. /*//缩小按钮
  305. this.PanelBottom.zoomOutButton.Click += new EventHandler(ZoomOutButton_Click);
  306. //放大按钮
  307. this.PanelBottom.zoomInButton.Click += new EventHandler(zoomInButton_Click);*/
  308. }
  309. private void ZoomOutButton_Click(object sender, EventArgs e)
  310. {
  311. this.ZoomOut();
  312. }
  313. private void zoomInButton_Click(object sender, EventArgs e)
  314. {
  315. this.ZoomIn();
  316. }
  317. public event EventHandler ToolChanging;
  318. protected void OnToolChanging()
  319. {
  320. if (ToolChanging != null)
  321. {
  322. ToolChanging(this, EventArgs.Empty);
  323. }
  324. }
  325. public event EventHandler ToolChanged;
  326. protected void OnToolChanged()
  327. {
  328. if (ToolChanged != null)
  329. {
  330. ToolChanged(this, EventArgs.Empty);
  331. }
  332. }
  333. /// <summary>
  334. /// Updates any pertinent EXIF tags, such as "Creation Software", to be
  335. /// relevant or up-to-date.
  336. /// </summary>
  337. /// <param name="document"></param>
  338. private void UpdateExifTags(Document document)
  339. {
  340. //PropertyItem pi = Exif.CreateAscii(ExifTagID.Software, PdnInfo.GetProductName(false));
  341. //document.Metadata.ReplaceExifValues(ExifTagID.Software, new PropertyItem[1] { pi });
  342. }
  343. protected override void OnDocumentChanging(Document newDocument)
  344. {
  345. base.OnDocumentChanging(newDocument);
  346. this.savedZb = this.ZoomBasis;
  347. this.savedSf = ScaleFactor;
  348. if (newDocument != null)
  349. {
  350. UpdateExifTags(newDocument);
  351. }
  352. }
  353. protected override void OnDocumentChanged()
  354. {
  355. bool oldDirty = this.Document.Dirty;
  356. this.Document.Invalidate();
  357. this.Document.Dirty = oldDirty;
  358. this.ZoomBasis = this.savedZb;
  359. if (this.savedZb == ZoomBasis.ScaleFactor)
  360. {
  361. ScaleFactor = this.savedSf;
  362. }
  363. AutoScrollPosition = new Point(0, 0);
  364. base.OnDocumentChanged();
  365. }
  366. //private sealed class OurProgressEvents : IFileTransferProgressEvents
  367. //{
  368. // private TransferProgressDialog progressDialog;
  369. // private ICancelable cancelSink;
  370. // private int itemCount = 0;
  371. // private int itemOrdinal = 0;
  372. // private string itemName = string.Empty;
  373. // private long totalWork;
  374. // private long totalProgress;
  375. // private const int maxPBValue = 200; // granularity of progress bar. 100 means 1%, 200 means 0.5%, etc.
  376. // private bool cancelRequested = false;
  377. // private ManualResetEvent operationEnded = new ManualResetEvent(false);
  378. // public OurProgressEvents()
  379. // {
  380. // }
  381. // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "cancelSink")]
  382. // public void BeginOperation(IWin32Window owner, EventHandler callWhenUIShown, ICancelable cancelSink)
  383. // {
  384. // if (this.progressDialog != null)
  385. // {
  386. // throw new InvalidOperationException("Operation already in progress");
  387. // }
  388. // this.progressDialog = new TransferProgressDialog();
  389. // this.progressDialog.Text = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.TransferProgress.Title");
  390. // this.progressDialog.Icon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.MenuFileOpenIcon.png").Reference);
  391. // this.progressDialog.Title = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemText.Initializing");
  392. // this.progressDialog.ProgressBar.Style = ProgressBarStyle.Marquee;
  393. // this.progressDialog.ProgressBar.Maximum = maxPBValue;
  394. // this.progressDialog.CancelClicked +=
  395. // delegate (object sender, EventArgs e)
  396. // {
  397. // this.cancelRequested = true;
  398. // this.cancelSink.RequestCancel();
  399. // UpdateUI();
  400. // };
  401. // EventHandler progressDialog_Shown =
  402. // delegate (object sender, EventArgs e)
  403. // {
  404. // callWhenUIShown(this, EventArgs.Empty);
  405. // };
  406. // this.cancelSink = cancelSink;
  407. // this.itemOrdinal = 0;
  408. // this.cancelRequested = false;
  409. // this.itemName = string.Empty;
  410. // this.itemCount = 0;
  411. // this.itemOrdinal = 0;
  412. // this.totalProgress = 0;
  413. // this.totalWork = 0;
  414. // this.progressDialog.Shown += progressDialog_Shown;
  415. // this.progressDialog.ShowDialog(owner);
  416. // this.progressDialog.Shown -= progressDialog_Shown;
  417. // this.progressDialog.Dispose();
  418. // this.progressDialog = null;
  419. // this.cancelSink = null;
  420. // }
  421. // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "itemCount")]
  422. // public void SetItemCount(int itemCount)
  423. // {
  424. // if (this.progressDialog.InvokeRequired)
  425. // {
  426. // this.progressDialog.BeginInvoke(new Procedure<int>(SetItemCount), new object[] { itemCount });
  427. // }
  428. // else
  429. // {
  430. // this.itemCount = itemCount;
  431. // UpdateUI();
  432. // }
  433. // }
  434. // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "itemOrdinal")]
  435. // public void SetItemOrdinal(int itemOrdinal)
  436. // {
  437. // if (this.progressDialog.InvokeRequired)
  438. // {
  439. // this.progressDialog.BeginInvoke(new Procedure<int>(SetItemOrdinal), new object[] { itemOrdinal });
  440. // }
  441. // else
  442. // {
  443. // this.itemOrdinal = itemOrdinal;
  444. // this.totalWork = 0;
  445. // this.totalProgress = 0;
  446. // UpdateUI();
  447. // }
  448. // }
  449. // public void SetItemInfo(string itemInfo)
  450. // {
  451. // if (this.progressDialog.InvokeRequired)
  452. // {
  453. // this.progressDialog.BeginInvoke(new Procedure<string>(SetItemInfo), new object[] { itemInfo });
  454. // }
  455. // else
  456. // {
  457. // this.itemName = itemInfo;
  458. // UpdateUI();
  459. // }
  460. // }
  461. // public void BeginItem()
  462. // {
  463. // if (this.progressDialog.InvokeRequired)
  464. // {
  465. // this.progressDialog.BeginInvoke(new Procedure(BeginItem), null);
  466. // }
  467. // else
  468. // {
  469. // this.progressDialog.ProgressBar.Style = ProgressBarStyle.Continuous;
  470. // }
  471. // }
  472. // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "totalWork")]
  473. // public void SetItemWorkTotal(long totalWork)
  474. // {
  475. // if (this.progressDialog.InvokeRequired)
  476. // {
  477. // this.progressDialog.BeginInvoke(new Procedure<long>(SetItemWorkTotal), new object[] { totalWork });
  478. // }
  479. // else
  480. // {
  481. // this.totalWork = totalWork;
  482. // UpdateUI();
  483. // }
  484. // }
  485. // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1500:VariableNamesShouldNotMatchFieldNames", MessageId = "totalProgress")]
  486. // public void SetItemWorkProgress(long totalProgress)
  487. // {
  488. // if (this.progressDialog.InvokeRequired)
  489. // {
  490. // this.progressDialog.BeginInvoke(new Procedure<long>(SetItemWorkProgress), new object[] { totalProgress });
  491. // }
  492. // else
  493. // {
  494. // this.totalProgress = totalProgress;
  495. // UpdateUI();
  496. // }
  497. // }
  498. // public void EndItem(WorkItemResult result)
  499. // {
  500. // if (this.progressDialog.InvokeRequired)
  501. // {
  502. // this.progressDialog.BeginInvoke(new Procedure<WorkItemResult>(EndItem), new object[] { result });
  503. // }
  504. // else
  505. // {
  506. // }
  507. // }
  508. // public void EndOperation(OperationResult result)
  509. // {
  510. // if (this.progressDialog.InvokeRequired)
  511. // {
  512. // this.progressDialog.BeginInvoke(new Procedure<OperationResult>(EndOperation), new object[] { result });
  513. // }
  514. // else
  515. // {
  516. // this.progressDialog.Close();
  517. // }
  518. // }
  519. // public WorkItemFailureAction ReportItemFailure(Exception ex)
  520. // {
  521. // if (this.progressDialog.InvokeRequired)
  522. // {
  523. // object result = this.progressDialog.Invoke(
  524. // new Function<WorkItemFailureAction, Exception>(ReportItemFailure),
  525. // new object[] { ex });
  526. // return (WorkItemFailureAction)result;
  527. // }
  528. // else
  529. // {
  530. // WorkItemFailureAction result;
  531. // result = ShowFileTransferFailedDialog(ex);
  532. // return result;
  533. // }
  534. // }
  535. // private WorkItemFailureAction ShowFileTransferFailedDialog(Exception ex)
  536. // {
  537. // WorkItemFailureAction result;
  538. // Icon formIcon = this.progressDialog.Icon;
  539. // string formTitle = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemFailureDialog.Title");
  540. // Image taskImage = PdnResources.GetImageResource("Icons.WarningIcon.png").Reference;
  541. // string introTextFormat = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemFailureDialog.IntroText.Format");
  542. // string introText = string.Format(introTextFormat, ex.Message);
  543. // TaskButton retryTB = new TaskButton(
  544. // PdnResources.GetImageResource("Icons.MenuImageRotate90CWIcon.png").Reference,
  545. // PdnResources.GetString("DocumentWorkspace.ShowFileDialog.RetryTB.ActionText"),
  546. // PdnResources.GetString("DocumentWorkspace.ShowFileDialog.RetryTB.ExplanationText"));
  547. // TaskButton skipTB = new TaskButton(
  548. // PdnResources.GetImageResource("Icons.HistoryFastForwardIcon.png").Reference,
  549. // PdnResources.GetString("DocumentWorkspace.ShowFileDialog.SkipTB.ActionText"),
  550. // PdnResources.GetString("DocumentWorkspace.ShowFileDialog.SkipTB.ExplanationText"));
  551. // TaskButton cancelTB = new TaskButton(
  552. // PdnResources.GetImageResource("Icons.CancelIcon.png").Reference,
  553. // PdnResources.GetString("DocumentWorkspace.ShowFileDialog.CancelTB.ActionText"),
  554. // PdnResources.GetString("DocumentWorkspace.ShowFileDialog.CancelTB.ExplanationText"));
  555. // List<TaskButton> taskButtons = new List<TaskButton>();
  556. // taskButtons.Add(retryTB);
  557. // // Only have the Skip button if there is more than 1 item being transferred.
  558. // // If only 1 item is begin transferred, Skip and Cancel are essentially synonymous.
  559. // if (this.itemCount > 1)
  560. // {
  561. // taskButtons.Add(skipTB);
  562. // }
  563. // taskButtons.Add(cancelTB);
  564. // int width96 = (TaskDialog.DefaultPixelWidth96Dpi * 4) / 3; // 33% wider
  565. // TaskButton clickedTB = TaskDialog.Show(
  566. // this.progressDialog,
  567. // formIcon,
  568. // formTitle,
  569. // taskImage,
  570. // true,
  571. // introText,
  572. // taskButtons.ToArray(),
  573. // retryTB,
  574. // cancelTB,
  575. // width96,
  576. // false,
  577. // 0,
  578. // out bool unuse);
  579. // if (clickedTB == retryTB)
  580. // {
  581. // result = WorkItemFailureAction.RetryItem;
  582. // }
  583. // else if (clickedTB == skipTB)
  584. // {
  585. // result = WorkItemFailureAction.SkipItem;
  586. // }
  587. // else
  588. // {
  589. // result = WorkItemFailureAction.CancelOperation;
  590. // }
  591. // return result;
  592. // }
  593. // private void UpdateUI()
  594. // {
  595. // int itemCount2 = Math.Max(1, this.itemCount);
  596. // double startValue = (double)this.itemOrdinal / (double)itemCount2;
  597. // double endValue = (double)(this.itemOrdinal + 1) / (double)itemCount2;
  598. // long totalWork2 = Math.Max(1, this.totalWork);
  599. // double lerp = (double)this.totalProgress / (double)totalWork2;
  600. // double newValue = Utility.Lerp(startValue, endValue, lerp);
  601. // int newValueInt = (int)Math.Ceiling(maxPBValue * newValue);
  602. // if (this.cancelRequested)
  603. // {
  604. // this.progressDialog.CancelEnabled = false;
  605. // this.progressDialog.Title = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemText.Canceling");
  606. // this.progressDialog.ProcessMsg = string.Empty;
  607. // this.progressDialog.ProgressBar.Style = ProgressBarStyle.Marquee;
  608. // }
  609. // else
  610. // {
  611. // this.progressDialog.CancelEnabled = true;
  612. // this.progressDialog.Title = this.itemName;
  613. // string progressFormat = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ProgressText.Format");
  614. // string progressText = string.Format(progressFormat, this.itemOrdinal + 1, this.itemCount);
  615. // this.progressDialog.ProcessMsg = progressText;
  616. // this.progressDialog.ProgressBar.Style = ProgressBarStyle.Continuous;
  617. // this.progressDialog.ProgressBar.Value = newValueInt;
  618. // }
  619. // }
  620. //}
  621. ///// <summary>
  622. ///// 更新测量单位,刷新UI
  623. ///// </summary>
  624. ///// <param name="measurementUnit"></param>
  625. //public void UpdateMeasureUnit(MeasurementUnit measurementUnit)
  626. //{
  627. // //循环所有测量,更新单位
  628. // if (this.GraphicsList != null
  629. // && this.GraphicsList.Count > 0)
  630. // {
  631. // int count = this.GraphicsList.Count;
  632. // for (int i = 0; i < count; i++)
  633. // {
  634. // if (this.GraphicsList[i].objectType == DrawClass.Measure)
  635. // {
  636. // ((MeasureDrawObject)(this.GraphicsList[i])).MeasurementUnit = measurementUnit;
  637. // }
  638. // }
  639. // }
  640. // this.Refresh();
  641. //}
  642. /// <summary>
  643. /// 分栏显示禁止滚动改变图片大小
  644. /// </summary>
  645. bool disableWheel = false;
  646. public void removeEvent()
  647. {
  648. disableWheel = true;
  649. }
  650. }
  651. }