private void Regulator_OnTransition(string state, object data)
        {
            var progress = 0;

            GameThread.InUpdate(() =>
            {
                switch (state)
                {
                case "Idle":
                    if (Callbacks.Count > 0)
                    {
                        ResolveCallbacks(BulletinResponseType.CANCEL);
                    }
                    if (BlockingDialog != null)
                    {
                        UIScreen.RemoveDialog(BlockingDialog);
                        BlockingDialog = null;
                    }
                    break;

                case "ActionInput":
                    //show blocking dialog for this action
                    //not used for bulletin right now
                    var req = ConnectionReg.CurrentRequest;
                    switch (req.Type)
                    {
                    case BulletinRequestType.CAN_POST_MESSAGE:
                    case BulletinRequestType.CAN_POST_SYSTEM_MESSAGE:
                        break;

                    default:
                        //something went terribly wrong - we don't have any dialog to handle this.
                        ConnectionReg.AsyncReset();
                        break;
                    }
                    break;

                case "ActionSuccess":
                    var packet = (BulletinResponse)data;
                    if (packet.Type == BulletinResponseType.SEND_SUCCESS)
                    {
                        CreatedMessage = packet.Messages[0];
                    }
                    else if (packet.Type == BulletinResponseType.MESSAGES)
                    {
                        BulletinBoard = packet.Messages;
                    }
                    ResolveCallbacks(BulletinResponseType.SUCCESS);
                    break;
                }
            });
        }
        private void Regulator_OnTransition(string state, object data)
        {
            var progress = 0;

            GameThread.InUpdate(() =>
            {
                switch (state)
                {
                case "Idle":
                    if (Callbacks.Count > 0)
                    {
                        ResolveCallbacks(NhoodResponseCode.CANCEL);
                    }
                    if (BlockingDialog != null)
                    {
                        UIScreen.RemoveDialog(BlockingDialog);
                        BlockingDialog = null;
                    }
                    break;

                case "ActionInput":
                    //show blocking dialog for this action
                    var req = ConnectionReg.CurrentRequest;
                    switch (req.Type)
                    {
                    case NhoodRequestType.CAN_NOMINATE:
                        //nomination dialog
                        //12 - 16
                        var nomCont    = new UINominationSelectContainer(ConnectionReg.CandidateList);
                        BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions()
                        {
                            Title           = GameFacade.Strings.GetString("f118", "12"),
                            Message         = GameFacade.Strings.GetString("f118", "13", new string[] { "your neighborhood" }),
                            Width           = 440,
                            GenericAddition = nomCont,
                            Buttons         = new UIAlertButton[] {
                                new UIAlertButton(UIAlertButtonType.OK, (btn2) => {
                                    var newReq = nomCont.GetRequest(req);
                                    if (newReq != null)
                                    {
                                        UIAlert.YesNo(
                                            GameFacade.Strings.GetString("f118", "14"),
                                            GameFacade.Strings.GetString("f118", "15", new string[] { nomCont.SelectedCandidate.Name }),
                                            true,
                                            (result) =>
                                        {
                                            if (result)
                                            {
                                                ConnectionReg.MakeRequest(newReq);
                                            }
                                        }
                                            );
                                    }
                                    else
                                    {
                                        //tell user they should select a nominee
                                    }
                                }, GameFacade.Strings.GetString("f118", "20")),
                                new UIAlertButton(UIAlertButtonType.Cancel, (btn2) => {
                                    ConnectionReg.AsyncReset();
                                })
                            }
                        }, false);
                        BlockingDialog.Opacity = 1;
                        break;

                    case NhoodRequestType.CAN_VOTE:
                        //voting dialog
                        BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions()
                        {
                            Title   = GameFacade.Strings.GetString("f118", "2"),
                            Message = GameFacade.Strings.GetString("f118", "3"),
                            Width   = 500,

                            Buttons = UIAlertButton.Ok((btn) =>
                            {
                                GameScreen.RemoveDialog(BlockingDialog);
                                var votingCont     = new UIVoteContainer(ConnectionReg.CandidateList);
                                votingCont.OnVote += (id) =>
                                {
                                    if (id == 0)
                                    {
                                        ConnectionReg.AsyncReset();
                                    }
                                    else
                                    {
                                        UIAlert.YesNo(
                                            GameFacade.Strings.GetString("f118", "9"),
                                            GameFacade.Strings.GetString("f118", "10", new string[] { votingCont.SelectedName }),
                                            true,
                                            (result) =>
                                        {
                                            if (result)
                                            {
                                                ConnectionReg.MakeRequest(votingCont.MakeRequest(req));
                                            }
                                        }
                                            );
                                    }
                                };
                                BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions()
                                {
                                    Title           = GameFacade.Strings.GetString("f118", "4"),
                                    Message         = GameFacade.Strings.GetString("f118", "5"),
                                    Width           = 600,
                                    GenericAddition = votingCont,
                                    Buttons         = new UIAlertButton[0]
                                }, false);

                                votingCont.InjectClose();

                                BlockingDialog.Opacity = 1;
                            })
                        }, true);
                        break;

                    case NhoodRequestType.CAN_RATE:
                        //rating dialog

                        var ratingCont = new UIRatingContainer(true);
                        BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions()
                        {
                            Title           = GameFacade.Strings.GetString("f115", "53"),
                            Message         = GameFacade.Strings.GetString("f115", "54"),
                            Width           = 450,
                            GenericAddition = ratingCont,
                            Buttons         = new UIAlertButton[] {
                                new UIAlertButton(UIAlertButtonType.OK, (btn2) => {
                                    ConnectionReg.MakeRequest(ratingCont.GetRequest(req));
                                }),
                                new UIAlertButton(UIAlertButtonType.Cancel, (btn2) => {
                                    ConnectionReg.AsyncReset();
                                })
                            }
                        }, true);
                        BlockingDialog.Opacity = 1;
                        break;

                    case NhoodRequestType.CAN_RUN:
                        //run dialog
                        var runCont    = new UIRatingContainer(false);
                        BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions()
                        {
                            Title           = GameFacade.Strings.GetString("f118", "17"),
                            Message         = GameFacade.Strings.GetString("f118", "18"),
                            Width           = 450,
                            GenericAddition = runCont,
                            Buttons         = new UIAlertButton[] {
                                new UIAlertButton(UIAlertButtonType.OK, (btn2) => {
                                    ConnectionReg.MakeRequest(runCont.GetRunRequest(req));
                                }),
                                new UIAlertButton(UIAlertButtonType.Cancel, (btn2) => {
                                    ConnectionReg.AsyncReset();
                                })
                            }
                        }, true);

                        BlockingDialog.Opacity = 1;
                        break;

                    default:
                        //something went terribly wrong - we don't have any dialog to handle this.
                        ConnectionReg.AsyncReset();
                        break;
                    }
                    break;

                case "ActionSuccess":
                    LastMessage = ((NhoodResponse)data).Message;
                    ResolveCallbacks(NhoodResponseCode.SUCCESS);
                    break;
                }
            });
        }