Exemplo n.º 1
0
        //响应保存按钮
        private void OnVertexSave(object sender, RoutedEventArgs e)
        {
            if (newEllipse == null && targetEllipse == null)
            {
                return;
            }


            if (VertexName.Text.Equals(""))
            {
                return;
            }

            string name = "_" + VertexName.Text;
            int    popularity;
            string info     = VertexInfo.Text;
            bool   restArea = HasRestArea.IsChecked.Value;
            bool   WC       = HasWC.IsChecked.Value;

            //如果用户输入的内容不符合规制,
            if (int.TryParse(VertexPopularityTextBox.Text, out popularity) == false || name.Equals(""))
            {
                PromptChange.Visibility = Visibility.Visible;
                return;
            }

            uint popu = uint.Parse(popularity.ToString());

            //如果不是新的点
            Console.WriteLine("onsaveVertex");
            if (VertexAdj.ContainsKey(name))
            {
                Vertex v = VertexAdj[name];
                v.reset(popu, info, restArea, WC);
                ScenicDll.CreateNewVertex(name, popu, info, restArea, WC);
                VertexAdj[name] = v;
            }
            else if (newEllipse != null)//如果是新的点
            {
                Vertex v = new Vertex(name, popu, info, restArea, WC);
                v.number = ScenicDll.CreateNewVertex(name, popu, info, restArea, WC);

                VertexAdj.Add(v.name, v);
                //点保存之后,设置点上的景点名称
                TextBlock newTextBlock = new TextBlock();
                newTextBlock.Text = v.name.Substring(1, v.name.Length - 1);
                Canvas.SetTop(newTextBlock, Canvas.GetTop(newEllipse) - 15);
                Canvas.SetLeft(newTextBlock, Canvas.GetLeft(newEllipse) + 25);
                Canvas.SetZIndex(newTextBlock, 1001);
                newTextBlock.Name = v.name + "TextBlcok";
                LTLCanvas.Children.Add(newTextBlock);
                newEllipse.Name = v.name;
                newEllipse      = null;
            }
            //添加之后放弃指向
            PromptChange.Visibility      = Visibility.Hidden;
            VertexName.Text              = "";
            VertexInfo.Text              = "";
            VertexPopularityTextBox.Text = "0";
        }
Exemplo n.º 2
0
        private void OnSortByPopularity(object sender, RoutedEventArgs e)
        {
            StringBuilder msg = new StringBuilder(1024);

            Console.WriteLine("OnSortByPopularity::" + ScenicDll.SortByPopularity(msg));
            Information.Text = msg.ToString();
        }
Exemplo n.º 3
0
        private void OnMiniSpanTree(object sender, RoutedEventArgs e)
        {
            StringBuilder msg = new StringBuilder(1024);

            Console.WriteLine("MiniSpanTree::" + ScenicDll.MiniSpanTree(msg));
            Information.Text = msg.ToString();
        }
Exemplo n.º 4
0
        private void OnLoopWay(object sender, RoutedEventArgs e)
        {
            StringBuilder msg = new StringBuilder(1024);

            Console.WriteLine("GetLoopGraph:: " + ScenicDll.GetLoopGraph(msg));
            Information.Text = msg.ToString();
        }
Exemplo n.º 5
0
        private void OnTourGraph(object sender, RoutedEventArgs e)
        {
            StringBuilder msg = new StringBuilder(1024);

            Console.WriteLine(ScenicDll.GetTourGuide(msg));
            Information.Text = "导游图为: " + msg.ToString();
        }
Exemplo n.º 6
0
        private void OnKeySearch(object sender, RoutedEventArgs e)
        {
            StringBuilder msg = new StringBuilder(1024);

            msg.Append(keyWord.Text);
            Console.WriteLine("OnSortByPopularity::" + ScenicDll.KeySearch(msg));
            Information.Text = msg.ToString();
        }
Exemplo n.º 7
0
        private void OnMiniDistance(object sender, RoutedEventArgs e)
        {
            if (startVertex.Text == "" || endVertex.Text == "")
            {
                return;
            }
            string        start = "_" + startVertex.Text;
            string        end   = "_" + endVertex.Text;
            StringBuilder msg   = new StringBuilder(1024);

            ScenicDll.MiniDistance(msg, start, end);
            Information.Text = msg.ToString();
        }
Exemplo n.º 8
0
        //保存边
        private void OnSaveEdge(object sender, RoutedEventArgs e)
        {
            if (startEllipse == endEllipse)
            {
                return;
            }

            //如果起点或终点为空,那么边保存无效
            if (startEllipse == null || endEllipse == null)
            {
                if (newPath != null)
                {
                    PathList.Remove(newPath);
                    LTLCanvas.Children.Remove(newPath);
                }
            }
            else
            {
                string startName = startEllipse.Name;
                string endName   = endEllipse.Name;
                //确保边权重是个数
                int distance;
                if (int.TryParse(EdgeDistance.Text, out distance) == false)
                {
                    PromptChange.Visibility = Visibility.Visible;
                    return;
                }

                uint dis = uint.Parse(distance.ToString());

                uint edgesN = ScenicDll.CreateNewEdge(startName, endName, dis);
                Console.WriteLine("edgesN = " + edgesN);
            }
            //将相关引用置空
            startEllipse            = null;
            endEllipse              = null;
            newPath                 = null;
            PromptChange.Visibility = Visibility.Hidden;
            EdgeDistance.Text       = "0";
        }