示例#1
0
 private void Setup()
 {
     if (this.Dispatcher.CheckAccess())
     {
         myBoard = new GameBoard();
         myBoard.SetBinding(WidthProperty, "myGrid.Height");
         myBoard.SetBinding(HeightProperty, "myGrid.Height");
         myBoard.Background = ThemeParser.GetColor(ThemeParser.Colors.Board);
         Grid.SetRowSpan(myBoard, 3);
         Grid.SetColumn(myBoard, 0);
         myChat = new ChatComponent();
         myChat.NewOutgoingMessage += new EventHandler <NewOutgoingMessageEventArgs>(Chat_NewOutgoingMessage);
         Grid.SetColumn(myChat, 1);
         Grid.SetRow(myChat, 2);
         myChat.Margin            = new Thickness(5, 0, 0, 0);
         myMenu                   = new MenuFader(myCanvas);
         myMenu.Margin            = new Thickness(25, 0, 25, 0);
         myMenu.HostGameClicked  += new EventHandler <HostGameClickEventArgs>(myMenu_HostGameClicked);
         myMenu.JoinGameClicked  += new EventHandler <JoinGameClickEventArgs>(myMenu_JoinGameClicked);
         myMenu.CloseGameClicked += new EventHandler <CloseGameClickEventArgs>(myMenu_CloseGameClicked);
         myMenu.StartGameClicked += new EventHandler <StartGameClickEventArgs>(myMenu_StartGameClicked);
         myGrid.Children.Add(myBoard);
         myGrid.Children.Add(myChat);
         myCanvas.Children.Add(myMenu);
         myBoard.GameBuilt        += new EventHandler <GameBoardBuiltEventArgs>(myBoard_GameBuilt);
         myBoard.Dice.RollEnded   += new EventHandler <RollEndedEventArgs>(Dice_RollEnded);
         myBoard.Dice.RollStarted += new EventHandler <RollStartedEventArgs>(Dice_RollStarted);
         myBoard.Dice.EndTurn     += new EventHandler <EndTurnEventArgs>(Dice_EndTurn);
         ToggleTurnItems(false);
     }
     else
     {
         this.Dispatcher.BeginInvoke(new Action(Setup), null);
     }
 }
        private void Setup()
        {
            if (this.Dispatcher.CheckAccess())
            {
                myBoard = new GameBoard();
                myBoard.SetBinding(WidthProperty, "myGrid.Height");
                myBoard.SetBinding(HeightProperty, "myGrid.Height");
                myBoard.Background = ThemeParser.GetColor(ThemeParser.Colors.Board);
                Grid.SetRowSpan(myBoard, 3);
                Grid.SetColumn(myBoard, 0);
                myChat = new ChatComponent();
                myChat.NewOutgoingMessage += new EventHandler<NewOutgoingMessageEventArgs>(Chat_NewOutgoingMessage);
                Grid.SetColumn(myChat, 1);
                Grid.SetRow(myChat, 2);
                myChat.Margin = new Thickness(5, 0, 0, 0);
                myMenu = new MenuFader(myCanvas);
                myMenu.Margin = new Thickness(25,0,25,0);
                myMenu.HostGameClicked += new EventHandler<HostGameClickEventArgs>(myMenu_HostGameClicked);
                myMenu.JoinGameClicked += new EventHandler<JoinGameClickEventArgs>(myMenu_JoinGameClicked);
                myMenu.CloseGameClicked += new EventHandler<CloseGameClickEventArgs>(myMenu_CloseGameClicked);
                myMenu.StartGameClicked += new EventHandler<StartGameClickEventArgs>(myMenu_StartGameClicked);
                myGrid.Children.Add(myBoard);
                myGrid.Children.Add(myChat);
                myCanvas.Children.Add(myMenu);
                myBoard.GameBuilt += new EventHandler<GameBoardBuiltEventArgs>(myBoard_GameBuilt);
                myBoard.Dice.RollEnded += new EventHandler<RollEndedEventArgs>(Dice_RollEnded);
                myBoard.Dice.RollStarted += new EventHandler<RollStartedEventArgs>(Dice_RollStarted);
                myBoard.Dice.EndTurn += new EventHandler<EndTurnEventArgs>(Dice_EndTurn);
                ToggleTurnItems(false);

            }
            else this.Dispatcher.BeginInvoke(new Action(Setup), null);
        }