當前位置: 首頁>>代碼示例>>C#>>正文


C# Rectangle.SetCurrentValue方法代碼示例

本文整理匯總了C#中System.Windows.Shapes.Rectangle.SetCurrentValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Rectangle.SetCurrentValue方法的具體用法?C# Rectangle.SetCurrentValue怎麽用?C# Rectangle.SetCurrentValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Shapes.Rectangle的用法示例。


在下文中一共展示了Rectangle.SetCurrentValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateRectangle

        private Rectangle CreateRectangle(double x, double y, int width, int height, Color color)
        {
            Rectangle rect = new Rectangle();
            rect.Height = 20;
            rect.Width = width;
            rect.Fill = new SolidColorBrush(color);
            rect.Stroke = Brushes.Black;
            rect.StrokeThickness = 1;

            // set dependency properties 'Canvas.Left' and 'Canvas.Top'
            rect.SetCurrentValue(Canvas.LeftProperty, x);
            rect.SetCurrentValue(Canvas.TopProperty, y);
            return rect;
        }
開發者ID:peterloos,項目名稱:Wpf_TowersOfHanoi,代碼行數:14,代碼來源:HanoiTowerControl.cs

示例2: UpdateDiscLocation

 // helper methods
 private void UpdateDiscLocation(Rectangle rect, int offset)
 {
     if (this.Dispatcher.CheckAccess())
     {
         // set dependency property 'Canvas.Top'
         double y = this.Height - 30 - offset * 20;
         rect.SetCurrentValue(Canvas.TopProperty, y);
     }
     else
     {
         this.Dispatcher.Invoke(
             (Action)(() => { this.UpdateDiscLocation(rect, offset); })
         );
     }
 }
開發者ID:peterloos,項目名稱:Wpf_TowersOfHanoi,代碼行數:16,代碼來源:HanoiTowerControl.cs

示例3: OnBusyStateChanged

		private static void OnBusyStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			var isBusy = (bool) e.NewValue;
			var wasBusy = (bool) e.OldValue;

			if (isBusy == wasBusy)
			{
				return;
			}

			var hostGridObject = (GetTargetVisual(d) ?? d);
			Debug.Assert(hostGridObject != null);

			var hostGrid = hostGridObject as Grid;
			if (hostGrid == null)
			{
				throw new InvalidCastException(
					string.Format(
						"The object being attached to must be of type {0}. Try embedding your visual inside a {0} control, and attaching the behavior to the {0} instead.",
						typeof(Grid).Name));
			}

			if (isBusy)
			{
				Debug.Assert(LogicalTreeHelper.FindLogicalNode(hostGrid, "BusyIndicator") == null);

				var dimBackground = GetDimBackground(d);
				var grid = new Grid
				           	{
				           		Name = "BusyIndicator",
				           		Opacity = 0.0
				           	};
				if (dimBackground)
				{
					grid.Cursor = Cursors.Wait;
					grid.ForceCursor = true;

					InputManager.Current.PreProcessInput += OnPreProcessInput;
				}
				grid.SetBinding(FrameworkElement.WidthProperty, new Binding("ActualWidth")
				                                                	{
				                                                		Source = hostGrid
				                                                	});
				grid.SetBinding(FrameworkElement.HeightProperty, new Binding("ActualHeight")
				                                                 	{
				                                                 		Source = hostGrid
				                                                 	});
				for (var i = 1; i <= 3; ++i)
				{
					grid.ColumnDefinitions.Add(new ColumnDefinition
					                           	{
					                           		Width = new GridLength(1, GridUnitType.Star)
					                           	});
					grid.RowDefinitions.Add(new RowDefinition
					                        	{
					                        		Height = new GridLength(1, GridUnitType.Star)
					                        	});
				}

				var viewbox = new Viewbox
				              	{
				              		HorizontalAlignment = HorizontalAlignment.Center,
				              		Stretch = Stretch.Uniform,
				              		StretchDirection = StretchDirection.Both,
				              		Child = new CircularProgressBar()
				              	};
				grid.SetCurrentValue(Panel.ZIndexProperty, 1000);
				grid.SetCurrentValue(Grid.RowSpanProperty, Math.Max(1, hostGrid.RowDefinitions.Count));
				grid.SetCurrentValue(Grid.ColumnSpanProperty, Math.Max(1, hostGrid.ColumnDefinitions.Count));
				if (GetAddMargins(d))
				{
					viewbox.SetCurrentValue(Grid.RowProperty, 1);
					viewbox.SetCurrentValue(Grid.ColumnProperty, 1);
				}
				else
				{
					viewbox.SetCurrentValue(Grid.RowSpanProperty, 3);
					viewbox.SetCurrentValue(Grid.ColumnSpanProperty, 3);
				}
				viewbox.SetCurrentValue(Panel.ZIndexProperty, 1);

				var dimmer = new Rectangle
				             	{
				             		Name = "Dimmer",
				             		Opacity = GetDimmerOpacity(d),
				             		Fill = GetDimmerBrush(d),
				             		Visibility = (dimBackground ? Visibility.Visible : Visibility.Collapsed)
				             	};
				dimmer.SetCurrentValue(Grid.RowSpanProperty, 3);
				dimmer.SetCurrentValue(Grid.ColumnSpanProperty, 3);
				dimmer.SetCurrentValue(Panel.ZIndexProperty, 0);
				grid.Children.Add(dimmer);

				grid.Children.Add(viewbox);

				grid.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(1.0, GetDimTransitionDuration(d)));

				hostGrid.Children.Add(grid);
			}
			else
//.........這裏部分代碼省略.........
開發者ID:AuditoryBiophysicsLab,項目名稱:ESME-Workbench,代碼行數:101,代碼來源:BusyIndicatorBehavior.cs


注:本文中的System.Windows.Shapes.Rectangle.SetCurrentValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。