Пример #1
0
 private void NationTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if ((e.Node is CityTreeNode) && (e.Button == MouseButtons.Right))
     {
         this.m_RightClickCityNode = e.Node as CityTreeNode;
     }
 }
Пример #2
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (!this.m_User.Logined)
     {
         MessageBox.Show("请先登录", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else if (this.m_NationTree.Nodes.Count == 0)
     {
         MessageBox.Show("城市节点为空,请先更新地图", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         string text = this.m_edtSearch.Text;
         if (string.IsNullOrEmpty(text))
         {
             MessageBox.Show("请输入搜索内容", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         }
         else
         {
             bool bName = true;
             text = text.Trim();
             if (char.IsNumber(text[0]))
             {
                 string[] strArray = text.Split(new char[] { ' ', ',' });
                 int      num      = int.Parse(strArray[0]) + 1;
                 int      num2     = int.Parse(strArray[1]) + 1;
                 text  = string.Format("{0:d2}0{1:d2}", num, num2);
                 bName = false;
             }
             CityTreeNode node = null;
             foreach (TreeNode node2 in this.m_NationTree.Nodes)
             {
                 foreach (TreeNode node3 in node2.Nodes)
                 {
                     CityTreeNode node4 = node3 as CityTreeNode;
                     if (node4.City.IsThisCity(text, bName))
                     {
                         node = node4;
                         break;
                     }
                 }
                 if (node != null)
                 {
                     break;
                 }
             }
             if (node == null)
             {
                 MessageBox.Show("没找到城市,可能关键字有误,或者该城市为中立城市", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 this.m_NationTree.Focus();
             }
             else
             {
                 node.Checked = true;
                 this.m_NationTree.SelectedNode = node;
                 this.m_NationTree.Focus();
             }
         }
     }
 }
Пример #3
0
        public void TestSingularAddToTree()
        {
            string       text = "content";
            CityTreeNode tree = new CityTreeNode();

            tree.Add(text);

            string result = tree.GetEntries(1)[0];

            Assert.AreEqual(result, text);
        }
Пример #4
0
        public void TestInvalidLetterSuggestions()
        {
            List <string> text = new List <string>(new string[] { "abcdef", "abd", "acdef" });
            CityTreeNode  tree = new CityTreeNode();

            text.ForEach(content => tree.Add(content));

            string        search      = "z";
            List <string> nextLetters = tree.GetNextLetters(search);

            CollectionAssert.AreEqual(new List <string>(), nextLetters);
        }
Пример #5
0
        public void TestMultipleAddToTree()
        {
            List <string> text = new List <string>(new string[] { "content", "john smith", "test" });
            CityTreeNode  tree = new CityTreeNode();

            text.ForEach(content => tree.Add(content));

            List <string> results = tree.GetEntries(3);

            foreach (string result in results)
            {
                Assert.AreEqual(true, text.Contains(result));
            }
        }
Пример #6
0
 public void ForceUpdateCity_Click(object sender, EventArgs e)
 {
     if (this.m_RightClickCityNode != null)
     {
         this.m_RightClickCityNode.Checked       = true;
         this.m_RightClickCityNode.City.ScanArmy = false;
         if (this.m_NationTree.SelectedNode == this.m_RightClickCityNode)
         {
             this.m_User.UpdateCity(this.m_RightClickCityNode.City, false);
         }
         else
         {
             this.m_NationTree.SelectedNode = this.m_RightClickCityNode;
         }
         this.m_RightClickCityNode = null;
     }
 }