Exemplo n.º 1
0
            public override void Update(MoveDetails details)
            {
                if (details.relation ==
                    Relation.IamPlayingAndMyMove)
                    board.Sensitive = true;
                else if (details.relation ==
                     Relation.IamPlayingAndMyOppsMove)
                    board.Sensitive = false;

                base.Update (details);
            }
Exemplo n.º 2
0
        public MoveDetailsTest()
        {
            //Arrange
            Mock <IResourceManagerFactory> mockResourceFactory = new Mock <IResourceManagerFactory>();

            mockApiHelper = new Mock <Utility.IAPIHelper>();
            Mock <Utility.Log.ILogger> mockLogger = new Mock <Utility.Log.ILogger>();

            moveDetails = new MoveDetails(mockApiHelper.Object,
                                          mockResourceFactory.Object,
                                          mockLogger.Object);
        }
Exemplo n.º 3
0
    public void GetMoveSoundFXMouseBorder()
    {
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE)
        {
            WallType = Wall.Type.CLOSED,
            Status   = MoveDetails.MoveStatus.ABORTED
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(1, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.BORDER, list[0]);
    }
Exemplo n.º 4
0
    public void GetMoveSoundFXMouseClosed()
    {
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE)
        {
            WallType = Wall.Type.CLOSED,
            Status   = MoveDetails.MoveStatus.FAILURE
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.CLOSED_WALL, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_NOT_PASS, list[1]);
    }
Exemplo n.º 5
0
    public void GetMoveSoundFXRabbitMouseHole()
    {
        MoveDetails moveDetails = new MoveDetails(BLUE_RABBIT)
        {
            WallType = Wall.Type.MOUSE_HOLE,
            Status   = MoveDetails.MoveStatus.FAILURE
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.MOUSE_HOLE, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_NOT_PASS, list[1]);
    }
Exemplo n.º 6
0
    public void GetMoveSoundFXRabbitRabbitHole()
    {
        MoveDetails moveDetails = new MoveDetails(BLUE_RABBIT)
        {
            WallType = Wall.Type.RABBIT_HOLE,
            Status   = MoveDetails.MoveStatus.SUCCESS_KNOWN
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.RABBIT_HOLE, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_PASS, list[1]);
    }
Exemplo n.º 7
0
    public void GetMoveSoundFXMouseOpen()
    {
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE)
        {
            WallType = Wall.Type.OPEN,
            Status   = MoveDetails.MoveStatus.SUCCESS_NEW
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.OPEN_WALL, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_PASS, list[1]);
    }
Exemplo n.º 8
0
    public void GetMoveSoundFXMouseMouseHole()
    {
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE)
        {
            WallType = Wall.Type.MOUSE_HOLE,
            Status   = MoveDetails.MoveStatus.SUCCESS_KNOWN
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetMoveSounds(moveDetails);

        Assert.AreEqual(2, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.MOUSE_HOLE, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.THOU_SHALT_PASS, list[1]);
    }
Exemplo n.º 9
0
            public PlayerPage(ICSGameObserverWidget widget,
					   MoveDetails details)
                : base(widget,
								      details)
            {
                Table table = new Table (5, 2, true);

                  drawButton =
                    new Button (Catalog.
                            GetString ("Draw"));
                  resignButton =
                    new Button (Catalog.
                            GetString ("Resign"));
                  abortButton =
                    new Button (Catalog.
                            GetString ("Abort"));
                  adjournButton =
                    new Button (Catalog.
                            GetString ("Adjourn"));
                  takebackButton =
                    new Button (Catalog.
                            GetString ("Takeback"));

                  drawButton.Clicked += OnClicked;
                  resignButton.Clicked += OnClicked;
                  abortButton.Clicked += OnClicked;
                  adjournButton.Clicked += OnClicked;
                  takebackButton.Clicked += OnClicked;

                uint row = 0, col = 0;
                  table.Attach (drawButton, col, col + 1, row,
                        row + 1);
                  col++;
                  table.Attach (resignButton, col, col + 1,
                        row, row + 1);
                  col = 0;
                  row++;
                  table.Attach (abortButton, col, col + 1,
                        row, row + 1);
                  col++;
                  table.Attach (adjournButton, col, col + 1,
                        row, row + 1);
                  col = 0;
                  row++;
                  table.Attach (takebackButton, col, col + 1,
                        row, row + 1);
                  table.ShowAll ();
                  movesBox.PackEnd (table, false, true, 2);
            }
