コード例 #1
0
        public void SolveSimpleWires(WirePosition expected, string serialNumber, params WireColor[] wires)
        {
            // Arrange
            var bomb = new Board { SerialNumber = serialNumber };
            var wireTest = new SimpleWires { WireList = wires, Board = bomb };

            // Act
            WirePosition actual = wireTest.GetWireToCut();

            // Assert
            Assert.AreEqual(expected, actual,
                string.Format("Expected: [{0}] in position [{1}], Actual: [{2}] in position [{3}]",
                wires[(int)expected],
                expected,
                wires[(int)actual],
                actual));
        }
コード例 #2
0
        public void SolveSimpleWires(WirePosition expected, string serialNumber, params WireColor[] wires)
        {
            // Arrange
            var bomb = new Board {
                SerialNumber = serialNumber
            };
            var wireTest = new SimpleWires {
                WireList = wires, Board = bomb
            };

            // Act
            WirePosition actual = wireTest.GetWireToCut();

            // Assert
            Assert.AreEqual(expected, actual,
                            string.Format("Expected: [{0}] in position [{1}], Actual: [{2}] in position [{3}]",
                                          wires[(int)expected],
                                          expected,
                                          wires[(int)actual],
                                          actual));
        }
コード例 #3
0
ファイル: NativeRenderer.cs プロジェクト: yazici/Logic.WPF
        public void DrawWire(object dc, IStyle style, XWire wire)
        {
            double thickness = style.Thickness / Zoom;
            double half      = thickness / 2.0;

            var pen = new Pen(
                new SolidColorBrush(
                    Color.FromArgb(
                        (byte)style.Stroke.A,
                        (byte)style.Stroke.R,
                        (byte)style.Stroke.G,
                        (byte)style.Stroke.B)),
                thickness);

            pen.Freeze();

            var position = WirePosition.Calculate(
                wire,
                InvertSize,
                ShortenWire,
                ShortenSize);

            if (wire.InvertStart)
            {
                (dc as DrawingContext).DrawEllipse(
                    null,
                    pen,
                    new Point(
                        position.InvertX1,
                        position.InvertY1),
                    InvertSize,
                    InvertSize);
            }

            if (wire.InvertEnd)
            {
                (dc as DrawingContext).DrawEllipse(
                    null,
                    pen,
                    new Point(
                        position.InvertX2,
                        position.InvertY2),
                    InvertSize,
                    InvertSize);
            }

            var gs = new GuidelineSet(
                new double[] { position.StartX + half, position.StartY + half },
                new double[] { position.EndX + half, position.EndY + half });

            (dc as DrawingContext).PushGuidelineSet(gs);

            (dc as DrawingContext).DrawLine(
                pen,
                new Point(
                    position.StartX,
                    position.StartY),
                new Point(
                    position.EndX,
                    position.EndY));

            (dc as DrawingContext).Pop();
        }