Example #1
0
        /// <summary>
        /// Set the current item
        /// </summary>
        /// <param name="guid">The guid of the item</param>
        /// <returns>true if the new item is set, false otherwise</returns>
        //public bool SetCurrent(Guid guid)
        //{
        //    var item = Items.Where(x => x.Guid == guid);
        //    if (item.Any())
        //    {
        //        IItem newItem = item.First();
        //        CurrentItem = newItem;

        //        //ResourceDictionary theme = Application.Current.MainWindow.Resources.MergedDictionaries[0];
        //        //ResourceDictionary appTheme = Application.Current.Resources.MergedDictionaries.Count > 0
        //        //                                  ? Application.Current.Resources.MergedDictionaries[0]
        //        //                                  : null;
        //        //theme.BeginInit();
        //        //theme.MergedDictionaries.Clear();
        //        //if (appTheme != null)
        //        //{
        //        //    appTheme.BeginInit();
        //        //    appTheme.MergedDictionaries.Clear();
        //        //}
        //        //else
        //        //{
        //        //    appTheme = new ResourceDictionary();
        //        //    appTheme.BeginInit();
        //        //    Application.Current.Resources.MergedDictionaries.Add(appTheme);
        //        //}
        //        //foreach (Uri uri in newTheme.UriList)
        //        //{
        //        //    ResourceDictionary newDict = new ResourceDictionary {Source = uri};
        //        //    /*AvalonDock and menu style needs to move to the application
        //        //     * 1. AvalonDock needs global styles as floatable windows can be created
        //        //     * 2. Menu's need global style as context menu can be created
        //        //    */
        //        //    if (uri.ToString().Contains("AvalonDock") ||
        //        //        uri.ToString().Contains("Wide;component/Interfaces/Styles/VS2012/Menu.xaml"))
        //        //    {
        //        //        appTheme.MergedDictionaries.Add(newDict);
        //        //    }
        //        //    else
        //        //    {
        //        //        theme.MergedDictionaries.Add(newDict);
        //        //    }
        //        //}
        //        //appTheme.EndInit();
        //        //theme.EndInit();
        //        _logger.Log("projectfile item set to " + newItem.Name, LogCategory.Info, LogPriority.None);
        //        _eventAggregator.GetEvent<ItemChangeEvent>().Publish(newItem);
        //    }
        //    return false;
        //}

        /// <summary>
        /// Adds a base item to the project-file manager
        /// </summary>
        /// <param name="theme">The item to add</param>
        /// <returns>true, if successful - false, otherwise</returns>
        public bool AddAtlas(AtlasModel Atlas)
        {
            if (!Atlass.Contains(Atlas))
            {
                Atlass.Add(Atlas);
                return(true);
            }
            return(false);
        }
Example #2
0
        public List <JOffer> GetAtlassOffers(string siteSource)
        {
            Console.WriteLine("-->GetOfferCount Started");
            try
            {
                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(siteSource);
                Console.WriteLine("--<GetOffer attr Started");
                HtmlNodeCollection offersFound = doc.DocumentNode.SelectNodes(".//div[@data-price]");

                //HtmlNode offerFound = doc.DocumentNode.SelectNodes(".//div[@data-price]");

                List <JOffer> offers = new List <JOffer>();
                if (offersFound != null)
                {
                    foreach (HtmlNode divNode in offersFound)
                    {
                        HtmlAttribute price    = divNode.Attributes["data-price"];
                        HtmlAttribute category = divNode.Attributes["data-acriss"];
                        //HtmlAttribute supplier = supplierInfo.Attributes["data-acriss"];
                        string supplier = divNode.SelectNodes(".//div[@class='overlay']//ul//li//a").ElementAt(2).Attributes["href"].Value.Split('/').Last();

                        JOffer offer = new JOffer(Atlass.GetSupplier(supplier), price.Value);

                        offer.SetCategory(category.Value);
                        offers.Add(offer);
                    }
                    Console.WriteLine("--<GetOffer attr Finished");
                    return(offers);
                }
                else
                {
                    return(offers);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Offers not found");
                return(null);
            }
        }