Exemplo n.º 10
0
    public void MoveThroughBorderDoesNotThrow()
    {
        Board  board        = new Board();
        Player movingPlayer = new Player(
            Player.Animal.MOUSE,
            Player.Color.RED,
            new Position(0, 0)
            );
        MoveDetails moveDetails = new MoveDetails(movingPlayer);

        board.Move(Tile.Direction.WEST, movingPlayer, null, moveDetails);

        Assert.AreEqual(MoveDetails.MoveStatus.ABORTED, moveDetails.Status);
        Assert.AreEqual(false, moveDetails.PlayAgain);
        Assert.AreSame(movingPlayer, moveDetails.Player);
    }
Exemplo n.º 11
0
    public void GetNextPlayerSounds()
    {
        List <Player> players = new List <Player>()
        {
            BLUE_RABBIT, RED_MOUSE
        };
        Game        game        = new Game(players, new Board(), 1);
        MoveDetails moveDetails = new MoveDetails(RED_MOUSE);

        List <SoundMixer.SoundFX> list = SoundMixer.GetNextPlayerSounds(moveDetails, game);

        Assert.AreEqual(3, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.HELLO, list[0]);
        Assert.AreEqual(SoundMixer.SoundFX.BLUE_RABBIT, list[1]);
        Assert.AreEqual(SoundMixer.SoundFX.WHERE_TO_GO, list[2]);
    }
Exemplo n.º 12
0
        public MoveDetailsTest()
        {
            //Arrange
            Mock <JKMServices.BLL.Interface.IResourceManagerFactory> mockBllJKMResource = new Mock <JKMServices.BLL.Interface.IResourceManagerFactory>();

            mockCRMCustomerDetails = new Mock <JKMServices.DAL.CRM.ICustomerDetails>();
            mockCRMMoveDetails     = new Mock <JKMServices.DAL.CRM.IMoveDetails>();
            Mock <Utility.Logger.ILogger> mockLogger = new Mock <Utility.Logger.ILogger>();

            moveDetails = new MoveDetails(
                mockCRMCustomerDetails.Object,
                mockCRMMoveDetails.Object,
                mockBllJKMResource.Object,
                null,
                mockLogger.Object);
        }
Exemplo n.º 13
0
    public void GetNextPlayerSoundsPlayAgain()
    {
        List <Player> players = new List <Player>()
        {
            BLUE_RABBIT, RED_MOUSE
        };
        Game        game        = new Game(players, new Board(), 1);
        MoveDetails moveDetails = new MoveDetails(BLUE_RABBIT)
        {
            PlayAgain = true
        };

        List <SoundMixer.SoundFX> list = SoundMixer.GetNextPlayerSounds(moveDetails, game);

        Assert.AreEqual(1, list.Count);
        Assert.AreEqual(SoundMixer.SoundFX.PLAY_AGAIN, list[0]);
    }
Exemplo n.º 14
0
            public PlayerPage(ICSGameObserverWidget widget,
					   MoveDetails details)
                : base(widget,
								      details)
            {
                HButtonBox box = new HButtonBox ();

                  drawButton =
                    new Button (Catalog.
                            GetString ("Draw"));
                  resignButton =
                    new Button (Catalog.
                            GetString ("Resign"));
                  abortButton =
                    new Button (Catalog.
                            GetString ("Abort"));
                  adjournButton =
                    new Button (Catalog.
                            GetString ("Adjourn"));
                  takebackButton =
                    new Button (Catalog.
                            GetString ("Takeback"));

                  drawButton.Clicked += OnClicked;
                  resignButton.Clicked += OnClicked;
                  abortButton.Clicked += OnClicked;
                  adjournButton.Clicked += OnClicked;
                  takebackButton.Clicked += OnClicked;

                  box.LayoutStyle = ButtonBoxStyle.Start;
                  box.PackStart (drawButton, false, false, 2);
                  box.PackStart (resignButton, false, false,
                         2);
                  box.PackStart (abortButton, false, false,
                         2);
                  box.PackStart (adjournButton, false, false,
                         2);
                  box.PackStart (takebackButton, false, false,
                         2);
                  box.ShowAll ();
                  PackStart (box, false, true, 2);
            }
        private void OnArrowClick(MoveDetails move)
        {
            var inputs = new List <IRLVIOValues>()
            {
                new RLVIOValues()
                {
                    IOName = "Move", Value = move.MoveNumber.ToString()
                }
            };

            var outputs = new List <IRLVIOValues>()
            {
                new RLVIOValues()
                {
                    IOName = "Direction", Value = move.Direction.ToString()
                }
            };

            visualizer.SelectNewItem(inputs, outputs, null);
        }
