Beispiel #1
0
        private void typeFactory_HttpSucess(object sender, HttpFactoryArgs <List <TypeInfo> > args)
        {
            var selectGroup = new ChannelTypeGroup();

            selectGroup.GroupName  = "已固定";
            selectGroup.ItemsGroup = new ObservableCollection <ChannelTypeItem>();

            var unSelectGroup = new ChannelTypeGroup();

            unSelectGroup.GroupName  = "未固定";
            unSelectGroup.ItemsGroup = new ObservableCollection <ChannelTypeItem>();

            _allViewModel.Groups.Add(selectGroup);
            _allViewModel.Groups.Add(unSelectGroup);

            var roamingValue = DataStoreUtils.GetRoamingSettingValue(_channelTypeSettingKey) as string;

            if (string.IsNullOrEmpty(roamingValue))
            {
                roamingValue = string.Join("/", args.Result.Take(ColNumber * 2).Select(v => v.TypeId.ToString()));
            }
            var firstLaunch = DataStoreUtils.GetLocalSettingValue(_channelTypeSettingKey) as string;

            if (string.IsNullOrEmpty(firstLaunch))
            {
                if (!roamingValue.Contains("75099"))
                {
                    roamingValue = roamingValue.Insert(0, "75099/");
                    roamingValue = roamingValue.Remove(roamingValue.LastIndexOf('/'));
                }
                if (!roamingValue.Contains(LiveTypeId.ToString()))
                {
                    roamingValue = roamingValue.Insert(0, string.Format("{0}/", LiveTypeId.ToString()));
                    roamingValue = roamingValue.Remove(roamingValue.LastIndexOf('/'));
                }
                DataStoreUtils.AddLocalSettingValue(_channelTypeSettingKey, "1");
                DataStoreUtils.AddRoamingSettingValue(_channelTypeSettingKey, roamingValue);
            }

            _isReorder = false;

            var selectValues = roamingValue.Split('/');

            foreach (var type in args.Result)
            {
                ProcessViewModel(selectValues, type.TypeId, type.Name);
            }
            foreach (var type in _localTypes)
            {
                ProcessViewModel(selectValues, type.TypeId, type.TypeName);
            }
            foreach (var selected in selectValues)
            {
                var item = _allViewModel.Groups[0].ItemsGroup.FirstOrDefault(v => v.TypeId == Convert.ToInt32(selected));
                if (item != null)
                {
                    _selectedViewModel.Add(item);
                }
            }
        }
Beispiel #2
0
        private ChannelTypeFactory()
        {
            _typeImages = new Dictionary <string, string>(19);
            _typeImages.Add("VIP尊享", "/Images/Channels/vip.png");
            _typeImages.Add("电影", "/Images/Channels/movie.png");
            _typeImages.Add("电视剧", "/Images/Channels/teleplay.png");
            _typeImages.Add("动漫", "/Images/Channels/cartoon.png");
            _typeImages.Add("综艺", "/Images/Channels/show.png");
            _typeImages.Add("体育", "/Images/Channels/sports.png");
            _typeImages.Add("热点", "/Images/Channels/hot.png");
            _typeImages.Add("游戏", "/Images/Channels/game.png");
            //_typeImages.Add("推荐分类", "/Images/Channels/recommend.png");
            _typeImages.Add("旅游", "/Images/Channels/travel.png");
            //_typeImages.Add("生活", "/Images/Channels/life.png");
            //_typeImages.Add("时尚", "/Images/Channels/modern.png");
            _typeImages.Add("音乐", "/Images/Channels/music.png");
            _typeImages.Add("娱乐", "/Images/Channels/flower.png");
            //_typeImages.Add("搞笑", "/Images/Channels/funny.png");
            _typeImages.Add("最近观看", "/Images/Channels/history.png");
            _typeImages.Add("我的收藏", "/Images/Channels/favoriten.png");
            _typeImages.Add("我的下载", "/Images/Channels/downloaded.png");
            //_typeImages.Add("直播", "/Images/Channels/live.png");

            _defaultImage          = "/Images/Channels/default.png";
            _channelTypeSettingKey = "ChannelTypeSettingKey";
            _localTypes            = new ChannelTypeItem[] {
                new ChannelTypeItem()
                {
                    TypeId = RecentTypeId, TypeName = "最近观看", ImageUri = _typeImages["最近观看"]
                },
                new ChannelTypeItem()
                {
                    TypeId = FavoritenTypeId, TypeName = "我的收藏", ImageUri = _typeImages["我的收藏"]
                },
                new ChannelTypeItem()
                {
                    TypeId = DownloadedTypeId, TypeName = "我的下载", ImageUri = _typeImages["我的下载"], Count = DownloadViewModel.Instance.DownloadingItems.Count
                }
                //new ChannelTypeItem(){TypeId = LiveTypeId, TypeName="直播", ImageUri = _defaultImage}
            };

            _allViewModel      = new ChannelTypeViewModel();
            _selectedViewModel = new ObservableCollection <ChannelTypeItem>();

            var selectGroup = new ChannelTypeGroup();

            selectGroup.GroupName = "已固定";

            var unSelectGroup = new ChannelTypeGroup();

            unSelectGroup.GroupName = "未固定";

            _allViewModel.Add(selectGroup);
            _allViewModel.Add(unSelectGroup);

            _typeFactory = new TypeFactory();
            _typeFactory.HttpSucessHandler += typeFactory_HttpSucess;
            _typeFactory.HttpFailorTimeOut += HttpFailorTimeOut;
        }
