当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.SetValue方法代码示例

本文整理汇总了C#中Windows.UI.Xaml.Shapes.Rectangle.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.SetValue方法的具体用法?C# Rectangle.SetValue怎么用?C# Rectangle.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.UI.Xaml.Shapes.Rectangle的用法示例。


在下文中一共展示了Rectangle.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MonitorControl

        public void MonitorControl(Panel panel)
        {
            Monitor = new Rectangle {Fill = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0))};
			Monitor.SetValue(Grid.RowSpanProperty, int.MaxValue - 1);
			Monitor.SetValue(Grid.ColumnSpanProperty, int.MaxValue - 1);

	        Monitor.ManipulationMode = ManipulationModes.All;
			Monitor.ManipulationStarted += MonitorManipulationStarted;
			Monitor.ManipulationDelta += MonitorManipulationDelta;

            panel.Children.Add(Monitor);
        }
开发者ID:selaromdotnet,项目名称:Coding4FunToolkit,代码行数:12,代码来源:MovementMonitor.cs

示例2: Render

        public override Rectangle Render()
        {
            Rectangle rectangle = new Rectangle();

            rectangle.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

            rectangle.Height = Utility.BULLET_SIZE * 2;
            rectangle.Width = Utility.BULLET_SIZE;

            rectangle.SetValue(Canvas.LeftProperty, _position.X);
            rectangle.SetValue(Canvas.TopProperty, _position.Y);
            _participant = rectangle;

            return rectangle;
        }
开发者ID:bramom,项目名称:Bug.RS,代码行数:15,代码来源:Bullet.cs

示例3: Activate

        private void Activate(Point2D item)
        {
            if (Map == null || Map.Layers == null)
            {
                return;
            }
            DrawLayer = new ElementsLayer();
            Map.Layers.Add(DrawLayer);
            rectangle = new Rectangle();
            rectangle.Stroke = this.Stroke;
            rectangle.StrokeThickness = this.StrokeThickness;
            rectangle.StrokeMiterLimit = this.StrokeMiterLimit;
            rectangle.StrokeDashOffset = this.StrokeDashOffset;
            rectangle.StrokeDashArray = this.StrokeDashArray;
            rectangle.StrokeDashCap = this.StrokeDashCap;
            rectangle.StrokeEndLineCap = this.StrokeEndLineCap;
            rectangle.StrokeLineJoin = this.StrokeLineJoin;
            rectangle.StrokeStartLineCap = this.StrokeStartLineCap;
            rectangle.Opacity = this.Opacity;
            rectangle.Fill = this.Fill;

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

            isActivated = true;
            isDrawing = true;
        }
开发者ID:SuperMap,项目名称:iClient-for-Win8,代码行数:27,代码来源:DrawRectangle.cs

示例4: CreateXAMLMatrix

 // Create an 8x8 Matrix UI that can turn LEDs on and off
 private void CreateXAMLMatrix()
 {
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             Rectangle r = new Rectangle();
             r.Name = string.Format("rect{0}{1}", i, j);
             r.SetValue(Grid.RowProperty, i);
             r.SetValue(Grid.ColumnProperty, j);
             r.Fill = new SolidColorBrush(Windows.UI.Colors.Black);
             r.PointerPressed += new PointerEventHandler(grdMatrix_pointer_pressed);
             grdMatrix.Children.Add(r);
         }
     }
 }
开发者ID:justinstigall,项目名称:MAX7219-WinIoTCore,代码行数:17,代码来源:MainPage.xaml.cs

示例5: OnNavigatedTo

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            rectangle = new Rectangle();
            rectangle.Fill = new SolidColorBrush(Colors.HotPink);
            rectangle.Width = 100;
            rectangle.Height = 100;

            rectangle.PointerPressed += new PointerEventHandler(OnRectanglePointerPressed);
            rectangle.PointerMoved += new PointerEventHandler(OnRectanglePointerMove);
            rectangle.PointerReleased += new PointerEventHandler(OnRectanglePointerReleased);

            rectangle.SetValue(Canvas.LeftProperty, 0);
            rectangle.SetValue(Canvas.TopProperty, 0);

            myCanvas.Children.Add(rectangle);
        }
