Ejemplo n.º 1
0
 public void GetHashCodeTest()
 {
     CategoryItem target = new CategoryItem("Hello", CategoryItemType.String);
     int expected = "^Hello$".GetHashCode();
     int actual = target.GetHashCode();
     Assert.AreEqual(expected, actual);
 }
 private async Task CreateCategoryItem(ImageMetaData imageMetaData)
 {
     Func<Task<IBitmap>> lazyImageFactory = () => downloadManager.DownloadImage(imageMetaData.imageThumbnail);
     var category = new CategoryItem(imageMetaData.imageUrl, imageMetaData.Category, lazyImageFactory);
     CategoryItems.Add(category);
     await category.LoadImage();
 }
Ejemplo n.º 3
0
 public void EqualsTest()
 {
     CategoryItem target = new CategoryItem("Hello", CategoryItemType.String);
     object obj = null;
     bool actual = target.Equals(obj);
     Assert.AreEqual(false, actual);
 }
Ejemplo n.º 4
0
        public CategoryItemCommandControl(CategoryItem item, CategoryItem.Command command)
        {
            if (command == null) 
                throw new ArgumentNullException("command");

            this.Command = command;
        }
Ejemplo n.º 5
0
 public void CategoryItemConstructorTest1()
 {
     CategoryItem target = new CategoryItem();
     
     Assert.AreEqual(string.Empty, target.Value);
     Assert.AreEqual(string.Empty, target.Pattern);
     Assert.AreEqual(CategoryItemType.Regex, target.Type);
 }
