本文整理汇总了C#中System.Windows.Shapes.Rectangle.ReadLocalValue方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.ReadLocalValue方法的具体用法?C# Rectangle.ReadLocalValue怎么用?C# Rectangle.ReadLocalValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Rectangle
的用法示例。
在下文中一共展示了Rectangle.ReadLocalValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadLocalProperty
public void ReadLocalProperty ()
{
PropertyUpdater data = new PropertyUpdater ();
Rectangle rectangle = new Rectangle { Opacity = 0f };
Binding binding = new Binding {
Path = new PropertyPath ("Opacity"),
Mode = BindingMode.OneWay,
Source = data
};
Assert.AreEqual (0.0, (double) rectangle.ReadLocalValue (Rectangle.OpacityProperty), "#1");
rectangle.SetBinding (Rectangle.OpacityProperty, binding);
Assert.IsTrue(rectangle.ReadLocalValue (Rectangle.OpacityProperty) is BindingExpressionBase, "#2");
}
示例2: BasicBind
public void BasicBind ()
{
Rectangle rectangle = new Rectangle ();
Binding binding = new Binding ("Opacity");
binding.Source = new Data { Opacity = 0.0 };
rectangle.SetBinding (Rectangle.OpacityProperty, binding);
Assert.AreEqual (0.0, rectangle.Opacity, "#1");
Assert.IsTrue (rectangle.ReadLocalValue (Rectangle.OpacityProperty) is BindingExpressionBase, "#2");
rectangle.Opacity = 1.0;
Assert.AreEqual(1.0, rectangle.Opacity, "#3");
Assert.AreEqual (1.0, rectangle.ReadLocalValue (Rectangle.OpacityProperty), "#4");
rectangle.SetBinding (Rectangle.OpacityProperty, binding);
Assert.IsTrue (rectangle.ReadLocalValue (Rectangle.OpacityProperty) is BindingExpressionBase, "#5");
Assert.AreEqual (0.0, rectangle.Opacity, "#6");
rectangle.ClearValue (Rectangle.OpacityProperty);
Assert.AreEqual (1.0, rectangle.Opacity, "#7");
Assert.AreEqual (DependencyProperty.UnsetValue, rectangle.ReadLocalValue (Rectangle.OpacityProperty), "#8");
}
示例3: TestOnceOffBinding2
public void TestOnceOffBinding2 ()
{
Canvas c = new Canvas { DataContext = 5.0 };
Rectangle r = new Rectangle ();
r.SetBinding (Rectangle.HeightProperty, new Binding { Mode = BindingMode.OneTime });
Assert.IsInstanceOfType<BindingExpressionBase> (r.ReadLocalValue (Rectangle.HeightProperty), "#1");
c.Children.Add (r);
Assert.IsInstanceOfType<BindingExpressionBase> (r.ReadLocalValue (Rectangle.HeightProperty), "#2");
CreateAsyncTest (c,
() => c.DataContext = 6.0,
() => {
Assert.IsInstanceOfType<BindingExpressionBase> (r.ReadLocalValue (Rectangle.HeightProperty), "#3");
Assert.AreEqual (6.0, r.Height, "#2");
}
);
}
示例4: TestOnceOffBinding3
public void TestOnceOffBinding3()
{
var source = new Rectangle { Width = 100 };
var dest = new Rectangle();
dest.SetBinding(Rectangle.WidthProperty, new Binding("Width") {
Mode = BindingMode.OneTime,
Source = source,
});
Assert.AreEqual(100, dest.Width, "#1");
Assert.IsInstanceOfType<BindingExpressionBase>(dest.ReadLocalValue(Rectangle.WidthProperty), "#a");
source.Width = 200;
Assert.AreEqual(100, dest.Width, "#2");
Assert.IsInstanceOfType<BindingExpressionBase>(dest.ReadLocalValue(Rectangle.WidthProperty), "#b");
}
示例5: TestOnceOffBinding
public void TestOnceOffBinding ()
{
Data data = new Data ();
Rectangle rectangle = new Rectangle { Opacity = 0f };
Binding binding = new Binding {
Path = new PropertyPath("Opacity"),
Mode = BindingMode.OneTime,
Source = data
};
rectangle.SetBinding (Rectangle.OpacityProperty, binding);
Assert.AreEqual (data.Opacity, rectangle.Opacity, "#1");
Assert.IsTrue(rectangle.ReadLocalValue(Rectangle.OpacityProperty) is BindingExpressionBase, "#2");
data.Opacity = 0;
Assert.AreNotEqual (data.Opacity, rectangle.Opacity, "#3");
}
示例6: TestTwoWayBinding2
public void TestTwoWayBinding2()
{
PropertyUpdater data = new PropertyUpdater { Opacity = 0.5f };
Rectangle r = new Rectangle();
r.SetBinding(Rectangle.OpacityProperty, new Binding
{
Path = new PropertyPath("Opacity"),
Source = data,
Mode = BindingMode.TwoWay
});
Assert.AreEqual(0.5, r.Opacity, "#1");
Assert.AreEqual(0.5, data.Opacity, "#2");
data.Opacity = 0;
Assert.AreEqual(0.0, r.Opacity, "#3");
r.Opacity = 1;
Assert.IsTrue(r.ReadLocalValue(Rectangle.OpacityProperty) is BindingExpressionBase, "#4");
Assert.AreEqual(1, r.Opacity, "#5");
Assert.AreEqual(1, data.Opacity, "#6");
r.ClearValue(Rectangle.OpacityProperty);
r.Opacity = 0.5;
Assert.AreEqual(1, data.Opacity, "#7");
}
示例7: RestoreOriginalValueOnStop_LocalValue
public void RestoreOriginalValueOnStop_LocalValue()
{
bool completed = false;
var target = new Rectangle { Opacity = 0.5 };
Storyboard sb = new Storyboard { FillBehavior = FillBehavior.Stop };
DoubleAnimation anim = new DoubleAnimation { From = 0, To = 1, Duration = TimeSpan.Zero };
Storyboard.SetTarget(anim, target);
Storyboard.SetTargetProperty(anim, new PropertyPath("Opacity"));
sb.Children.Add(anim);
sb.Completed += (o, e) => completed = true;
sb.Begin();
EnqueueConditional(() => completed, "#1");
Enqueue(() => Assert.AreEqual(0.5, (double)target.ReadLocalValue(FrameworkElement.OpacityProperty), "#2"));
EnqueueTestComplete();
}
示例8: DataContextTest
public void DataContextTest ()
{
object context = new object ();
Grid grid = new Grid { DataContext = context };
Rectangle r = new Rectangle ();
grid.Children.Add (r);
Assert.AreEqual (context, r.DataContext, "#1");
Assert.AreEqual (DependencyProperty.UnsetValue, r.ReadLocalValue (FrameworkElement.DataContextProperty), "#2");
}
示例9: ArrangeTest_ChildLargerThanFinalRect_LocalValue
public void ArrangeTest_ChildLargerThanFinalRect_LocalValue ()
{
Border c = new Border ();
Rectangle r = new Rectangle ();
c.Child = r;
r.Width = 50;
r.Height = 50;
c.Measure (new Size (25, 25));
c.Arrange (new Rect (0, 0, 25, 25));
Assert.AreEqual (DependencyProperty.UnsetValue, r.ReadLocalValue (FrameworkElement.ActualWidthProperty), "local r.actualwidth");
Assert.AreEqual (DependencyProperty.UnsetValue, c.ReadLocalValue (FrameworkElement.ActualWidthProperty), "local c.actualwidth");
}