public void SetAccViewDataStore()
        {
            var accs = LocalContext.GetAllAccounts().Select(acc => new AccountGridItem(acc, this));

            filteredCollection     = new SelectableFilterCollection <AccountGridItem>(AccountsView, accs);
            AccountsView.DataStore = filteredCollection;
        }
Esempio n. 2
0
        public override void AddedToDocument(GH_Document document)
        {
            base.AddedToDocument(document);

            ExpireComponent = () => this.ExpireSolution(true);

            Accounts = LocalContext.GetAllAccounts();
        }
        private void LoadAccounts()
        {
            accounts = new ObservableCollection <Account>(LocalContext.GetAllAccounts());
            AccountListBox.ItemsSource = accounts;

            if (accounts.Any(x => x.IsDefault))
            {
                int index = accounts.Select((v, i) => new { acc = v, index = i }).First(x => x.acc.IsDefault).index;
                AccountListBox.SelectedIndex = index;
            }
        }
Esempio n. 4
0
        private void LoadAccounts()
        {
            var acc = LocalContext.GetAllAccounts();

            accounts.Clear();
            foreach (var a in acc)
            {
                accounts.Add(a);
            }

            if (accounts.Any(x => x.IsDefault))
            {
                int index = accounts.Select((v, i) => new { acc = v, index = i }).First(x => x.acc.IsDefault).index;
                defaultAccountBox.SelectedIndex = index;
            }
        }
Esempio n. 5
0
        public void SaveOrUpdateAccount(Account newAccount)
        {
            var existingAccounts = LocalContext.GetAllAccounts();
            var newUri           = new Uri(newAccount.RestApi);

            var serverName = GetServerName(newUri);

            foreach (var acc in existingAccounts)
            {
                var eUri = new Uri(acc.RestApi);
                if ((eUri.Host == newUri.Host) && (acc.Email == newAccount.Email) && (eUri.Port == newUri.Port))
                {
                    acc.ServerName = serverName;
                    acc.Token      = newAccount.Token;
                    LocalContext.RemoveAccount(acc); // TODO: Add update account method, as this is rather stupid
                    LocalContext.AddAccount(acc);
                    return;
                }
            }
            newAccount.ServerName = serverName;
            LocalContext.AddAccount(newAccount);
        }