Esempio n. 1
0
        private void drawReferenceCircles()
        {
            int    i = 0;
            string controlNameBase = "ReferenceCircle";
            string name            = controlNameBase + i;

            // do it once, only after the control has been loaded:
            if (MainGrid.IsLoaded && (MainGrid.FindName(name) as Ellipse) == null)
            {
                foreach (double radius in circleDistances)
                {
                    // keep in mind that ScannedArea is a bit raised over what we consider the robot center.

                    // radius = MapperSettings.referenceCircleRadiusMeters;
                    double diamW = radius * ScannedArea.ActualWidth / rangeMaxValueM;
                    double diamH = radius * ScannedArea.ActualHeight * 2.0d / rangeMaxValueM;

                    // draw reference circle (usually 2 meters):
                    Ellipse circle = new Ellipse()
                    {
                        Name            = controlNameBase + i,
                        Width           = diamW,
                        Height          = diamH,
                        Margin          = new Thickness((MainGrid.ActualWidth - diamW) / 2.0d, (MainGrid.ActualHeight * 2.0d - diamH) / 2.0d, 0, 0),
                        Stroke          = Brushes.Cyan,
                        StrokeThickness = 1
                    };
                    MainGrid.Children.Add(circle);
                    MainGrid.RegisterName(circle.Name, circle);
                    i++;
                }
            }
        }
Esempio n. 2
0
        //Index页面下的UI控制
        private void ShowIndex()
        {
            scrollIndex.Visibility    = Visibility.Visible;
            scrollMessages.Visibility = Visibility.Collapsed;

            Message m0 = MessagesKeeper.Get(0);

            if (m0 == null)
            {
                MessageBox.Show("数据加载中,请稍后……");
                return;
            }

            foreach (int sonId in m0.SonsId)
            {
                Message m1 = MessagesKeeper.Get(sonId);
                if (m1 != null)
                {
                    ScrollViewer sv = getIndexTextBlock(m1);
                    if (!stackPanel.Children.Contains(sv))
                    {
                        stackPanel.Children.Add(sv);
                        MainGrid.RegisterName("scrollViewerIndex" + m1.Id, sv);
                    }
                }
            }
        }
Esempio n. 3
0
        public void CreateNGrid(int x, int y)
        {
            A = x;

            //repaint
            int intTotalChildren = MainGrid.Children.Count - 1;

            for (int intCounter = intTotalChildren; intCounter > 0; intCounter--)
            {
                if (MainGrid.Children[intCounter].GetType() == typeof(Grid))
                {
                    Grid ucCurrentChild = (Grid)MainGrid.Children[intCounter];
                    MainGrid.Children.Remove(ucCurrentChild);
                }
            }
            //Clear the List
            RuleCells.Clear();
            Grid NGrid = new Grid();

            NGrid.Width  = Double.NaN;
            NGrid.Height = Double.NaN;
            NGrid.HorizontalAlignment = HorizontalAlignment.Left;
            NGrid.VerticalAlignment   = VerticalAlignment.Top;
            NGrid.SetValue(Grid.RowProperty, 1);
            NGrid.SetValue(Grid.ColumnProperty, 1);
            NGrid.SetValue(Grid.RowSpanProperty, 2);

            for (int i = 0; i < y; i++)
            {
                ColumnDefinition gridCol = new ColumnDefinition();
                gridCol.Width = GridLength.Auto;
                NGrid.ColumnDefinitions.Add(gridCol);
            }

            for (int i = 0; i < x; i++)
            {
                RowDefinition rowdef = new RowDefinition();
                rowdef.Height = GridLength.Auto;
                NGrid.RowDefinitions.Add(rowdef);
            }

            for (int i = 0; i < x; i++)
            {
                List <Cell> sublist = new List <Cell>();
                for (int j = 0; j < y; j++)
                {
                    Label Box = new Label();

                    if (Z == 1)
                    {
                        if (i == 0 && j == 0 || i == 0 && j == 2 || i == 2 && j == 0 || i == 2 && j == 2)
                        {
                            Box.Visibility = Visibility.Hidden;
                            Box.IsEnabled  = false;
                        }
                    }


                    //Middle one is off the charts.
                    if ((i == (x * 2) / 5 && j == (y * 2) / 5))
                    {
                        Box.IsEnabled = false;
                    }


                    Box.Width  = 120 / x;
                    Box.Height = 120 / y;
                    Box.Name   = "Y" + i.ToString() + "Y" + j.ToString();

                    object o = MainGrid.FindName(Box.Name);
                    if (o != null)
                    {
                        MainGrid.UnregisterName(Box.Name);
                    }
                    MainGrid.RegisterName(Box.Name, Box);


                    //  if (neighbourhood != 4)
                    {
                        Cell cell = new Cell(i, j);
                        cell.State = 3;
                        sublist.Add(cell);
                    }


                    Box.MouseDown        += new MouseButtonEventHandler(Cell_Click);
                    Box.BorderBrush       = new SolidColorBrush(Colors.Gray);
                    Box.BorderThickness   = new Thickness(1);
                    Box.FontSize          = 14;
                    Box.FontWeight        = FontWeights.Bold;
                    Box.Foreground        = new SolidColorBrush(Colors.Black);
                    Box.VerticalAlignment = VerticalAlignment.Top;
                    Grid.SetRow(Box, i);
                    Grid.SetColumn(Box, j);
                    NGrid.Children.Add(Box);
                }
                RuleCells.Add(sublist);
            }


            RuleGrid = NGrid;
            MainGrid.Children.Add(NGrid);
        }
