LayersTreeEx.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using SuperMap.Mapping;
  2. using SuperMap.UI;
  3. using System.Windows.Forms;
  4. namespace WWPipeLine.MapBasic
  5. {
  6. public class LayersTreeEx : ToolWindowExtend
  7. {
  8. private MapControl m_MapControl;
  9. public LayersTree m_LayersTree;
  10. public LayersTreeEx(MapControl m)
  11. {
  12. this.TabText = "图层列表";
  13. this.Text = "LayersTreeEx图层列表";
  14. this.Tag = "MainControls";
  15. m_MapControl = m;
  16. m_LayersTree = new LayersTree { Name = "LayersTreeEx", Dock = DockStyle.Fill };
  17. m_LayersTree.LabelEdit = false;
  18. m_LayersTree.Font = new System.Drawing.Font("微软雅黑", 9);
  19. m_LayersTree.ItemHeight = 23;
  20. m_LayersTree.ShowRootLines = true;
  21. m_LayersTree.MultiSelect = false;//获取或设置是否支持同时选中多个树节点。 默认为值 true。
  22. m_LayersTree.DragNodeEnabled = false;//是否启用拖拽节点功能,false表示不启用,此时,所有选中树节点的拖动鼠标操作都无效。
  23. m_LayersTree.ShowVisibleScaleSign = true;//获取或设置是否在图层图标位置显示最大或最小比例尺的标识。
  24. m_LayersTree.Icons = TreeIconTypes.Visible | TreeIconTypes.Selectable | TreeIconTypes.TypeIcon;
  25. m_LayersTree.Map = m_MapControl.Map;
  26. m_LayersTree.Interactions[InteractionType.KeyF2] = new KeyEventHandler(KeyEventHandlerNull);
  27. m_LayersTree.Interactions[InteractionType.NodeDrop] = new KeyEventHandler(KeyEventHandlerNull);
  28. m_LayersTree.Interactions[InteractionType.KeyDelete] = new KeyEventHandler(KeyEventHandlerNull);
  29. m_LayersTree.Interactions[InteractionType.FileDrop] = new KeyEventHandler(KeyEventHandlerNull);
  30. this.Controls.Add(m_LayersTree);
  31. }
  32. private void LayersTreeEx_Load(object sender, System.EventArgs e)
  33. {
  34. //foreach (TreeNode treeNode in m_LayersTree.Nodes)
  35. //{
  36. // if (treeNode.Nodes.Count > 0) treeNode.ExpandAll();
  37. //}
  38. //LayerGroup lg = m_MapControl.Map.Layers.FindLayer("LayerGroup#1") as LayerGroup;
  39. //foreach (Layer r in lg)
  40. //{
  41. // r.IsVisible = false;
  42. // r.IsEditable = false;
  43. // r.IsSelectable = false;
  44. //}
  45. //foreach (Layer r in ComsStatic.MapLayers)
  46. //{
  47. // r.IsEditable = false;
  48. //}
  49. //m_LayersTree.ExpandAll();
  50. }
  51. private void KeyEventHandlerNull(object sender = null, KeyEventArgs e = null) { e.Handled = true; }
  52. private void InitializeComponent()
  53. {
  54. this.SuspendLayout();
  55. //
  56. // LayersTreeEx
  57. //
  58. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  59. this.ClientSize = new System.Drawing.Size(800, 450);
  60. this.Name = "LayersTreeEx";
  61. this.Text = "LayerTreeExText";
  62. this.ResumeLayout(false);
  63. }
  64. }
  65. }