开发者ID:kiewic,项目名称:WindowsStoreApps,代码行数:21,代码来源:MainPage.xaml.cs

示例6: CreateSquaresOfType

 private void CreateSquaresOfType(int rows, int cols, Grid grid, double width, double margin, string name)
 {
     for (int row = 0; row < rows; row++)
     {
         grid.RowDefinitions.Add(new RowDefinition());
         for (int col = 0; col < cols; col++)
         {
             grid.ColumnDefinitions.Add(new ColumnDefinition());
             var rect = new Rectangle() { Width = width, Height = width, Margin = new Thickness(0, 0, margin, margin), Fill = new SolidColorBrush(Colors.White)/*, Opacity = 0.2*/ };
             grid.Children.Add(rect);
             rect.SetValue(Grid.RowProperty, row);
             rect.SetValue(Grid.ColumnProperty, col);
             var binding = new Binding();
             binding.Path = new PropertyPath(string.Format("Squares{1}[{0}]", row * cols + col, name));
             rect.SetBinding(OpacityProperty, binding);
         }
     }
 }
开发者ID:Keraxel,项目名称:w8template-stopwatch,代码行数:18,代码来源:MainPage.xaml.cs

示例7: Tower

        public Tower(Canvas canvas, int x, int y, int v, int delay, int radius, BitmapImage img)
        {
            ImageBrush imgBrush = new ImageBrush();
            imgBrush.ImageSource = img;
            this.rect = new Rectangle();
            rect.Fill = imgBrush;
            rect.SetValue(Canvas.LeftProperty, x);
            rect.SetValue(Canvas.TopProperty, y);
            rect.Width = 45;
            rect.Height = 65;
            canvas.Children.Add(rect);

            this.x = x;
            this.y = y;
            //this.img = img;
            this.radius = radius;
            this.bulletVelocity = v;
            this.delay = delay;
            this.shotDelayCount = delay;
        }
开发者ID:RodionXedin,项目名称:Game1-TowerDefence,代码行数:20,代码来源:Tower.cs

示例8: setImage

        public void setImage(Canvas canvas, BitmapImage img)
        {
            /*
            Random r = new Random();
            byte red = (byte)r.Next(0, byte.MaxValue + 1);
            byte green = (byte)r.Next(0, byte.MaxValue + 1);
            byte blue = (byte)r.Next(0, byte.MaxValue + 1);
            Brush brush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, red, green, blue));
            */

            ImageBrush imgBrush = new ImageBrush();
            imgBrush.ImageSource = img;

            this.rect = new Rectangle();
            rect.Fill = imgBrush;
            //rect.Fill = brush;
            rect.SetValue(Canvas.LeftProperty, x);
            rect.SetValue(Canvas.TopProperty, y);
            rect.Width = 20;
            rect.Height = 20;
            canvas.Children.Add(rect);
        }
开发者ID:RodionXedin,项目名称:Game1-TowerDefence,代码行数:22,代码来源:Bullet.cs

示例9: Unit

        public Unit(Canvas canvas, int x, int y, BitmapImage img, List<Point> path, double health)
        {
            this.health = health;

            ImageBrush imgBrush = new ImageBrush();
            imgBrush.ImageSource = img;
            this.rect = new Rectangle();
            rect.Fill = imgBrush;
            rect.SetValue(Canvas.LeftProperty, x);
            rect.SetValue(Canvas.TopProperty, y);
            rect.Width = 72;
            rect.Height = 72;
            canvas.Children.Add(rect);

            this.x = x;
            this.y = y;
            this.vx = 0;
            this.vy = 0;
            this.velocity = 2;
            this.path = path;
            this.isFinish = false;
            this.stepIndex = 0;
        }
开发者ID:RodionXedin,项目名称:Game1-TowerDefence,代码行数:23,代码来源:Unit.cs

