本文整理汇总了C#中System.Windows.Ink.DrawingAttributes.PropertyDataChanged事件的典型用法代码示例。如果您正苦于以下问题:C# DrawingAttributes.PropertyDataChanged事件的具体用法?C# DrawingAttributes.PropertyDataChanged怎么用?C# DrawingAttributes.PropertyDataChanged使用的例子?那么, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在类System.Windows.Ink.DrawingAttributes
的用法示例。
在下文中一共展示了DrawingAttributes.PropertyDataChanged事件的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShadowedStroke
class ShadowedStroke : Stroke
{
// Be sure to pass in the DrawingAttributes when you create the stroke to
// subscribe to the PropertyDataChaned event.
public ShadowedStroke(StylusPointCollection stylusPoints, DrawingAttributes drawingAttributes)
: base(stylusPoints, drawingAttributes)
{
this.DrawingAttributes.PropertyDataChanged += new PropertyDataChangedEventHandler(DrawingAttributes_PropertyDataChanged);
}
Guid shadow = new Guid("12345678-9012-3456-7890-123456789012");
public bool Shadowed
{
// Return the value of the custom property, shadow.
// If there is no custom property, return false.
get
{
if (!this.DrawingAttributes.ContainsPropertyData(shadow))
{
return false;
}
object propertyData = this.DrawingAttributes.GetPropertyData(shadow);
if (propertyData is bool)
{
return (bool)propertyData;
}
else
{
return false;
}
}
// Set the value of the custom property.
set
{
this.DrawingAttributes.AddPropertyData(shadow, value);
}
}
void DrawingAttributes_PropertyDataChanged(object sender, PropertyDataChangedEventArgs e)
{
this.OnInvalidated(new EventArgs());
}
protected override void DrawCore(System.Windows.Media.DrawingContext context, DrawingAttributes overrides)
{
// create a drop shadow
//
if (this.Shadowed)
{
Geometry pathGeometry = this.GetGeometry(overrides).Clone();
pathGeometry.Transform = new TranslateTransform(5, 0);
try
{
context.PushOpacity(0.5);
context.DrawGeometry(Brushes.DarkGray, null, pathGeometry);
}
finally
{
context.Pop();
}
}
base.DrawCore(context, overrides);
}
}