PolygonalProperty.xaml.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using Compdfkit_Tools.Common;
  2. using ComPDFKitViewer;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. namespace Compdfkit_Tools.Measure.Property
  19. {
  20. /// <summary>
  21. /// PolygonalProperty.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class PolygonalProperty : UserControl
  24. {
  25. public ObservableCollection<int> SizeList { get; set; } = new ObservableCollection<int>
  26. {
  27. 6,8,9,10,12,14,18,20,24,26,28,32,30,32,48,72
  28. };
  29. bool IsLoadedData = false;
  30. //private AnnotAttribEvent PolygonalEvent { get; set; }
  31. public PolygonalProperty()
  32. {
  33. InitializeComponent();
  34. }
  35. private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
  36. {
  37. if (IsLoadedData)
  38. {
  39. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
  40. //PolygonalEvent?.UpdateAnnot();
  41. }
  42. }
  43. private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  44. {
  45. if (IsLoadedData)
  46. {
  47. int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
  48. bool isBold = false;
  49. bool isItalic = false;
  50. switch (selectIndex)
  51. {
  52. case 0:
  53. isBold = false;
  54. isItalic = false;
  55. break;
  56. case 1:
  57. isBold = true;
  58. isItalic = false;
  59. break;
  60. case 2:
  61. isBold = false;
  62. isItalic = true;
  63. break;
  64. case 3:
  65. isBold = true;
  66. isItalic = true;
  67. break;
  68. default:
  69. break;
  70. }
  71. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.IsBold, isBold);
  72. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.IsItalic, isItalic);
  73. //PolygonalEvent?.UpdateAnnot();
  74. }
  75. }
  76. private void FontSizeCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  77. {
  78. if (IsLoadedData)
  79. {
  80. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.FontSize, (sender as ComboBox).SelectedItem);
  81. //PolygonalEvent?.UpdateAnnot();
  82. }
  83. }
  84. private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  85. {
  86. ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
  87. if (selectItem != null && selectItem.Content != null)
  88. {
  89. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.FontName, selectItem.Content.ToString());
  90. //PolygonalEvent?.UpdateAnnot();
  91. }
  92. }
  93. private void UserControl_Loaded(object sender, RoutedEventArgs e)
  94. {
  95. Binding SizeListbinding = new Binding();
  96. SizeListbinding.Source = this;
  97. SizeListbinding.Path = new System.Windows.PropertyPath("SizeList");
  98. FontSizeComboBox.SetBinding(ComboBox.ItemsSourceProperty, SizeListbinding);
  99. IsLoadedData = true;
  100. }
  101. private void UserControl_Unloaded(object sender, RoutedEventArgs e)
  102. {
  103. IsLoadedData = false;
  104. }
  105. private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
  106. {
  107. SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
  108. if (checkBrush != null)
  109. {
  110. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.Color, checkBrush.Color);
  111. //PolygonalEvent?.UpdateAnnot();
  112. }
  113. }
  114. private void FillColorPickerControl_ColorChanged(object sender, EventArgs e)
  115. {
  116. SolidColorBrush checkBrush = FillColorPickerControl.GetBrush() as SolidColorBrush;
  117. if (checkBrush != null)
  118. {
  119. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.FillColor, checkBrush.Color);
  120. //PolygonalEvent?.UpdateAnnot();
  121. }
  122. }
  123. private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
  124. {
  125. if (IsLoadedData)
  126. {
  127. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue / 100D);
  128. //PolygonalEvent?.UpdateAnnot();
  129. }
  130. }
  131. private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
  132. {
  133. if (IsLoadedData)
  134. {
  135. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.LineStyle, CPDFLineStyleControl.DashStyle);
  136. //PolygonalEvent?.UpdateAnnot();
  137. }
  138. }
  139. private void FontColorPickerControl_ColorChanged(object sender, EventArgs e)
  140. {
  141. SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush;
  142. if (checkBrush != null)
  143. {
  144. //PolygonalEvent?.UpdateAttrib(AnnotAttrib.FontColor, checkBrush.Color);
  145. //PolygonalEvent?.UpdateAnnot();
  146. }
  147. }
  148. //public void SetAnnotArgsData(PolygonMeasureArgs annotArgs)
  149. //{
  150. // Dictionary<AnnotAttrib, object> attribDict = new Dictionary<AnnotAttrib, object>();
  151. // attribDict[AnnotAttrib.Color] = annotArgs.LineColor;
  152. // attribDict[AnnotAttrib.Transparency] = annotArgs.Transparency;
  153. // attribDict[AnnotAttrib.Thickness] = annotArgs.LineWidth;
  154. // attribDict[AnnotAttrib.LineStyle] = annotArgs.LineDash;
  155. // attribDict[AnnotAttrib.FontColor] = annotArgs.FontColor;
  156. // attribDict[AnnotAttrib.FillColor] = annotArgs.FillColor;
  157. // attribDict[AnnotAttrib.FontName] = annotArgs.FontName;
  158. // attribDict[AnnotAttrib.IsBold] = annotArgs.IsBold;
  159. // attribDict[AnnotAttrib.IsItalic] = annotArgs.IsItalic;
  160. // attribDict[AnnotAttrib.FontSize] = annotArgs.FontSize;
  161. // attribDict[AnnotAttrib.NoteText] = annotArgs.Content;
  162. // AnnotAttribEvent annotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotArgs, attribDict);
  163. // SetAnnotEventData(annotEvent);
  164. //}
  165. //public void SetAnnotEventData(AnnotAttribEvent annotEvent)
  166. //{
  167. // PolygonalEvent = null;
  168. // if (annotEvent != null)
  169. // {
  170. // foreach (AnnotAttrib attrib in annotEvent.Attribs.Keys)
  171. // {
  172. // switch (attrib)
  173. // {
  174. // case AnnotAttrib.Color:
  175. // BorderColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
  176. // break;
  177. // case AnnotAttrib.FillColor:
  178. // FillColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
  179. // break;
  180. // case AnnotAttrib.Transparency:
  181. // double transparennt = Convert.ToDouble(annotEvent.Attribs[attrib]);
  182. // if (transparennt > 1)
  183. // {
  184. // transparennt = (transparennt / 255D);
  185. // }
  186. // CPDFOpacityControl.OpacityValue = (int)(transparennt * 100);
  187. // break;
  188. // case AnnotAttrib.LineStyle:
  189. // CPDFLineStyleControl.DashStyle = (DashStyle)(annotEvent.Attribs[attrib]);
  190. // break;
  191. // case AnnotAttrib.FontColor:
  192. // FontColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
  193. // break;
  194. // case AnnotAttrib.FontName:
  195. // {
  196. // string fontName = (string)annotEvent.Attribs[AnnotAttrib.FontName];
  197. // if (fontName.Contains("Courier"))
  198. // {
  199. // FontCombox.SelectedIndex = 1;
  200. // }
  201. // else if (fontName == "Arial" || fontName.Contains("Helvetica"))
  202. // {
  203. // FontCombox.SelectedIndex = 0;
  204. // }
  205. // else if (fontName.Contains("Times"))
  206. // {
  207. // FontCombox.SelectedIndex = 2;
  208. // }
  209. // else
  210. // {
  211. // FontCombox.SelectedIndex = -1;
  212. // }
  213. // }
  214. // break;
  215. // case AnnotAttrib.FontSize:
  216. // SetFontSize(Convert.ToDouble(annotEvent.Attribs[attrib]));
  217. // break;
  218. // case AnnotAttrib.NoteText:
  219. // NoteTextBox.Text = annotEvent.Attribs[attrib].ToString();
  220. // break;
  221. // default:
  222. // break;
  223. // }
  224. // }
  225. // bool isBold = false;
  226. // bool isItalic = false;
  227. // if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsBold))
  228. // {
  229. // isBold = (bool)annotEvent.Attribs[AnnotAttrib.IsBold];
  230. // }
  231. // if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsItalic))
  232. // {
  233. // isItalic = (bool)annotEvent.Attribs[AnnotAttrib.IsItalic];
  234. // }
  235. // SetFontStyle(isBold, isItalic);
  236. // }
  237. // PolygonalEvent = annotEvent;
  238. //}
  239. public void SetFontStyle(bool isBold, bool isItalic)
  240. {
  241. if (isBold == false && isItalic == false)
  242. {
  243. FontStyleCombox.SelectedIndex = 0;
  244. return;
  245. }
  246. if (isBold && isItalic == false)
  247. {
  248. FontStyleCombox.SelectedIndex = 1;
  249. return;
  250. }
  251. if (isBold == false && isItalic)
  252. {
  253. FontStyleCombox.SelectedIndex = 2;
  254. return;
  255. }
  256. if (isBold && isItalic)
  257. {
  258. FontStyleCombox.SelectedIndex = 3;
  259. }
  260. }
  261. private void SetFontSize(double size)
  262. {
  263. int index = SizeList.IndexOf((int)size);
  264. FontSizeComboBox.SelectedIndex = index;
  265. }
  266. }
  267. }