Exemplo n.º 16
0
 public void SaveMoveDetails(MoveDetails movedetails)
 {
     if (movedetails.MoveID == 0)
     {
         context.MoveDetails.Add(movedetails);
     }
     else
     {
         MoveDetails dbEntry = context.MoveDetails.Find(movedetails.MoveID);
         if (dbEntry != null)
         {
             dbEntry.MoveID      = movedetails.MoveID;
             dbEntry.MoveItemsID = movedetails.MoveItemsID;
             dbEntry.ItemName    = movedetails.ItemName;
             //dbEntry.Quantity = movedetails.Quantity;
             //dbEntry.Rate = movedetails.Rate;
             //dbEntry.TotalAmount = movedetails.TotalAmount;
         }
     }
     context.SaveChanges();
 }
            public void Add(MoveDetails details)
            {
                if (details.movenumber < first_move_number)
                    first_move_number =
                        details.movenumber;

                if (details.WhiteMoved)
                  {
                      WhiteMove (details);
                      return;
                  }

                if (total_rows == 0
                    && details.movenumber == 1)
                    return;
                // just update the value. a row would already have been added
                BlackMove (details);
            }
            protected virtual void InitGameWidget(MoveDetails
							       details)
            {
                board = new CairoViewerBoard (details.pos);
                gameWidget = new ChessGameWidget (board);
            }
            protected virtual void InitGameWidget(MoveDetails
							       details)
            {
                board = new CairoViewerBoard (details.pos);
                board.showAnimations =
                    App.Session.showAnimations;
                gameWidget = new ChessGameWidget (board);
            }
            protected void UpdateTitleLabelForMove(CairoBoard
								board,
								MoveDetails
								details)
            {
                string notation = details.verbose_notation;
                if (notation.Equals ("none"))
                    return;
                if (details.WhiteMoved)
                    resultLabel.Markup =
                        String.
                        Format ("<b>{0}. {1}</b>",
                            details.movenumber,
                            details.
                            pretty_notation);
                else
                    resultLabel.Markup =
                        String.
                        Format ("<b>{0}... {1}</b>",
                            details.movenumber -
                            1,
                            details.
                            pretty_notation);
            }
            public virtual void Update(MoveDetails details)
            {
                lastMove = details;
                UpdateTitleLabelForMove (board, details);
                if (movesWidget.AutoAppend)
                  {
                      SetMoveInfo (board, details);
                      board.SetPosition (details.pos);
                      board.QueueDraw ();
                  }

                int factor =
                    details.inMilliseconds ? 1 : 1000;
                gameWidget.whiteClock.RemainingTime =
                    details.whites_remaining_time *
                    factor;
                gameWidget.blackClock.RemainingTime =
                    details.blacks_remaining_time *
                    factor;
                if (details.whiteToMove)
                  {
                      gameWidget.whiteClock.Start ();
                      gameWidget.blackClock.Stop ();
                  }
                else
                  {
                      gameWidget.whiteClock.Stop ();
                      gameWidget.blackClock.Start ();
                  }
                movesWidget.Add (details);
            }
            public ObservingGamePage(ICSGameObserverWidget
						  widget,
						  MoveDetails details)
                : base()
            {
                this.win = widget;
                gameId = details.gameNumber;

                InitGameWidget (details);

                movesWidget = new ChessMovesWidget ();
                movesWidget.CursorChanged += OnCursorChanged;

                gameWidget.WhiteAtBottom =
                    !details.blackAtBottom;
                board.side = details.blackAtBottom;
                gameWidget.whiteClock.Configure (details.
                                 initial_time
                                 * 60,
                                 (uint)
                                 details.
                                 increment);
                gameWidget.blackClock.Configure (details.
                                 initial_time
                                 * 60,
                                 (uint)
                                 details.
                                 increment);

                white = details.white;
                black = details.black;
                gameWidget.White = white;
                gameWidget.Black = black;

                gameWidget.Show ();
                board.Show ();
                movesWidget.Show ();

                HBox box = new HBox ();
                Button closeButton;
                if (Config.WindowsBuild)
                    closeButton =
                        new Button (Stock.Close);
                else
                  {
                      closeButton = new Button ("");
                      closeButton.Image =
                          new Image (Stock.Close,
                                 IconSize.Menu);
                  }
                resultLabel = new Label ();
                resultLabel.Xalign = 0;
                box.PackStart (resultLabel, true, true, 2);
                box.PackStart (closeButton, false, false, 2);

                PackStart (box, false, true, 2);

                box = new HBox ();
                ScrolledWindow scroll = new ScrolledWindow ();
                scroll.HscrollbarPolicy = PolicyType.Never;
                scroll.VscrollbarPolicy =
                    PolicyType.Automatic;
                scroll.Add (movesWidget);

                VBox movesBox = new VBox ();
                movesBox.PackStart (scroll, true, true, 2);
                AddGameNavigationButtons (movesBox);

                box.PackStart (gameWidget, true, true, 2);
                box.PackStart (movesBox, false, true, 2);
                PackStart (box, true, true, 2);

                closeButton.Clicked += OnCloseButtonClicked;

                Update (details);
                ShowAll ();
            }
            protected void SetMoveInfo(CairoBoard
						    board,
						    MoveDetails details)
            {
                string notation = details.verbose_notation;
                if (notation.Equals ("none"))
                    return;
                char src_rank, src_file, dst_rank, dst_file;
                if (notation.ToLower ().Equals ("o-o"))
                  {
                      src_file = 'e';
                      // Note: whiteToMove indicates that black made the move!
                      src_rank = dst_rank =
                          details.
                          whiteToMove ? '8' : '1';
                      dst_file = 'g';
                  }
                else if (notation.ToLower ().Equals ("o-o-o"))
                  {
                      src_file = 'e';
                      // Note: whiteToMove indicates that black made the move!
                      src_rank = dst_rank =
                          details.
                          whiteToMove ? '8' : '1';
                      dst_file = 'c';
                  }
                else
                  {
                      int idx = notation.IndexOf ('/');
                      idx++;
                      src_file = notation[idx++];
                      src_rank = notation[idx++];
                      idx++;	// skip extra char
                      dst_file = notation[idx++];
                      dst_rank = notation[idx++];
                  }

                board.SetMoveInfo (src_rank - '1',
                           src_file - 'a',
                           dst_rank - '1',
                           dst_file - 'a');
            }
