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

C# Windows.Rect类代码示例

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

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



Rect类属于System.Windows命名空间,在下文中一共展示了Rect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Create3DViewPort

        private void Create3DViewPort()
        {
            var hvp3d = new HelixViewport3D();
            Viewport3D vp3d = new Viewport3D();
            var lights = new DefaultLights();
            var tp = new Teapot();

            hvp3d.Children.Add(lights);
            hvp3d.Children.Add(tp);

            vp3d = hvp3d.Viewport;
            tata.Children.Add(vp3d); // comenter ca pour test

            /* MEGA TEST DE L'ESPACE SUBSAHARIEN */

            RenderTargetBitmap bmp = new RenderTargetBitmap(800, 800, 96, 96, PixelFormats.Pbgra32);
            var rect = new Rect(0, 0, 800, 800);
            vp3d.Measure(new Size(800, 800));
            vp3d.Arrange(rect);
            vp3d.InvalidateVisual();
            
            bmp.Render(vp3d);

            PngBitmapEncoder png = new PngBitmapEncoder();
            png.Frames.Add(BitmapFrame.Create(bmp));

            String filepath = "C:\\Users\\Remi\\Desktop\\canardmasque.png";
            using (Stream stm = File.Create(filepath))
            {
                png.Save(stm);
            }
        }
开发者ID:remi-hernandez,项目名称:renderHelixViewPort3d,代码行数:32,代码来源:MainWindow.xaml.cs


示例2: ButtonSave_Click

        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            var rect = new Rect { Width = 512, Height = 384 };
            var dv = new DrawingVisual();

            var dc = dv.RenderOpen();
            dc.PushTransform(new TranslateTransform(-rect.X, -rect.Y));
            dc.DrawRectangle(InkCanvasMain.Background, null, rect);
            InkCanvasMain.Strokes.Draw(dc);
            dc.Close();

            var rtb = new RenderTargetBitmap((int)rect.Width, (int)rect.Height, 96, 96, PixelFormats.Default);
            rtb.Render(dv);
            var enc = new PngBitmapEncoder();
            enc.Frames.Add(BitmapFrame.Create(rtb));

            var fn = TextBoxFileName.Text;
            if (!fn.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) fn += ".png";
            using (Stream s = File.Create(TegakiImageFolder + "/" + fn))
            {
                enc.Save(s);
            }
            ((TegakiWindowViewModel)DataContext).AddToMediaList(System.IO.Path.GetFullPath(TegakiImageFolder + "/" + fn));
            Close();
        }
开发者ID:kb10uy,项目名称:Kbtter4,代码行数:25,代码来源:TegakiWindow.xaml.cs


示例3: CenterToArea

        /// <summary>
        /// Moves the <see cref="window"/> to the center of the given <see cref="area"/>.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <param name="area">The aera.</param>
        public static void CenterToArea(this Window window, Rect area)
        {
            if (area == Rect.Empty) return;

            window.Left = Math.Abs(area.Width - window.Width) / 2 + area.Left;
            window.Top = Math.Abs(area.Height - window.Height) / 2 + area.Top;
        }
开发者ID:cg123,项目名称:xenko,代码行数:12,代码来源:WindowHelper.cs


示例4: LogicalRectToDevice

        public static Rect LogicalRectToDevice(Rect logicalRectangle)
        {
            Point topLeft = LogicalPixelsToDevice(new Point(logicalRectangle.Left, logicalRectangle.Top));
            Point bottomRight = LogicalPixelsToDevice(new Point(logicalRectangle.Right, logicalRectangle.Bottom));

            return new Rect(topLeft, bottomRight);
        }
开发者ID:Guiedo,项目名称:BehaviorIsManaged,代码行数:7,代码来源:DpiHelper.cs


示例5: RectZoomX

		public static Rect RectZoomX(Rect rect, Point zoomCenter, double ratio)
		{
			Rect res = rect;
			res.X = zoomCenter.X - (zoomCenter.X - rect.X) * ratio;
			res.Width = rect.Width * ratio;
			return res;
		}
开发者ID:BdGL3,项目名称:CXPortal,代码行数:7,代码来源:CoordinateUtils.cs


示例6: DrawTile

 protected override void DrawTile(DrawingContext dc, Rect TileRect)
 {
     if (!_tileImage.IsReady)
         dc.DrawRectangle(Brushes.LemonChiffon, null, TileRect);
     else
         dc.DrawImage(_tileImage.Image, TileRect);
 }
开发者ID:NpoSaut,项目名称:netMapViewControlLib,代码行数:7,代码来源:MapImageTileElement.cs


