public void Method_can_mutate_own_state() { var p = new MutablePoint(10, 10); p.TranslateInPlace(20, 0); Assert.Equal(30, p.X); }
public void CancelDrag(IInputModeContext context, PointD originalLocation) { wrappedHandler.CancelDrag(context, originalLocation); shadowObject.Remove(); shadowObject = null; shadowLocation = null; emulatedOffset = PointD.Origin; }
protected SceneObject(string name, MutablePoint positionPoint, MutableSize size, Scene parent = null) { Name = name; PositionPoint = positionPoint; Size = size; Parent = parent; parent?.AddSceneObject(this); }
public static void Executa() { var p1 = new MutablePoint(1, 2); var p2 = p1; Console.WriteLine($"{nameof(p1)} after {nameof(p2)} is modified: {p1}"); Console.WriteLine($"{nameof(p2)}: {p2}"); }
public void DragFinished(IInputModeContext context, PointD originalLocation, PointD newLocation) { wrappedHandler.HandleMove(context, originalLocation, newLocation); wrappedHandler.DragFinished(context, originalLocation, newLocation); shadowObject.Remove(); shadowObject = null; shadowLocation = null; emulatedOffset = PointD.Origin; }
Curve createCurve(MutablePoint start, MutablePoint end) { MutablePoint center = new MutablePoint(() => { PointF result = getCenterOffsetByLine(edge, offset); return(result); }); List <MutablePoint> points = new List <MutablePoint>() { start, center, end }; return(new Curve(points)); }
public static void Main() { var p1 = new MutablePoint(1, 2); var p2 = p1; p2.Y = 200; Console.WriteLine($"{nameof(p1)} after {nameof(p2)} is modified: {p1}"); Console.WriteLine($"{nameof(p2)}: {p2}"); MutateAndDisplay(p2); Console.WriteLine($"{nameof(p2)} after passing to a method: {p2}"); }
public void ValueTypeTest() { var p1 = new MutablePoint(1, 2); var p2 = p1; p2.Y = 200; Assert.Equal(1, p1.X); Assert.Equal(2, p1.Y); Assert.Equal(200, p2.Y); MutateAndDisplay(p2); Assert.Equal(1, p2.X); Assert.Equal(200, p2.Y); }
public void InitializeDrag(IInputModeContext context) { wrappedHandler.InitializeDrag(context); this.shadowLocation = node.Layout.GetTopLeft(); this.emulatedOffset = PointD.Origin; var dummyNode = new SimpleNode { Layout = new DynamicRectangle(shadowLocation, node.Layout), Style = new ShapeNodeStyle { Shape = ShapeNodeShape.RoundRectangle, Brush = Brushes.Transparent, Pen = new Pen(Brushes.Gray, 2) } }; shadowObject = context.CanvasControl.RootGroup.AddChild(dummyNode, GraphModelManager.DefaultNodeDescriptor).ToFront(); }
static void Main(string[] args) { //string a = "hello"; //string b = "h"; //// Append to contents of 'b' //b += "ello"; //Console.WriteLine(a == b); //Console.WriteLine(object.ReferenceEquals(a, b)); var p1 = new MutablePoint(1, 2); var p2 = p1; p2.Y = 200; Console.WriteLine($"{nameof(p1)} after {nameof(p2)} is modified: {p1}"); Console.WriteLine($"{nameof(p2)}: {p2}"); MutateAndDisplay(p2); Console.WriteLine($"{nameof(p2)} after passing to a method: {p2}"); }
public void CreateImmutableValueTypes() { IFixture fixture = new Fixture(); // Autofixture can also create values of non-primitive value types. ImmutablePoint immutablePoint = fixture.Create <ImmutablePoint>(); DateTime time1 = fixture.Create <DateTime>(); DateTimeOffset time2 = fixture.Create <DateTimeOffset>(); // By default it can only handle value types that have a defined constructor with parameters. Assert.Throws( Is.InstanceOf <ObjectCreationException>(), () => fixture.Create <MutablePoint>() ); // If you need to create a value of a mutable value type // and set the properties afterwards, you can instruct AutoFixture to do so // by using a Customization. Customizations will be covered in-depth in another tutorial file. fixture.Customize(new SupportMutableValueTypesCustomization()); MutablePoint mutablePoint = fixture.Create <MutablePoint>(); }
public void init() { isCanvasDirty = false; animationStoped = false; hasActiveVertex = false; isShowingPath = false; activeVertices = new HashSet <int>(); markedVertices = new Dictionary <int, Color>(); colors = new Colors(); nodes = new Dictionary <int, Node>(); mouseCoords = new MutablePoint(new PointF(0, 0)); bindedLines = new Dictionary <int, Line>(); markedEdges = new List <Tuple <int, int> >(); plot.onMouseMove += onMouseMove; onRewrite(nodes, new GraphEventArgs(graph.get().Keys.ToArray(), new int[0])); render(true); isInited = true; }
Text getTextByLine(Line edge, float offset = 1) { MutablePoint lineCenter = new MutablePoint(() => { PointF result = getCenterOffsetByLine(edge, offset); return(result); //float k = (edge.MutableEnd.value.Y - edge.MutableStart.value.Y) / (edge.MutableEnd.value.X - edge.MutableStart.value.X); //float c = (edge.MutableEnd.value.X * edge.MutableStart.value.Y - edge.MutableStart.value.X * edge.MutableEnd.value.Y) / (edge.MutableEnd.value.X - edge.MutableStart.value.X); //Func<float, float> offsetLineX = (float x) => k * x + c + (orderInPair == 1 ? 0.5f : -0.5f), // offsetLineY = (float y) => (y - c - (orderInPair == 1 ? 0.5f : -0.5f)) / k; //return new PointF((edge.MutableEnd.value.X + edge.MutableStart.value.X) / 2.0f, (offsetLineX(edge.MutableEnd.value.X) + offsetLineX(edge.MutableStart.value.X)) / 2.0f); }); //MutablePoint textPosition = new MutablePoint(lineCenter, () => //{ // return new PointF(orderInPair == 1 ? -0.25f : 0.25f, 0.5f); //}); Text text = new Text(weight, lineCenter, 0.5f, Color); return(text); }
public ShapeSceneObject(string name, MutablePoint positionPoint, MutableSize size, Scene parent = null) : base(name, positionPoint, size, parent) { }
public AnimatedSceneObject(string name, MutablePoint positionPoint, MutableSize size, Animation.Animation animation, Scene parent = null) : base(name, positionPoint, size, parent) { Animation = animation; Animation.Start(); // TODO ??? }
protected SceneObject() { Name = GetType().Name; PositionPoint = new MutablePoint(0, 0); Size = new MutableSize(10, 10); }
private static void MutateAndDisplay(MutablePoint p) { p.X = 100; Console.WriteLine($"Point mutated in a methodo: {p}"); }
public AnimatedSceneObject(string name, MutablePoint positionPoint, MutableSize size, string animName, Scene parent = null) : this(name, positionPoint, size, AnimationManager.Instance.GetAnimationByName(animName), parent) { }