示例#1
0
        public void InitVisualControl()
        {
            _vInfo = new Grid()
            {
                IsHitTestVisible = false
            };
            Grid grd = new Grid()
            {
                Height = viewmodel.height2, Width = viewmodel.len2, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left
            };
            Border brdback = new Border()
            {
                Background = viewmodel.background, Width = viewmodel.len2, Height = viewmodel.height2, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, CornerRadius = new CornerRadius(10), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Blue
            };
            //brdback.Effect = new System.Windows.Media.Effects.DropShadowEffect() ;
            Border brd = new Border()
            {
                Background = brush, Width = viewmodel.len2, Height = viewmodel.height2, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, CornerRadius = new CornerRadius(10), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Blue
            };

            OperateHelper.bind(this, "location", _vInfo, Border.MarginProperty);

            TextBlock txt = new TextBlock()
            {
                VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(5, 1, 0, 0), Foreground = viewmodel.fontBrush, FontSize = viewmodel.fontSize2
            };

            OperateHelper.bind(this, "info", txt, TextBlock.TextProperty);

            //vLinkLine = new Line() { StrokeThickness = 2, Stroke = viewmodel.lineBrush };
            //vLinkLine.Effect = new System.Windows.Media.Effects.DropShadowEffect();
            //OperateHelper.bind(this, "locationX", vLinkLine, Line.X1Property);
            //OperateHelper.bind(this, "locationY", vLinkLine, Line.Y1Property);
            //OperateHelper.bind(this, "centerX", vLinkLine, Line.X2Property);
            //OperateHelper.bind(this, "centerY", vLinkLine, Line.Y2Property);
            vLinkLine = new Microsoft.Expression.Controls.LineArrow()
            {
                StrokeThickness = 1, Stroke = viewmodel.lineBrush, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, ArrowSize = 5, EndArrow = Microsoft.Expression.Media.ArrowType.StealthArrow
            };
            OperateHelper.bind(this, "lineMargin", vLinkLine, Microsoft.Expression.Controls.LineArrow.MarginProperty);
            OperateHelper.bind(this, "lineWidth", vLinkLine, Microsoft.Expression.Controls.LineArrow.WidthProperty);
            OperateHelper.bind(this, "lineHeight", vLinkLine, Microsoft.Expression.Controls.LineArrow.HeightProperty);
            OperateHelper.bind(this, "lineDir", vLinkLine, Microsoft.Expression.Controls.LineArrow.StartCornerProperty);



            Border brd2 = new Border()
            {
                Width = viewmodel.len2, Height = viewmodel.height2, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, CornerRadius = new CornerRadius(10)
            };

            brd2.Background = viewmodel.brushCover;
            grd.Children.Add(brdback);
            grd.Children.Add(brd);
            grd.Children.Add(txt);
            grd.Children.Add(brd2);
            _vInfo.Children.Add(grd);
            //vInfo.Child = txt;
        }
示例#2
0
        public void refreshLocation()
        {
            foreach (line lin in lines)
            {
                lin.center = root.map.earthManager.transformD3DToScreen(lin.d3dLocation);
                isLeft     = lin.center.X < root.grid.ActualWidth / 2;

                //List<DynSceneLibrary.CObjectPosition> ele = root.map.GetElementPositions("ACLineSegment_Layer", lin.id);
                //if (ele != null)
                //{
                //    GeneralTransform3DTo2D gt = root.map.GetTransform3DTo2D();
                //    Point3D org = new Point3D(ele[0].ObjectPosition.Left, 0, ele[0].ObjectPosition.Top);
                //    lin.center = gt.Transform(org);

                //    isLeft = lin.center.X < root.grid.ActualWidth / 2;
                //}
            }
            _bound = null;



            double allheight = lines.Count * viewmodel.height2 + (lines.Count - 1) * viewmodel.span;

            if (lines.Count > 0)
            {
                int    idx = 0;
                double top = bound.Top + bound.Height / 2 - allheight / 2;
                foreach (line lin in lines.OrderBy(p => p.center.Y))
                {
                    double left = isLeft ? bound.Left - 50 - lin.len : bound.Right + 50;
                    lin.location = new Thickness(left, top, 0, 0);
                    top         += viewmodel.height2 + viewmodel.span;
                    lin.idx      = idx;
                    idx++;
                }

                // 相交互换
                int   changecount = 0;
                line  oldlin = null;
                Point p1, p2;
                Point p3             = new Point();
                int   allchangecount = 0;
                do
                {
                    allchangecount++;
                    changecount = 0;
                    foreach (line lin in lines.OrderBy(p => p.idx))
                    {
                        if (lin.idx == 0)
                        {
                            oldlin = lin;
                            continue;
                        }
                        else
                        {
                            p1 = new Point(oldlin.locationX, oldlin.locationY);
                            p2 = new Point(lin.locationX, lin.locationY);
                            if (OperateHelper.GetIntersection(oldlin.center, p1, lin.center, p2, ref p3) == 1)
                            {
                                Thickness tmp = lin.location;
                                lin.location    = oldlin.location;
                                oldlin.location = tmp;
                                int tmpi = lin.idx;
                                lin.idx    = oldlin.idx;
                                oldlin.idx = tmpi;
                                changecount++;
                            }
                            else
                            {
                                oldlin = lin;
                            }
                        }
                    }
                }while (changecount > 0 && allchangecount < 20);



                //======断面名称
                double top2  = bound.Top + bound.Height / 2 - allheight / 2 - viewmodel.fontSizeSectionName - 10;
                double left2 = isLeft ? bound.Left - 50 - viewmodel.len2 : bound.Right + 50 + 10;
                location = new Thickness(left2, top2, 0, 0);
                RaisePropertyChanged(() => location);
            }
        }