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


C# DrawingAttributes.AddPropertyData方法代码示例

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


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

示例1: OnMouseMove

        public override void OnMouseMove(System.Windows.Controls.InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                bottomRight = e.GetPosition(inkCanvas);
                if(topLeft != bottomRight)
                {
                    StylusPointCollection pts = new StylusPointCollection();
                    GetRectangle(pts, (s) =>
                    {
                        if (StrokeResult != null)
                            inkCanvas.Strokes.Remove(StrokeResult);

                        DrawingAttributes drawingAttributes = new DrawingAttributes
                        {
                            Color = inkCanvas.DefaultDrawingAttributes.Color,
                            Width = inkCanvas.DefaultDrawingAttributes.Width,
                            StylusTip = StylusTip.Ellipse,
                            IgnorePressure = true,
                            FitToCurve = true
                        };
                        var BackgroundColor = inkCanvas.DefaultDrawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor);
                        drawingAttributes.AddPropertyData(DrawAttributesGuid.BackgroundColor, BackgroundColor);

                        StrokeResult = new RectangleStroke(s, drawingAttributes);
                        inkCanvas.Strokes.Add(StrokeResult);
                    }
                    );
                }

            }
        }
开发者ID:sonicrang,项目名称:RangPaint,代码行数:32,代码来源:DrawRectangle.cs

示例2: DecodeAsISF


//.........这里部分代码省略.........
                }
                else if (KnownIds.Color == guid)
                { 
                    cb = SerializationHelper.Decode(stream, out dw);
 
                    Color color = Color.FromRgb((byte)(dw & 0xff), (byte)((dw & 0xff00) >> Native.BitsPerByte), (byte)((dw & 0xff0000) >> (Native.BitsPerByte * 2))); 
                    da.Color = color;
                    maximumStreamSize -= cb; 
                }
                else if (KnownIds.StylusTipTransform == guid)
                {
                    try 
                    {
                        object data; 
                        cb = ExtendedPropertySerializer.DecodeAsISF(stream, maximumStreamSize, guidList, tag, ref guid, out data); 

                        Matrix matrix = Matrix.Parse((string)data); 
                        da.StylusTipTransform = matrix;
                    }
                    catch (InvalidOperationException) // Matrix.Parse failed.
                    { 
                        System.Diagnostics.Debug.Assert(false, "Corrupt Matrix in the ExtendedPropertyCollection!");
                    } 
                    finally 
                    {
                        maximumStreamSize -= cb; 
                    }
                }
                else
                { 
                    object data;
                    cb = ExtendedPropertySerializer.DecodeAsISF(stream, maximumStreamSize, guidList, tag, ref guid, out data); 
                    maximumStreamSize -= cb; 
                    da.AddPropertyData(guid,data);
                } 
            }

            if (0 != maximumStreamSize)
            { 
                throw new ArgumentException ();
            } 
 
            //
            // time to create our drawing attributes. 
            //
            // 1) First we need to evaluate PenTip / StylusTip
            // Here is the V1 - V2 mapping
            // 
            // PenTip.Circle == StylusTip.Ellipse
            // PenTip.Rectangle == StylusTip.Rectangle 
            // PenTip.Rectangle == StylusTip.Diamond 
            if (penTip == PenTip.Default)
            { 
                //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;
                } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:67,代码来源:DrawingAttributeSerializer.cs


注:本文中的System.Windows.Ink.DrawingAttributes.AddPropertyData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。