Exemplo n.º 24
0
            // <12> r-r---k- ---nqpp- --p-pnp- b-Pp---- ---P-P-- --N-P-P- --QB--BP RR----K- B -1 0 0 0 0 4 134 GMPopov GMAkopian 0 120 0 34 34 3060 352 19 R/f1-b1 (14:29) Rfb1 0 0 0
            public static MoveDetails FromBuffer(byte[]buffer,
							      int start,
							      int end)
            {
                MoveDetails details = new MoveDetails (new ArrayList());

                // <12> rnbqkb-r pppppppp -----n-- -------- ---P---- -------- PPP-PPPP RNBQKBNR
                for (int i = 0; i < 8; i++)
                  {
                      ParserUtils.SkipWhitespace (buffer,
                                      ref
                                      start,
                                      end);
                      StringBuilder buf =
                          new StringBuilder ();
                      for (int j = 0; j < 8; j++)
                        {
                            char ch =
                                (char)
                                buffer[start++];
                            if (ch == '-')
                                ch = '.';
                            buf.Append (ch);
                            if(j != 7)
                                buf.Append (' ');
                        }
                      details.pos.Add (buf.ToString ());
                  }

                // W -1 1 1 1 1 1 65 GuestSDSP uvsravikiran
                string token;

                token = ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);
                details.whiteToMove = token[0] == 'W';

                details.doublePushFile =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));

                token = ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);
                details.whiteCanCastleShort = token[0] == '1';
                token = ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);
                details.whiteCanCastleLong = token[0] == '1';

                token = ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);
                details.blackCanCastleShort = token[0] == '1';
                token = ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);
                details.blackCanCastleLong = token[0] == '1';

                details.movesSinceLastIrreversibleMove =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));

                details.gameNumber =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));

                details.white =
                    ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);
                details.black =
                    ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);

                // -1 3 0 39 39 180000 180000 2 N/g8-f6 (0:00.000) Nf6 1 1 0
                details.relation =
                    (Relation) Int32.Parse (ParserUtils.
                                GetNextToken
                                (buffer,
                                 ref start,
                                 end));

                details.initial_time =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));
                details.increment =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));

                details.whites_material_strength =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));
                details.blacks_material_strength =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));

                details.whites_remaining_time =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));
                details.blacks_remaining_time =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));

                details.movenumber =
                    Int32.Parse (ParserUtils.
                             GetNextToken (buffer,
                                   ref start,
                                   end));
                details.verbose_notation =
                    ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);

                token = ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);
                token = token.Substring (1, token.Length - 2);	// strip off the braces

                details.previous_move_time =
                    ParserUtils.ParseMoveTime (token,
                                   out
                                   details.
                                   inMilliseconds);

                details.pretty_notation =
                    ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);

                token = ParserUtils.GetNextToken (buffer,
                                  ref start,
                                  end);
                details.blackAtBottom = token.Length > 0
                    && token[0] == '1';

                details.pos.Insert (0,
                            String.
                            Format
                            ("{0} {1}{2}{3}{4}",
                             details.
                             whiteToMove ? "white" :
                             "black",
                             details.
                             whiteCanCastleShort ? 'K' : ' ',
                             details.
                             whiteCanCastleLong ? 'Q' : ' ',
                             details.
                             blackCanCastleShort ? 'k' : ' ',
                             details.
                             blackCanCastleLong ? 'q' : ' '));
                details.pos.Insert (0, "");

                return details;
            }
        private void SetAllMoves()
        {
            if (lvMoves.Children.Count == 0)
            {
                this.allMoves = new List <MoveDetails>();
                for (int a = 0; a < this.maxMoves; a++)
                {
                    allMoves.Add(new MoveDetails {
                        MoveNumber = a + 1
                    });
                }

                foreach (MoveDetails mv in allMoves)
                {
                    StackPanel pnl = new StackPanel();
                    pnl.Orientation = Orientation.Horizontal;

                    TextBlock txt = new TextBlock();
                    txt.HorizontalAlignment = HorizontalAlignment.Left;
                    txt.TextWrapping        = TextWrapping.Wrap;
                    txt.Text = mv.MoveNumber.ToString();
                    txt.VerticalAlignment = VerticalAlignment.Top;

                    var upMove = new MoveDetails()
                    {
                        MoveNumber = mv.MoveNumber, Direction = 0
                    };
                    Rectangle up = new Rectangle();
                    up.Width  = 20;
                    up.Height = 20;
                    up.Margin = new Thickness(20, 0, 0, 5);
                    up.Fill   = new ImageBrush {
                        ImageSource = new BitmapImage(new Uri(System.IO.Path.Combine("Images", "arrow-up.png"), UriKind.Relative))
                    };
                    up.HorizontalAlignment = HorizontalAlignment.Stretch;
                    up.VerticalAlignment   = VerticalAlignment.Top;
                    up.Stretch             = Stretch.Uniform;
                    up.Cursor      = Cursors.Hand;
                    up.MouseEnter += Dir_MouseEnter;
                    up.MouseLeave += Dir_MouseLeave;
                    up.InputBindings.Add(new MouseBinding()
                    {
                        Gesture = new MouseGesture(MouseAction.LeftClick),
                        Command = new ItemClickedCommand(() =>
                        {
                            OnArrowClick(upMove);
                        })
                    });

                    var rightMove = new MoveDetails()
                    {
                        MoveNumber = mv.MoveNumber, Direction = 1
                    };
                    Rectangle right = new Rectangle();
                    right.Width  = 20;
                    right.Height = 20;
                    right.Margin = new Thickness(20, 0, 0, 5);
                    right.Fill   = new ImageBrush {
                        ImageSource = new BitmapImage(new Uri(System.IO.Path.Combine("Images", "arrow-right.png"), UriKind.Relative))
                    };
                    right.HorizontalAlignment = HorizontalAlignment.Stretch;
                    right.VerticalAlignment   = VerticalAlignment.Top;
                    right.Stretch             = Stretch.Uniform;
                    right.Cursor      = Cursors.Hand;
                    right.MouseEnter += Dir_MouseEnter;
                    right.MouseLeave += Dir_MouseLeave;
                    right.InputBindings.Add(new MouseBinding()
                    {
                        Gesture = new MouseGesture(MouseAction.LeftClick),
                        Command = new ItemClickedCommand(() =>
                        {
                            OnArrowClick(rightMove);
                        })
                    });

                    var downMove = new MoveDetails()
                    {
                        MoveNumber = mv.MoveNumber, Direction = 2
                    };
                    Rectangle down = new Rectangle();
                    down.Width  = 20;
                    down.Height = 20;
                    down.Margin = new Thickness(20, 0, 0, 5);
                    down.Fill   = new ImageBrush {
                        ImageSource = new BitmapImage(new Uri(System.IO.Path.Combine("Images", "arrow-down.png"), UriKind.Relative))
                    };
                    down.HorizontalAlignment = HorizontalAlignment.Stretch;
                    down.VerticalAlignment   = VerticalAlignment.Top;
                    down.Stretch             = Stretch.Uniform;
                    down.Cursor      = Cursors.Hand;
                    down.MouseEnter += Dir_MouseEnter;
                    down.MouseLeave += Dir_MouseLeave;
                    down.InputBindings.Add(new MouseBinding()
                    {
                        Gesture = new MouseGesture(MouseAction.LeftClick),
                        Command = new ItemClickedCommand(() =>
                        {
                            OnArrowClick(downMove);
                        })
                    });

                    var leftMove = new MoveDetails()
                    {
                        MoveNumber = mv.MoveNumber, Direction = 3
                    };
                    Rectangle left = new Rectangle();
                    left.Width  = 20;
                    left.Height = 20;
                    left.Margin = new Thickness(20, 0, 0, 5);
                    left.Fill   = new ImageBrush {
                        ImageSource = new BitmapImage(new Uri(System.IO.Path.Combine("Images", "arrow-left.png"), UriKind.Relative))
                    };
                    left.HorizontalAlignment = HorizontalAlignment.Stretch;
                    left.VerticalAlignment   = VerticalAlignment.Top;
                    left.Stretch             = Stretch.Uniform;
                    left.Cursor      = Cursors.Hand;
                    left.MouseEnter += Dir_MouseEnter;
                    left.MouseLeave += Dir_MouseLeave;
                    left.InputBindings.Add(new MouseBinding()
                    {
                        Gesture = new MouseGesture(MouseAction.LeftClick),
                        Command = new ItemClickedCommand(() =>
                        {
                            OnArrowClick(leftMove);
                        })
                    });

                    pnl.Children.Add(txt);
                    pnl.Children.Add(up);
                    pnl.Children.Add(right);
                    pnl.Children.Add(down);
                    pnl.Children.Add(left);

                    lvMoves.Children.Add(pnl);
                }
            }
        }