Beispiel #3
0
        private void typeFactory_HttpSucess(object sender, HttpFactoryArgs<List<TypeInfo>> args)
        {
            var selectGroup = new ChannelTypeGroup();
            selectGroup.GroupName = "已固定";
            selectGroup.ItemsGroup = new ObservableCollection<ChannelTypeItem>();

            var unSelectGroup = new ChannelTypeGroup();
            unSelectGroup.GroupName = "未固定";
            unSelectGroup.ItemsGroup = new ObservableCollection<ChannelTypeItem>();

            _allViewModel.Groups.Add(selectGroup);
            _allViewModel.Groups.Add(unSelectGroup);

            var roamingValue = DataStoreUtils.GetRoamingSettingValue(_channelTypeSettingKey) as string;
            if (string.IsNullOrEmpty(roamingValue))
                roamingValue = string.Join("/", args.Result.Take(ColNumber * 2).Select(v => v.TypeId.ToString()));
            var firstLaunch = DataStoreUtils.GetLocalSettingValue(_channelTypeSettingKey) as string;
            if (string.IsNullOrEmpty(firstLaunch))
            {
                if (!roamingValue.Contains("75099"))
                {
                    roamingValue = roamingValue.Insert(0, "75099/");
                    roamingValue = roamingValue.Remove(roamingValue.LastIndexOf('/'));
                }
                if (!roamingValue.Contains(LiveTypeId.ToString()))
                {
                    roamingValue = roamingValue.Insert(0, string.Format("{0}/", LiveTypeId.ToString()));
                    roamingValue = roamingValue.Remove(roamingValue.LastIndexOf('/'));
                }
                DataStoreUtils.AddLocalSettingValue(_channelTypeSettingKey, "1");
                DataStoreUtils.AddRoamingSettingValue(_channelTypeSettingKey, roamingValue);
            }

            _isReorder = false;

            var selectValues = roamingValue.Split('/');
            foreach (var type in args.Result)
            {
                ProcessViewModel(selectValues, type.TypeId, type.Name);
            }
            foreach (var type in _localTypes)
            {
                ProcessViewModel(selectValues, type.TypeId, type.TypeName);
            }
            foreach(var selected in selectValues)
            {
                var item = _allViewModel.Groups[0].ItemsGroup.FirstOrDefault(v => v.TypeId == Convert.ToInt32(selected));
                if (item != null)
                {
                    _selectedViewModel.Add(item);
                }
            }
        }
Beispiel #4
0
        private ChannelTypeFactory()
        {
            _typeImages = new Dictionary<string, string>(19);
            _typeImages.Add("VIP尊享", "/Images/Channels/vip.png");
            _typeImages.Add("电影", "/Images/Channels/movie.png");
            _typeImages.Add("电视剧", "/Images/Channels/teleplay.png");
            _typeImages.Add("动漫", "/Images/Channels/cartoon.png");
            _typeImages.Add("综艺", "/Images/Channels/show.png");
            _typeImages.Add("体育", "/Images/Channels/sports.png");
            _typeImages.Add("热点", "/Images/Channels/hot.png");
            _typeImages.Add("游戏", "/Images/Channels/game.png");
            //_typeImages.Add("推荐分类", "/Images/Channels/recommend.png");
            _typeImages.Add("旅游", "/Images/Channels/travel.png");
            //_typeImages.Add("生活", "/Images/Channels/life.png");
            //_typeImages.Add("时尚", "/Images/Channels/modern.png");
            _typeImages.Add("音乐", "/Images/Channels/music.png");
            _typeImages.Add("娱乐", "/Images/Channels/flower.png");
            //_typeImages.Add("搞笑", "/Images/Channels/funny.png");
            _typeImages.Add("最近观看", "/Images/Channels/history.png");
            _typeImages.Add("我的收藏", "/Images/Channels/favoriten.png");
            _typeImages.Add("我的下载", "/Images/Channels/downloaded.png");
            //_typeImages.Add("直播", "/Images/Channels/live.png");

            _defaultImage = "/Images/Channels/default.png";
            _channelTypeSettingKey = "ChannelTypeSettingKey";
            _localTypes = new ChannelTypeItem[] {
                new ChannelTypeItem(){TypeId = RecentTypeId, TypeName="最近观看", ImageUri=_typeImages["最近观看"]},
                new ChannelTypeItem(){TypeId = FavoritenTypeId, TypeName="我的收藏", ImageUri=_typeImages["我的收藏"]},
                new ChannelTypeItem(){TypeId = DownloadedTypeId, TypeName="我的下载", ImageUri=_typeImages["我的下载"], Count = DownloadViewModel.Instance.DownloadingItems.Count}
                //new ChannelTypeItem(){TypeId = LiveTypeId, TypeName="直播", ImageUri = _defaultImage}
            };

            _allViewModel = new ChannelTypeViewModel();
            _selectedViewModel = new ObservableCollection<ChannelTypeItem>();

            var selectGroup = new ChannelTypeGroup();
            selectGroup.GroupName = "已固定";

            var unSelectGroup = new ChannelTypeGroup();
            unSelectGroup.GroupName = "未固定";

            _allViewModel.Add(selectGroup);
            _allViewModel.Add(unSelectGroup);

            _typeFactory = new TypeFactory();
            _typeFactory.HttpSucessHandler += typeFactory_HttpSucess;
            _typeFactory.HttpFailorTimeOut += HttpFailorTimeOut;
        }