Example #1
0
        private void bEdit_Click(object sender, RoutedEventArgs e)
        {
            if (lbAccounts.SelectedItem != null)
            {
                Account       acc    = (Account)lbAccounts.SelectedItem;
                AccountDialog dialog = new AccountDialog();
                dialog.EditAccount(acc);

                if (dialog.ShowModalDialog())
                {
                    //QSTN: Can this copy be done better?
                    acc.Url      = dialog.Account.Url;
                    acc.UserName = dialog.Account.UserName;
                    acc.Password = dialog.Account.Password;

                    if (dialog.Account.IsDefault)
                    {
                        Account oldDefault = AccountManager.FindCurrentDefault();
                        if (oldDefault != null)
                        {
                            oldDefault.IsDefault = false;
                        }

                        acc.IsDefault = true;
                    }
                }
            }
        }
Example #2
0
        public async void OnAccountItemClick(object sender, ItemClickEventArgs e)
        {
            if (!(e.ClickedItem is AccountListViewItemViewModel selectedAccount))
            {
                return;
            }

            var editOperationDialog = new AccountDialog(new AccountDialogViewModel(selectedAccount.Model))
            {
                PrimaryButtonText = _localizationService.GetTranslateByKey(Localization.Save),
                CloseButtonText   = _localizationService.GetTranslateByKey(Localization.Cancel)
            };

            await editOperationDialog.ShowAsync();

            switch (editOperationDialog.Result)
            {
            case DialogResult.Save:
                await _model.UpdateAccount(selectedAccount.Model, GetCancellationToken());
                await UpdateAccounts();

                break;

            case DialogResult.Delete:
                await _model.DeleteAccount(selectedAccount.Model, GetCancellationToken());
                await UpdateAccounts();

                break;
            }
        }
Example #3
0
        public override void Execute(object parameter)
        {
            var dialog = new AccountDialog();

            if (dialog.ShowDialog().IsTrue())
            {
                AccountManager.AddNewAccount(dialog.Account);
            }
        }
Example #4
0
        private void bNew_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new AccountDialog();

            if (dialog.ShowModalDialog())
            {
                AccountManager.AddNewAccount(dialog.Account);
                lbAccounts.SelectedIndex = lbAccounts.Items.Count - 1;
            }
        }
Example #5
0
        private void createAccountButton_Click(object sender, EventArgs e)
        {
            AccountDialog dialog = new AccountDialog();

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                int  userId  = Accounts.CreateUser(dialog.StoredUsername, dialog.StoredPassword);
                User newUser = AppDatabase.UserTable.GetUserById(userId);

                accountsListView.AddObject(newUser);
                accountsListView.SelectedObject = newUser;
            }
        }
Example #6
0
        public async void OnAddAccountClick(object sender, RoutedEventArgs e)
        {
            var newAccount          = new AccountDialogViewModel(_model.CreateNewAccount());
            var editOperationDialog = new AccountDialog(newAccount)
            {
                PrimaryButtonText = _localizationService.GetTranslateByKey(Localization.Save),
                CloseButtonText   = _localizationService.GetTranslateByKey(Localization.Cancel)
            };

            await editOperationDialog.ShowAsync();

            if (editOperationDialog.Result == DialogResult.Save)
            {
                await _model.SaveAccount(newAccount.Model, GetCancellationToken());
                await UpdateAccounts();
            }
        }
Example #7
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            // Close all maple connections in Players[]

            AccountDialog.Dispose();
            ModifyDialog.Dispose();

            base.Dispose(disposing);

            foreach (Client Player in AccountInfo.Players)
            {
                if (Player != null)
                {
                    Player.MapleConnect.ReceiveLoopThread.Abort();
                }
            }

            System.Windows.Forms.Application.Exit();
        }
Example #8
0
 /// <summary>
 /// EventHandler for buttonAddAccount.Click
 /// Shows AddAccount dialog
 /// </summary>
 private void buttonAddAccount_Click(object sender, EventArgs e)
 {
     AccountDialog.Show();
 }