示例10: CriaMeuPin

        private DependencyObject CriaMeuPin()
        {
            var MeuGrid = new Grid();
            MeuGrid.RowDefinitions.Add(new RowDefinition());
            MeuGrid.RowDefinitions.Add(new RowDefinition());
            MeuGrid.Background = new SolidColorBrush(Colors.Transparent);

            var MeuRetangulo = new Rectangle { Fill = new SolidColorBrush(Colors.Red), Height = 10, Width = 22 };
            MeuRetangulo.SetValue(Grid.RowProperty, 0);
            MeuRetangulo.SetValue(Grid.ColumnProperty, 0);
            MeuGrid.Children.Add(MeuRetangulo);

            var MeuPoligono = new Polygon()
            {
                Points = new PointCollection() { new Point(1, 0), new Point(22, 0), new Point(11, 40) },
                Stroke = new SolidColorBrush(Colors.Red),
                Fill = new SolidColorBrush(Colors.Red)
            };
            MeuPoligono.SetValue(Grid.RowProperty, 1);
            MeuPoligono.SetValue(Grid.ColumnProperty, 0);
            MeuGrid.Children.Add(MeuPoligono);

            return MeuGrid;
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:24,代码来源:MainPage.xaml.cs

示例11: RefreshCanvas

		private void RefreshCanvas()
		{
			_mainCanvas.Children.Clear();
			var mainImage = new Image() { Source = _viewModel.Image };
			mainImage.PointerPressed += MainImage_PointerPressed;
			_mainCanvas.Children.Add(mainImage);
			foreach (var frame in _viewModel.Frames)
			{
				var frameRectangle = new Rectangle()
				{
					Width = frame.Width,
					Height = frame.Height,
					Stroke = new SolidColorBrush()
					{
						Color = Colors.White,
					},
				};
				frameRectangle.SetValue(Canvas.LeftProperty, frame.X);
				frameRectangle.SetValue(Canvas.TopProperty, frame.Y);
				_mainCanvas.Children.Add(frameRectangle);
				if (frame.Image != null)
				{
					var frameImage = new Image()
					{
						Width = frame.Width,
						Height = frame.Height,
						Source = frame.Image,
					};
					frameImage.SetValue(Canvas.LeftProperty, frame.X);
					frameImage.SetValue(Canvas.TopProperty, frame.Y);
					_mainCanvas.Children.Add(frameImage);
				}
			}
		}
开发者ID:mooso,项目名称:Composographer,代码行数:34,代码来源:FramingPage.xaml.cs

示例12: FillWaveForm

        public void FillWaveForm(WaveForm wave)
        {
            Children.Clear();
            RowDefinitions.Clear();
            ColumnDefinitions.Clear();

            if (wave != null)
            {
                //create the waveform
                int index = 0;
                int sample;
                RowDefinition row1 = new RowDefinition();
                row1.Height = new GridLength(2, GridUnitType.Star);
                RowDefinitions.Add(row1);
                RowDefinition row2 = new RowDefinition();
                row1.Height = new GridLength(1, GridUnitType.Star);
                RowDefinitions.Add(row2);
                for (sample = 0; sample < wave.Samples.Length; sample = sample + 6)
                {
                    int s = sample / 6;
                    if((s & 1) == 0)
                    {
                        int i = wave.Samples[sample];
                        ColumnDefinition col = new ColumnDefinition();
                        col.Width = new GridLength(1, GridUnitType.Star);
                        ColumnDefinitions.Add(col);
                        Thickness margin = new Thickness();
                        margin.Bottom = 1;
                        margin.Top = 1;
                        Rectangle r = new Rectangle
                        {
                            Height = i / 2,
                            Margin = margin,
                            VerticalAlignment = VerticalAlignment.Bottom
                        };
                        Rectangle r2 = new Rectangle
                        {
                            Height = i / 4,
                            Margin = margin,
                            VerticalAlignment = VerticalAlignment.Top
                        };
                        r.SetValue(ColumnProperty, index);
                        r.SetValue(RowProperty, 0);
                        r2.SetValue(ColumnProperty, index);
                        r2.SetValue(RowProperty, 1);
                        r.Fill = new SolidColorBrush(Colors.White);
                        r2.Fill = new SolidColorBrush(Colors.White);
                        Children.Add(r);
                        Children.Add(r2);
                        index = index + 2;
                    }
                    else
                    {
                        ColumnDefinition col = new ColumnDefinition();
                        col.Width = new GridLength(1, GridUnitType.Star);
                        ColumnDefinitions.Add(col);
                    }
                    
                }
                _slider.Minimum = 0;
                _slider.StepFrequency = 1;
                _slider.IsThumbToolTipEnabled = false;
                _slider.Style = (Style) Application.Current.Resources["WaveFormSlider"];
                _slider.SetValue(ColumnSpanProperty, index);
                _slider.ValueChanged += Slider_ValueChanged;
                Children.Add(_slider);
                _playbackTimer.Start();
            }
        }
开发者ID:justijndepover,项目名称:Soundcloudplus,代码行数:69,代码来源:WaveFormControl.cs

示例13: updateMyScreen

        private void updateMyScreen(AccelerometerReadingChangedEventArgs e)
        {
            // updates the textblocks

            previousReading = currentReading;
            currentReading = e.Reading;

            if (previousReading != null)
            {

                double xValue = currentReading.AccelerationX - previousReading.AccelerationX;
                double yValue = currentReading.AccelerationY - previousReading.AccelerationY;
                double zValue = currentReading.AccelerationZ - previousReading.AccelerationZ;

                if (xValue < 0) xValue -= 2 * xValue;
                if (yValue < 0) yValue -= 2 * yValue;
                if (zValue < 0) zValue -= 2 * zValue;

                data_width.Text = String.Format("{0,5:0.00}", xValue);
                data_length.Text = String.Format("{0,5:0.00}", yValue);
                data_depth.Text = String.Format("{0,5:0.00}", zValue);

                // draws on the canvas

                double currentXOnGraph = Math.Abs((xValue * 200) - 200);
                double currentYOnGraph = Math.Abs((yValue * 200) - 200);
                double currentZOnGraph = Math.Abs((zValue * 200) - 200);

                Rectangle xPoint = new Rectangle();
                Rectangle yPoint = new Rectangle();
                Rectangle zPoint = new Rectangle();

                xPoint.Fill = new SolidColorBrush(Colors.Red);
                yPoint.Fill = new SolidColorBrush(Colors.Blue);
                zPoint.Fill = new SolidColorBrush(Colors.Green);

                // set the pixel size 

                xPoint.Width = 1;
                xPoint.Height = 2;
                yPoint.Width = 1;
                yPoint.Height = 2;
                zPoint.Width = 1;
                zPoint.Height = 2;

                // These pixels will be "pasted into" the canvas by setting their position 
                // according to the currentX/Y/Z-on-graph values. To set their position 
                // relative to the canvas, pass the canvas properties on to the pixels via 
                // the SetValue method. Use a generic iterator to determine the distance 
                // the pixel should be from the left side of the canvas.

                xPoint.SetValue(Canvas.LeftProperty, iterateur);
                xPoint.SetValue(Canvas.TopProperty, currentXOnGraph);
                yPoint.SetValue(Canvas.LeftProperty, iterateur);
                yPoint.SetValue(Canvas.TopProperty, currentYOnGraph);
                zPoint.SetValue(Canvas.LeftProperty, iterateur);
                zPoint.SetValue(Canvas.TopProperty, currentZOnGraph);

                // finally, associate pixels with the canvas

                my_canvas.Children.Add(xPoint);
                my_canvas.Children.Add(yPoint);
                my_canvas.Children.Add(zPoint);

                if (iterateur == 399)
                {
                    my_canvas.Children.Clear();
                    iterateur = 0;
                }
                else
                {
                    iterateur++;
                }
            }

        }
开发者ID:asromain,项目名称:SleepCycle,代码行数:76,代码来源:Accelerometer.xaml.cs

示例14: UpdateGrid

        void UpdateGrid()
        {
            if (_root == null || ItemsSource == null)
            {
                return;
            }
            _root.Children.Clear();
            _root.ColumnDefinitions.Clear();
            _independentValues.Clear();
            _dependentValues.Clear();
            BindingEvaluator independentBinding = new BindingEvaluator(IndependentValuePath);
            BindingEvaluator dependentBinding = new BindingEvaluator(DependentValuePath);

            int column = 0;
            foreach (var item in ItemsSource)
            {
                var independentValue = independentBinding.Eval(item).ToString();
                var dependentValue = (long)dependentBinding.Eval(item);
                _dependentValues.Add(dependentValue);
                _root.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });

                TextBlock independentTB = new TextBlock();
                independentTB.Text = independentValue;
                independentTB.FontSize = IndependentValueFontSize;
                independentTB.Foreground = IndependentValueBrush;
                independentTB.VerticalAlignment = VerticalAlignment.Center;
                independentTB.HorizontalAlignment = HorizontalAlignment.Center;
                independentTB.SetValue(Grid.RowProperty, 3);
                independentTB.SetValue(Grid.ColumnProperty, column++);
                _root.Children.Add(independentTB);
            }
            Rectangle rc = new Rectangle();
            rc.Fill = GridLineBrush;
            rc.Height = 1;
            rc.SetValue(Grid.RowProperty, 1);
            rc.SetValue(Grid.ColumnSpanProperty, column);
            _root.Children.Add(rc);

            var min = _dependentValues.Min();
            var max = _dependentValues.Max();
            long temp = 0;
            if (min >= 0 && max >= 0)
            {
                temp = max;
            }
            else if (min < 0 && max >= 0)
            {
                temp = max - min;
            }
            else if (max < 0)
            {
                temp = -min;
            }

            var height = (this.ActualHeight - 1 - 30) / temp;


            for (int i = 0; i < _dependentValues.Count; i++)
            {
                var dependentValue = _dependentValues[i];
                TextBlock dependentTB = new TextBlock();
                dependentTB.Text = dependentValue.ToString();
                dependentTB.FontSize = DependentValueFontSize;
                dependentTB.Foreground = dependentValue >= 0 ? PositiveValueBrush : NegativeValueBrush;
                dependentTB.VerticalAlignment = dependentValue > 0 ? VerticalAlignment.Top : VerticalAlignment.Bottom;
                dependentTB.HorizontalAlignment = HorizontalAlignment.Center;
                dependentTB.SetValue(Grid.RowProperty, dependentValue > 0 ? 2 : 0);
                dependentTB.SetValue(Grid.ColumnProperty, i);

                Rectangle dependentRC = new Rectangle();
                dependentRC.Fill = dependentValue >= 0 ? PositiveValueBrush : NegativeValueBrush;
                dependentRC.Height = Math.Abs(height * dependentValue);
                dependentRC.Margin = new Thickness(20, 0, 20, 0);
                dependentRC.VerticalAlignment = dependentValue <= 0 ? VerticalAlignment.Top : VerticalAlignment.Bottom;
                dependentRC.SetValue(Grid.RowProperty, dependentValue <= 0 ? 2 : 0);
                dependentRC.SetValue(Grid.ColumnProperty, i);
                _root.Children.Add(dependentRC);
                _root.Children.Add(dependentTB);

            }
        }
