当前位置: 首页>>代码示例>>C#>>正文


C# Windows.Rect类代码示例

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


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


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