Exemple #1
0
    private void setState(States newState)
    {
        //what to do to get ready for state change
        vBox.Remove(statusText);
        statusText.Text = "";
        switch (currentState)
        {
        case States.Main:
            vBox.Remove(scroll);
            menu.Add(main);
            break;

        case States.History:
            vBox.Remove(historyView);
            menu.Add(history);
            break;

        case States.Favorites:
            vBox.Remove(favoritesView);
            menu.Add(favorites);
            break;

        case States.Home:
            vBox.Remove(homeView);
            homeView.setDefaultState();
            menu.Add(home);
            break;
        }

        //what to do to finalise the state change
        switch (newState)
        {
        case States.Main:
            win.Title = response.title;
            vBox.Add(scroll);
            menu.Remove(main);
            vBox.PackStart(statusText, false, false, 0);
            setButtonStates();
            break;

        case States.History:
            win.Title = "History";
            reloadHistory();
            vBox.Add(historyView);
            menu.Remove(history);
            break;

        case States.Favorites:
            win.Title = "Favorites";
            reloadFavorites();
            vBox.Add(favoritesView);
            vBox.PackStart(statusText, false, false, 0);
            menu.Remove(favorites);
            break;

        case States.Home:
            win.Title = "Homepage settings";
            vBox.Add(homeView);
            menu.Remove(home);
            break;
        }
        currentState = newState;
        win.ShowAll();
    }