Ejemplo n.º 6
0
 public void CompareToTest()
 {
     CategoryItem target = new CategoryItem("Hello", CategoryItemType.String);
     CategoryItem other = new CategoryItem("GoodBye", CategoryItemType.String);
     int expected = "^Hello^".CompareTo("^GoodBye$");
     int actual;
     actual = target.CompareTo(other);
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 7
0
        public void CategoryItemEquality()
        {
            CategoryItem a = new CategoryItem("Hello", CategoryItemType.String);
            CategoryItem b = new CategoryItem("Hello", CategoryItemType.String);

            Assert.IsTrue(a == b, "Equality operator failed");
            Assert.AreEqual(true, a.Equals(b), "Explicit call to IEquatable<T> method failed");
            Assert.AreEqual(a, b, "Generic Assert.AreEqual call failed");
        }
Ejemplo n.º 8
0
 public void EqualsTest1()
 {
     CategoryItem target = new CategoryItem("Hello", CategoryItemType.String);
     object obj = new CategoryItem("Hello", CategoryItemType.String);
     bool expected = true; 
     bool actual;
     actual = target.Equals(obj);
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 9
0
    public static CategoryItem FillOne(DataRow r, IncludeToFill inc)
    {
        CategoryItem c = new CategoryItem();

        if (inc.Id) c.Id = (int)r["Id"];
        if (inc.CategoryName) c.CategoryName = (string)r["Name"];
        if (inc.SubCategory) c.SubCategories = GetChildCategories(c.Id);

        return c;
    }
Ejemplo n.º 10
0
        protected virtual DataTemplate FindEditorTemplate(CategoryItem category)
        {
            if (category == null) return null;

            Editor editor = category.Editor;

            if (editor == null) return null;

            DataTemplate template = editor.InlineTemplate as DataTemplate;
            if (template != null) return template;

            return resourceLocator.GetResource(editor.InlineTemplate) as DataTemplate;
        }
Ejemplo n.º 11
0
        // GET: CategoryItems/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CategoryItem categoryItem = db.CategoryItems.Find(id);

            if (categoryItem == null)
            {
                return(HttpNotFound());
            }
            return(View(categoryItem));
        }
Ejemplo n.º 12
0
        public void Add(string contextItemPath, string name, bool expectCategory)
        {
            var settings = MockSettings(ID.NewID, ID.NewID);
            var manager  = new CategoryManager(settings);

            using (var db = new Db
            {
                new DbTemplate("category1", settings.CategoryTemplateIds.ElementAt(0))
                {
                    new DbField("Title")
                },
                new DbTemplate("category2", settings.CategoryTemplateIds.ElementAt(1))
                {
                    new DbField("Title")
                },
                new DbItem("blog", ID.NewID, settings.BlogTemplateIds.First())
                {
                    new DbItem("Categories", ID.NewID, ID.NewID)
                    {
                        new DbItem("alpha", ID.NewID, settings.CategoryTemplateIds.ElementAt(0)),
                        new DbItem("beta", ID.NewID, settings.CategoryTemplateIds.ElementAt(1)),
                        new DbItem("gamma", ID.NewID, settings.CategoryTemplateIds.ElementAt(0))
                    },
                    new DbItem("Entries", ID.NewID, ID.NewID)
                    {
                        new DbItem("entry1", ID.NewID, settings.EntryTemplateIds.First())
                    }
                }
            })
            {
                var entryItem = contextItemPath != null?db.GetItem(contextItemPath) : null;

                CategoryItem categoryItem = null;

                using (new SecurityDisabler())
                {
                    categoryItem = manager.Add(name, entryItem);
                }

                if (expectCategory)
                {
                    Assert.That(categoryItem, Is.Not.Null);
                    Assert.That(categoryItem.Name, Is.EqualTo(name));
                }
                else
                {
                    Assert.That(categoryItem, Is.Null);
                }
            }
        }
        public List <T> GetSelectValues <T>()
        {
            List <T> list = new List <T>(this.BindedListBox.SelectedItems.Count);

            foreach (var item in this.BindedListBox.SelectedItems)
            {
                CategoryItem i = item as CategoryItem;
                if (i != null && i.Value != null)
                {
                    list.Add((T)(i.Value));
                }
            }
            return(list);
        }
Ejemplo n.º 14
0
        private static void AddCore(Type type, ProcessorAttribute att)
        {
            if (att == null)
            {
                att = new ProcessorAttribute();
            }

            CategoryItem item = new CategoryItem();
            item.Name = String.IsNullOrEmpty(att.Name) ? type.ToString() : att.Name;
            item.Introduce = String.IsNullOrEmpty(att.Introduce) ? type.ToString() : att.Introduce;
            item.Category = att.Category;
            item.Value = type;
            CategoryItems.Add(item);
        }
Ejemplo n.º 15
0
        public async Task <IHttpActionResult> DeleteCategoryItem(int id)
        {
            CategoryItem categoryItem = await db.CategoryItems.FindAsync(id);

            if (categoryItem == null)
            {
                return(NotFound());
            }

            db.CategoryItems.Remove(categoryItem);
            await db.SaveChangesAsync();

            return(Ok(categoryItem));
        }
        public void ShouldListenToPropertyVisibilityChanges()
        {
            CategoryItem     category = new CategoryItem(new PropertyGrid(), new CategoryAttribute());
            PropertyItemMock property = new PropertyItemMock("property");

            category.AddProperty(property);
            Assert.IsFalse(category.HasVisibleProperties);

            property.IsBrowsable = true;
            Assert.IsTrue(category.HasVisibleProperties);

            property.IsBrowsable = false;
            Assert.IsFalse(category.HasVisibleProperties);
        }
        private void BindedListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Object obj = this.BindedListBox.SelectedItem;

            if (obj == null)
            {
                this.BindedTextBox.Text = String.Empty;
            }
            else
            {
                CategoryItem item = obj as CategoryItem;
                this.BindedTextBox.Text = item.Introduce;
            }
        }
