private void OnSubmit(object sender, UploadStringCompletedEventArgs e)
        {
            LinePnts = new List <Point>();
            CPathAnalyzeResult obj = _spatial.OnNetAnalyse(e);

            if (obj == null || obj.Paths == null)
            {
                return;
            }
            CNetPath  path        = obj.Paths[0];
            int       edgeNum     = path.Edges.Length;
            Paragraph myParagraph = new Paragraph();

            myParagraph.Inlines.Add(new Run()
            {
                Text = "1.从起点出发"
            });
            Bold       bold;
            IMSMark    mark;
            StackPanel panel;

            for (int i = 0; i < edgeNum; i++)
            {
                CNetEdge edge = path.Edges[i];
                if (i != 0)
                {
                    myParagraph.Inlines.Add(new Run()
                    {
                        Text = (i + 1).ToString() + "."
                    });
                }
                myParagraph.Inlines.Add(new Run()
                {
                    Text = "经"
                });
                bold = new Bold()
                {
                    Foreground = new SolidColorBrush(Colors.Red)
                };
                bold.Inlines.Add(edge.FieldValus[2]);
                myParagraph.Inlines.Add(bold);
                if (i != edgeNum - 1)
                {
                    myParagraph.Inlines.Add(new Run()
                    {
                        Text = "到达"
                    });
                    bold = new Bold()
                    {
                        Foreground = new SolidColorBrush(Colors.Red)
                    };
                    bold.Inlines.Add(path.Nodes[i + 1].FieldValus[0] + "\n");
                    myParagraph.Inlines.Add(bold);
                }
                else
                {
                    myParagraph.Inlines.Add(new Run()
                    {
                        Text = "到达终点"
                    });
                }
                if (GraphicsLayer != null)
                {
                    if (m_road == null)
                    {
                        m_road = new IMSPolyline(CoordinateType.Logic);
                        m_road.Shape.Stroke = new SolidColorBrush(Colors.Red);
                        GraphicsLayer.AddGraphics(m_road);
                    }
                    for (int j = 0; j < edge.Dots.Length; j++)
                    {
                        m_road.Points.Add(new Point(edge.Dots[j].x, edge.Dots[j].y));
                        LinePnts.Add(new Point(edge.Dots[j].x, edge.Dots[j].y));
                    }
                    panel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    panel.Children.Add(new Image()
                    {
                        Source = new BitmapImage(new Uri("/images/bus/stop.png", UriKind.Relative))
                    });
                    panel.Children.Add(new TextBlock()
                    {
                        Text = edge.FieldValus[2]
                    });
                    mark = new IMSMark(panel, CoordinateType.Logic)
                    {
                        EnableDrag = false, EnableAnimation = false
                    };
                    mark.X = edge.Dots[edge.Dots.Length / 2].x;
                    mark.Y = edge.Dots[edge.Dots.Length / 2].y;
                    m_markLayer.AddMark(mark);
                    m_stopList.Add(mark);
                }
            }
            m_road.Draw();
            if (netWindow == null)
            {
                netWindow = new NetWindow();
            }
            if (netWindow != null)
            {
                this.netWindow.g_graphicLayer = this.GraphicsLayer;
                this.netWindow.m_markLayer    = this.m_markLayer;
                this.netWindow.OgicPnts       = this.LinePnts;
                netWindow.Show();
                this.netWindow.Margin = new Thickness(0, 120, 0, 0);
                this.netWindow.HorizontalAlignment = HorizontalAlignment.Right;
                this.netWindow.roadReslut.Blocks.Add(myParagraph);
            }
            SuccessFlag = true;
        }
Beispiel #2
0
        private void OnSubmit(object sender, UploadStringCompletedEventArgs e)
        {
            ClearRoad();
            roadReslut.Blocks.Clear();
            if (e.Error != null)
            {
                MessageBox.Show("分析失败,错误原因为:" + e.Error.Message, "提示", MessageBoxButton.OK);
                return;
            }
            try
            {
                if (e.Result.IndexOf("COperResult") > -1)
                {
                    COperResult res = VectorObj.GetObject(e, typeof(COperResult)) as COperResult;
                    MessageBox.Show(res.ErrorInfo, "提示", MessageBoxButton.OK);
                    return;
                }
                CPathAnalyzeResult obj = _spatial.OnNetAnalyse(e);
                if (obj == null || obj.Paths == null)
                {
                    return;
                }
                CNetPath  path        = obj.Paths[0];
                int       edgeNum     = path.Edges.Length;
                Paragraph myParagraph = new Paragraph();
                myParagraph.Inlines.Add(new Run()
                {
                    Text = "1.从起点出发"
                });
                Bold       bold;
                IMSMark    mark;
                StackPanel panel;
                for (int i = 0; i < edgeNum; i++)
                {
                    CNetEdge edge = path.Edges[i];
                    if (i != 0)
                    {
                        myParagraph.Inlines.Add(new Run()
                        {
                            Text = (i + 1).ToString() + "."
                        });
                    }
                    myParagraph.Inlines.Add(new Run()
                    {
                        Text = "经"
                    });
                    bold = new Bold()
                    {
                        Foreground = new SolidColorBrush(Colors.Red)
                    };
                    bold.Inlines.Add(edge.FieldValus[2]);
                    myParagraph.Inlines.Add(bold);
                    if (i != edgeNum - 1)
                    {
                        myParagraph.Inlines.Add(new Run()
                        {
                            Text = "到达"
                        });
                        bold = new Bold()
                        {
                            Foreground = new SolidColorBrush(Colors.Red)
                        };
                        bold.Inlines.Add(path.Nodes[i + 1].FieldValus[0] + "\n");
                        myParagraph.Inlines.Add(bold);
                    }
                    else
                    {
                        myParagraph.Inlines.Add(new Run()
                        {
                            Text = "到达终点"
                        });
                    }
                    if (GraphicsLayer != null)
                    {
                        if (m_road == null)
                        {
                            m_road = new IMSPolyline(CoordinateType.Logic);
                            m_road.Shape.Stroke = new SolidColorBrush(Colors.Red);
                            GraphicsLayer.AddGraphics(m_road);
                        }
                        for (int j = 0; j < edge.Dots.Length; j++)
                        {
                            m_road.Points.Add(new Point(edge.Dots[j].x, edge.Dots[j].y));
                        }
                        panel = new StackPanel()
                        {
                            Orientation = Orientation.Horizontal
                        };
                        panel.Children.Add(new Image()
                        {
                            Source = new BitmapImage(new Uri("../images/bus/stop.png", UriKind.Relative))
                        });
                        panel.Children.Add(new TextBlock()
                        {
                            Text = edge.FieldValus[2]
                        });
                        mark = new IMSMark(panel, CoordinateType.Logic, MarkLayer)
                        {
                            EnableAnimation = false, EnableDrag = false
                        };
                        mark.X = edge.Dots[edge.Dots.Length / 2].x;
                        mark.Y = edge.Dots[edge.Dots.Length / 2].y;
                        MarkLayer.AddMark(mark);
                        m_stopList.Add(mark);
                    }
                }


                m_road.Draw();
                roadReslut.Blocks.Add(myParagraph);
                radioButton1.IsChecked = false;
                radioButton2.IsChecked = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButton.OK);
            }
        }