Esempio n. 4
0
        public void MatrixAnimationUsingPathDoesRotateWithTangentExample()
        {
            // Create a NameScope for the page so that
            // we can use Storyboards.
            NameScope.SetNameScope(MainGrid, new NameScope());

            // Create a button.
            Map.MapBlock aButton = new Map.MapBlock();
            aButton.LeftSideVisable  = true;
            aButton.RightSideVisable = true;
            // Create a MatrixTransform. This transform
            // will be used to move the button.
            MatrixTransform buttonMatrixTransform = new MatrixTransform();

            aButton.RenderTransform = buttonMatrixTransform;

            // Register the transform's name with the page
            // so that it can be targeted by a Storyboard.
            MainGrid.RegisterName("ButtonMatrixTransform", buttonMatrixTransform);

            // Create a Canvas to contain the button
            // and add it to the page.
            // Although this example uses a Canvas,
            // any type of panel will work.
            Canvas mainPanel = new Canvas();

            mainPanel.Width  = 400;
            mainPanel.Height = 400;
            mainPanel.Children.Add(aButton);
            MainGrid.Children.Add(mainPanel);

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure   pFigure       = new PathFigure();

            pFigure.StartPoint = new Point(10, 100);
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();

            pBezierSegment.Points.Add(new Point(35, 0));
            pBezierSegment.Points.Add(new Point(135, 0));
            pBezierSegment.Points.Add(new Point(160, 100));
            pBezierSegment.Points.Add(new Point(180, 190));
            pBezierSegment.Points.Add(new Point(285, 200));
            pBezierSegment.Points.Add(new Point(310, 100));
            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating
            // its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();

            matrixAnimation.PathGeometry   = animationPath;
            matrixAnimation.Duration       = TimeSpan.FromSeconds(5);
            matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the rectangle in addition
            // to moving it.
            matrixAnimation.DoesRotateWithTangent = true;

            // Set the animation to target the Matrix property
            // of the MatrixTransform named "ButtonMatrixTransform".
            Storyboard.SetTargetName(matrixAnimation, "ButtonMatrixTransform");
            Storyboard.SetTargetProperty(matrixAnimation,
                                         new PropertyPath(MatrixTransform.MatrixProperty));

            // Create a Storyboard to contain and apply the animation.
            Storyboard pathAnimationStoryboard = new Storyboard();

            pathAnimationStoryboard.Children.Add(matrixAnimation);

            // Start the storyboard when the button is loaded.
            aButton.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                // Start the storyboard.
                pathAnimationStoryboard.Begin(MainGrid);
            };
        }