Exemplo n.º 1
0
 /// <summary>
 /// 解除事件,设置选择模式为普通模式相同的icons
 /// </summary>
 private void m_GeoprocessingTree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
 {
     if ((e.Node != null))
     {
         e.Node.SelectedImageIndex = e.Node.ImageIndex;
         if ((e.Node.Tag != null))
         {
             bool handled = false;
             if (e.Node.ImageIndex == ICON_TOOL)//树节点处于未选定状态时所显示图像的图像列表索引值为2
             {
                 IGisTool tool = e.Node.Tag as IGisTool;
                 if (tool != null)
                 {
                     FireToolSelected(tool, ref handled);
                 }
             }
             else
             {
                 //假定它是个文件夹
                 IGisToolboxGroup group = e.Node.Tag as IGisToolboxGroup;
                 if (group != null)
                 {
                     FireGroupSelected(group, ref handled);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 将事件传递给所有监听者
 /// </summary>
 private void FireGroupSelected(IGisToolboxGroup group, ref bool handled)
 {
     if (this.GroupSelected != null)
     {
         this.GroupSelected(group, ref handled);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 显示组描述
 /// </summary>
 void GisToolbox_GroupSelected(IGisToolboxGroup group, ref bool handled)
 {
     this.m_textbox.Clear();                                                                           //清除所有文本
     this.m_textbox.Text = group.Name + Environment.NewLine + Environment.NewLine + group.Description; //文本内容为组的工具名和组的工具描述
     this.m_textbox.Select(0, group.Name.Length);                                                      //选择文本框中的文本框的范围为组名的长度
     this.m_textbox.SelectionFont = new Font(this.Font, FontStyle.Bold);                               //文本字体
     handled = true;
 }
Exemplo n.º 4
0
 /// <summary>
 /// 清除所有组
 /// </summary>
 public void Clear()
 {
     for (int i = m_nodes.Count - 1; i >= 0; i--)//循环删除树节点
     {
         IGisToolboxGroup group = m_nodes[i].Tag as IGisToolboxGroup;
         if (group != null)
         {
             m_nodes.RemoveAt(i);
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 删除指定位置的组
 /// </summary>
 /// <param name="item">需要删除的工具</param>
 /// <returns>成功删除返回true,失败返回false</returns>
 public bool Remove(IGisToolboxGroup item)
 {
     foreach (TreeNode node in m_nodes)
     {
         if (node.Tag as IGisToolboxGroup == item)
         {
             m_nodes.Remove(node);
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 判断组列表中是否包含特定组
        /// </summary>
        /// <param name="item">特定组</param>
        /// <returns>包含返回true,不包含返回false</returns>
        public bool Contains(IGisToolboxGroup item)
        {
            if (item == null)
            {
                return(false);
            }

            for (int i = 0; i < m_nodes.Count; i++)
            {
                IGisToolboxGroup group = m_nodes[i].Tag as IGisToolboxGroup;
                if (group == item)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 添加新的工具到组中
        /// </summary>
        /// <param name="item">需要添加的新的工具</param>
        public void Add(IGisToolboxGroup item)
        {
            if (this.Equals(item))//需要添加的工具与被添加的组相同,抛出异常
            {
                throw new InvalidOperationException();
            }

            GisToolboxGroup group = item as GisToolboxGroup;

            if (group == null)//需要添加的工具是空的,抛出异常
            {
                throw new InvalidCastException();
            }

            int i = 0;

            for (; i < m_nodes.Count; i++)
            {
                if (m_nodes[i].Tag as IGisToolboxGroup == null)//检查当前组中是否有空位
                {
                    break;
                }
            }

            TreeNode node = ((GisToolboxGroup)item).Node;//数据类型转换

            if (i < m_nodes.Count)
            {
                //如果当前组中有空位,将工具添加到空位上
                m_nodes.Insert(i, node);
            }
            else
            {
                //如果当前组没有空位,将工具添加到当前组的末尾
                m_nodes.Add(node);
            }
        }