public void TestDisconnectWire_SinkTerminalDataSetToNull() { var wire = new WireModel(_outputTerminalMoq.Object, _inputTerminalMoq.Object); wire.DisconnectWire(); _inputTerminalMoq.VerifySet(m => m.Data = null); }
public WireViewModel(WireModel model) { x1 = model.X1; y1 = model.Y1; x2 = model.X2; y2 = model.Y2; }
public void TestDisconnectWire_SinkTerminalDisconnected() { var wire = new WireModel(_outputTerminalMoq.Object, _inputTerminalMoq.Object); wire.DisconnectWire(); _inputTerminalMoq.Verify(m => m.DisconnectWire(wire)); }
public void TestDisableWire_DataPassedThrough() { var wire = new WireModel(_outputTerminalMoq.Object, _inputTerminalMoq.Object); _outputTerminalMoq.Object.Data = 2; wire.DisableWire(); Assert.IsNull(_inputTerminalMoq.Object.Data); }
public void TestEnableWire_DataPassedThrough() { var wire = new WireModel(_outputTerminalMoq.Object, _inputTerminalMoq.Object); _outputTerminalMoq.SetupGet(m => m.Data).Returns(2); wire.EnableWire(); _inputTerminalMoq.VerifySet(m => m.Data = 2); }
/// <summary> /// Removes a wire from the diagram. /// </summary> /// <param name="wireModel"></param> public void RemoveWire(WireModel wireModel) { var wire = Wires.FirstOrDefault(w => w.WireModel == wireModel); if (wire is object) { Wires.Remove(wire); } }
public void TestConstructor_InputIsObject_OverridesRulesAndConnectsTerminals() { var inputTerminalMoq = new Mock <TerminalModel>("", typeof(object), Direction.North, TerminalKind.Input, 0); var outputTerminalMoq = new Mock <TerminalModel>("", typeof(Child), Direction.North, TerminalKind.Output, 0); var wire = new WireModel(outputTerminalMoq.Object, inputTerminalMoq.Object); inputTerminalMoq.Verify(t => t.ConnectWire(wire), Times.Once); outputTerminalMoq.Verify(t => t.ConnectWire(wire), Times.Once); }
public void TestConstructor_InputCanBeCastToOutput_ConnectsTerminals() { var inputTerminalMoq = new Mock <TerminalModel>("", typeof(Parent), Direction.North, TerminalKind.Input, 0); var outputTerminalMoq = new Mock <TerminalModel>("", typeof(Child), Direction.North, TerminalKind.Output, 0); var wire = new WireModel(outputTerminalMoq.Object, inputTerminalMoq.Object); inputTerminalMoq.Verify(t => t.ConnectWire(wire), Times.Once); outputTerminalMoq.Verify(t => t.ConnectWire(wire), Times.Once); }
public void TestConstructor_EndPointSetToSourcePosition() { _outputTerminalMoq.SetupGet(m => m.X).Returns(5); _outputTerminalMoq.SetupGet(m => m.Y).Returns(6); var wire = new WireModel(_outputTerminalMoq.Object, _inputTerminalMoq.Object); Assert.AreEqual(5, wire.X2); Assert.AreEqual(6, wire.Y2); }
public Wire(WireModel wire) { Model = wire ?? throw new ArgumentNullException(nameof(wire)); wire.PropertyChanged += ModelPropertyChanged; wire.WireDataChanged += WireDataChanged; SetWireColor(); X1 = Model.X1; Y1 = Model.Y1; X2 = Model.X2; Y2 = Model.Y2; }
public void CreateWireRenderer(WireModel wireModel) { Wire = wireModel.source.AddComponent <LineRenderer>(); Wire.material = new Material(Shader.Find("Mobile/Particles/Alpha Blended")); Wire.alignment = LineAlignment.TransformZ; Wire.endWidth = wireModel.width; Wire.startWidth = wireModel.width; Wire.startColor = wireModel.color; Wire.endColor = wireModel.color; }
public Form1() { InitializeComponent(); _context = BufferedGraphicsManager.Current; _context.MaximumBuffer = new Size(Width, Height); _buffer = _context.Allocate(CreateGraphics(), new Rectangle(0, 0, Width, Height)); _wireModel = new WireModel(OBJ_PATH, Width, Height); }
public Point[] GetWirePoints(WireModel model, double x1, double y1, double x2, double y2, Direction bannedDirectionForStart, Direction bannedDirectionForEnd) { _wireModel = model; var start = new Point(x1, y1); var end = new Point(x2, y2); var stubStart = TranslatePointInDirection(start, DirectionHelpers.OppositeDirection(bannedDirectionForStart), WireDistanceOutOfTerminal); var stubEnd = TranslatePointInDirection(end, DirectionHelpers.OppositeDirection(bannedDirectionForEnd), WireDistanceOutOfTerminal); if (_wireModel != null) { bannedDirectionForStart = DirectionHelpers.OppositeDirection(_wireModel.SinkTerminal.Direction); bannedDirectionForEnd = DirectionHelpers.OppositeDirection(_wireModel.SourceTerminal.Direction); stubStart = TranslatePointInDirection(start, _wireModel.SinkTerminal.Direction, WireDistanceOutOfTerminal); stubEnd = TranslatePointInDirection(end, _wireModel.SourceTerminal.Direction, WireDistanceOutOfTerminal); } if (StubsAreTooCloseTogether(stubStart, stubEnd)) { return(new Point[] { start, stubStart, stubEnd, end }); } _uTurned = false; var backwardPoints = new List <Point> { end }; WireTwoPoints(stubEnd, stubStart, bannedDirectionForEnd, bannedDirectionForStart, backwardPoints, 2, true); if (_uTurned) { bannedDirectionForEnd = GetBannedDirectionFromPoints(backwardPoints[1], backwardPoints[2]); stubEnd = backwardPoints[2]; } var points = new List <Point> { start }; WireTwoPoints(stubStart, stubEnd, bannedDirectionForStart, bannedDirectionForEnd, points); if (_uTurned) { points.Add(backwardPoints[1]); } points.Add(end); return(points.ToArray()); }
/// <inheritdoc/> public Action Execute(object parameter) { if (parameter is TerminalModel toTerminal) { var wire = new WireModel(); _fromTerminal.ConnectWire(wire, toTerminal); var wireViewModel = new Wire(wire, new WirePathingAlgorithum()) { DoAnimationWhenViewIsLoaded = _animateWireWhenLoaded, }; _diagram.AddWire(wireViewModel); return(() => { _fromTerminal.DisconnectWire(wire, toTerminal); _diagram.RemoveWire(wireViewModel); }); } return(() => { }); }
public void TestConstructor_OutputTerminalSecondArgument_SourceTerminalSetToInputTermina() { var wire = new WireModel(_outputTerminalMoq.Object, _inputTerminalMoq.Object); Assert.AreEqual(_outputTerminalMoq.Object, wire.SourceTerminal); }
public void TestConstructor_InputTerminalFirstArgument_SinkTerminalSetToInputTerminal() { var wire = new WireModel(_inputTerminalMoq.Object, _outputTerminalMoq.Object); Assert.AreEqual(_inputTerminalMoq.Object, wire.SinkTerminal); }
/// <summary> /// Adds a wire to the diagram. /// </summary> /// <param name="wireModel">The wire to add.</param> public void AddWire(WireModel wireModel) { AddWire(new Wire(wireModel, new WirePathingAlgorithum())); }
public void TestConstructor_SetsSinkTerminalConnectedWireToSelf() { var wire = new WireModel(_outputTerminalMoq.Object, _inputTerminalMoq.Object); _inputTerminalMoq.Verify(t => t.ConnectWire(wire)); }