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


C# Stroke.Add方法代码示例

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


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

示例1: TestOpenSaveStroke

        public void TestOpenSaveStroke()
        {
            var stroke = new Stroke();
            stroke.Add(new Point(1, 2));
            stroke.Add(new Point(3, 4));
            var mem = new System.IO.MemoryStream();
            var f = Obf.OpenBinaryFormat.ToMemory(mem);
            stroke.Save(f, 1);
            var bytes = mem.ToArray();
            f.Close();

            f = Obf.OpenBinaryFormat.FromBytes(bytes);
            var newStroke = new Stroke();
            newStroke.Read(f);
            Assert.True(newStroke.Count == 2);
            Assert.True(newStroke[0].X == 1);
            Assert.True(newStroke[0].Y == 2);
            Assert.True(newStroke[1].X == 3);
            Assert.True(newStroke[1].Y == 4);
        }
开发者ID:bvssvni,项目名称:csharp-sketch,代码行数:20,代码来源:TestOpenSave.cs

示例2: TestOpenSaveFrameData

        public void TestOpenSaveFrameData()
        {
            var frameData = new FrameData();
            var frame = new Frame();
            frameData.Frames.Add(frame);
            var stroke = new Stroke();
            stroke.Add(new Point(0, 0));
            stroke.Add(new Point(100, 100));
            frame.Strokes.Add(stroke);

            System.IO.MemoryStream mem = new System.IO.MemoryStream();
            Obf.OpenBinaryFormat f = Obf.OpenBinaryFormat.ToMemory(mem);
            frameData.Save(f);

            var bytes = mem.ToArray();
            f.Close();

            f = Obf.OpenBinaryFormat.FromBytes(bytes);

            var newFrameData = new FrameData();
            newFrameData.Read(f);

            f.Close();

            Assert.True(newFrameData.Frames.Count == 1);
            frame = newFrameData.Frames[0];
            Assert.True(frame.Strokes.Count == 1);
            stroke = frame.Strokes[0];
            Assert.True(stroke.Count == 2);
            var p1 = stroke[0];
            Assert.True(p1.X == 0);
            Assert.True(p1.Y == 0);
            var p2 = stroke[1];
            Assert.True(p2.X == 100);
            Assert.True(p2.Y == 100);
        }
开发者ID:bvssvni,项目名称:csharp-sketch,代码行数:36,代码来源:TestOpenSave.cs

示例3: Collect

		void Collect (Stroke stroke, UITouch touch, UIView view, bool coalesced, bool predicted)
		{
			if (view == null)
				throw new ArgumentNullException ();

			// Only collect samples that actually moved in 2D space.
			var location = touch.GetPreciseLocation (view);
			var previousSample = stroke.Samples.LastOrDefault ();
			if (Distance (previousSample?.Location, location) < 0.003)
				return;

			var sample = new StrokeSample {
				Timestamp = touch.Timestamp,
				Location = location,
				Coalesced = coalesced,
				Predicted = predicted
			};
			bool collectForce = touch.Type == UITouchType.Stylus || view.TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available;
			if (collectForce)
				sample.Force = touch.Force;

			if (touch.Type == UITouchType.Stylus) {
				var estimatedProperties = touch.EstimatedProperties;
				sample.EstimatedProperties = estimatedProperties;
				sample.EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates;
				sample.Altitude = touch.AltitudeAngle;
				sample.Azimuth = touch.GetAzimuthAngle (view);

				if (stroke.Samples.Count == 0 && estimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
					stroke.ExpectsAltitudeAzimuthBackfill = true;
				} else if (stroke.ExpectsAltitudeAzimuthBackfill &&
						   !estimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
					for (int index = 0; index < stroke.Samples.Count; index++) {
						var priorSample = stroke.Samples [index];
						var updatedSample = priorSample;

						if (updatedSample.EstimatedProperties.HasFlag (UITouchProperties.Altitude)) {
							updatedSample.EstimatedProperties &= ~UITouchProperties.Altitude;
							updatedSample.Altitude = sample.Altitude;
						}
						if (updatedSample.EstimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
							updatedSample.EstimatedProperties &= ~UITouchProperties.Azimuth;
							updatedSample.Azimuth = sample.Azimuth;
						}
						stroke.Update (updatedSample, index);
					}
					stroke.ExpectsAltitudeAzimuthBackfill = false;
				}
			}

			if (predicted) {
				stroke.AddPredicted (sample);
			} else {
				var index = stroke.Add (sample);
				if (touch.EstimatedPropertiesExpectingUpdates != 0) {
					outstandingUpdateIndexes [touch.EstimationUpdateIndex] = new StrokeIndex {
						Stroke = stroke,
						Index = index
					};
				}
			}
		}
开发者ID:xamarin,项目名称:monotouch-samples,代码行数:62,代码来源:StrokeGestureRecognizer.cs


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