Exemplo n.º 1
0
        private void CreateSectorShape(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            SectorShape shape = new SectorShape(new RectangleF2D(new PointF(0, 30), new SizeF(80, 10)), 40, 270);

            shape.Appearance.ContentBrush = new SolidBrushObject(Color.Red);
            shape.Name = "sectorShape";
            needleShape.Add(shape);
        }
Exemplo n.º 2
0
        private void CreateBoxNeedle(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            BoxShape shape = new BoxShape(new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10)));

            shape.Appearance.ContentBrush = new SolidBrushObject(Color.Gray);
            shape.Name = "boxNeedle";
            needleShape.Add(shape);
        }
Exemplo n.º 3
0
        private void CreateArcNeedle(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            ArcShape shape = new ArcShape(new RectangleF2D(new PointF(-10, 0), new SizeF(20, 10)), 180, -60);

            shape.Appearance.ContentBrush = new SolidBrushObject(Color.White);
            shape.Name = "arcNeedle";
            needleShape.Add(shape);
        }
Exemplo n.º 4
0
        /// <summary>Resets to prepare for the next operation.</summary>
        public void Reset()
        {
            // Reset/update state for the next use/await of this instance.
            Version++;
            _result            = null;
            _capturedContext   = null;
            _continuation      = null;
            _continuationState = null;
#if TARGETS_NET || TARGETS_NETCORE || GREATERTHAN_NETSTANDARD13
            _executionContext = null;
#endif
        }
Exemplo n.º 5
0
 public Needle(T target)
 {
     if (target == null)
     {
         _target   = null;
         _hashCode = base.GetHashCode();
     }
     else
     {
         _target   = new StructNeedle <T>(target);
         _hashCode = target.GetHashCode();
     }
 }
Exemplo n.º 6
0
 public Needle(T target)
 {
     if (ReferenceEquals(target, null))
     {
         _target   = null;
         _hashCode = base.GetHashCode();
     }
     else
     {
         _target   = new StructNeedle <T>(target);
         _hashCode = target.GetHashCode();
     }
 }
Exemplo n.º 7
0
        private void CreateTextShape(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            TextShape shape = new TextShape();

            shape.Box  = new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10));
            shape.Text = "    > > > > > ";
            shape.AppearanceText.TextBrush = new SolidBrushObject(Color.Salmon);
            needleShape.Add(shape);
        }
Exemplo n.º 8
0
        private void CreateEllipseNeedle(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            EllipseShape shape = new EllipseShape(new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10)));
            LinearGradientBrushObject brush = new LinearGradientBrushObject(new PointF2D(2, 0), new PointF2D(0, 2));

            brush.StartColor = Color.Yellow;
            brush.EndColor   = Color.Magenta;
            shape.Appearance.ContentBrush = brush;
            shape.Name = "ellipseNeedle";
            needleShape.Add(shape);
        }
Exemplo n.º 9
0
        public Needle(T target)
        {
            if (target == null)
            {
                _target   = null;
                _hashCode = base.GetHashCode();
            }
            else
            {
                _target   = new StructNeedle <T>(target);
                _hashCode = target.GetHashCode();
            }

            _onCompleted = new StrongDelegateCollection(true);
        }
Exemplo n.º 10
0
 protected void SetTargetValue(T value)
 {
     if (_target is StructNeedle <T> )
     {
         // This may throw NotSupportedException if SetTargetError has just executed
         try
         {
             _target.Value = value;
             return;
         }
         catch (NotSupportedException)
         {
             // preventing return
         }
     }
     _target = new StructNeedle <T>(value);
 }
Exemplo n.º 11
0
        private void CreatePolylineNeedle(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            PolylineShape shape = new PolylineShape();

            shape.Points = new PointF[] {
                new PointF(0, 20), new PointF(-40, 25),
                new PointF(20, 5), new PointF(100, 0),
                new PointF(20, -5), new PointF(-40, -25),
                new PointF(0, -20)
            };

            shape.Appearance.ContentBrush = new SolidBrushObject(Color.Yellow);
            shape.Name = "polylineNeedle";
            needleShape.Add(shape);
        }
