本文整理匯總了C#中System.Windows.Shapes.Rectangle.SetValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Rectangle.SetValue方法的具體用法?C# Rectangle.SetValue怎麽用?C# Rectangle.SetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Shapes.Rectangle
的用法示例。
在下文中一共展示了Rectangle.SetValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreatePushpinObject
// creates object to be drawn on the map
private Grid CreatePushpinObject()
{
//Creating a Grid element.
Grid MyGrid = new Grid();
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.Background = new SolidColorBrush(Colors.Transparent);
//Creating a Rectangle
Rectangle MyRectangle = new Rectangle();
MyRectangle.Fill = new SolidColorBrush(Color.FromArgb(0xF9, 0x00, 0x68, 0));
MyRectangle.Height = 20;
MyRectangle.Width = 20;
MyRectangle.SetValue(Grid.RowProperty, 0);
MyRectangle.SetValue(Grid.ColumnProperty, 0);
//Adding the Rectangle to the Grid
MyGrid.Children.Add(MyRectangle);
//Creating a Polygon
Polygon MyPolygon = new Polygon();
MyPolygon.Points.Add(new Point(2, 0));
MyPolygon.Points.Add(new Point(22, 0));
MyPolygon.Points.Add(new Point(2, 40));
MyPolygon.Stroke = new SolidColorBrush(Colors.Black);
MyPolygon.Fill = new SolidColorBrush(Colors.Black);
MyPolygon.SetValue(Grid.RowProperty, 1);
MyPolygon.SetValue(Grid.ColumnProperty, 0);
//Adding the Polygon to the Grid
MyGrid.Children.Add(MyPolygon);
return MyGrid;
}
示例2: MainWindow
public MainWindow()
{
InitializeComponent();
imagen = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + @"\Imagenes\imagen.jpg"));
Rectangle rectangle = new Rectangle();
rectangle.Width = 500;
rectangle.Height = 500;
rectangle.Fill = new ImageBrush(imagen);
tablero = new Tablero(3, 3, imagen);
foreach (Pieza p in tablero.Piezas)
{
Rectangle r = new Rectangle();
r.Width = Canvas.Width / tablero.Filas;
r.Height = Canvas.Height / tablero.Columnas;
r.Fill = new ImageBrush(p.Imagen);
r.Stroke = new SolidColorBrush(Colors.Black);
r.StrokeThickness = 1;
r.SetValue(Canvas.LeftProperty, Convert.ToDouble(p.Columna * (Canvas.Width / tablero.Filas)));
r.SetValue(Canvas.TopProperty, Convert.ToDouble(p.Fila * (Canvas.Height / tablero.Columnas)));
Canvas.Children.Add(r);
}
}
示例3: Render
public void Render()
{
NEATGenome genome = (NEATGenome)this.pop.BestGenome;
Substrate substrate = SubstrateFactory.factorSandwichSubstrate(resolution, resolution);
HyperNEATCODEC codec = new HyperNEATCODEC();
NEATNetwork phenotype = (NEATNetwork)codec.Decode(this.pop, substrate, genome);
TrialEvaluation trial = new TrialEvaluation(phenotype, this.testCase);
IntPair actualPos = trial.Query(resolution);
// clear what was there before
GridCanvas.Children.Clear();
//
double boxWidth = GridCanvas.ActualWidth / resolution;
double boxHeight = GridCanvas.ActualHeight / resolution;
double delta = 2.0 / resolution;
int index = 0;
for (int row = 0; row < resolution; row++)
{
double y = -1 + (row * delta);
double boxY = row * boxHeight;
for (int col = 0; col < resolution; col++)
{
double x = -1 + (col * delta);
double boxX = col * boxWidth;
Rectangle r = new Rectangle();
r.SetValue(Canvas.LeftProperty, boxX);
r.SetValue(Canvas.TopProperty, boxY);
r.Width = boxWidth;
r.Height = boxHeight;
if (this.testCase.GetPixel(x, y) > 0)
{
r.Fill = Brushes.Blue;
}
else
{
double d = trial.Output[index];
int c = trial.Normalize(d, 255);
SolidColorBrush b = new SolidColorBrush(Color.FromRgb(255, (byte)c, 255));
r.Fill = b;
r.Stroke = Brushes.Black;
}
GridCanvas.Children.Add(r);
index++;
}
}
Rectangle target = new Rectangle();
target.SetValue(Canvas.LeftProperty, actualPos.X * boxWidth);
target.SetValue(Canvas.TopProperty, actualPos.Y * boxHeight);
target.Width = boxWidth;
target.Height = boxHeight;
target.Fill = Brushes.Red;
GridCanvas.Children.Add(target);
}
示例4: detail
public detail()
{
InitializeComponent();
List<Stand> tab = (List<Stand>)PhoneApplicationService.Current.State["stands"];
int index = (int)PhoneApplicationService.Current.State["index"];
//MessageBox.Show(index.ToString());
Stand item = tab[index];
station_id.Text = "Station n°" + item.Id;
add.Text = item.Add.ToString();
ab.Text = "Places : " + item.Ab.ToString();
ap.Text = "Velos : " + item.Ap.ToString();
ac.Text = "Capacité disponible : " + item.Ac.ToString();
tc.Text = "Capacité totale: : " + item.Tc.ToString();
GeoCoordinate loc = new GeoCoordinate();
//Location loc = new Location();
loc.Longitude = item.Lng;
loc.Latitude = item.Lat;
Map Carte = new Map();
Carte.Center = loc;
Carte.ZoomLevel = 17.0;
Pushpin pin = new Pushpin();
pin.GeoCoordinate = loc;
//pin.Location = loc;
ContentMap.Children.Add(Carte);
ImageBrush imgBrush = new ImageBrush();
imgBrush.Stretch = System.Windows.Media.Stretch.UniformToFill;
imgBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"velo_bleu.png", UriKind.Relative));
Grid MyGrid = new Grid();
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.RowDefinitions.Add(new RowDefinition());
MyGrid.Background = new SolidColorBrush(Colors.Transparent);
Rectangle MyRectangle = new Rectangle();
MyRectangle.Fill = imgBrush;
MyRectangle.Height = 52;
MyRectangle.Width = 85;
MyRectangle.SetValue(Grid.RowProperty, 0);
MyRectangle.SetValue(Grid.ColumnProperty, 0);
MyGrid.Children.Add(MyRectangle);
MapLayer layer = new MapLayer();
MapOverlay overlay = new MapOverlay();
overlay.GeoCoordinate = pin.GeoCoordinate;
overlay.Content = MyGrid;
layer.Add(overlay);
//Carte.Children.Add(pin);
Carte.Layers.Add(layer);
}
示例5: erstelleKran
private void erstelleKran()
{
this.kran = new Rectangle();
this.kran.Fill = Brushes.Black;
this.kran.Width = this.schlittenBreite;
this.kran.Height = this.schlittenHoehe;
kran.SetValue(Canvas.TopProperty, yKoordiante);
kran.SetValue(Canvas.LeftProperty, xKoordinate);
draufSicht.Children.Add(kran);
}
示例6: 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.ManipulationStarted += MonitorManipulationStarted;
Monitor.ManipulationDelta += MonitorManipulationDelta;
panel.Children.Add(Monitor);
}
示例7: Init
/// <summary>
/// 畫界麵
/// </summary>
public void Init()
{
midiBase = new MidiBase();
//填充樂器數據
foreach (string item in Enum.GetNames(typeof(MidiToneType)))
{
MidiTypeCb.Items.Add(item);
}
//畫格子
for (int i = 0; i < 56; i++)
{
ColumnDefinition col = new ColumnDefinition();
KeyGrid.ColumnDefinitions.Add(col);
}
for (int i = 0; i < 48; i++)
{
Rectangle rect = new Rectangle();
rect.SetValue(Grid.ColumnSpanProperty, 2);
int tem = i % 12; //計算餘數,
int tem1 = i / 12;
int tem2 = tem > 4 ? 1 : 0;
rect.SetValue(Grid.ColumnProperty, tem1 * 14 + tem + tem2);
rect.MouseDown += Rect_MouseDown;
rect.MouseUp += Rect_MouseUp;
rect.MouseMove += Rect_MouseMove;
//判斷是黑鍵還是白鍵
string name;
if (tem ==1 || tem ==3 || tem ==6 || tem ==8 || tem ==10)
{
name = "black" + i.ToString("00");
rect.Fill = new SolidColorBrush(Colors.Black);
rect.SetValue(Grid.ZIndexProperty, 1); //通過zindex改變黑白鍵的顯示順序
}
else
{
name = "white" + i.ToString("00");
rect.Fill = new SolidColorBrush(Colors.White);
rect.SetValue(Grid.RowSpanProperty, 2);
rect.SetValue(Grid.ZIndexProperty, 0);
}
rect.Name = name; //做標記,包含黑白鍵和音階信息
KeyGrid.Children.Add(rect);
KeyGrid.RegisterName(name, rect); //必須這樣注冊才能用 findname找到
}
}
示例8: LoadEventMark
public void LoadEventMark(MapEventMaster mem) {
int markSize = 16;
var rec = new Rectangle {
Width = markSize,
Height = markSize,
Stroke = Brushes.Red,
StrokeThickness = 5,
SnapsToDevicePixels = true
};
rec.SetValue(Canvas.LeftProperty, (mem.icon_pos_x - markSize/2)*SCALE_PARAMETER + LEFT_OFFSET);
rec.SetValue(Canvas.TopProperty, (mem.icon_pos_y - markSize/2)*SCALE_PARAMETER + TOP_OFFSET);
rec.SetValue(Grid.ZIndexProperty, 129);
AreaCanvas.Children.Add(rec);
}
示例9: RenderIntensityMap
public override void RenderIntensityMap()
{
for (int i = 0; i < HeatMapSource.Columns; i++)
{
for (int j = 0; j < HeatMapSource.Rows; j++)
{
byte intensity = worstCaseHeatPoints[i, j];
Rectangle r = new Rectangle();
r.SetValue(Grid.ColumnProperty, i + 1);
r.SetValue(Grid.RowProperty, HeatMapSource.Rows - j);
r.Fill = new SolidColorBrush(Color.FromRgb((byte)Math.Abs(intensity), (byte)Math.Abs(intensity), (byte)Math.Abs(intensity)));
this.HeatMapGrid.Children.Add(r);
}
}
}
示例10: SetIcon
internal void SetIcon(System.Windows.Media.ImageSource imageSource)
{
var rect = new Rectangle();
rect.Width = 32;
rect.Height = 32;
rect.UseLayoutRounding = true;
rect.Fill = Brushes.White;
rect.OpacityMask = new ImageBrush(imageSource) { Stretch = Stretch.None };
rect.SetValue(Canvas.LeftProperty, 6.5);
rect.SetValue(Canvas.TopProperty, 6.5);
Canvas c = new Canvas();
c.Children.Add(rect);
this.Content = c;
}
示例11: 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;
}
示例12: Draw
public static void Draw(UIElementCollection children)
{
foreach (var option in selections)
{
var rect = new Rectangle();
rect.Width = option.intersection.Width;
rect.Height = option.intersection.Height;
rect.SetValue(Canvas.LeftProperty, option.intersection.X);
rect.SetValue(Canvas.TopProperty, option.intersection.Y);
rect.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
rect.StrokeThickness = 1;
rect.Fill = new SolidColorBrush(Color.FromArgb(100, 255, 0, 0));
children.Add(rect);
option.Advance();
children.Add(option.label);
}
}
示例13: LoadMapOnView
private void LoadMapOnView()
{
if (currentMap != null)
{
mapCanvas.Children.Clear();
mapCanvas.Width = (currentMap.Breedte * blokscale) + 10;
mapCanvas.Height = (currentMap.Hoogte * blokscale) + 10;
for (int i = 0; i < currentMap.Hoogte; i++)
{
for (int j = 0; j < currentMap.Breedte; j++)
{
Rectangle blok = new Rectangle();
blok.Stroke = new SolidColorBrush(Colors.Black);
blok.StrokeThickness = 0.3;
blok.Width = blokscale;
blok.Height = blokscale;
switch (currentMap.GetElement(j, i))
{
case 0:
blok.Fill = new SolidColorBrush(Colors.LightGray);
break;
case 1:
blok.Fill = new SolidColorBrush(Colors.Red);
break;
case 2:
blok.Fill = new SolidColorBrush(Colors.Green);
break;
case 3:
blok.Fill = new SolidColorBrush(Colors.Orange);
break;
case 4:
blok.Fill = new SolidColorBrush(Colors.Yellow);
break;
default:
blok.Fill = new SolidColorBrush(Colors.Black);
break;
}
blok.SetValue(Canvas.LeftProperty, (double)(blokscale * (j + 1)));
blok.SetValue(Canvas.TopProperty, (double)(blokscale * (i + 1)));
mapCanvas.Children.Add(blok);
}
}
}
}
示例14: GeneraTablero
/// <summary>
/// Método para generar el tablero en pantalla
/// </summary>
/// <param name="tablero"></param>
public void GeneraTablero(Tablero tablero)
{
TableroReinas.ColumnDefinitions.Clear();
TableroReinas.RowDefinitions.Clear();
TableroReinas.Children.Clear();
for (int i = 0; i < tablero.NumeroReinas; i++)
{
TableroReinas.ColumnDefinitions.Add(new ColumnDefinition() { Width = CellSize });
TableroReinas.RowDefinitions.Add(new RowDefinition() { Height = CellSize });
}
for (int i = 0; i < tablero.NumeroReinas; i++)
{
for (int j = 0; j < tablero.NumeroReinas; j++)
{
Rectangle r = new Rectangle();
<<<<<<< HEAD
r.SetValue(Grid.RowProperty, j);
r.SetValue(Grid.ColumnProperty, i);
if (((i * tablero.NumeroReinas) + j) % 2 == 0)
=======
r.SetValue(Grid.RowProperty, i);
r.SetValue(Grid.ColumnProperty, j);
if ((i + j) % 2 == 0)
>>>>>>> Práctica 6 completa
r.Fill = new SolidColorBrush(Colors.Black);
else
r.Fill = new SolidColorBrush(Colors.White);
TableroReinas.Children.Add(r);
if (tablero.Reinas[i, j] == 1)
{
Ellipse c = new Ellipse();
c.Fill = new SolidColorBrush(Color.FromArgb(255, 164, 16, 52));
c.SetValue(Grid.ColumnProperty, j);
c.SetValue(Grid.RowProperty, i);
TableroReinas.Children.Add(c);
}
}
}
}
示例15: Star
public Star(double size)
{
double op = GlobalValue.OPACITY;
Rectangle e = new Rectangle();
e.Width = size;
e.Height = size;
if (GlobalValue.IsRColor == null)
e.Fill = new SolidColorBrush(Color.FromArgb(255, (byte)(128 + (128 * GlobalValue.random.NextDouble())),
(byte)(128 + (128 * GlobalValue.random.NextDouble())),
(byte)(128 + (128 * GlobalValue.random.NextDouble()))));
else
e.Fill = new SolidColorBrush(Color.FromArgb(255, GlobalValue.IsRColor.Color.R,
GlobalValue.IsRColor.Color.G, GlobalValue.IsRColor.Color.B));
e.Opacity = op;
e.SetValue(Canvas.LeftProperty, -e.Width / 2);
e.SetValue(Canvas.TopProperty, -e.Height / 2);
this.Children.Add(e);
}