开发者ID:GJian,项目名称:UWP-master,代码行数:81,代码来源:ColumnChart.cs

示例15: InitializeDayLabelBoxes

        private void InitializeDayLabelBoxes()
        {
            int column = 0;
            CalendarGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            foreach (var day in Enum.GetValues(typeof(DayOfWeek)))
            {
                //Runtime generate controls and setting style
                Rectangle box = new Rectangle();
                box.Style = Application.Current.Resources["CalendarLabelBox"] as Style;
                box.SetValue(Grid.RowProperty, 0);
                box.SetValue(Grid.ColumnProperty, column);

                TextBlock textBlock = new TextBlock();
                textBlock.Style = Application.Current.Resources["CalendarLabel"] as Style;
                textBlock.Text = day.ToString();

                //Runtime setting the control Grid.Row and Grid.Column XAML property value
                textBlock.SetValue(Grid.RowProperty, 0);
                textBlock.SetValue(Grid.ColumnProperty, column);

                //Adding the box and the textblock control to the Grid during runtime
                CalendarGrid.Children.Add(box);
                CalendarGrid.Children.Add(textBlock);

                column++;
            }
        }
开发者ID:CSMastermind,项目名称:VApp,代码行数:27,代码来源:Calendar.xaml.cs


注:本文中的Windows.UI.Xaml.Shapes.Rectangle.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。