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


C# StylusPointCollection.Add方法代码示例

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


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

示例1: GetRectangle

        void GetRectangle(StylusPointCollection pts, Action<StylusPointCollection> exec)
        {
            pts.Add(new StylusPoint(topLeft.X, topLeft.Y));
            pts.Add(new StylusPoint(bottomRight.X, bottomRight.Y));

            exec(pts);
        }
开发者ID:sonicrang,项目名称:RangPaint,代码行数:7,代码来源:DrawRectangle.cs

示例2: MyIP_MouseLeftButtonDown

        //A new stroke object named MyStroke is created. MyStroke is added to the StrokeCollection of the InkPresenter named MyIP
        private void MyIP_MouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            MyIP.CaptureMouse();
            if (eraseflag == true)
            {

                StylusPointCollection MyStylusPointCollection = new StylusPointCollection();
                MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP));
                NewStroke = new Stroke(MyStylusPointCollection);
                NewStroke.DrawingAttributes.Color = Colors.Red;
                MyIP.Strokes.Add(NewStroke); StylusPointCollection ErasePointCollection = new StylusPointCollection();


            }
            else
            {
                StylusPointCollection pointErasePoints = e.StylusDevice.GetStylusPoints(MyIP);
                StrokeCollection hitStrokes = MyIP.Strokes.HitTest(pointErasePoints);
                if (hitStrokes.Count > 0)
                {
                    foreach (Stroke hitStroke in hitStrokes)
                    {
                        MyIP.Strokes.Remove(hitStroke);
                        //undoStack.Push(hitStroke);
                        //undoStateBufferStack.Push(true);
                    }
                }
            }
        }
开发者ID:TinusGreen,项目名称:GendacProjects,代码行数:30,代码来源:MainPage.xaml.cs

示例3: ToWindowsStroke

        public static WindowsInk.Stroke ToWindowsStroke(NineInk.Stroke nineStroke)
        {
            var points = new StylusPointCollection();

            foreach (var point in nineStroke.Points)
                points.Add(new StylusPoint(point.X, point.Y, point.Pressure));

            var drwAttr = new WindowsInk.DrawingAttributes();
            var c = new Color();
            c.R = nineStroke.DrawingAttributes.Color.R;
            c.G = nineStroke.DrawingAttributes.Color.G;
            c.B = nineStroke.DrawingAttributes.Color.B;
            c.A = nineStroke.DrawingAttributes.Color.A;
            drwAttr.Color = c;

            switch (nineStroke.DrawingAttributes.Brush.Name)
            {
                case "Rectangle":
                    drwAttr.StylusTip = WindowsInk.StylusTip.Rectangle;
                    break;
                case "Ellipse":
                default:
                    drwAttr.StylusTip = WindowsInk.StylusTip.Ellipse;
                    break;
            }
            drwAttr.Height = nineStroke.DrawingAttributes.Height;
            drwAttr.Width = nineStroke.DrawingAttributes.Width;
            drwAttr.IsHighlighter = nineStroke.DrawingAttributes.IsHighlighter;

            return new WindowsInk.Stroke(points, drwAttr);
        }
开发者ID:aragoubi,项目名称:Nine,代码行数:31,代码来源:StrokeConverter.cs

示例4: Representation

 public Stroke Representation()
 {
     StylusPointCollection collection = new StylusPointCollection();
     foreach (var data in stylusPoints)
         collection.Add(data.Representation());
     return new Stroke(collection);
 }
开发者ID:rudi-c,项目名称:htn-stylus,代码行数:7,代码来源:InkData.cs

示例5: checkIfStrokeSelected

        private static void checkIfStrokeSelected(MouseButtonEventArgs e, InkPresenter inkCanvas, StylusPointCollection spc)
        {
            spc.Add(new StylusPoint(e.GetPosition(inkCanvas).X, e.GetPosition(inkCanvas).Y));

            if (inkCanvas.Strokes.HitTest(spc).Count > 0)
            {
                removeSelectedStroke(inkCanvas, spc);
            }

            return;
        }
开发者ID:kiangkuang,项目名称:SilverlightFill,代码行数:11,代码来源:Delete.cs

示例6: Stroke_StylusPointCollection

		public void Stroke_StylusPointCollection ()
		{
			StylusPointCollection spc = new StylusPointCollection ();
			spc.Add (new StylusPoint (1, 2));

			Stroke s = new Stroke (spc);
			Assert.AreEqual (1, s.StylusPoints.Count, "StylusPoints-1");

			spc.Add (new StylusPoint (3, 4));
			Assert.AreEqual (2, s.StylusPoints.Count, "StylusPoints-2");

			s.StylusPoints.Add (new StylusPoint (5, 6));
			Assert.AreEqual (3, s.StylusPoints.Count, "StylusPoints-3a");
			Assert.AreEqual (3, spc.Count, "StylusPoints-3b");

			Assert.Throws<ArgumentException> (delegate {
				s.HitTest (null);
			}, "HitTest-null");
			Assert.IsTrue (s.HitTest (s.StylusPoints), "HitTest-StylusPoints");
		}
