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


C# Viewbox.SetCurrentValue方法代码示例

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


在下文中一共展示了Viewbox.SetCurrentValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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.Controls.Viewbox.SetCurrentValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。