PageRenderTime 86ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/DeveloperBranches/Ken/Previous/UIObjects/TreeViewInterfaces.cs

#
C# | 364 lines | 324 code | 40 blank | 0 comment | 1 complexity | 0f860969403e86e49ff248df62ee6b66 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
  1. using System;
  2. using System.Net;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Documents;
  6. using System.Windows.Ink;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. using System.Windows.Shapes;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Diagnostics;
  14. using UIObjects.DragDropInterfaces;
  15. namespace UIObjects.TreeViewInterfaces
  16. {
  17. public enum TreeNodeImageFormat
  18. {
  19. Unknown,
  20. Png,
  21. Jpeg
  22. }
  23. public enum SpecialPropertyType
  24. {
  25. ContextMenu,
  26. Image,
  27. Children
  28. }
  29. public enum SpecialStockActionMenu
  30. {
  31. AddChildNode,
  32. Cut,
  33. Copy,
  34. Paste,
  35. Edit,
  36. Search
  37. }
  38. [AttributeUsage(AttributeTargets.Field)]
  39. public class TransferCreationMappingAttribute : Attribute
  40. {
  41. public string DisplayText { get; private set; }
  42. public TransferCreationMappingAttribute(string displayText)
  43. {
  44. this.DisplayText = displayText;
  45. }
  46. }
  47. [Flags()]
  48. public enum TransferCreationMappingType
  49. {
  50. [TransferCreationMapping("Copy To")]
  51. CopyTo = 1,
  52. [TransferCreationMapping("Move To")]
  53. MoveTo = 2,
  54. [TransferCreationMapping("Shortcut To")]
  55. ShortcutTo = 4,
  56. [TransferCreationMapping("Create New")]
  57. CreateNew = 8,
  58. [TransferCreationMapping("Custom Drop/Paste To")]
  59. Custom = 16
  60. }
  61. public enum QueryBranchType
  62. {
  63. If,
  64. ElseIf,
  65. Switch,
  66. SwitchCase,
  67. SwitchDefault,
  68. Throw,
  69. Catch,
  70. Finally,
  71. ForEach,
  72. For,
  73. Do,
  74. While,
  75. Continue,
  76. Break
  77. }
  78. [AttributeUsage(AttributeTargets.Field)]
  79. public class PropertyTypeAttribute : Attribute
  80. {
  81. public string DisplayText { get; private set; }
  82. public Type PropertyType { get; private set; }
  83. public bool IsTag { get; private set; }
  84. public SpecialPropertyType SpecialPropertyType { get; private set; }
  85. public PropertyTypeAttribute(string displayText, Type propertyType)
  86. {
  87. this.DisplayText = displayText;
  88. this.PropertyType = propertyType;
  89. }
  90. public PropertyTypeAttribute(string displayText, Type propertyType, bool isTag)
  91. {
  92. this.DisplayText = displayText;
  93. this.PropertyType = propertyType;
  94. this.IsTag = isTag;
  95. }
  96. public PropertyTypeAttribute(string displayText, SpecialPropertyType specialPropertyType)
  97. {
  98. this.DisplayText = displayText;
  99. this.SpecialPropertyType = specialPropertyType;
  100. }
  101. }
  102. [AttributeUsage(AttributeTargets.Field)]
  103. public class StockActionMenuAttribute : Attribute
  104. {
  105. public string DisplayText { get; private set; }
  106. public SpecialStockActionMenu? SpecialStockActionMenu { get; private set; }
  107. public StockActionMenuAttribute(string displayText)
  108. {
  109. this.DisplayText = displayText;
  110. }
  111. public StockActionMenuAttribute(string displayText, SpecialStockActionMenu specialStockActionMenu)
  112. {
  113. this.DisplayText = displayText;
  114. this.SpecialStockActionMenu = specialStockActionMenu;
  115. }
  116. }
  117. public enum TreeNodePropertyStockBinding
  118. {
  119. HardValue,
  120. Stub,
  121. Placeholder,
  122. FromQuery,
  123. FromAdvancedQuery,
  124. FromClipboard,
  125. FromResource,
  126. FromImageUpload
  127. }
  128. public enum TreeNodeMenuItemStockAction
  129. {
  130. [StockActionMenu("Add Child Node", SpecialStockActionMenu.AddChildNode)]
  131. AddChildNode,
  132. [StockActionMenu("Rename")]
  133. Rename,
  134. [StockActionMenu("Delete")]
  135. Delete,
  136. [StockActionMenu("Cut", SpecialStockActionMenu.Cut)]
  137. Cut,
  138. [StockActionMenu("Copy", SpecialStockActionMenu.Copy)]
  139. Copy,
  140. [StockActionMenu("Paste", SpecialStockActionMenu.Paste)]
  141. Paste,
  142. [StockActionMenu("Expand")]
  143. Expand,
  144. [StockActionMenu("Expand All")]
  145. ExpandAll,
  146. [StockActionMenu("Collapse")]
  147. Collapse,
  148. [StockActionMenu("Collapse All")]
  149. CollapseAll,
  150. [StockActionMenu("Check All")]
  151. CheckAll,
  152. [StockActionMenu("Uncheck All")]
  153. UncheckAll,
  154. [StockActionMenu("Edit...", SpecialStockActionMenu.Edit)]
  155. Edit,
  156. [StockActionMenu("Search...", SpecialStockActionMenu.Search)]
  157. Search
  158. }
  159. [Flags()]
  160. public enum TreeNodePropertyType
  161. {
  162. [PropertyType("Checked Property", typeof(bool))]
  163. Checked = 1,
  164. [PropertyType("Context Menu", SpecialPropertyType.ContextMenu)]
  165. ContextMenu = 2,
  166. [PropertyType("Text Property", typeof(string))]
  167. Text = 4,
  168. [PropertyType("Tool Tip Text Property", typeof(string))]
  169. ToolTipText = 8,
  170. [PropertyType("Child Ordinal Property", typeof(int))]
  171. ChildOrdinal = 16,
  172. [PropertyType("Level Property", typeof(int))]
  173. Level = 32,
  174. [PropertyType("Full Path Property", typeof(string))]
  175. FullPath = 64,
  176. [PropertyType("Image Property", SpecialPropertyType.Image)]
  177. Image = 128,
  178. [PropertyType("Image Index", typeof(int))]
  179. ImageIndex = 256,
  180. [PropertyType("Image Key Property", typeof(object))]
  181. ImageKey = 512,
  182. [PropertyType("Is Expanded Property", typeof(bool))]
  183. IsExpanded = 1024,
  184. [PropertyType("Is Visible Property", typeof(bool))]
  185. IsVisible = 2048,
  186. [PropertyType("Is Children Visible Property", typeof(bool))]
  187. IsChildrenVisible = 4096,
  188. [PropertyType("Tag Property", typeof(object), true)]
  189. Tag = 8192,
  190. [PropertyType("Has Children Property", typeof(bool))]
  191. HasChildren = 16384,
  192. [PropertyType("Children Property", SpecialPropertyType.Children)]
  193. Children = 16384
  194. }
  195. [Flags()]
  196. public enum TreeNodeOperationType
  197. {
  198. PreCopyOperation,
  199. PreMoveOperation,
  200. PreLinkOperation,
  201. PreDeleteOperation,
  202. PreRenameOperation,
  203. PreExpandOperation,
  204. PostCopyOperation,
  205. PostMoveOperation,
  206. PostLinkOperation,
  207. PostDeleteOperation,
  208. PostRenameOperation,
  209. PostExpandOperation
  210. }
  211. [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
  212. public class TreeNodeRootSourceAttribute : System.Attribute
  213. {
  214. public TreeNodeRootSourceAttribute(Type BaseClass, string ImageResourceURL)
  215. {
  216. }
  217. }
  218. [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
  219. public class TreeNodeAttribute : System.Attribute
  220. {
  221. public TreeNodeAttribute(Type BaseClass, string ImageResourceURL)
  222. {
  223. }
  224. }
  225. [AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
  226. public class TreeNodePropertyAttribute : System.Attribute
  227. {
  228. public TreeNodePropertyAttribute(TreeNodePropertyType type)
  229. {
  230. }
  231. }
  232. [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
  233. public class TreeNodeOperationAttribute : System.Attribute
  234. {
  235. public TreeNodeOperationAttribute(TreeNodeOperationType operations)
  236. {
  237. }
  238. }
  239. [AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
  240. public class TreeNodeChildSourceAttribute : System.Attribute
  241. {
  242. public TreeNodeChildSourceAttribute(Type ItemType, DragDropEffects allowedEffects, int SourceOrderNumber)
  243. {
  244. }
  245. public TreeNodeChildSourceAttribute(Type ItemType, DragDropEffects allowedEffects, string whereExpression, string orderByExpression, string selectExpression)
  246. {
  247. }
  248. }
  249. namespace Test
  250. {
  251. public class MyEntity
  252. {
  253. public string Name { get; set; }
  254. public MyEntity(string name)
  255. {
  256. this.Name = name;
  257. }
  258. public static explicit operator MyNode(MyEntity entity)
  259. {
  260. var myChildNode = new MyNode(entity);
  261. return myChildNode;
  262. }
  263. public List<MyChildEntity> ChildEntities
  264. {
  265. get
  266. {
  267. return new List<MyChildEntity>() { new MyChildEntity("Bob"), new MyChildEntity("Susan"), new MyChildEntity("Jim") };
  268. }
  269. }
  270. }
  271. public class MyChildEntity
  272. {
  273. public string Name { get; set; }
  274. public MyChildEntity(string name)
  275. {
  276. this.Name = name;
  277. }
  278. public static explicit operator MyChildNode(MyChildEntity entity)
  279. {
  280. var myChildNode = new MyChildNode(entity);
  281. return myChildNode;
  282. }
  283. }
  284. [TreeNode(typeof(MyChildEntity), "")]
  285. public class MyChildNode
  286. {
  287. public string Name { get; set; }
  288. private MyChildEntity Entity { get; set; }
  289. public MyChildNode(MyChildEntity entity)
  290. {
  291. this.Entity = entity;
  292. }
  293. }
  294. [TreeNode(typeof(MyEntity), "")]
  295. public class MyNode
  296. {
  297. private MyEntity Entity { get; set; }
  298. public MyNode(MyEntity entity)
  299. {
  300. this.Entity = entity;
  301. }
  302. [TreeNodeChildSource(typeof(MyChildEntity), DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link, "", "", "")]
  303. public IQueryable<MyChildNode> ChildNodes
  304. {
  305. get
  306. {
  307. return this.Entity.ChildEntities.AsQueryable().Where(e => e.Name == "Bob").Select<MyChildEntity, MyChildNode>(e => (MyChildNode)e);
  308. }
  309. }
  310. }
  311. static public class Test
  312. {
  313. static void TestNodes()
  314. {
  315. var myNode = (MyNode)new MyEntity("Bill");
  316. var myChildEntities = myNode.ChildNodes;
  317. foreach (MyChildNode childNode in myChildEntities)
  318. {
  319. Debug.WriteLine(childNode.Name);
  320. }
  321. }
  322. }
  323. }
  324. }