Ejemplo n.º 1
0
        public static async void RequestChangeLang()
        {
            var dialog = new Epx.Controls.MessageDialog()
            {
                TopTitle            = GoLine2.Properties.Resources.Message,
                Title               = GoLine2.Properties.Resources.ChangeLang,
                Content             = $"{GoLine2.Properties.Resources.ChangeLangTips}\n({Settings.NextLang})",
                PrimaryButtonText   = GoLine2.Properties.Resources.OK,
                SecondaryButtonText = GoLine2.Properties.Resources.Cancel
            };
            var result = await dialog.ShowAsync();

            if (result == Epx.Controls.MessageDialogResult.Fail || result == Epx.Controls.MessageDialogResult.Secondary)
            {
                return;
            }
            //Do if current set to debug mode
            if (Settings.DebugMode)
            {
                var debugdialog = new Epx.Controls.MessageDialog()
                {
                    TopTitle            = GoLine2.Properties.Resources.Message,
                    Title               = GoLine2.Properties.Resources.DebugMode,
                    Content             = GoLine2.Properties.Resources.DebugExplain,
                    PrimaryButtonText   = GoLine2.Properties.Resources.OK,
                    SecondaryButtonText = GoLine2.Properties.Resources.Cancel
                };
                await debugdialog.ShowAsync();
            }
            string tips = string.Empty;

            if (Settings.NewestLang == "zh-CN")
            {
                Settings.NewestLang = "en-US";
                Settings.NextLang   = "中文";
            }
            else
            {
                Settings.NewestLang = "zh-CN";
                Settings.NextLang   = "English";
            }
            Settings.Save();
            if (Settings.NewestLang != Settings.UsingLang)
            {
                App.Restart();
            }
        }
Ejemplo n.º 2
0
        private async void OnModeSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //Check the selected item, when the selector initilize,
            //there will raise a selection changed will not selected
            if (e.AddedItems.Count < 1)
            {
                return;
            }
            var selectedItem = e.AddedItems[0];

            if (selectedItem == null)
            {
                return;
            }
            //Get selected mode
            var selectedMode = selectedItem as SelectionItem <GameMode>;

            ////Ask for login when game mode is the type will record score
            //Online mode is in testing, so refuse to enter online mode.
            if (selectedMode.Value == GameMode.PvPOnline)
            {
                /*ModeList.SelectedIndex = -1;
                 * var dialog = new Epx.Controls.MessageDialog()
                 * {
                 *  TopTitle = Properties.Resources.Message,
                 *  Title = Properties.Resources.Tips,
                 *  Content = Properties.Resources.TestingTips,
                 *  PrimaryButtonText = Properties.Resources.OK,
                 *  SecondaryButtonText = Properties.Resources.Cancel
                 * };
                 * await dialog.ShowAsync();
                 * return;*/
            }
            if (selectedMode.Value == GameMode.PvPOnline && App.LoginedAccount == null)
            {
                //Show dialog
                var dialog = new Epx.Controls.MessageDialog()
                {
                    TopTitle            = Properties.Resources.Message,
                    Title               = Properties.Resources.RequireLogin,
                    Content             = Properties.Resources.LoginRequestTips,
                    PrimaryButtonText   = Properties.Resources.Login,
                    SecondaryButtonText = Properties.Resources.Guest
                };
                var result = await dialog.ShowAsync();

                //If user select to login
                if (result == Epx.Controls.MessageDialogResult.Primary)
                {
                    //Register eventhandler to navigate to game page for login successful
                    //Navigate to user page
                    var          userpage = new UserPage();
                    EventHandler handler  = null;
                    handler = (obj, args) =>
                    {
                        userpage.LoginSuccessed -= handler;
                        NavigateGamePage(selectedMode.Value);
                    };
                    userpage.LoginSuccessed += handler;
                    MainWindow.FlyoutNavigateServices.Navigate(userpage);
                    ModeList.SelectedIndex = -1;
                }
                else if (result == Epx.Controls.MessageDialogResult.Secondary)
                {
                    //If user select to guest
                    //Go to the game page
                    //Game page will create guest account if there is no logined account
                    NavigateGamePage(selectedMode.Value);
                }
                else
                {
                    ModeList.SelectedIndex = -1;
                }
            }
            else
            {
                //When game mode is not the type will record score
                //Go to game page
                NavigateGamePage(selectedMode.Value);
            }
        }