Пример #1
0
		protected virtual void OnTransactionAdd4(TransactionAddState state, InputDialogGump ui)
		{
			double value;

			if (String.IsNullOrWhiteSpace(ui.InputText) || !Double.TryParse(ui.InputText, out value))
			{
				User.SendMessage(0x22, "Value '{0}' is not valid.", ui.InputText);
				ui.Refresh();
				return;
			}

			state.Value = value;

			OnTransactionAdd(state);
		}
Пример #2
0
		protected virtual void OnTransactionAdd3(TransactionAddState state, InputDialogGump ui)
		{
			if (String.IsNullOrWhiteSpace(ui.InputText) || AutoDonate.Transactions.ContainsKey(ui.InputText))
			{
				User.SendMessage(0x22, "Transaction ID '{0}' is not valid.", ui.InputText);
				ui.Refresh();
				return;
			}

			state.ID = ui.InputText.Trim();

			OnTransactionAdd4(state);
		}
Пример #3
0
		protected virtual void OnTransactionAdd1(TransactionAddState state, InputDialogGump ui)
		{
			IAccount acc;

			if (String.IsNullOrWhiteSpace(ui.InputText) || (acc = Accounts.GetAccount(ui.InputText)) == null)
			{
				User.SendMessage(0x22, "Account '{0}' could not be found.", ui.InputText);
				ui.Refresh();
				return;
			}

			state.Account = acc;
			state.Email = acc.Email;

			OnTransactionAdd2(state);
		}
Пример #4
0
		protected virtual void OnTransactionAdd2(TransactionAddState state, InputDialogGump ui)
		{
			if (String.IsNullOrWhiteSpace(ui.InputText) || ui.InputText.Count(c => c == '@') != 1 ||
				ui.InputText.LastIndexOf('.') < ui.InputText.LastIndexOf('@') ||
				ui.InputText.Any(c => c != '.' && c != '@' && c != '-' && c != '_' && !Char.IsLetterOrDigit(c)))
			{
				User.SendMessage(0x22, "Email '{0}' is not valid.", ui.InputText);
				ui.Refresh();
				return;
			}

			state.Email = ui.InputText.Trim();

			OnTransactionAdd3(state);
		}
Пример #5
0
        protected virtual void OnTransactionImport()
        {
            var input = new InputDialogGump(User, Hide())
            {
                Title = "Import Transactions",
                Html = "Import transactions from a file.\n\n" + //
                       "File Formats: \n*.json\n\n" + //
                       "Root Directory: " + Core.BaseDirectory
            };

            input.AcceptHandler = b =>
            {
                input.InputText = IOUtility.GetSafeFilePath(input.InputText, true);

                var path = Path.Combine(Core.BaseDirectory, input.InputText);

                if (!Insensitive.EndsWith(path, ".json"))
                {
                    input.InputText = String.Empty;
                    input.User.SendMessage("File not supported: {0}", path);
                    input.Refresh(true);
                    return;
                }

                if (!File.Exists(path))
                {
                    input.InputText = String.Empty;
                    input.User.SendMessage("File not found: {0}", path);
                    input.Refresh(true);
                    return;
                }

                OnTransactionImport(new FileInfo(path));
            };

            input.CancelHandler = Refresh;

            input.Send();
        }