开发者ID:dfr0,项目名称:moon,代码行数:20,代码来源:StrokeTest.cs

示例7: myInkPresenter_MouseLeftButtonDown

 private void myInkPresenter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     //捕获鼠标焦点
     myInkPresenter.CaptureMouse();
     myPointCollection = new StylusPointCollection();
     myPointCollection.Add(e.StylusDevice.GetStylusPoints(myInkPresenter));
     currentStroke = new Stroke(myPointCollection);
     //设置画笔属性
     currentStroke.DrawingAttributes.Color = currentColor;
     currentStroke.DrawingAttributes.Height = sliderThickness.Value;
     currentStroke.DrawingAttributes.Width = sliderThickness.Value;
     myInkPresenter.Strokes.Add(currentStroke);
 }
开发者ID:Tek-Eternal,项目名称:MyInkPresenter,代码行数:13,代码来源:MainPage.xaml.cs

示例8: Deserialize

 public void Deserialize(XmlNode xmlNode, FlowDocument flowDocument)
 {
     var inkCanvas = new InkCanvasEx();
     foreach (XmlNode strokeNode in xmlNode.ChildNodes)
     {
         var points = new StylusPointCollection();
         foreach (XmlNode pointNode in strokeNode.ChildNodes)
         {
             points.Add(new StylusPoint(Double.Parse(pointNode.Attributes["X"].InnerText),
                 Double.Parse(pointNode.Attributes["Y"].InnerText)));
         }
         inkCanvas.Strokes.Add(new Stroke(points)); //TODO DrawingAttributes
     }
     flowDocument.Blocks.Add(new DrawerBlock { Child = new DrawerControl { Strokes = inkCanvas.Strokes }});
 }
开发者ID:hinduCoder,项目名称:Diploma,代码行数:15,代码来源:IDeserializeBlockStrategy.cs

示例9: down

        public static void down(MouseButtonEventArgs e, InkPresenter inkCanvas, Grid LayoutRoot)
        {
            dragStarted = true;
            inkCanvas.CaptureMouse();

            clickedLayer = Common.hitTestLayer(e, inkCanvas);
            initialPos = e.GetPosition(inkCanvas);

            StylusPointCollection spc = new StylusPointCollection();
            spc.Add(new StylusPoint(e.GetPosition(inkCanvas).X, e.GetPosition(inkCanvas).Y));

            hitCount = inkCanvas.Strokes.HitTest(spc).Count;

            System.Diagnostics.Debug.WriteLine("layer " + clickedLayer);

            if (clickedLayer != -1)
            {

                //Calculate offset of left, right, top, bottom
                calculateOffset(e, inkCanvas);

                //System.Diagnostics.Debug.WriteLine("maxLeft " + MainPage.layerList[clickedLayer].imageToBorderDist[LEFT]);
                //System.Diagnostics.Debug.WriteLine("offSetLeft " + offSetLeft);
                //System.Diagnostics.Debug.WriteLine("positionY" + e.GetPosition(inkCanvas).Y);
                //System.Diagnostics.Debug.WriteLine("maxTop " + MainPage.layerList[clickedLayer].imageToBorderDist[TOP]);
                //System.Diagnostics.Debug.WriteLine("offSetTop " + offSetTop);

                //if the clickedLayer's image is out of bound
                if (clickedLayer != -1 && MainPage.layerList[clickedLayer].imgBackup != null)
                {
                    replaceMovingImgWithBackupImg(LayoutRoot);

                }
                else
                {
                    //temporarly save image in image backup
                    imageBackup = new WriteableBitmap((BitmapSource)MainPage.layerList[clickedLayer].img.Source);
                }

            }

            //Line clicked
            if (hitCount > 0)
            {
                moveInkToNewInkPresenter(inkCanvas, LayoutRoot, spc);
            }
        }
开发者ID:kiangkuang,项目名称:SilverlightFill,代码行数:47,代码来源:Drag.cs

示例10: TouchPoint2

        public TouchPoint2(TouchInfo info, UIElement source)
        {
            this.Source = source;

            #if SILVERLIGHT
            Stroke = new Stroke();
            #else
            var stylusPoints = new StylusPointCollection(1);
            stylusPoints.Add(new StylusPoint(info.Position.X, info.Position.Y));
            Stroke = new Stroke(stylusPoints);
            #endif

            TouchDeviceId = info.TouchDeviceId;
            StartTime = DateTime.Now;

            #if SILVERLIGHT
            UpdateTouchStroke(info);
            #endif
            UpdateTouchInfo(info);
        }
