Example #1
0
        /// <summary>
        /// Ustaw książkę, ukryj pierszą kolumnę
        /// (będzie ona służyła tylko do rozpoznawania statusów w kodzie,
        /// w interfejsie status będzie rozróżniany poprzez kolory)
        /// </summary>
        /// <param name="bookList"></param>
        public void SetBook(List <User> bookList)
        {
            if (ListViewAddressBook.InvokeRequired)
            {
                SetUsersCallBack f = new SetUsersCallBack(SetBook);
                Invoke(f, new object[] { bookList });
            }
            else
            {
                ListViewAddressBook.View = View.Details;


                int       itemHeight = 20;
                ImageList imgList    = new ImageList();
                imgList.ImageSize = new Size(1, itemHeight);

                ListViewAddressBook.SmallImageList = imgList;

                foreach (var item in bookList)
                {
                    ListViewItem listViewItem = new ListViewItem(new string[] { item.UserState.ToString(), item.UserName, item.UserDesc });
                    ListViewAddressBook.Items.Add(listViewItem);
                }

                ListViewAddressBook.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                ListViewAddressBook.Columns[0].Width = 0;
            }
        }
Example #2
0
        /// <summary>
        /// Edytuj książkę po otrzymaniu zmian, sortuj kontakty od dostępnego
        /// </summary>
        /// <param name="bookList"></param>
        private void EditBook(List <User> bookList)
        {
            if (ListViewAddressBook.InvokeRequired)
            {
                SetUsersCallBack f = new SetUsersCallBack(EditBook);
                this.Invoke(f, new object[] { bookList });
            }
            else
            {
                foreach (ListViewItem lvi in ListViewAddressBook.Items)
                {
                    foreach (var item in bookList)
                    {
                        if (lvi.SubItems[1].Text == item.UserName)
                        {
                            if (item.UserState != Status.UNKNOWN)
                            {
                                int stateIndex = (int)item.UserState;
                                lvi.SubItems[0].Text = stateIndex.ToString();
                                //SetText("Użytkownik " + item.UserName + " zaktualizował swój status!");

                                PopUpTimer.Enabled = true;
                                Console.WriteLine(stateIndex.ToString());
                                popUpForm.labelWho.Text  = item.UserName;
                                popUpForm.labelWhat.Text = "Użytkownik zaktualizował swój status!";
                                popUpForm.ShowDialog();

                                ListViewAddressBook.Sort();
                            }
                            if (item.UserDesc != null && item.UserDesc != "")
                            {
                                lvi.SubItems[2].Text = item.UserDesc;
                                //SetText("Użytkownik " + item.UserName + " zaktualizował swój opis!");

                                PopUpTimer.Enabled       = true;
                                popUpForm.labelWho.Text  = item.UserName;
                                popUpForm.labelWhat.Text = "Użytkownik zaktualizował swój opis!";
                                popUpForm.ShowDialog();
                            }
                        }
                    }
                }
            }
        }