示例7: SingleClick

 public static void SingleClick(Rect dragRectangle)
 {
     var startPoint = GetCenterPoint(dragRectangle);
     SetCursorPos(startPoint.X, startPoint.Y);
     mouse_event(MouseEventFlags.LeftDown, (uint)startPoint.X, (uint)startPoint.Y, 0, 0);
     mouse_event(MouseEventFlags.LeftUp, (uint)startPoint.X, (uint)startPoint.Y, 0, 0);
 }
开发者ID:paramadeep,项目名称:endhira,代码行数:7,代码来源:Mouse.cs


示例8: SelectionMovedOrResizedStroke

		public SelectionMovedOrResizedStroke(CommandStack commandStack, StrokeCollection selection, Rect newrect, Rect oldrect, int editingOperationCount)
			: base(commandStack) {
			_selection = selection;
			_newrect = newrect;
			_oldrect = oldrect;
			_editingOperationCount = editingOperationCount;
		}
开发者ID:paradoxfm,项目名称:ledx2,代码行数:7,代码来源:UndoInkStroke.cs


示例9: MainWindow

        public MainWindow(IDBOperation dbOperation)
        {
            Rect rc = SystemParameters.WorkArea;//获取工作区大小
            //this.Width = 1366;
            //this.Height = 766;
            this.Width = rc.Width;
            this.Height = rc.Height;
            rcnormal = new Rect((rc.Width - 1366) / 2, (rc.Height - 766) / 2, 1366, 766);
            InitializeComponent();
            this.dbOperation = dbOperation;

            //if (!FullScreenHelper.IsFullscreen(this))
            //{
            //    FullScreenHelper.GoFullscreen(this);
            //}
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
            //this.KeyDown += new KeyEventHandler(MainWindow_KeyDown);
            //this.StateChanged += new EventHandler(MainWindow_StateChanged);

            //根据分辨率判断标题字体大小
            if (rc.Width < 1680)
            {
                _title_dept.FontSize = 17;
                _title_1.FontSize = 24;
            }
            else
            {
                _title_dept.FontSize = 22;
                _title_1.FontSize = 30;
            }
        }
开发者ID:wuqiangqiang,项目名称:lnxcp,代码行数:31,代码来源:MainWindow.xaml.cs


示例10: RenderState

		public RenderState(Rect renderVisible, Rect visible, Rect output, RenderTo renderingType)
		{
			this.renderVisible = renderVisible;
			this.visible = visible;
			this.output = output;
			this.renderingType = renderingType;
		}
开发者ID:BdGL3,项目名称:CXPortal,代码行数:7,代码来源:RenderState.cs


