• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Shapes.Rectangle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Rectangle类属于Windows.UI.Xaml.Shapes命名空间,在下文中一共展示了Rectangle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
        }
开发者ID:federico-ardila,项目名称:SlidePuzzle2,代码行数:34,代码来源:TileRenderer.cs


示例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;

            

        }
开发者ID:amiit,项目名称:Handwriting_Detection,代码行数:37,代码来源:main1.xaml.cs


示例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;
        }
开发者ID:Arasz,项目名称:Invaders,代码行数:31,代码来源:InvadersHelper.cs


示例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;
        }
开发者ID:SuperMap,项目名称:iClient-for-Win8,代码行数:27,代码来源:DrawRectangle.cs


示例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();
        }
开发者ID:Blackjack92,项目名称:TrainFit,代码行数:29,代码来源:HamburgerMenu.cs


示例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);
                }
        }
开发者ID:jgreenlee24,项目名称:LightsOut_WinStore,代码行数:33,代码来源:MainPage.xaml.cs


示例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;
        }
开发者ID:bramom,项目名称:Bug.RS,代码行数:25,代码来源:Ship.cs


示例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();
		}
开发者ID:selaromdotnet,项目名称:Coding4FunToolkit,代码行数:28,代码来源:ColorSlider2.cs


示例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);
				}
			}
		}
开发者ID:mooso,项目名称:Composographer,代码行数:34,代码来源:FramingPage.xaml.cs


示例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);

            }

        }
开发者ID:ronlemire2,项目名称:UWP-Testers,代码行数:33,代码来源:ColorList1Page.xaml.cs


示例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();
        }
开发者ID:tupunco,项目名称:Tup.WinRTControls,代码行数:32,代码来源:ColorPicker.cs


示例12: OnApplyTemplate

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ProgressTrackRect = GetTemplateChild("ProgressTrackRect") as Rectangle;
            HorizontalTrackRect = GetTemplateChild("HorizontalTrackRect") as Rectangle;
        }
开发者ID:Yardley999,项目名称:MGTV,代码行数:7,代码来源:ProgressSilder.cs


示例13: AddHand

 private void AddHand(Rectangle hand)
 {
     if (!face.Children.Contains(hand))
     {
         face.Children.Add(hand);
     }
 }
开发者ID:Bhaswanth-Sourcebits,项目名称:MetroAnalogueClock,代码行数:7,代码来源:MainPage.xaml.cs


示例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));
 }
开发者ID:Rasetech,项目名称:Template10,代码行数:8,代码来源:ControlWrapper.cs


示例15: GamePiece

 public GamePiece()
 {
     Rectangle rectangle = new Rectangle();
     rectangle.Width = 50;
     rectangle.Height = 50;
     rectangle.Fill = _colorBrushOn;
     _rectangle = rectangle;
     _on = true;
 }
开发者ID:roydor,项目名称:Flipper,代码行数:9,代码来源:GamePiece.cs


示例16: PaletteRect

 public PaletteRect(Rectangle rOuter, Rectangle rInner, int i, ColorPicker p)
 {
     OuterRect = rOuter;
     InnerRect = rInner;
     _color = ((SolidColorBrush)OuterRect.Fill).Color;
     index = i;
     Picker = p;
     InnerRect.PointerPressed += InnerRect_Selected;
 }
开发者ID:patrickgh3,项目名称:chip,代码行数:9,代码来源:PaletteRect.cs


示例17: InfoView

 public InfoView()
     :base( "InfoView", "BookInfoSection" )
 {
     Rectangle Rect = new Rectangle();
     Rect.Height = Height;
     Rect.Width = Width;
     Rect.Fill = new SolidColorBrush( Properties.APPEARENCE_THEME_MINOR_BACKGROUND_COLOR );
     Children.Add( Rect );
 }
开发者ID:tgckpg,项目名称:wenku10,代码行数:9,代码来源:InfoView.cs


示例18: CreateBorder

 public static Rectangle CreateBorder()
 {
     var rectangle = new Rectangle();
     rectangle.Stroke = new SolidColorBrush(Color.FromArgb(100, 174, 169, 169));
     rectangle.StrokeThickness = 2;
     rectangle.Height = 2 * Utility.MARGIN + Utility.WORLD_HEIGHT * Utility.SPRITE_WIDTH;
     rectangle.Width = 2 * Utility.MARGIN + Utility.WORLD_WIDTH * Utility.SPRITE_WIDTH;
     return rectangle;
 }
开发者ID:bramom,项目名称:Bug.RS,代码行数:9,代码来源:Utility.cs


示例19: DoDrawRectangle

 //draw a rectangle using windows store graphics
 protected override void DoDrawRectangle(Point topLeftPoint, Point bottomRightPoint)
 {
     Windows.UI.Xaml.Shapes.Rectangle rectangle = new Windows.UI.Xaml.Shapes.Rectangle();
     rectangle.Fill = new SolidColorBrush(Colors.Green);
     rectangle.Width = bottomRightPoint.X - topLeftPoint.X;
     rectangle.Height = bottomRightPoint.Y - topLeftPoint.Y;
     Canvas.SetLeft(rectangle, topLeftPoint.X);
     Canvas.SetTop(rectangle, topLeftPoint.Y);
     _canvas.Children.Add(rectangle);
 }
开发者ID:housemeow,项目名称:MyPaint,代码行数:11,代码来源:WindowsStoreGraphics.cs


示例20: CodeAnimator

        public CodeAnimator(CodeDelegate del)
            : base(new Rectangle())
        {
            _delegate = del;
            _elem = new Rectangle();

            _duration = new Duration(GetTimeSpan(1, OrSo.Tick));

            _reverse = false;
        }
开发者ID:ThatLousyGuy,项目名称:Monolith,代码行数:10,代码来源:CodeAnimator.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WindowsFormsApplication13.DataManager类代码示例发布时间:2022-05-26
下一篇:
C# Shapes.Ellipse类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap