示例#1
0
 private void canvas_MouseUp(object sender, MouseEventArgs e)
 {
     isMouseDown = false;
     if (endClickDot == null)
     {
         startClickDot = null;
     }
     else if (startClickDot != null && endClickDot != null)
     {
         model.AddNewLine((Point)startClickDot, (Point)endClickDot);
         startClickDot = null;
         endClickDot   = null;
     }
 }
示例#2
0
        public void HandleSecondDotClicked(object o)
        {
            //Start must precede
            if (startClickDot == null)
            {
                return;
            }

            var values = (int[])o;
            int Row    = values[0];
            int Col    = values[1];

            //Toggle on
            if (IsValidEndPoint(Row, Col))
            {
                endClickDot = Shapes.Dots[FieldSize * Row + Col];
                model.AddNewLine(new Tuple <Point, Point>(new Point(startClickDot.Row, startClickDot.Col)
                                                          , new Point(endClickDot.Row, endClickDot.Col)));

                startClickDot.IsSelected = false;
                startClickDot            = null;
                endClickDot = null;
            }
        }
示例#3
0
        public void TestAddLineValid()
        {
            model.Restart();

            //Add Valid Lines
            model.AddNewLine(new Point(0, 0), new Point(0, 1)); // Horizontal | Left  -> Right
            model.AddNewLine(new Point(1, 1), new Point(1, 0)); // Horizontal | Right -> Left
            model.AddNewLine(new Point(1, 0), new Point(2, 0)); // Vertical   | Top   -> Bottom
            model.AddNewLine(new Point(2, 1), new Point(1, 1)); // Vertical   | Bottom -> Top

            //There must be 4 valid lines
            Assert.AreEqual(4, model.Lines.Count);
            Assert.AreEqual(0, model.Rectangles.Count);
            Assert.AreEqual(false, model.GameEnded);

            //Add same lines
            model.AddNewLine(new Point(0, 1), new Point(0, 0)); // line0 flipped - same - no add
            model.AddNewLine(new Point(1, 0), new Point(1, 1)); // line1 flipped - same - no add
            model.AddNewLine(new Point(2, 0), new Point(1, 0)); // line2 flipped - same - no add
            model.AddNewLine(new Point(1, 1), new Point(2, 1)); // line3 flipped - same - no add

            //There must be 4 valid lines
            Assert.AreEqual(4, model.Lines.Count);
            Assert.AreEqual(0, model.Rectangles.Count);
            Assert.AreEqual(false, model.GameEnded);
        }