コード例 #1
0
        private async void Initialize()
        {
            Accounts = new MyObservableList <AccountDataItem>(await AccountsManager.GetAllAccounts());

            // TODO: What if RememberUsername is edited? That's quite a minor case, not worth building something for, but it's potentially a flaw
            AccountsWithRememberUsername = Accounts.Sublist(i => i.RememberUsername && !i.IsDefaultOfflineAccount);

            AccountsManager.OnAccountDeleted += new WeakEventHandler <Guid>(AccountsManager_OnAccountDeleted).Handler;

            var lastLoginLocalId = AccountsManager.GetLastLoginLocalId();

            if (lastLoginLocalId != Guid.Empty)
            {
                var lastLogin = Accounts.FirstOrDefault(i => i.LocalAccountId == lastLoginLocalId);

                if (lastLogin != null && lastLogin.RememberUsername && !lastLogin.IsDefaultOfflineAccount)
                {
                    Username = lastLogin.Username;
                }
            }
        }