Exemple #1
0
 public int? AskInteger(string question, int defaultValue)
 {
     return _engine.Invoke<int?>(() =>
                                     {
                                         var dlg = new InputDlg("Question", question,
                                                                defaultValue.ToString(
                                                                    CultureInfo.InvariantCulture));
                                         int result = dlg.GetPositiveInt();
                                         return dlg.DialogResult.GetValueOrDefault() ? result : (int?) null;
                                     });
 }
Exemple #2
0
 public static int InputInt(string title, string prompt, int n)
 {
     var dlg = new InputDlg(title, prompt, n.ToString(CultureInfo.InvariantCulture));
     return dlg.GetInteger();
 }
Exemple #3
0
        private void StartJoinGame(HostedGameViewModel hostedGame, DataNew.Entities.Game game)
        {
            var client = new Octgn.Site.Api.ApiClient();
            if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
            {
                throw new UserMessageException("The game server is currently down. Please try again later.");
            }
            Log.InfoFormat("Starting to join a game {0} {1}", hostedGame.GameId, hostedGame.Name);
            Program.IsHost = false;
            var password = "";
            if (hostedGame.HasPassword)
            {
                Dispatcher.Invoke(new Action(() =>
                    {
                        var dlg = new InputDlg("Password", "Please enter this games password", "");
                        password = dlg.GetString();
                    }));
            }
            Program.GameEngine = new GameEngine(game, Program.LobbyClient.Me.UserName,password);
            Program.CurrentOnlineGameName = hostedGame.Name;
            IPAddress hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).FirstOrDefault();
            if (hostAddress == null)
            {
                Log.WarnFormat("Dns Error, couldn't resolve {0}", AppConfig.GameServerPath);
                throw new UserMessageException("There was a problem with your DNS. Please try again.");
            }

            try
            {
                Log.InfoFormat("Creating client for {0}:{1}", hostAddress, hostedGame.Port);
                Program.Client = new Client(hostAddress, hostedGame.Port);
                Log.InfoFormat("Connecting client for {0}:{1}", hostAddress, hostedGame.Port);
                Program.Client.Connect();
            }
            catch (Exception e)
            {
                Log.Warn("Start join game error ", e);
                throw new UserMessageException("Could not connect. Please try again.");
            }
        }
Exemple #4
0
        public static int InputInt(string title, string prompt, int n)
        {
            var dlg = new InputDlg(title, prompt, n.ToString(CultureInfo.InvariantCulture));

            return(dlg.GetInteger());
        }
 private void RenameFolderClick(object sender, RoutedEventArgs e)
 {
     if (SelectedList == null) return;
     var id = new InputDlg("Rename Folder", "Please enter a new folder name", "");
     var name = id.GetString();
     if (String.IsNullOrWhiteSpace(name)) return;
     try
     {
         var di = new DirectoryInfo(SelectedList.Path);
         var newPath = Path.Combine(di.Parent.FullName, name);
         Directory.Move(SelectedList.Path, newPath);
         var parent = SelectedList.Parent;
         parent.DeckLists.Remove(SelectedList);
         parent.DeckLists.Add(new DeckList(newPath, this.Dispatcher, parent));
     }
     catch (Exception ex)
     {
         Log.Warn("RenameFolderClick", ex);
         TopMostMessageBox.Show(
             "This folder name is invalid.",
             "Invalid",
             MessageBoxButton.OK,
             MessageBoxImage.Information);
     }
 }
 private void NewFolderClick(object sender, RoutedEventArgs e)
 {
     if (SelectedList == null) return;
     var id = new InputDlg("Create a New Folder", "Please enter a folder name", "");
     var name = id.GetString();
     if (String.IsNullOrWhiteSpace(name)) return;
     try
     {
         var path = Path.Combine(SelectedList.Path, name);
         Directory.CreateDirectory(path);
         SelectedList.DeckLists.Add(new DeckList(path, this.Dispatcher, SelectedList, false));
     }
     catch (Exception ex)
     {
         Log.Warn("NewFolderClick", ex);
         TopMostMessageBox.Show(
             "This folder name is invalid.",
             "Invalid",
             MessageBoxButton.OK,
             MessageBoxImage.Information);
     }
 }