开发者ID:tuliosouza,项目名称:ASG,代码行数:20,代码来源:TouchPoint2.cs

示例11: GetStrokeCollectionFromPoints

        private StrokeCollection GetStrokeCollectionFromPoints(dynamic strokePoints)
        {
            var strokeCollection = new StrokeCollection();

            foreach (var stroke in strokePoints.Strokes)
            {
                var points = new StylusPointCollection();

                foreach (var point in stroke.Points)
                {
                    var x = (float)point.X;
                    var y = (float)point.Y;

                    points.Add(new StylusPoint(x, y));
                }

                strokeCollection.Add(new Stroke(points));
            }

            return strokeCollection;
        }
开发者ID:brenoferreira,项目名称:Canvas-Handwriting-Recognition,代码行数:21,代码来源:RecognitionController.cs

示例12: ConvertToStrokeCollection

        public static StrokeCollection ConvertToStrokeCollection(SerializableStrokeCollection strokeCollection)
        {
            StrokeCollection resultCollection = new StrokeCollection();
            foreach (var stroke in strokeCollection)
            {
                DrawingAttributes drawingAttr = new DrawingAttributes
                {
                    Color = stroke.DrawingAttributes.Color,
                    FitToCurve = stroke.DrawingAttributes.FitToCurve,
                    Height = stroke.DrawingAttributes.Height,
                    Width = stroke.DrawingAttributes.Width,
                    IgnorePressure = stroke.DrawingAttributes.IgnorePressure,
                    IsHighlighter = stroke.DrawingAttributes.IsHighlighter,
                    StylusTipTransform = stroke.DrawingAttributes.StylusTipTransform
                };
                switch (stroke.DrawingAttributes.StylusTip)
                {
                    case SerializableDrawingAttributes.StylusTips.Ellipse:
                        drawingAttr.StylusTip = StylusTip.Ellipse;
                        break;
                    case SerializableDrawingAttributes.StylusTips.Rectangle:
                        drawingAttr.StylusTip = StylusTip.Rectangle;
                        break;
                    default:
                        break;
                }

                StylusPointCollection spc = new StylusPointCollection();
                foreach (var stylusPoint in stroke.StylusPoints)
                {
                    StylusPoint sp = new StylusPoint { X = stylusPoint.X, Y = stylusPoint.Y, PressureFactor = stylusPoint.PressureFactor };
                    spc.Add(sp);
                }
                Stroke newStroke = new Stroke(spc);
                newStroke.DrawingAttributes = drawingAttr;
                resultCollection.Add(newStroke);
            }
            return resultCollection;
        }
开发者ID:tuliosouza,项目名称:ASG,代码行数:39,代码来源:StrokeHelper.cs

示例13: Add_StylusPointCollection_MultipleTimes

		public void Add_StylusPointCollection_MultipleTimes ()
		{
			StylusPointCollection spc = new StylusPointCollection ();
			StylusPointCollection child = new StylusPointCollection ();
			child.Add (new StylusPoint (1, 2));
			spc.Add (child);
			Assert.AreEqual (1, spc.Count, "Count-1");
			// twice
			Assert.Throws<InvalidOperationException> (delegate {
				spc.Add (child);
			}, "child already added");
			Assert.AreEqual (1, spc.Count, "Count-2");
			Assert.Throws<InvalidOperationException> (delegate {
				spc.Add (spc);
			}, "child already added/2");
			Assert.AreEqual (1, spc.Count, "Count-3");
		}
开发者ID:dfr0,项目名称:moon,代码行数:17,代码来源:StylusPointCollectionTest.cs

示例14: Add_StylusPoint_Collection_Validation

		public void Add_StylusPoint_Collection_Validation ()
		{
			StylusPointCollection spc = new StylusPointCollection ();
			// not an ArgumentNullException (or NRE)
			Assert.Throws<ArgumentException> (delegate {
				spc.Add ((StylusPointCollection) null);
			}, "null");
		}
开发者ID:dfr0,项目名称:moon,代码行数:8,代码来源:StylusPointCollectionTest.cs

示例15: Add_StylusPointCollection_Empty

		public void Add_StylusPointCollection_Empty ()
		{
			StylusPointCollection spc = new StylusPointCollection ();
			StylusPointCollection child = new StylusPointCollection ();
			spc.Add (child);
			// twice
			spc.Add (child);
			// self
			spc.Add (spc);
			Assert.AreEqual (0, spc.Count, "Count-3");
		}
开发者ID:dfr0,项目名称:moon,代码行数:11,代码来源:StylusPointCollectionTest.cs


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