예제 #1
0
        }//AddNewList

        /// <summary>
        /// CreateUIList
        /// </summary>
        /// <param name="newList"></param>
        /// <param name="progressDialog"></param>
        private void CreateUIList(ShoppingListDTO newList, int position = 0)
        {
            CtrlShoppingList item = new CtrlShoppingList(this, ShAppContext, newList);

            item.Event_DeleteItem += DeleteList;
            item.Event_EditItem   += EditList;
            item.Event_ClickItem  += ClickList;
            llShoppingLst.AddView(item, position);
            llShoppingLst.RequestLayout();
        }//CreateUIList
예제 #2
0
        public void ProcessMessage(Intent intent)
        {
            //intent.GetStringExtra("WearMessage");
            var allUiLists = ListsManager.Instance.Lists.Where(x => x.IsDeleted == false).OrderBy(x => x.ListDate).ToList();


            ViewGroup viewGroup = (ViewGroup)llShoppingLst;

            //remove all that are not in the datalist
            for (int i = 0; i < viewGroup.ChildCount; i++)
            {
                CtrlShoppingList child = viewGroup.GetChildAt(i) as CtrlShoppingList;
                if (child == null)
                {
                    continue;
                }
                var foundList = allUiLists.Where(x => x.InternalId == child.Data.InternalId).FirstOrDefault();
                if (foundList == null)
                {
                    ((child as View).Parent as ViewGroup).RemoveView(child);
                }
            }//for

            for (int i = 0; i < allUiLists.Count; i++)
            {
                CtrlShoppingList wantedView = null;
                for (int j = 0; j < viewGroup.ChildCount; j++)
                {
                    CtrlShoppingList child = viewGroup.GetChildAt(j) as CtrlShoppingList;
                    if (child.Data.InternalId == allUiLists[i].InternalId)
                    {
                        wantedView = child;
                        break;
                    }
                }//for

                if (wantedView != null)
                {
                    // update the existing ones
                    wantedView.UpdateCtrlData(allUiLists[i]);
                }
                else
                {
                    CreateUIList(allUiLists[i], i);
                }
            } //for
        }     //ProcessMessage