示例11: Annotate

		/// <summary>
		/// Annotates the specified isoline collection.
		/// </summary>
		/// <param name="collection">The collection.</param>
		/// <param name="visible">The visible rectangle.</param>
		/// <returns></returns>
		public Collection<IsolineTextLabel> Annotate(IsolineCollection collection, Rect visible)
		{
			Collection<IsolineTextLabel> res = new Collection<IsolineTextLabel>();

			foreach (var line in collection.Lines)
			{
				double way = 0;
				foreach (var segment in line.GetSegments())
				{
					double length = segment.GetLength();
					way += length;
					if (way > wayBeforeText)
					{
						way = 0;
						res.Add(new IsolineTextLabel
						{
							Text = line.RealValue.ToString("G2"),
							Position = segment.Max,
							Rotation = (segment.Max - segment.Min).ToAngle()
						});
					}
				}
			}

			return res;
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:32,代码来源:IsolineTextAnnotater.cs


示例12: GetAutoConnectHitRect

 internal static Rect GetAutoConnectHitRect(DependencyObject target)
 {
     Size size = FreeFormPanel.GetChildSize(target);
     Point location = FreeFormPanel.GetLocation(target);
     Rect rect = new Rect(new Point(location.X - HitRegionOffset, location.Y - HitRegionOffset), new Size(size.Width + (HitRegionOffset * 2), size.Height + (HitRegionOffset * 2)));
     return rect;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:AutoConnectHelper.cs


示例13: ContainsPoint

 /// <summary>
 /// Returns a value indicating whether a point is inside the bounding box of the element.
 /// </summary>
 /// <param name="element"></param>
 /// <param name="pointRelativeToElement"></param>
 /// <returns></returns>
 public static bool ContainsPoint(this FrameworkElement element, Point pointRelativeToElement)
 {
     //TODO: Silverlight allows more complex geometries than Rectangle.
     Rect rect = new Rect { X = 0, Y = 0, Width = element.ActualWidth, Height=element.ActualHeight };
     
     return rect.Contains(pointRelativeToElement);            
 }
开发者ID:nhannd,项目名称:Xian,代码行数:13,代码来源:UIElementExtensions.cs


示例14: FillArea

 /// <summary>
 /// Moves and resize the <see cref="window"/> to make it fill the whole given <see cref="area"/>.
 /// </summary>
 /// <param name="window">The window.</param>
 /// <param name="area">The area.</param>
 public static void FillArea(this Window window, Rect area)
 {
     window.Width = area.Width;
     window.Height = area.Height;
     window.Left = area.Left;
     window.Top = area.Top;
 }
开发者ID:cg123,项目名称:xenko,代码行数:12,代码来源:WindowHelper.cs


示例15: WpfMonitor

 public WpfMonitor(IntPtr handle, uint index)
     : base(handle, index)
 {
     MonitorRect = new Rect(0, 10, 100, 100);
     WorkRect = new Rect(0, 10, 100, 100);
     Name = "fake";
 }
开发者ID:cashlalala,项目名称:Win32-Monitor-API,代码行数:7,代码来源:WpfMonitor.cs


示例16: ReadWaypointId

        private void ReadWaypointId()
        {
            var actData = (Mooege.Common.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70015].Data;
            var wayPointInfo = actData.WayPointInfo;

            var proximity = new Rect(this.Position.X - 1.0, this.Position.Y - 1.0, 2.0, 2.0);
            var scenes = this.World.QuadTree.Query<Scene>(proximity);
            if (scenes.Count == 0) return; // TODO: fixme! /raist

            var scene = scenes[0]; // Parent scene /fasbat

            if (scenes.Count == 2) // What if it's a subscene? /fasbat
            {
                if (scenes[1].ParentChunkID != 0xFFFFFFFF)
                    scene = scenes[1];
            }

            for (int i = 0; i < wayPointInfo.Length; i++)
            {
                if (wayPointInfo[i].SNOLevelArea == -1)
                    continue;

                if (scene.Specification == null) continue;
                foreach (var area in scene.Specification.SNOLevelAreas)
                {
                    if (wayPointInfo[i].SNOWorld != this.World.WorldSNO.Id || wayPointInfo[i].SNOLevelArea != area)
                        continue;

                    this.WaypointId = i;
                    break;
                }
            }
        }
开发者ID:ralje,项目名称:mooege,代码行数:33,代码来源:Waypoint.cs


示例17: Update

 public override void Update()
 {
     Console.WriteLine("update");
     MonitorRect = new Rect(50,50,150,200);
     WorkRect = new Rect(50, 50, 150, 200);
     Name = "Changed";
 }
开发者ID:cashlalala,项目名称:Win32-Monitor-API,代码行数:7,代码来源:WpfMonitor.cs


示例18: CreateAndAddAdornment

        void CreateAndAddAdornment(ITextViewLine line, SnapshotSpan span, Brush brush, bool extendToRight)
        {
            var markerGeometry = _view.TextViewLines.GetMarkerGeometry(span);

            double left = 0;
            double width = _view.ViewportWidth + _view.MaxTextRightCoordinate;
            if (markerGeometry != null)
            {
                left = markerGeometry.Bounds.Left;
                if (!extendToRight) width = markerGeometry.Bounds.Width;
            }

            Rect rect = new Rect(left, line.Top, width, line.Height);

            RectangleGeometry geometry = new RectangleGeometry(rect);

            GeometryDrawing drawing = new GeometryDrawing(brush, new Pen(), geometry);
            drawing.Freeze();

            DrawingImage drawingImage = new DrawingImage(drawing);
            drawingImage.Freeze();

            Image image = new Image();
            image.Source = drawingImage;

            Canvas.SetLeft(image, geometry.Bounds.Left);
            Canvas.SetTop(image, geometry.Bounds.Top);

            _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
        }
开发者ID:ijprest,项目名称:BackgroundColorFix,代码行数:30,代码来源:BackgroundColorVisualManager.cs


示例19: RightClick

 public static void RightClick(Rect targetRectangle)
 {
     var clickPoint = GetCenterPoint(targetRectangle);
     Cursor.Position = clickPoint;
     mouse_event(MouseEventFlags.RightDown, (uint) clickPoint.X, (uint) clickPoint.Y, 0, 0);
     mouse_event(MouseEventFlags.RightUp, (uint) clickPoint.X, (uint) clickPoint.Y, 0, 0);
 }
开发者ID:paramadeep,项目名称:endhira,代码行数:7,代码来源:Mouse.cs


示例20: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            Rect rect = new Rect(startPoint, endPoint);
            rect.Offset(-0.5d, -0.5d);

            drawingContext.DrawRectangle(fill, stroke, rect);
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:7,代码来源:PlacementAdorner.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Windows.ResourceDictionary类代码示例发布时间:2022-05-26
下一篇:
C# Windows.QueryContinueDragEventArgs类代码示例发布时间: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