Пример #1
0
        public PageAddFavorite()
        {
            InitializeComponent();
            _feContainer            = this.Container as FrameworkElement;
            stbCloseMenu.Completed += stbCloseMenu_Completed;
            stbOpenMenu.Completed  += stbOpenMenu_Completed;
            lstChanelsLiked         = CodePublic.ReadDataFromIsolatedStorage();
            if (lstChanelsLiked == null)
            {
                return;
            }
            var vm = DataContext as MenuMainVM;

            if (vm != null)
            {
                foreach (var chanelLiked in lstChanelsLiked)
                {
                    foreach (var itemChanel in vm.propData.chanelsCollection)
                    {
                        if (chanelLiked.groupName != null && chanelLiked.groupName.Equals(itemChanel.groupName))
                        {
                            foreach (var chanel in itemChanel.chanels)
                            {
                                if (chanelLiked.chanelId.Equals(chanel.chanelId))
                                {
                                    chanel.isLiked = true;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            if (isOpen)
            {
                MenuSetting();
                e.Cancel = true;
                return;
            }
            var vm = DataContext as MenuMainVM;

            vm.chanelsByGroup = CodePublic.ReadDataFromIsolatedStorage();
            //while (vm.chanelsByGroup.Contains(vm.chanelFav))
            //{
            //    vm.chanelsByGroup.Remove(vm.chanelFav);
            //}
            if (vm.chanelsByGroup != null)
            {
                for (int i = 0; i < vm.chanelsByGroup.Count; i++)
                {
                    if (vm.chanelsByGroup[i].chanelId == vm.chanelFav.chanelId)
                    {
                        vm.chanelsByGroup.Remove(vm.chanelsByGroup[i]);
                    }
                }
            }
            vm.chanelsByGroup.Add(vm.chanelFav);
            base.OnBackKeyPress(e);
        }
Пример #3
0
        private void searchChanel(string text)
        {
            var vm    = DataContext as MenuMainVM;
            var query = from mContact in vm.propData.chanelsCollectionInOne
                        where
                        mContact.chanelName.ToLower().Contains(text.ToLower())
                        select mContact;
            var listQuery = new ObservableCollection <Chanel>(query);

            vm.listShowing = CodePublic.getListToBiding(listQuery);
        }
        private void BtnItemGroupChanel_OnClick(object sender, RoutedEventArgs e)
        {
            var item = (GetListChanels)(sender as Button).DataContext;
            var vm   = DataContext as MenuMainVM;

            vm.groupChanelItem = item;
            if (item.groupId == CodePublic.groupChanelId)
            {
                vm.chanelsByGroup = CodePublic.ReadDataFromIsolatedStorage();
                //while (vm.chanelsByGroup.Contains(vm.chanelFav))
                //{
                //    vm.chanelsByGroup.Remove(vm.chanelFav);
                //}
                //vm.chanelsByGroup.Add(vm.chanelFav);

                if (vm.chanelsByGroup != null)
                {
                    for (int i = 0; i < vm.chanelsByGroup.Count; i++)
                    {
                        if (vm.chanelsByGroup[i].chanelId == vm.chanelFav.chanelId)
                        {
                            vm.chanelsByGroup.Remove(vm.chanelsByGroup[i]);
                        }
                    }
                    vm.chanelsByGroup.Add(vm.chanelFav);
                }
                else
                {
                    vm.chanelsByGroup = new ObservableCollection <Chanel>();
                    vm.chanelsByGroup.Add(vm.chanelFav);
                }
            }
            else
            {
                vm.chanelsByGroup = item.chanels;
            }

            MenuSetting();

            NavigationService.Navigate(
                new Uri(
                    "/View/PageMainPanel.xaml", UriKind.RelativeOrAbsolute));
            while (this.NavigationService.BackStack.Any())
            {
                this.NavigationService.RemoveBackEntry();
            }
            //NavigationService.GoBack();
        }
Пример #5
0
        private void BtnChanelItem_OnClick(object sender, RoutedEventArgs e)
        {
            var item = (Chanel)(sender as Button).DataContext;

            if (item != null)
            {
                if (lstChanelsLiked == null)
                {
                    lstChanelsLiked = new ObservableCollection <Chanel>();
                }
                item.isLiked = !item.isLiked;
                if (item.isLiked)
                {
                    lstChanelsLiked.Add(item);
                    CodePublic.SaveDataToIsolatedStorage(lstChanelsLiked);
                }
                else
                {
                    foreach (var chanel in lstChanelsLiked)
                    {
                        if (chanel.chanelId == item.chanelId)
                        {
                            lstChanelsLiked.Remove(chanel);
                            CodePublic.SaveDataToIsolatedStorage(lstChanelsLiked);
                            break;
                        }
                    }
                }
                var vm = DataContext as MenuMainVM;
                if (vm != null)
                {
                    vm.propData.chanelsCollection[0].numChannel = lstChanelsLiked.Count == 1? 1 : lstChanelsLiked.Count - 1;
                }
                //var lst = CodePublic.ReadDataFromIsolatedStorage();
            }

            //var chanel = CodePublic.ReadDataFromIsolatedStorage();
            // MessageBox.Show(chanel[0].chanelName);
        }
Пример #6
0
        private void BtnItemGroupChanel_OnClick(object sender, RoutedEventArgs e)
        {
            var item = (GetListChanels)(sender as Button).DataContext;
            var vm   = DataContext as MenuMainVM;

            vm.groupChanelItem = item;
            vm.chanelsByGroup  = item.chanels;
            if (vm != null && vm.chanelsByGroup != null)
            {
                if (item.groupId == CodePublic.groupChanelId)
                {
                    vm.chanelsByGroup = CodePublic.ReadDataFromIsolatedStorage();
                    //while (vm.chanelsByGroup.Contains(vm.chanelFav))
                    //{
                    //    vm.chanelsByGroup.Remove(vm.chanelFav);
                    //}
                    //vm.chanelsByGroup.Add(vm.chanelFav);

                    if (vm.chanelsByGroup != null)
                    {
                        for (int i = 0; i < vm.chanelsByGroup.Count; i++)
                        {
                            if (vm.chanelsByGroup[i].chanelId == vm.chanelFav.chanelId)
                            {
                                vm.chanelsByGroup.Remove(vm.chanelsByGroup[i]);
                            }
                        }
                        vm.chanelsByGroup.Add(vm.chanelFav);
                    }
                    else
                    {
                        vm.chanelsByGroup = new ObservableCollection <Chanel>();
                        vm.chanelsByGroup.Add(vm.chanelFav);
                    }
                }
            }
            MenuSetting();
        }
Пример #7
0
        private async void getDataFromService(object obj)
        {
            isLoading = true;
            try
            {
                propData = await repositoryServices.GetDataChanelsTask();
            }
            catch (Exception ex)
            {
                propData = repositoryServices.GetResulTask();
            }
            isLoading = false;
            if (propData != null)
            {
                propData.chanelsCollection.First().chanels.Remove(propData.chanelsCollection.First().chanels.Last());
                groupChanels = propData.chanelsCollection;
                var item1 = propData.chanelsCollection.First();
                groupChanelItem = item1;

                var chanel1 = new Chanel();
                chanel1.chanelId   = "#123";
                chanel1.chanelName = "Thêm kênh yêu thích";
                chanel1.icon       = "/Assets/Images/addFavChanel.png";
                chanelFav          = chanel1;
                chanelsByGroup     = CodePublic.ReadDataFromIsolatedStorage();
                if (chanelsByGroup == null)
                {
                    propData.chanelsCollection[0].numChannel = 0;
                }
                else
                {
                    propData.chanelsCollection[0].numChannel = chanelsByGroup.Count - 1;
                }
                if (chanelsByGroup == null)
                {
                    chanelsByGroup = new ObservableCollection <Chanel>();
                    chanelsByGroup.Add(chanel1);
                }
                else
                {
                    for (int i = 0; i < chanelsByGroup.Count; i++)
                    {
                        if (chanelsByGroup[i].chanelId == chanelFav.chanelId)
                        {
                            chanelsByGroup.Remove(chanelsByGroup[i]);
                        }
                    }
                    chanelsByGroup.Add(chanelFav);
                }
                int indexId = 0;
                foreach (var item in propData.chanelsCollection)
                {
                    indexId++;
                    var query1 = item.chanels.Select(x =>
                    {
                        x.groupName = item.groupName;
                        x.groupId   = indexId;
                        if (!x.icon.Contains(".jpg"))
                        {
                            x.icon = x.icon + ".jpg";
                        }
                        return(x);
                    });
                    var lstChanel = new ObservableCollection <Chanel>(query1);
                    foreach (var chanel in lstChanel)
                    {
                        propData.chanelsCollectionInOne.Add(chanel);
                    }
                }
                var lst = propData.chanelsCollectionInOne;
                listShowing = CodePublic.getListToBiding(lst);
            }
        }