Exemplo n.º 12
0
        private void CreatePolygonNeedle(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            PolygonShape shape = new PolygonShape();

            shape.Points = new PointF[] {
                new PointF(0, 10),
                new PointF(75, 10),
                new PointF(70, -5),
                new PointF(100, 0),
                new PointF(65, -10),
                new PointF(70, 5),
                new PointF(0, -10)
            };

            shape.Appearance.ContentBrush = new SolidBrushObject(Color.AliceBlue);
            shape.Name = "polygonNeedle";
            needleShape.Add(shape);
        }
Exemplo n.º 13
0
        private void CreatePathNeedle(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            PathShape shape = new PathShape();

            shape.Points = new ShapePoint[] {
                new ShapePoint(new PointF(0, 20), PathPointType.Start),
                new ShapePoint(new PointF(50, 0), PathPointType.Line),
                new ShapePoint(new PointF(0, -20), PathPointType.Line),
                new ShapePoint(new PointF(100, 0), PathPointType.Line),
                new ShapePoint(new PointF(0, 20), PathPointType.CloseSubpath | PathPointType.Line)
            };

            SolidBrushObject brush = new SolidBrushObject(Color.Red);

            shape.Appearance.ContentBrush = brush;

            shape.Name = "pathNeedle";
            needleShape.Add(shape);
        }
Exemplo n.º 14
0
        private void CreateComplexNeedle(INeedle needle)
        {
            ComplexShape needleShape = (ComplexShape)needle.Shape;

            needleShape.Collection.Clear();

            PolylineShape basic = new PolylineShape(new PointF[] {
                new PointF(25, 20), new PointF(100, 0), new PointF(25, -20),
                new PointF(95, 0), new PointF(25, 20)
            });

            basic.Appearance.ContentBrush = new SolidBrushObject(Color.Azure);
            basic.Name = "basic";

            PolylineShape cap = new PolylineShape(new PointF[] {
                new PointF(100, 0), new PointF(105, 5),
                new PointF(110, 0), new PointF(105, -5)
            });

            cap.Appearance.ContentBrush = new SolidBrushObject(Color.BurlyWood);
            cap.Name = "cap";

            needleShape.AddRange(new BaseShape[] { basic, cap });
        }
Exemplo n.º 15
0
 /// <summary>Completes with an error.</summary>
 /// <param name="error">The exception.</param>
 public void SetException(Exception error)
 {
     _result = new ExceptionStructNeedle <TResult>(error);
     SignalCompletion();
 }
Exemplo n.º 16
0
 protected void SetTargetError(Exception error)
 {
     _target = new ExceptionStructNeedle <T>(error);
 }
Exemplo n.º 17
0
 /// <summary>Completes with a successful result.</summary>
 /// <param name="result">The result.</param>
 public void SetResult(TResult result)
 {
     _result = new StructNeedle <TResult>(result);
     SignalCompletion();
 }
Exemplo n.º 18
0
 public ReadOnlyNeedle(T target)
 {
     _target = new StructNeedle <T>(target);
 }
Exemplo n.º 19
0
 public ReadOnlyNeedle(INeedle <T> target)
 {
     _target = target;
 }
Exemplo n.º 20
0
 public ReadOnlyNeedle()
 {
     _target = null;
 }
Exemplo n.º 21
0
 public virtual void Free()
 {
     _target = null;
 }
Exemplo n.º 22
0
 protected void SetTargetError(Exception error)
 {
     _target = new ExceptionStructNeedle <T>(error);
     Thread.MemoryBarrier();
 }
Exemplo n.º 23
0
        private INeedle <T> _target; // Can be null - set in SetTargetValue and SetTargetError

        public Needle()
        {
            _target   = null;
            _hashCode = base.GetHashCode();
        }
Exemplo n.º 24
0
 public static TNeedle Create(INeedle <T> target)
 {
     return(_create.Invoke(target));
 }
Exemplo n.º 25
0
 public static TNeedle CreateNestedNeedle <T, TNeedle>(INeedle <T> target)
     where TNeedle : INeedle <T>
 {
     return(NestedNeedleCreator <T, TNeedle> .Create(target));
 }
Exemplo n.º 26
0
        private INeedle <T> _target; // Can be null - set in SetTargetValue and SetTargetError

        public Needle()
        {
            _target      = null;
            _hashCode    = base.GetHashCode();
            _onCompleted = new StrongDelegateCollection(true);
        }