Document.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* ==============================================================================
  2. * 功能描述:Document
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/12/17 16:18:00
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace TestCad.Model
  12. {
  13. /// <summary>
  14. /// Document
  15. /// </summary>
  16. class Document
  17. {
  18. private Document()
  19. {
  20. m_Objects = new List<CADObject>();
  21. Elements =new Dictionary<string, List<CADObject>>();
  22. }
  23. public static Document CreateDocument()
  24. {
  25. return new Document();
  26. }
  27. private List<CADObject> m_Objects;
  28. public Dictionary<string, List<CADObject>> Elements { get; private set; }
  29. public void AddObject(CADObject cadObject)
  30. {
  31. m_Objects.Add(cadObject);
  32. }
  33. /// <summary>
  34. ///
  35. /// </summary>
  36. /// <param name="document"></param>
  37. public void GroupElements()
  38. {
  39. var group = m_Objects.GroupBy(bim => bim.GetType().Name);
  40. var dic = new Dictionary<string, List<CADObject>>();
  41. foreach (var collection in group)
  42. {
  43. dic[collection.Key + "s"] = collection.ToList();
  44. }
  45. Elements = dic;
  46. }
  47. }
  48. }