Example #1
0
        private void FavDial()
        {
            FavoriteItem favItem = GetSelectedFavItem();

            if (favItem == null)
            {
                return;
            }
            _favoritesManager.FavListDial(favItem);
            Close();
        }
Example #2
0
        private void FavDeleteBtn_Click(object sender, System.EventArgs e)
        {
            FavoriteItem favItem = GetSelectedFavItem();

            if (favItem == null)
            {
                return;
            }

            _favoritesManager.DelFavorite(favItem.Number);
            _favListUpdate = true;
            _favoritesManager.FavListSave();
        }
Example #3
0
        private void HistDial()
        {
            if (CallHistoryList.SelectedRows.Count == 0)
            {
                return;
            }

            DataGridViewRow row     = CallHistoryList.SelectedRows[0];
            FavoriteItem    favItem = new FavoriteItem()
            {
                Number = FavListGetString(row.Cells[HISTLIST_NUMBER].Value),
                Name   = FavListGetString(row.Cells[HISTLIST_NAME].Value),
            };

            _favoritesManager.FavListDial(favItem);
            Close();
        }
Example #4
0
        private List <FavoriteItem> FavListGet(bool onlyValid)
        {
            List <FavoriteItem> favList = new List <FavoriteItem>();

            foreach (DataGridViewRow row in FavList.Rows)
            {
                FavoriteItem favItem = new FavoriteItem()
                {
                    Number     = FavListGetNumber(row.Cells[FAVLIST_NUMBER].Value),
                    Name       = FavListGetString(row.Cells[FAVLIST_NAME].Value),
                    Address    = FavListGetString(row.Cells[FAVLIST_ADDRESS].Value),
                    Port       = FavListGetInt(row.Cells[FAVLIST_PORT].Value),
                    DirectDial = FavListGetInt(row.Cells[FAVLIST_DIRECTDIAL].Value),
                };
                //Debug.WriteLine(favItem);
                if ((!onlyValid || favItem.IsValid) && !favItem.IsEmpty)
                {
                    favList.Add(favItem);
                }
            }
            return(favList);
        }
 public void FavListDial(FavoriteItem favItem)
 {
     //Debug.WriteLine($"Dial {favItem}");
     DialFavorite?.Invoke(favItem);
 }
Example #6
0
 public bool IsEqual(FavoriteItem item)
 {
     return(item.Number == Number && item.Name == Name && item.Address == Address && item.Port == Port && item.DirectDial == DirectDial);
 }
Example #7
0
        private void FavListShow()
        {
            int scrollPos     = FavList.FirstDisplayedScrollingRowIndex;
            int?selectedIndex = null;

            for (int i = 0; i < FavList.Rows.Count; i++)
            {
                if (FavList.Rows[i].Selected)
                {
                    selectedIndex = i;
                    break;
                }
            }

            FavList.SuspendLayout();

            List <FavoriteItem> favList = _favoritesManager.Favorites;

            if (_favListSortColumnIndex.HasValue)
            {
                favList.Sort(new FavoritesItemSorter(_favListSortColumnIndex.Value, _favListSortColumnAscend));
            }

            List <DataGridViewRow> rows = new List <DataGridViewRow>();

            for (int favIdx = 0; favIdx < favList.Count; favIdx++)
            {
                FavoriteItem favItem = favList[favIdx];
                if (favItem.IsEmpty)
                {
                    continue;
                }

                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(FavList);
                row.Cells[FAVLIST_INDEX].Value      = (favIdx + 1).ToString();
                row.Cells[FAVLIST_NUMBER].Value     = favItem.Number;
                row.Cells[FAVLIST_NAME].Value       = favItem.Name;
                row.Cells[FAVLIST_ADDRESS].Value    = favItem.Address;
                row.Cells[FAVLIST_PORT].Value       = favItem.Port > 0 ? favItem.Port.ToString() : "";
                row.Cells[FAVLIST_DIRECTDIAL].Value = favItem.DirectDial > 0 ? favItem.DirectDial.ToString() : "";

                /*
                 * var btnCell = (row.Cells[FAVLIST_DIALBTN] as DataGridViewButtonCell);
                 * //btnCell.ToolTipText = "Add/Delete HD Timer";
                 * if (favItem.IsValid)
                 * {
                 *      btnCell.Style.ForeColor = Color.Black;
                 * }
                 * else
                 * {
                 *      btnCell.Style.ForeColor = Color.LightGray;
                 * }
                 */

                rows.Add(row);
            }

            FavList.Rows.Clear();
            FavList.Rows.AddRange(rows.ToArray());

            if (selectedIndex.HasValue && selectedIndex < FavList.Rows.Count)
            {
                FavList.Rows[selectedIndex.Value].Selected = true;
            }

            if (scrollPos > -1 && scrollPos < FavList.Rows.Count)
            {
                FavList.FirstDisplayedScrollingRowIndex = scrollPos;
            }

            FavList.ResumeLayout();
        }