Example #1
0
        private void UpdateListViewContact()
        {
            if (!Application.Current.Dispatcher.CheckAccess())
            {
                Application.Current.Dispatcher.BeginInvoke(
                  DispatcherPriority.Background,
                  new Action(UpdateListViewContact));
                return;
            }
            listview_contacts.Items.Clear();
            int size = listContact.Count();
            ContactDB contact;
            listContactItem.Clear();

            for (int i = 0; i < size; i++)
            {
                contact = listContact[i];
                string email = contact.ListEmail.Count() > 0 ? contact.ListEmail[0].Value : "";
                string fax = contact.ListFax.Count() > 0 ? contact.ListFax[0].Value : "";

                ListViewContactItem item = new ListViewContactItem();
                item.Id = contact.Id;
                item.Index = i;
                item.Name = contact.Name;
                item.EmailAddress = email;
                item.Fax = fax;
                item.ImportedFrom = contact.AccountName;

                listContactItem.Add(item);
                listview_contacts.Items.Add(item);
            }
            ReSortingContactList();

            layout_loading.Visibility = Visibility.Collapsed;
            allowAction = true;
        }
        private void UpdateListViewContact()
        {
            if (!Application.Current.Dispatcher.CheckAccess())
            {
                Application.Current.Dispatcher.BeginInvoke(
                  DispatcherPriority.Background,
                  new Action(UpdateListViewContact));
                return;
            }
            isAllCheck = false;

            listview_contacts.Items.Clear();
            listItem.Clear();
            if (currentMode == MODE_LOCAL_CONTACT || currentMode == MODE_PRINTER_CONTACT)
            {
                int size = listContact.Count();

                ContactDB contact;
                for (int i = 0; i < size; i++)
                {
                    contact = listContact[i];
                    string email = contact.ListEmail.Count() > 0 ? contact.ListEmail[0].Value : "";
                    string fax = contact.ListFax.Count() > 0 ? contact.ListFax[0].Value : "";
                    string account = contact.AccountName;

                    ListViewContactItem item = new ListViewContactItem();
                    item.IsCheck = isAllCheck;
                    item.Index = i;
                    item.Id = contact.Id;
                    item.Name = contact.Name;
                    item.EmailAddress = email;
                    item.Fax = fax;
                    item.ImportedFrom = account;

                    listItem.Add(item);
                    listview_contacts.Items.Add(item);
                }
            }
            else if (currentMode == MODE_PRINTER_GROUP_CONTACT && listDisplayContact != null)
            {
                int size = listDisplayContact.Count();
                Object contactObj;
                for (int i = 0; i < size; i++)
                {
                    contactObj = listDisplayContact[i];
                    int id = -1;
                    string name = "";
                    string email = "";
                    string fax = "";
                    string account = "";

                    if (contactObj is ContactDB)
                    {
                        ContactDB contactDB = ((ContactDB)contactObj);
                        id = contactDB.Id;
                        name = contactDB.Name;
                        email = contactDB.ListEmail.Count() > 0 ? contactDB.ListEmail[0].Value : "";
                        fax = contactDB.ListFax.Count() > 0 ? contactDB.ListFax[0].Value : "";
                        account = contactDB.AccountName;
                    }
                    else if (contactObj is ContactPrinter)
                    {
                        ContactPrinter contactPrinter = ((ContactPrinter)contactObj);
                        id = contactPrinter.Id;
                        name = contactPrinter.Name;
                        email = contactPrinter.Email;
                        fax = contactPrinter.Fax;
                        account = contactPrinter.FromPrinter.Name;
                    }
                    ListViewContactItem item = new ListViewContactItem();

                    item.IsCheck = isAllCheck;
                    item.Index = i;
                    item.Id = id;
                    item.Name = name;
                    item.EmailAddress = email;
                    item.Fax = fax;
                    item.ImportedFrom = account;
                    
                    listItem.Add(item);
                    listview_contacts.Items.Add(item);
                }
            }
            ReSorting();

            layout_loading.Visibility = Visibility.Collapsed;
            allowAction = true;
        }
        private async void UpdateListView()
        {
            var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // update on ui thread
                listview_contacts.Items.Clear();
                myItemsList.Clear();
                int size = listContact.Count();
                ContactDB contact;
                ListViewContactItem item;
                for (int i = 0; i < size; i++)
                {
                    contact = listContact[i];
                    int id = contact.Id;
                    string name = contact.Name;
                    string email = contact.ListEmail.Count() > 0 ? contact.ListEmail[0].Value : "";
                    string fax = contact.ListFax.Count() > 0 ? contact.ListFax[0].Value : "";
                    string groupName = contact.GroupName;
                    string accountName = contact.AccountName;

                    item = new ListViewContactItem();
                    item.IsCheck = isAllCheck;
                    item.Index = i;

                    // add data
                    item.Id = id;
                    item.Name = name;
                    item.EmailAddress = email;
                    item.Fax = fax;
                    item.Group = groupName;
                    item.ImportedFrom = accountName;

                    myItemsList.Add(item);

                    listview_contacts.Items.Add(item);
                }
                layout_loading.Visibility = Visibility.Collapsed;
                allowAction = true;
            });
        }
        private void UpdateListViewContact()
        {
            if (!Application.Current.Dispatcher.CheckAccess())
            {
                Application.Current.Dispatcher.BeginInvoke(
                  DispatcherPriority.Background,
                  new Action(UpdateListViewContact));
                return;
            }

            listview_contacts.Items.Clear();
            listContactItem.Clear();
            listDisplayContact = GetContactListByGroupName(selectedGroup.GroupName);
            int size = listDisplayContact.Count();
            Object contactObj;
            ContactDB contactDB;
            ContactPrinter contactPrinter;

            for (int i = 0; i < size; i++)
            {
                contactObj = listDisplayContact[i];
                int id = -1;
                string name = "";
                string email = "";
                string fax = "";
                string account = "";

                if (contactObj is ContactDB)
                {
                    contactDB = (ContactDB)contactObj;
                    id = contactDB.Id;
                    name = contactDB.Name;
                    email = contactDB.ListEmail.Count() > 0 ? contactDB.ListEmail[0].Value : "";
                    fax = contactDB.ListFax.Count() > 0 ? contactDB.ListFax[0].Value : "";
                    account = contactDB.AccountName;
                }
                else if (contactObj is ContactPrinter)
                {
                    contactPrinter = (ContactPrinter)contactObj;
                    id = contactPrinter.Id;
                    name = contactPrinter.Name;
                    email = contactPrinter.Email;
                    fax = contactPrinter.Fax;
                    account = contactPrinter.FromPrinter.Name;
                }

                ListViewContactItem item = new ListViewContactItem();
                item.Id = id;
                item.Index = i;
                item.Name = name;
                item.EmailAddress = email;
                item.Fax = fax;
                item.ImportedFrom = account;

                listview_contacts.Items.Add(item);
            }
            ReSortingContactList();

            layout_loading.Visibility = Visibility.Collapsed;
            allowAction = true;
        }
        private void LoadContacts()
        {
            listview_contacts.Items.Clear();
            listItem.Clear();

            ListViewContactItem item;
            int count = controllerAndData.ListData.Count;
            ContactDB contact;

            for(int i = 0; i < count; i++)
            {
                contact = controllerAndData.ListData[i];

                string email = "", fax = "";

                foreach (EmailDB emailDB in contact.ListEmail)
                {
                    if (emailDB.EmailType.IsPreferred)
                    {
                        email = emailDB.Value;
                        break;
                    }
                }

                foreach (FaxDB faxDB in contact.ListFax)
                {
                    if (faxDB.FaxType.IsPreferred)
                    {
                        fax = faxDB.Value;
                        break;
                    }
                }

                item = new ListViewContactItem();
                item.Id = contact.Id;
                item.Index = i;
                item.Name = contact.Name;
                item.EmailAddress = email;
                item.Fax = fax;
                item.ImportedFrom = contact.AccountName;

                listItem.Add(item);
                listview_contacts.Items.Add(item);
            }
        }