本文整理汇总了C#中Windows.UI.Xaml.Shapes.Rectangle类的典型用法代码示例。如果您正苦于以下问题:C# Rectangle类的具体用法?C# Rectangle怎么用?C# Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于Windows.UI.Xaml.Shapes命名空间,在下文中一共展示了Rectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TileRenderer
public TileRenderer(Canvas canvas, string displayText, Tile tile)
{
storyboard = new Storyboard();
Tile = tile;
this.canvas = canvas;
Width = DefaultWidth;
Height = DefaultHeight;
rectangle = new Rectangle
{
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch,
Stroke = new SolidColorBrush(Colors.Black),
Fill = new SolidColorBrush(Colors.WhiteSmoke)
};
Children.Add(rectangle);
text = new TextBlock
{
Text = displayText,
HorizontalAlignment = HorizontalAlignment.Stretch,
TextAlignment = TextAlignment.Center,
FontSize = 36,
Foreground = new SolidColorBrush(Colors.Black),
FontWeight = FontWeights.Bold,
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(0, 26, 0, 26)
};
Children.Add(text);
canvas.Children.Add(this);
SetPosition();
tile.PositionChanged += UpdatePosition;
}
示例2: main1
// Image io=
public main1()
{
this.InitializeComponent();
this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
canvas.PointerMoved += canvas_pointer_moved;
canvas.PointerPressed += canvas_pointer_pressed;
canvas.PointerExited += canvas_pointer_exited;
canvas.PointerReleased += canvas_pointer_released;
tool = "pencil";
FillColor = Colors.Blue;
BorderColor = Colors.Black;
var colors = typeof(Colors).GetTypeInfo().DeclaredProperties;
foreach (var item in colors)
{
//ImageBrush i= i
Rectangle r = new Rectangle();
//r.Fill=I
//fill.Items.Add(item);
}
for (int i = 1; i < 20; i++)
{
ComboBoxItem Items = new ComboBoxItem();
Items.Content = i;
thick.Items.Add(Items);
}
thick.SelectedIndex = 0;
}
示例3: StarControlFactory
public static UIElement StarControlFactory(double scale)
{
// Draw star shape
Array starShapes = Enum.GetValues(typeof(StarShape));
StarShape randomShape = (StarShape)starShapes.GetValue(_random.Next(0, starShapes.Length));
UIElement starControl; //ISSUE: Is this type good?
switch (randomShape)
{
case StarShape.Rectangle:
starControl = new Rectangle()
{Fill = new SolidColorBrush(RandomColor()) };
break;
case StarShape.Ellipse:
starControl = new Ellipse()
{ Fill = new SolidColorBrush(RandomColor()) };
break;
case StarShape.Star:
starControl = new Star()
{ Fill = new SolidColorBrush(RandomColor()) };
break;
default:
starControl = new Star()
{ Fill = new SolidColorBrush(RandomColor()) };
break;
}
return starControl;
}
示例4: 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;
}
示例5: OnApplyTemplate
protected override void OnApplyTemplate()
{
// Find the left pane in the control template and store a reference
LeftPanePresenter = GetTemplateChild("leftPanePresenter") as ContentPresenter;
MainPaneRectangle = GetTemplateChild("mainPaneRectangle") as Rectangle;
var mainToggleButton = GetTemplateChild("toggleButtonHamburgerMenu") as ToggleButton;
var sideToggleButton = XamlHelper.GetChildrenOfType<ToggleButton>(LeftPanePresenter.Content as StackPanel).FirstOrDefault();
if (MainPaneRectangle != null)
{
MainPaneRectangle.Tapped += (sender, e) => { IsLeftPaneOpen = false; };
}
// Ensure that the TranslateX on the RenderTransform of the left pane is set to the negative value of the left pa
SetLeftPanePresenterX();
// Set open/close for the sidebar
if(mainToggleButton != null)
{
mainToggleButton.Click += OpenSidebar;
}
if (sideToggleButton != null)
{
sideToggleButton.Click += CloseSidebar;
}
base.OnApplyTemplate();
}
示例6: CreateGrid
private void CreateGrid()
{
// Remove all previously-existing rectangles
paintCanvas.Children.Clear();
grid = new bool[gridWidth, gridWidth];
int rectSize = (int)paintCanvas.Width / gridWidth;
SolidColorBrush black = new SolidColorBrush(Colors.Black);
SolidColorBrush white = new SolidColorBrush(Colors.White);
// Turn entire grid on and create rectangles to represent it
for (int r = 0; r < gridWidth; r++)
for (int c = 0; c < gridWidth; c++)
{
grid[r, c] = true;
Rectangle rect = new Rectangle();
rect.Fill = white;
rect.Width = rectSize + 1;
rect.Height = rect.Width + 1;
rect.Stroke = black;
int x = c * rectSize;
int y = r * rectSize;
Canvas.SetTop(rect, y);
Canvas.SetLeft(rect, x);
// Add the new rectangle to the canvas' children
paintCanvas.Children.Add(rect);
}
}
示例7: Render
public override Rectangle Render()
{
Rectangle rectangle = new Rectangle();
//rectangle.ManipulationMode = ManipulationModes.All;
//rectangle.ManipulationDelta += rectangle_ManipulationDelta;
//rectangle.Tapped += rectangle_Tapped;
ParentCanvas.ManipulationMode = ManipulationModes.All;
ParentCanvas.ManipulationDelta += rectangle_ManipulationDelta;
ParentCanvas.Tapped += rectangle_Tapped;
rectangle.StrokeThickness = 3;
rectangle.Height = Utility.SPRITE_HEIGHT;
rectangle.Width = Utility.SPRITE_WIDTH;
_participant = rectangle;
ImageBrush ib = new ImageBrush();
ib.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/ship 90x60.png", UriKind.RelativeOrAbsolute));
_participant.Fill = ib;
_participant.SetValue(Canvas.LeftProperty, _position.X);
_participant.SetValue(Canvas.TopProperty, _position.Y);
return _participant;
}
示例8: OnApplyTemplate
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
Body = GetTemplateChild(BodyName) as Grid;
_horizontalSlider = GetTemplateChild(HorizontalSliderName) as SuperSlider;
_verticalSlider = GetTemplateChild(VerticalSliderName) as SuperSlider;
_horizontalSelectedColor = GetTemplateChild(HorizontalSelectedColorName) as Rectangle;
_verticalSelectedColor = GetTemplateChild(VerticalSelectedColorName) as Rectangle;
if (_horizontalSlider != null)
_horizontalSlider.ApplyTemplate();
if (_verticalSlider != null)
_verticalSlider.ApplyTemplate();
if (Color.A == 0 && Color.R == 0 && Color.G == 0 && Color.B == 0)
Color = Windows.UI.Color.FromArgb(255, 6, 255, 0); // this should be theme accent brush I think.
else
UpdateLayoutBasedOnColor();
if (Thumb == null)
Thumb = new ColorSliderThumb();
IsEnabledVisualStateUpdate();
}
示例9: 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);
}
}
}
示例10: ColorList1Page
public ColorList1Page() {
this.InitializeComponent();
IEnumerable<PropertyInfo> properties = typeof(Colors).GetTypeInfo().DeclaredProperties;
foreach (PropertyInfo property in properties) {
Color clr = (Color)property.GetValue(null);
StackPanel vertStackPanel = new StackPanel { VerticalAlignment = VerticalAlignment.Center };
TextBlock txtblkName = new TextBlock {
Text = property.Name,
FontSize = 24 };
TextBlock txtblkRgb = new TextBlock {
Text = String.Format("{0:X2}-{1:X2}-{2:X2}-{3:X2}", clr.A, clr.R, clr.G, clr.B),
FontSize = 18
};
vertStackPanel.Children.Add(txtblkName);
vertStackPanel.Children.Add(txtblkRgb);
StackPanel horzStackPanel = new StackPanel { Orientation = Orientation.Horizontal };
Rectangle rectangle = new Rectangle {
Width = 72,
Height = 72,
Fill = new SolidColorBrush(clr),
Margin = new Thickness(6)
};
horzStackPanel.Children.Add(rectangle);
horzStackPanel.Children.Add(vertStackPanel);
stackPanel.Children.Add(horzStackPanel);
}
}
示例11: OnApplyTemplate
/// <summary>
/// Builds the visual tree for the ColorPicker control when the template is applied.
/// </summary>
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
m_rootElement = GetTemplateChild("RootElement") as Panel;
m_hueMonitor = GetTemplateChild("HueMonitor") as Rectangle;
m_sampleSelector = GetTemplateChild("SampleSelector") as Canvas;
m_hueSelector = GetTemplateChild("HueSelector") as Canvas;
m_selectedColorView = GetTemplateChild("SelectedColorView") as Rectangle;
m_colorSample = GetTemplateChild("ColorSample") as Rectangle;
m_hexValue = GetTemplateChild("HexValue") as TextBlock;
m_rootElement.RenderTransform = m_scale = new ScaleTransform();
m_hueMonitor.PointerPressed += m_hueMonitor_PointerPressed;
m_hueMonitor.PointerReleased += m_hueMonitor_PointerReleased;
m_hueMonitor.PointerMoved += m_hueMonitor_PointerMoved;
m_colorSample.PointerPressed += m_colorSample_PointerPressed;
m_colorSample.PointerReleased += m_colorSample_PointerReleased;
m_colorSample.PointerMoved += m_colorSample_PointerMoved;
m_sampleX = m_colorSample.Width;
m_sampleY = 0;
m_huePos = 0;
UpdateVisuals();
}
示例12: OnApplyTemplate
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
ProgressTrackRect = GetTemplateChild("ProgressTrackRect") as Rectangle;
HorizontalTrackRect = GetTemplateChild("HorizontalTrackRect") as Rectangle;
}
示例13: AddHand
private void AddHand(Rectangle hand)
{
if (!face.Children.Contains(hand))
{
face.Children.Add(hand);
}
}
示例14: OnApplyTemplate
protected override void OnApplyTemplate()
{
if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
return;
Indicator = GetTemplateChild(nameof(Indicator)) as Rectangle;
if (Indicator == null)
throw new NullReferenceException(nameof(Indicator));
}
示例15: GamePiece
public GamePiece()
{
Rectangle rectangle = new Rectangle();
rectangle.Width = 50;
rectangle.Height = 50;
rectangle.Fill = _colorBrushOn;
_rectangle = rectangle;
_on = true;
}