本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
}
示例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++;
}
}
}
示例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);
}
}
示例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++;
}
}