Ejemplo n.º 18
0
        public void ParseRankingTest1() 
        {
            string temp_directory_path = TestUtility.TestData[TestUtility.KEY_TEMP_DIRECTORY];

            TestUtility.EnsureLogin(network_);

            DirectoryInfo temp_directory = new DirectoryInfo(temp_directory_path);

            Assert.That(TestUtility.InitDirectory(temp_directory), Is.True, "ParseRankingTest1-1");

            DownloadKind kind = new DownloadKind();
            kind.SetDuration(false, false, true, false, false);
            CategoryItem categoryItem = new CategoryItem();
            categoryItem.id = "music";
            categoryItem.short_name = "mus";
            categoryItem.name = "音楽";
            categoryItem.page = new int[] { 3, 1, 1, 1, 0 };
            List<CategoryItem> categoryList = new List<CategoryItem>();
            categoryList.Add(categoryItem);
            kind.CategoryList = categoryList;
            kind.SetTarget(true, true, true);
            kind.SetFormat(DownloadKind.FormatKind.Html);

            NicoNetwork.NetworkWaitDelegate onWait = delegate(string message, int current, int total)
            {
                TestUtility.Message("({0}/{1}){2}", current, total, message);
                TestUtility.Wait();
            };

            TestUtility.Message("Running ParseRankingTest1.");
            network_.DownloadRanking(temp_directory.FullName, kind, onWait);

            NicoListManager.ParseRankingKind parse_ranking_kind;
            List<Video> video_list;

            try
            {
                parse_ranking_kind = NicoListManager.ParseRankingKind.TotalPoint;
                video_list = NicoListManager.ParseRanking(temp_directory.FullName, DateTime.Now, parse_ranking_kind);
                Assert.Fail("ParseRankingTest1-2");
            }
            catch (InvalidOperationException e)
            {
                TestUtility.Message(e.Message);
            }

            parse_ranking_kind = NicoListManager.ParseRankingKind.TermPoint;
            video_list = NicoListManager.ParseRanking(temp_directory.FullName, DateTime.Now, parse_ranking_kind);
            Assert.That(video_list.Count, Is.GreaterThan(0), "ParseRankingTest1-3");
        }