Exemplo n.º 26
0
 public MoveMadeEventArgs(MoveDetails details)
 {
     this.details = details;
 }
            private void BlackMove(MoveDetails details)
            {
                TreeIter iter;

                if (total_rows == 0)
                  {
                      store.AppendValues (details.
                                  movenumber - 1,
                                  "*",
                                  GetMove
                                  (details), null,
                                  details);
                      store.GetIterFirst (out iter);
                      total_rows++;
                      blacksMoveNext = false;
                      if (!autoAppend)
                          return;
                      SetHighlighted (iter, 0,
                              BLACK_MOVE_COL);
                      return;
                  }

                TreePath path;

                if (!FindMoveRow
                    (details.movenumber - 1, out path,
                     out iter))
                    return;

                store.SetValue (iter,
                        BLACK_MOVE_COL,
                        GetMove (details));
                store.SetValue (iter,
                        BLACK_MOVE_DETAILS_COL,
                        details);
                blacksMoveNext = false;
                if (!autoAppend)
                    return;
                SetHighlighted (iter,
                        path.
                        Indices[0], BLACK_MOVE_COL);
            }
            private void WhiteMove(MoveDetails details)
            {
                TreeIter iter;
                TreePath path;
                if (FindMoveRow
                    (details.movenumber, out path, out iter))
                  {
                      store.SetValue (iter,
                              WHITE_MOVE_COL,
                              GetMove (details));
                      store.SetValue (iter,
                              WHITE_MOVE_DETAILS_COL,
                              details);
                  }
                else
                  {
                      iter = store.AppendValues (details.
                                     movenumber,
                                     GetMove
                                     (details),
                                     null,
                                     details,
                                     null);
                      path = new TreePath (new int[]
                                   {
                                   total_rows});
                      total_rows++;
                  }

                blacksMoveNext = true;
                if (!autoAppend)
                    return;
                SetHighlighted (iter, path.Indices[0],
                        WHITE_MOVE_COL);

                ScrollToCell (path,
                          GetColumn (WHITE_MOVE_COL),
                          false, 0, 0);
            }
            private void AddGamePage(MoveDetails details)
            {
                string title = String.Format ("{0} vs {1}",
                                  details.white,
                                  details.black);
                gamesStore.AppendValues (title,	// markup
                             title);

                ObservingGamePage info;
                bool myGame =
                    ObservingGamePage.IsMyGame (details.
                                    relation);
                if (myGame)
                    info = new PlayerPage (this, details);
                else
                    info = new ObservingGamePage (this,
                                      details);

                currentGames[details.gameNumber] = info;

                Label label = new Label (title);
                gamesBook.AppendPage (info, label);
                gamesBook.Page = gamesBook.NPages - 1;
                if (GamePageAddedEvent != null)
                    GamePageAddedEvent (this,
                                new
                                GamePageAddedEventArgs
                                (myGame));
                AdjustCursorForCurrentPage ();
                MovesGetter.GetMovesAsync (client,
                               details.gameNumber,
                               info.OnGetMoves);
            }
            public void Update(MoveDetails details)
            {
                if (!currentGames.
                    ContainsKey (details.gameNumber))
                  {
                      AddGamePage (details);
                      return;
                  }

                ObservingGamePage info = (ObservingGamePage)
                    currentGames[details.gameNumber];
                info.Update (details);
                int num = gamesBook.PageNum (info);
                if (num == gamesBook.CurrentPage)
                    return;

                TreePath path =
                    new TreePath (new int[]{ num });
                TreeIter iter;
                gamesStore.GetIter (out iter, path);
                string text =
                    (string) gamesStore.GetValue (iter,
                                      1);
                string markup =
                    String.Format ("<b>{0}</b>", text);
                gamesStore.SetValue (iter, 0, markup);
            }
Exemplo n.º 31
0
            protected override void InitGameWidget(MoveDetails
								details)
            {
                board = new CairoPlayerBoard (details.pos);
                board.MoveEvent += OnMoveEvent;
                gameWidget = new ChessGameWidget (board);
            }
 private string GetMove(MoveDetails details)
 {
     return details.pretty_notation;
 }
Exemplo n.º 33
0
            private void CreateMoveDetails(int movenum,
							string move)
            {
                string detailed_notation;
                player.Move (move, out detailed_notation);
                MoveDetails details =
                    new MoveDetails (player.
                             GetPosition ());
                details.pretty_notation = move;
                details.movenumber = movenum;
                details.verbose_notation = detailed_notation;
                details.whiteToMove = player.WhiteToMove;
                moves.Add (details);
            }
            private string GetHighlightedMove(MoveDetails
							   details)
            {
                return String.
                    Format
                    ("<span background=\"#f0f0ff\"><b>{0}</b></span>",
                     details.pretty_notation);
            }