public MainPage()
        {
            this.InitializeComponent();

            initLedMatrixDevice();

            for (int i = 0; i < MATRIX_SIZE; i++)
            {
                TextBlock tb = new TextBlock();
                tb.Text = "0x00";
                tb.HorizontalAlignment = HorizontalAlignment.Center;
                tb.VerticalAlignment = VerticalAlignment.Center;
                tb.SetValue(Grid.RowProperty, i);
                tb.SetValue(Grid.ColumnProperty, MATRIX_SIZE);
                _matrix.Children.Add(tb);

                _matrixRowValue[i] = tb;

                for (int j = 0; j < MATRIX_SIZE; j++)
                {
                    Ellipse led = new Ellipse();
                    led.Width = 40;
                    led.Height = 40;
                    led.HorizontalAlignment = HorizontalAlignment.Center;
                    led.VerticalAlignment = VerticalAlignment.Center;
                    led.Fill = _off;
                    led.SetValue(Grid.RowProperty, i);
                    led.SetValue(Grid.ColumnProperty, j);
                    led.PointerPressed += Led_PointerPressed;
                    _matrix.Children.Add(led);

                    setMatrixData(i, j, 0);
                }
            }
        }
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            var width = this.ActualWidth;
            var height = this.ActualHeight;

            var min = Math.Min(width, height);

            var cwidth = min/8;
            for (var r = 0; r < 8; r++)
            {
                for (var c = 0; c < 8; c++)
                {
                    var ellipse = new Ellipse() {Width = cwidth, Height = cwidth};
                    grid.Children.Add(ellipse);
                    ellipse.Tag = r*8 + c;
                    ellipse.Stroke = new SolidColorBrush(Colors.White);
                    ellipse.Fill = _offBrush;
                    ellipse.PointerPressed += Ellipse_PointerPressed;
                    ellipse.SetValue(Grid.RowProperty, r);
                    ellipse.SetValue(Grid.ColumnProperty, c);
                }
            }

            _backpack = new Adafrut8x8LEDBackpack();
            await _backpack.initializeAsync();
        }
Esempio n. 3
0
        private void Activate(Point2D item)
        {
            if (Map == null || Map.Layers == null)
            {
                return;
            }
            ellipse = new Ellipse();
            #region 所有风格的控制
            ellipse.Stroke = Stroke;
            ellipse.StrokeThickness = StrokeThickness;
            ellipse.Fill = Fill;
            ellipse.StrokeMiterLimit = StrokeMiterLimit;
            ellipse.StrokeDashOffset = StrokeDashOffset;
            ellipse.StrokeDashArray = StrokeDashArray;
            ellipse.StrokeDashCap = StrokeDashCap;
            ellipse.StrokeEndLineCap = StrokeEndLineCap;
            ellipse.StrokeLineJoin = StrokeLineJoin;
            ellipse.StrokeStartLineCap = StrokeStartLineCap;
            ellipse.Opacity = Opacity;
            #endregion

            DrawLayer = new ElementsLayer();
            Map.Layers.Add(DrawLayer);

            ellipse.SetValue(ElementsLayer.BBoxProperty, new Rectangle2D(item, item));
            DrawLayer.Children.Add(ellipse);

            isActivated = true;
            isDrawing = true;
        }
Esempio n. 4
0
        private void createGameGrid(int gridSize)
        {
            int cols, rows;
            // create row and col definitions
            for( cols=0; cols < gridSize; cols++)
            {
                contentGrid.RowDefinitions.Add(new RowDefinition());
                contentGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            // add rectangle to the grid squares
            // make them a little smaller
            Rectangle myR;
            for (cols = 0; cols < gridSize; cols++)
            {
                for (rows = 0; rows < gridSize; rows++)
                {
                    myR = new Rectangle();
                    myR.Name = "r" + cols.ToString() + "_" + rows.ToString(); // r0_1
                    myR.Width = (contentGrid.Width / gridSize) - 4;
                    myR.Height = (contentGrid.Height / gridSize) - 4;
                    myR.HorizontalAlignment = HorizontalAlignment.Center;
                    myR.VerticalAlignment = VerticalAlignment.Center;
                    myR.SetValue(Grid.RowProperty, rows);
                    myR.SetValue(Grid.ColumnProperty, cols);
                    myR.Fill = new SolidColorBrush(Colors.LightGray);
                    myR.Tapped += MyR_Tapped;
                    contentGrid.Children.Add(myR);
                }
            }

            Ellipse myE;

            //TransformGroup myTransformGroup = new TransformGroup();
            //TranslateTransform transTransForm;
            //transTransForm = new TranslateTransform();
            //transTransForm.X = contentGrid.Width * ((gridSize - 1) / gridSize);
            //transTransForm.Y = contentGrid.Height* ((gridSize - 1) / gridSize);
            //transTransForm.SetValue(NameProperty, "myTranslateTransform");
            //myTransformGroup.Children.Add(transTransForm);

            for (cols = 0; cols < 2; cols++)
            {
                myE = new Ellipse();
                myE.Name = "piece" + cols.ToString();
                myE.Height = (contentGrid.Height / gridSize) - 6;
                myE.Width = (contentGrid.Width / gridSize) - 6;
                myE.Stroke = new SolidColorBrush(Colors.Red);
                myE.StrokeThickness = 0;
                myE.Fill = new SolidColorBrush(Colors.Yellow);

                myE.SetValue(Grid.RowProperty, cols);
                myE.SetValue(Grid.ColumnProperty, cols);
                myE.Tapped += MyE_Tapped;

                //myE.RenderTransform = myTransformGroup;

                _ellipseHeight = myE.Height;
                _ellipseWidth = myE.Width;

                contentGrid.Children.Add(myE);
            }
        }
        private void AddBackgroundRings()
        {
            //Add outer background circle
            var outerRingBackground = new Ellipse
            {
                Width = (OuterRingRadius * 2) + StripWidth,
                Height = (OuterRingRadius * 2) + StripWidth,
                Stroke = new SolidColorBrush(Color.FromArgb(255, 30, 30, 30)),
                StrokeThickness = StripWidth
            };

            //Ensure these are drawn behind everything
            outerRingBackground.SetValue(ZIndexProperty, -5);

            SetLeft(outerRingBackground, (CentreX - OuterRingRadius - (StripWidth / 2)));
            SetTop(outerRingBackground, (CentreY - OuterRingRadius - (StripWidth / 2)));

            outerRingBackground.IsHitTestVisible = false;

            Children.Add(outerRingBackground);

            //Add inner background circle
            var innerRingBackground = new Ellipse
            {
                Width = (InnerRingRadius * 2) + StripWidth,
                Height = (InnerRingRadius * 2) + StripWidth,
                Stroke = new SolidColorBrush(Color.FromArgb(255, 50, 50, 50)),
                StrokeThickness = StripWidth
            };

            //Ensure these are drawn behind everything
            innerRingBackground.SetValue(ZIndexProperty, -5);

            SetLeft(innerRingBackground, (CentreX - InnerRingRadius - (StripWidth / 2)));
            SetTop(innerRingBackground, (CentreY - InnerRingRadius - (StripWidth / 2)));

            innerRingBackground.IsHitTestVisible = false;

            Children.Add(innerRingBackground);
        }