Ejemplo n.º 19
0
        private bool IsModelValid(CategoryItem model)
        {
            if (model == null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 20
0
        public ActionResult Index(string categoryType)
        {
            PostsByCategoryViewModel ByCategoryVM      = null;
            List <ArticleItem>       articles          = null;
            DataAccessLayer          datalayer         = null;
            CategoryItem             category          = null;
            List <NewsItem>          breakingNewsItems = null;
            List <RelatedNewsItem>   relatedNews       = null;

            //check if categoryType is valid category
            if (!string.IsNullOrEmpty(categoryType))
            {
                datalayer = new DataAccessLayer();

                articles = datalayer.GetArticlesByCategory(categoryType);

                if (articles != null)
                {
                    if (articles.Count > 0)
                    {
                        category = new CategoryItem {
                            Id = articles[0].Category.Id, Name = articles[0].Category.Name, Name_english = articles[0].Category.Name_english
                        };
                    }
                }

                //populate breaking news
                breakingNewsItems = datalayer.GetBreakingNews();



                relatedNews = datalayer.GetRelatedNews(categoryType, 5);
            }
            else
            {
                //redirect to home page for empty or null category input
                return(RedirectToAction("Index", "Home"));
            }



            ByCategoryVM                   = new PostsByCategoryViewModel();
            ByCategoryVM.Articles          = articles;
            ByCategoryVM.Category          = category;
            ByCategoryVM.BreakingNewsItems = breakingNewsItems;
            ByCategoryVM.RelatedNews       = relatedNews;

            return(View(ByCategoryVM));
        }
Ejemplo n.º 21
0
        private static void AddCore(Type type, ProcessorAttribute att)
        {
            if (att == null)
            {
                att = new ProcessorAttribute();
            }

            CategoryItem item = new CategoryItem();

            item.Name      = String.IsNullOrEmpty(att.Name) ? type.ToString() : att.Name;
            item.Introduce = String.IsNullOrEmpty(att.Introduce) ? type.ToString() : att.Introduce;
            item.Category  = att.Category;
            item.Value     = type;
            CategoryItems.Add(item);
        }
Ejemplo n.º 22
0
        public async Task <Response> Create(CategoryItem categoryItem)
        {
            try
            {
                var response = await ApiService
                               .GetInstance()
                               .Create("api/category/create", categoryItem);

                return(response);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public void ShouldApplyHasVisiblePropertiesByAtLeastOneOccurrence()
        {
            CategoryItem category = new CategoryItem(new PropertyGrid(), new CategoryAttribute());

            Assert.IsFalse(category.HasVisibleProperties);

            category.AddProperty(new PropertyItemMock("property1")
            {
                IsBrowsable = true
            });
            Assert.IsTrue(category.HasVisibleProperties);

            category.AddProperty(new PropertyItemMock("property2"));
            Assert.IsTrue(category.HasVisibleProperties);
        }
Ejemplo n.º 24
0
 public CategoryItemDeatailPage(CategoryItem categoryItem)
 {
     this.categoryItem = categoryItem;
     InitializeComponent();
     labelTitle.Text   = categoryItem.Title;
     labelContent.Text = categoryItem.Content;
     if (categoryItem.ImageCover == null)
     {
         stackLayout.Children.Remove(imageItem);
     }
     else
     {
         imageItem.Source = categoryItem.ImageCover;
     }
 }
        public CategoryItem GetCategoryItem(int categoryId)
        {
            CategoryItem item = null;

            if (_categoryItems.ContainsKey(categoryId))
            {
                item = _categoryItems[categoryId];
            }
            else
            {
                throw new Exception("Item does not exist.");
            }

            return(item.Clone());
        }
 bool NameRepetition(string name, CategoryItem categoryItem)
 {
     if (categoryItem.Name == name)
     {
         return(true);
     }
     foreach (var cItem in categoryItem.Children)
     {
         if (NameRepetition(name, cItem))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 27
0
        public async Task <Response> Update(CategoryItem categoryItem)
        {
            try
            {
                var response = await ApiService
                               .GetInstance()
                               .Update <CategoryItem>("api/category/update", categoryItem, categoryItem.Id);

                return(response);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 28
0
        /// <summary>选择某个类别时的显示
        /// </summary>
        /// <param name="id">类别的ID</param>
        /// <returns>该类别的View</returns>
        public ActionResult Cate(int id, int?p)
        {
            ViewData["CurrentCateID"] = id;

            CategoryItem cate = CategoryManager.Instance.GetCategoryById(id);
            int          pi   = p ?? 0; //表示页索引

            int CurrentCatePageCount     = 0;
            IList <ProductItem> products = ProductManager.GetPagedProductsByCategory(cate.CategoryID, pi, 9, out CurrentCatePageCount);

            ViewData["PageCount"]        = CurrentCatePageCount;
            ViewData["CurrentPageIndex"] = pi;

            return(View("Index", products));
        }
        public void ShouldNotifyIsExpandedValueChange()
        {
            CategoryItem category = new CategoryItem(new PropertyGrid(), "category");

            int eventsNumber = 0;

            category.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsExpanded")
                                                         {
                                                             eventsNumber++;
                                                         }
            };

            category.IsExpanded = !category.IsExpanded;
            Assert.AreEqual <int>(1, eventsNumber);
        }
Ejemplo n.º 30
0
        // GET: CategoryItems/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CategoryItem categoryItem = db.CategoryItems.Find(id);

            if (categoryItem == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", categoryItem.CategoryId);
            return(View(categoryItem));
        }
Ejemplo n.º 31
0
 public HttpResponseMessage Update([FromBody] CategoryItem item)
 {
     try
     {
         repository.Update(item);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (UnauthorizedAccessException)
     {
         return(Request.CreateResponse(HttpStatusCode.Unauthorized));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Ejemplo n.º 32
0
        /// <summary>用户选择产品页时的返回
        /// </summary>
        /// <returns></returns>
        public ActionResult Index(int?p)
        {
            CategoryItem cate = CategoryManager.Instance.GetFirstChildCate();

            ViewData["CurrentCateID"] = cate.CategoryID;

            int pi = p ?? 0; //表示页索引

            int CurrentCatePageCount     = 0;
            IList <ProductItem> products = ProductManager.GetPagedProductsByCategory(cate.CategoryID, pi, 10, out CurrentCatePageCount);

            ViewData["PageCount"]        = CurrentCatePageCount;
            ViewData["CurrentPageIndex"] = pi;

            return(View(products));
        }
Ejemplo n.º 33
0
        public int AddCategoryItem(CategoryItem item)
        {
            const string sql = "INSERT Category (Name, Noise) VALUES (@Name, @Noise);";

            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();

                SqlCommand cmd = new SqlCommand(sql + _getLastIdSQL, conn);
                cmd.Parameters.AddWithValue("@Name", item.Name);
                cmd.Parameters.AddWithValue("@Noise", item.Noise);
                item.Id = (int)cmd.ExecuteScalar();
            }

            return(item.Id);
        }
Ejemplo n.º 34
0
        public ActionResult Edit(Item item, int CategoryId)
        {
            // Item previousItem = _db.Items.Include(items => items.Categories).ThenInclude(join => join.Category).FirstOrDefault(items => items.ItemId == item.ItemId);
            CategoryItem join = _db.CategoryItem.FirstOrDefault(catItem => catItem.CategoryId == CategoryId && catItem.ItemId == item.ItemId);

            if (CategoryId != 0 && join == null)
            {
                _db.CategoryItem.Add(new CategoryItem()
                {
                    CategoryId = CategoryId, ItemId = item.ItemId
                });
            }
            _db.Entry(item).State = EntityState.Modified;
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 35
0
        public ActionResult AjaxForm()
        {
            var model   = new CategoryItem();
            var lstCate = _categoryApi.GetChildByParentId(false);

            ViewBag.lstCate    = lstCate;
            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;
            if (DoAction == ActionType.Edit)
            {
                model = _categoryApi.GetItemById(ArrId.FirstOrDefault());
            }
            model.AgencyId  = UserItem.AgencyID;
            ViewBag.lstUnit = _dnUnitApi.GetAllList();
            return(View(model));
        }
Ejemplo n.º 36
0
        public async Task <CategoryItem> Add(CategoryItem item)
        {
            var categoryRepository = _unitOfWork.GetRepository <Category>();
            var newItem            = new Category()
            {
                Description = item.Description,
                ParentId    = item.Parent?.OptionValue,
                Title       = item.Title,
            };
            await categoryRepository.InsertAsync(newItem);

            await _unitOfWork.SaveChangesAsync();

            item.Id = newItem.Id;
            return(item);
        }
Ejemplo n.º 37
0
    private void Awake()
    {
        Instance = this;

        inventoryUIItemList.SetActive(false);
        inventoryUICategoryList.SetActive(false);
        inventoryUISelected.SetActive(false);

        for (int i = 0; i < (int)ItemCategory.LengthOfEnum; i++)
        {
            GameObject   obj  = Instantiate(categoryItemPrefab, categoryListParent);
            CategoryItem item = obj.GetComponent <CategoryItem>();
            item.Set((ItemCategory)i);
            allCategories.Add(item);
        }
    }
Ejemplo n.º 38
0
        public static EXListViewItem CategoryItemToListItem(CategoryItem item, Category category, ListViewGroup group)
        {
            EXListViewItem newItem = new EXListViewItem(item.Value);

            newItem.SubItems.Add(new EXListViewSubItem(item.Type.ToString()));
            newItem.Name    = item.Value;
            newItem.TagData = item;
            if (category != null)
            {
                newItem.SubItems.Add(new EXListViewSubItem(category.Name));
            }
            if (group != null)
            {
                newItem.Group = group;
            }
            return(newItem);
        }
Ejemplo n.º 39
0
        public async Task <IActionResult> Create([Bind("Id,CategoryId,Name,Description,TargetAmount,ActualAmount")] CategoryItem categoryItem, int householdId)
        {
            if (User.IsInRole(nameof(Roles.Demo)))
            {
                TempData["Alert"] = "That action can not be done by demo users";
                return(RedirectToAction("Index", "Home"));
            }
            if (ModelState.IsValid)
            {
                _context.Add(categoryItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "HouseHolds", new { id = householdId }));
            }
            TempData["Alert"] = "Error Creating Category Item";
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 40
0
        public void AddChild(CategoryItem sourceItem, CategoryItem targetItem)
        {
            if (targetItem == null)
            {
                return;
            }

            targetItem.CategoryItems.Add(sourceItem);

            if (sourceItem.CategoryItems != null)
            {
                foreach (CategoryItem item in sourceItem.CategoryItems)
                {
                    this.AddChild(item, sourceItem);
                }
            }
        }
Ejemplo n.º 41
0
 public ObjectResult addCategoryItem([FromBody] CategoryItem item)
 {
     item.Id = null;
     if (this.entityCRUD.Add <CategoryItem>(item).Result)
     {
         this.hubContext.Clients.All.SendAsync("categoryChange");
         return(Ok(true));
     }
     else
     {
         return(BadRequest(new ErrorModel
         {
             Messege = "Lỗi nhập liệu, vui lòng nhập đầy đủ các trường",
             Status = 400
         }));
     }
 }
Ejemplo n.º 42
0
        public static TemplateProvider FromFile(string file)
        {
            TemplateProvider template = new TemplateProvider();
            IniSection[] sections = IniParser.Parse(file);

            for (int i = 0; i < sections.Length; i++)
            {
                Category category = Category.FromFormat(sections[i].Name);

                template.categories.Add(category);

                CategoryItem[] items = new CategoryItem[sections[i].Count];
                for (int j = 0; j < sections[i].Count; j++)
                {
                    items[j] = CategoryItem.FromFormat(sections[i][j]);
                }
                category.AddRange(items);
            }
            return template;
        }
Ejemplo n.º 43
0
        public void CategoryItemConstructorTest()
        {
            string value = "Hello";
            CategoryItemType type = CategoryItemType.WildCard; 
            CategoryItem target = new CategoryItem(value, type);

            Assert.AreEqual("Hello", target.Value);
            Assert.AreEqual(".*Hello.*", target.Pattern);
            Assert.AreEqual(CategoryItemType.WildCard, target.Type);

            target.Value = "GoodBye";

            Assert.AreEqual("GoodBye", target.Value);
            Assert.AreEqual(".*GoodBye.*", target.Pattern);
            Assert.AreEqual(CategoryItemType.WildCard, target.Type);

            target.Type = CategoryItemType.String;
            
            Assert.AreEqual("GoodBye", target.Value);
            Assert.AreEqual("^GoodBye$", target.Pattern);
            Assert.AreEqual(CategoryItemType.String, target.Type);
        }
Ejemplo n.º 44
0
	   private void ShowLivePreview(CategoryItem categoryItem){
		  if (preview != null) {
			 preview.PreviewList.BeginUpdate();
			 preview.PreviewList.Items.Clear();
			 string star = "";

			 Regex regex = null;
			 try {
				regex = new Regex(categoryItem.Pattern, Utility.REGEX_OPTIONS);
				Console.WriteLine(categoryItem.Pattern);
			 } catch (Exception ex) {
				preview.PreviewList.Items.Clear();
				preview.PreviewList.Items.Add(ex.Message);
				preview.PreviewList.EndUpdate();
				return;
			 }

			 foreach (StartItem item in manager.StartItems) {
				star = item.Name.Contains("\\") ? "*" : "";
				if (regex.Match(item.Name).Success) {
				    preview.PreviewList.Items.Add(star + item.Name);
				}
			 }
			 preview.PreviewList.EndUpdate();
		  }
	   }
Ejemplo n.º 45
0
        private async Task GetCategory(Theme theme)
        {     
       
            Func<Task<IBitmap>> lazyImageFactory = async () => 
            {
                var feed = await _rssReader.GetFeed(theme.FeedUrl);
                var firstImageFromFeed = _rssReader.GetFirstImageMetaData(feed);
                firstImageFromFeed.Category = theme.Name;
                return await _downloadManager.DownloadImage(firstImageFromFeed.imageThumbnail);
            };

            
            var categoryItem = new CategoryItem(theme.FeedUrl, theme.Name, lazyImageFactory);
            CategoryItems.Add(categoryItem);
            await categoryItem.LoadImage();
        
        }
Ejemplo n.º 46
0
 private async Task GetTop4WallPaperItems()
 {
     var rssForFeed = await _rssReader.GetFeed(_themes.Top4.FeedUrl);
     var imageMetaData = _rssReader.GetImageMetaData(rssForFeed);
     var taskList = new List<Task>();
     foreach (var imd in imageMetaData)
     {
         SetupLiveTile(imd.GetResizedImageUrl());
         Func<Task<IBitmap>> lazyImageFactory = () => _downloadManager.DownloadImage(imd.imageThumbnail);
         var categoryItem = new CategoryItem(imd.imageUrl ,imd.Category, lazyImageFactory);
         Top4Items.Add(categoryItem);
         taskList.Add(categoryItem.LoadImage());
     }
     await Task.WhenAll(taskList);
 }  
 private void Top4Selected(CategoryItem item)
 {
     _lockscreenHelper.SetLockscreen(item.Id);
     SelectedTop4 = null;
 }
Ejemplo n.º 48
0
	   private void newToolStripMenuItem_Click(object sender, EventArgs e) {
		  CategoryItem item = new CategoryItem();
		  IgnoreList.Instance.Add(item);
		  _ignoreList.Items.Add(TemplateEditor.CategoryItemToListItem(item, null, null));
	   }
 private async Task DownloadImage(CategoryItem categoryItem)
 {
     try
     {
         using (var library = new MediaLibrary())
         {
             var imagestream = await _downloadHelper.GetImageStream(new ImageMetaData(categoryItem.Id));
             library.SavePicture(string.Join(".", categoryItem.Name, ".jpg"), imagestream);
         }
         MessageBox.Show("Image has been saved your pictures!");
     }
     catch (Exception e)
     {
     }
 }
 private void NavigateToCategoryList(CategoryItem item)
 {
     try
     {
         var categoryItem = item as CategoryItem;
         _navigationService.UriFor<CategoryListViewModel>()
                           .WithParam(x => x.Category, categoryItem.Name)
                           .Navigate();
     }
     catch (Exception e)
     {
     }
 }
Ejemplo n.º 51
0
 internal void Initialize(CategoryItem parentItem)
 {
     this.parentItem = parentItem;
 }
 public async Task SetLockscreen(CategoryItem item)
 {           
     await _lockscreen.SetLockscreen(item.Id);
 }
Ejemplo n.º 53
0
        /// <summary>
        /// Fetches all the categories in the table.
        /// </summary>
        /// <returns>Returns a list of categories.</returns>
        public static List<CategoryItem> FetchDataCategories()
        {
            try
            {
                List<CategoryItem> list = new List<CategoryItem>();
                string sql = "SELECT DISTINCT Category FROM Bid";

                SetConnectionString();
                using (var connection = new SqlConnection(_connectionString))
                {
                    connection.Open();

                    using (var command = new SqlCommand(sql, connection))
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                do
                                {
                                    //sets the value from the reader
                                    CategoryItem item = new CategoryItem();
                                    item.Value = (string)reader["Category"];
                                    list.Add(item);
                                    item = null;
                                } while (reader.Read());
                            }
                        }
                    }
                }

                return list;
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 54
0
	   void _templateTable_BeginEditing(object sender, XPTable.Events.CellEditEventArgs e) {
		  if (e.Column == 0) { // The Pattern column
			 Row currentRow = _templateTable.TableModel.Rows[e.Row];
			 editingCategoryItem = (CategoryItem)currentRow.Tag;
			 Console.WriteLine(editingCategoryItem);
		  }
	   }
Ejemplo n.º 55
0
	   void _templateTable_AfterEditing(object sender, XPTable.Events.CellEditEventArgs e) {
		  if (preview != null) {
			 // reset preview
			 preview.PreviewList.Items.Clear();
		  }

		  editingCategoryItem = null;
		  Row currentRow = _templateTable.TableModel.Rows[e.Row];
		  CategoryItem currentItem = (CategoryItem)currentRow.Tag;

		  if (e.Column == 0) { // The Pattern column
			 currentItem.Value = e.Cell.Text;
		  } else if (e.Column == 1) { // The Type column
			 currentItem.Type = (CategoryItemType)Enum.Parse(typeof(CategoryItemType), e.Cell.Text);
		  } else if (e.Column == 2) { // The Category column
			 SetCategory(currentItem, e.Cell.Text);
		  }
	   }
Ejemplo n.º 56
0
	   void SetCategory(CategoryItem item, string formatCategoryName) {
		  Category cat = FindCategory(formatCategoryName);
		  if (cat == null) {
			 Category newCat = Category.FromFormat(formatCategoryName);
			 this.template.Add(newCat);
			 item.Parent = newCat;
			 item.Parent.Add(item);
			 AddCategoryToTree(newCat.Name);
		  } else {
			 item.Parent = cat;
			 item.Parent.Add(item);
		  }
	   }
Ejemplo n.º 57
0
	   private void newToolStripMenuItem_Click(object sender, EventArgs e) {
		  Category category = null;
		  if ((_categoryTree.SelectedNode != null) && (_categoryTree.SelectedNode.Name != "")) {
			 category = FindCategoryByName(_categoryTree.SelectedNode.Name);
			 if (category == null) {
				// this may be a middle node;
				Category newCat = Category.FromFormat(_categoryTree.SelectedNode.Name);
				this.template.Add(newCat);
//				AddCategoryToTree(newCat.Name);  // not necessary
				category = newCat;
			 }
		  } else {
			 category = orphan;
		  }
		  CategoryItem item = new CategoryItem();
		  item.Value = "Pattern " + (category.Items.Count + 1);
		  category.Add(item);
		  _templateTable.TableModel.Rows.Add(CategoryItemToRow(item));
	   }
Ejemplo n.º 58
0
	   public static EXListViewItem CategoryItemToListItem(CategoryItem item, Category category, ListViewGroup group){
		  EXListViewItem newItem = new EXListViewItem(item.Value);
		  newItem.SubItems.Add(new EXListViewSubItem(item.Type.ToString()));
		  newItem.Name = item.Value;
		  newItem.TagData = item;
		  if (category != null) { newItem.SubItems.Add(new EXListViewSubItem(category.Name)); }
		  if (group != null) { newItem.Group = group; }
		  return newItem;
	   }
Ejemplo n.º 59
0
	   public static Row CategoryItemToRow(CategoryItem item) {
		  string category = "";
		  if (item.Parent != null) { category = item.Parent.ToFormat(); }
		  Row result = new Row(new string[] { item.Value, item.Type.ToString(), category });
		  result.Tag = item;
		  return result;
	   }
Ejemplo n.º 60
0
    /// <summary>
    /// Iterates the recursive to save.
    /// </summary>
    /// <param name="parent">The parent.</param>
    /// <param name="priceMatrixItem">The price matrix item.</param>
    /// <param name="item">The item.</param>
    /// <param name="controlCollection">The control collection.</param>
    private static void IterateRecursiveToSave(Category parent, IPriceMatrixItem priceMatrixItem, Item item, ControlCollection controlCollection)
    {
      string key = item.Template.Key;

      if (key.Equals("pricematrix settings"))
      {
        Category category = null;
        if (priceMatrixItem is Category)
        {
          category = (Category)priceMatrixItem;
        }

        ChildList children = item.Children;
        foreach (Item child in children)
        {
          IPriceMatrixItem categoryChild = null;
          if (category != null)
          {
            categoryChild = category.GetElement(child.Name);
          }

          IterateRecursiveToSave(category, categoryChild, child, controlCollection);
        }
      }
      else if (key.Equals("pricematrix site"))
      {
        string itmId = item.Name;

        /*
                        siteIds += itmId + "|";
        */
        string defaultId = item["standardprice"];
        string defaultName = string.Empty;
        if (!string.IsNullOrEmpty(defaultId))
        {
          Item defaultItem = Sitecore.Context.ContentDatabase.GetItem(defaultId);
          if (defaultItem != null)
          {
            /*
                                    defaultName = defaultItem.Name;
            */
          }
        }

        Category category;
        if (priceMatrixItem is Category)
        {
          category = (Category)priceMatrixItem;
          category.Id = itmId;
        }
        else
        {
          category = new Category(itmId);
          if (parent != null)
          {
            parent.AddCategory(category);
          }
        }

        ChildList children = item.Children;
        foreach (Item child in children)
        {
          IPriceMatrixItem categoryChild = null;
          if (category != null)
          {
            categoryChild = category.GetElement(child.Name);
          }

          IterateRecursiveToSave(category, categoryChild, child, controlCollection);
        }
      }
      else if (key.Equals("pricematrix price"))
      {
        string aTitle = item["title"];
        if (string.IsNullOrEmpty(aTitle))
        {
          /*
                              aTitle = item.Name;
          */
        }

        string itmchildId = item.Name;
        string priceIds = string.Empty;

        /*
                        priceIds += itmchildId + "|";
        */
        string itmchildPrice = string.Empty;

        // Check that it indeed finds the textbox.
        if (controlCollection != null)
        {
          var textBox = Utils.MainUtil.FindControl(item.Parent.Name + "_" + itmchildId, controlCollection) as Text;
          if (textBox != null)
          {
            itmchildPrice = textBox.Value;
          }
        }

        CategoryItem categoryItem;
        if (priceMatrixItem is CategoryItem)
        {
          categoryItem = (CategoryItem)priceMatrixItem;
          categoryItem.Id = itmchildId;
          categoryItem.Amount = itmchildPrice;
        }
        else
        {
          categoryItem = new CategoryItem(itmchildId, itmchildPrice);
          if (parent != null)
          {
            parent.AddItem(categoryItem);
          }
        }
      }
    }