本文整理汇总了C#中System.Windows.Ink.DrawingAttributes.ContainsPropertyData方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingAttributes.ContainsPropertyData方法的具体用法?C# DrawingAttributes.ContainsPropertyData怎么用?C# DrawingAttributes.ContainsPropertyData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Ink.DrawingAttributes
的用法示例。
在下文中一共展示了DrawingAttributes.ContainsPropertyData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PersistStylusTip
/// <Summary>
/// Encodes the StylusTip in the ISF stream.
/// </Summary>
#endif
private static void PersistStylusTip(DrawingAttributes da, Stream stream, GuidList guidList, ref uint cbData, ref BinaryWriter bw)
{
//
// persist the StylusTip
//
if (da.ContainsPropertyData(KnownIds.StylusTip))
{
System.Diagnostics.Debug.Assert(da.StylusTip != StylusTip.Ellipse, "StylusTip was put in the EPC for the default value!");
//
// persist PenTip.Rectangle for V1 ISF
//
Debug.Assert(bw != null);
cbData += SerializationHelper.Encode(stream, (uint)guidList.FindTag(KnownIds.PenTip, true));
cbData += SerializationHelper.Encode(stream, (uint)PenTip.Rectangle);
using (MemoryStream localStream = new MemoryStream(6)) //reasonable default
{
Int32 stylusTip = Convert.ToInt32(da.StylusTip, System.Globalization.CultureInfo.InvariantCulture);
System.Runtime.InteropServices.VarEnum type = SerializationHelper.ConvertToVarEnum(PersistenceTypes.StylusTip, true);
ExtendedPropertySerializer.EncodeAttribute(KnownIds.StylusTip, stylusTip, type, localStream);
cbData += ExtendedPropertySerializer.EncodeAsISF(KnownIds.StylusTip, localStream.ToArray(), stream, guidList, 0, true);
}
}
}
示例2: PersistDrawingFlags
private static void PersistDrawingFlags(DrawingAttributes da, Stream stream, GuidList guidList, ref uint cbData, ref BinaryWriter bw)
{
//
// always serialize DrawingFlags, even when it is the default of AntiAliased. V1 loaders
// expect it.
//
Debug.Assert(bw != null);
cbData += SerializationHelper.Encode(stream, (uint)guidList.FindTag(KnownIds.DrawingFlags, true));
cbData += SerializationHelper.Encode(stream, (uint)(int)da.DrawingFlags);
if (da.ContainsPropertyData(KnownIds.CurveFittingError))
{
Debug.Assert(bw != null);
cbData += SerializationHelper.Encode(stream, (uint)guidList.FindTag(KnownIds.CurveFittingError, true));
cbData += SerializationHelper.Encode(stream, (uint)(int)da.GetPropertyData(KnownIds.CurveFittingError));
}
}
示例3: PersistColorAndTransparency
private static void PersistColorAndTransparency(DrawingAttributes da, Stream stream, GuidList guidList, ref uint cbData, ref BinaryWriter bw)
{
// if the color is non-default (e.g. not black), then store it
// the v1 encoder throws away the default color (Black) so it isn't valuable
// to save.
if (da.ContainsPropertyData(KnownIds.Color))
{
Color daColor = da.Color;
System.Diagnostics.Debug.Assert(da.Color != (Color)DrawingAttributes.GetDefaultDrawingAttributeValue(KnownIds.Color), "Color was put in the EPC for the default value!");
//Note: we don't store the alpha value of the color (we don't use it)
uint r = (uint)daColor.R, g = (uint)daColor.G, b = (uint)(daColor.B);
uint colorVal = r + (g << Native.BitsPerByte) + (b << (Native.BitsPerByte * 2));
Debug.Assert(bw != null);
cbData += SerializationHelper.Encode(stream, (uint)guidList.FindTag(KnownIds.Color, true));
cbData += SerializationHelper.Encode(stream, colorVal);
}
//set transparency if Color.A is set
byte alphaChannel = da.Color.A;
if (alphaChannel != 255)
{
//note: Color.A is set to 255 by default, which means fully opaque
//transparency is just the opposite - 0 means fully opaque so
//we need to flip the values
int transparency = MathHelper.AbsNoThrow(( (int)alphaChannel ) - 255);
Debug.Assert(bw != null);
cbData += SerializationHelper.Encode(stream, (uint)guidList.FindTag(KnownIds.Transparency, true));
cbData += SerializationHelper.Encode(stream, Convert.ToUInt32(transparency));
}
}
示例4: DecodeAsISF
//.........这里部分代码省略.........
//Since StylusTip is stored in the EPC at this point (if set), we can compare against it here.
if (da.StylusTip != StylusTip.Ellipse)
{
//
// StylusTip was set to something other than Ellipse
// when we last serialized (or else StylusTip would be Ellipse, the default)
// when StylusTip is != Ellipse and we serialize, we set PenTip to Rectangle
// which is not the default. Therefore, if PenTip is back to Circle,
// that means someone set it in V1 and we should respect that by
// changing StylusTip back to Ellipse
//
da.StylusTip = StylusTip.Ellipse;
}
//else da.StylusTip is already set
}
else
{
System.Diagnostics.Debug.Assert(penTip == PenTip.Rectangle);
if (da.StylusTip == StylusTip.Ellipse)
{
//
// PenTip is Rectangle and StylusTip was either not set
// before or was set to Ellipse and PenTip was changed
// in a V1 ink object. Either way, we need to change StylusTip to Rectangle
da.StylusTip = StylusTip.Rectangle;
}
//else da.StylusTip is already set
}
//
// 2) next we need to set hight and width
//
if (da.StylusTip == StylusTip.Ellipse &&
widthIsSetInISF &&
!heightIsSetInISF)
{
//
// special case: V1 PenTip of Circle only used Width to compute the circle size
// and so it only serializes Width of 53
// but since our default is Ellipse, if Height is unset and we use the default
// height of 30, then your ink that looked like 53,53 in V1 will look
// like 30,53 here.
//
//
stylusHeight = stylusWidth;
da.HeightChangedForCompatabity = true;
}
// need to convert width/height into Avalon, since they are stored in HIMETRIC in ISF
stylusHeight *= StrokeCollectionSerializer.HimetricToAvalonMultiplier;
stylusWidth *= StrokeCollectionSerializer.HimetricToAvalonMultiplier;
// Map 0.0 width to DrawingAttributes.DefaultXXXXXX (V1 53 equivalent)
double height = DoubleUtil.IsZero(stylusHeight) ? (Double)DrawingAttributes.GetDefaultDrawingAttributeValue(KnownIds.StylusHeight) : stylusHeight;
double width = DoubleUtil.IsZero(stylusWidth) ? (Double)DrawingAttributes.GetDefaultDrawingAttributeValue(KnownIds.StylusWidth) : stylusWidth;
da.Height = GetCappedHeightOrWidth(height);
da.Width = GetCappedHeightOrWidth(width);
//
// 3) next we need to set IsHighlighter (by looking for RasterOperation.MaskPen)
//
//
// always store raster op
//
da.RasterOperation = rasterOperation;
if (rasterOperation == DrawingAttributeSerializer.RasterOperationDefaultV1)
{
//
// if rasterop is default, make sure IsHighlighter isn't in the EPC
//
if (da.ContainsPropertyData(KnownIds.IsHighlighter))
{
da.RemovePropertyData(KnownIds.IsHighlighter);
}
}
else
{
if (rasterOperation == DrawingAttributeSerializer.RasterOperationMaskPen)
{
da.IsHighlighter = true;
}
}
//else, IsHighlighter will be set to false by default, no need to set it
//
// 4) see if there is a transparency we need to add to color
//
if (transparency > DrawingAttributeSerializer.TransparencyDefaultV1)
{
//note: Color.A is set to 255 by default, which means fully opaque
//transparency is just the opposite - 0 means fully opaque so
//we need to flip the values
int alpha = MathHelper.AbsNoThrow(transparency - 255);
Color color = da.Color;
color.A = Convert.ToByte(alpha);
da.Color = color;
}
return cbTotal;
}