private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            OnPropertyChanged("Styles");
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                if (e.NewItems != null)
                {
                    foreach (var newItem in e.NewItems.OfType <ComplexStyle>())
                    {
                        newItem.PropertyChanged += ItemChangedProperty;
                    }
                }
                HasItems = true;
                break;

            case NotifyCollectionChangedAction.Remove:
                if (e.OldItems != null)
                {
                    foreach (var olditem in e.OldItems.OfType <ComplexStyle>())
                    {
                        olditem.PropertyChanged -= ItemChangedProperty;
                    }
                }
                HasItems = Styles.Any(); break;

            case NotifyCollectionChangedAction.Reset:
                HasItems = false; break;
            }
        }
예제 #2
0
        public Style AddStyle(Style style)
        {
            style.StyleId = Styles.Any() ? Styles.Max(s => s.StyleId) + 1 : 1;
            Styles.Add(style);

            return(style);
        }
        private string BundleHtml()
        {
            var result = new StringBuilder();
            var hash   = "";

            if (Scripts.Any())
            {
                hash = GetHash(Scripts);
            }
            else if (Styles.Any())
            {
                hash = GetHash(Styles);
            }

            var path    = string.Format("~{0}{1}-{2}", BundleHelper.BUNDLE_VPATH, GetCategory(CategoryName), hash);
            var pathcss = path + ".css";
            var pathjs  = path + ".js";

            var bundlecss = BundleHelper.GetCssBundle(pathcss);
            var bundlejs  = BundleHelper.GetJsBundle(pathjs);

            if (bundlecss == null && bundlejs == null)
            {
                if (Styles.Any())
                {
                    bundlecss = BundleHelper.CssBundle(pathcss);
                    foreach (var style in Styles)
                    {
                        bundlecss.Include(style);
                    }
                    BundleHelper.AddBundle(bundlecss);
                }

                if (Scripts.Any())
                {
                    bundlejs = BundleHelper.JsBundle(pathjs);
                    foreach (var script in Scripts)
                    {
                        bundlejs.Include(script, true);
                    }
                    BundleHelper.AddBundle(bundlejs);
                }
            }

            if (bundlecss != null)
            {
                result.AppendLine(BundleHelper.HtmlLink(pathcss));
            }
            if (bundlejs != null)
            {
                result.AppendLine(BundleHelper.HtmlScript(pathjs));
            }
            return(result.ToString());
        }
예제 #4
0
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement(nameof(DirectedGraph), Namespace);
            writer.WriteAttributeIfNotNull(nameof(Title), Title);
            writer.WriteAttributeIfNotNull(nameof(Background), Background);

            writer.WriteStartElement(nameof(Nodes));
            foreach (var node in Nodes)
            {
                node.WriteXml(writer);
            }
            writer.WriteEndElement();

            writer.WriteStartElement(nameof(Links));
            foreach (var link in Links)
            {
                link.WriteXml(writer);
            }
            writer.WriteEndElement();

            if (Categories.Any())
            {
                writer.WriteStartElement(nameof(Categories));
                foreach (var category in Categories)
                {
                    category.WriteXml(writer);
                }
                writer.WriteEndElement();
            }

            if (Styles.Any())
            {
                writer.WriteStartElement(nameof(Styles));
                foreach (var style in Styles)
                {
                    style.WriteXml(writer);
                }
                writer.WriteEndElement();
            }

            if (Properties.Any())
            {
                writer.WriteStartElement(nameof(Properties));
                foreach (var property in Properties)
                {
                    property.WriteXml(writer);
                }
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
예제 #5
0
        private static string BuildStyles()
        {
            if (!Styles.Any())
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder();

            //sb.Append($@"<style type=""text/css"">");

            foreach (var css in Styles)
            {
                sb.Append($@"{css}");
            }

            //sb.Append($@"</style>");

            return(sb.ToString());
        }
예제 #6
0
 public bool ShouldSerializeStyles() => Styles.Any();
예제 #7
0
        protected override UriQuery GetUriQuery()
        {
            UriQuery query = base.GetUriQuery();

            if (!string.IsNullOrEmpty(ArtistPick))
            {
                query.Add("artist_pick", ArtistPick);
            }

            if (Variety.HasValue)
            {
                query.Add("variety", Variety.Value);
            }

            if (!string.IsNullOrEmpty(Distribution))
            {
                query.Add("distribution", Distribution);
            }

            if (Adventurousness.HasValue)
            {
                query.Add("adventurousness", Adventurousness.Value);
            }

            if (!string.IsNullOrEmpty(SeedCatalog))
            {
                query.Add("seed_catalog", SeedCatalog);
            }

            if (Description.Any())
            {
                foreach (Term description in Description)
                {
                    query.Add("description", description);
                }
            }

            if (Styles.Any())
            {
                foreach (Term style in Styles)
                {
                    query.Add("style", style);
                }
            }

            if (Moods.Any())
            {
                foreach (Term mood in Moods)
                {
                    query.Add("mood", mood);
                }
            }

            if (MaxTempo.HasValue)
            {
                query.Add("max_tempo", MaxTempo.Value);
            }

            if (MinTempo.HasValue)
            {
                query.Add("min_tempo", MinTempo.Value);
            }

            if (MaxLoudness.HasValue)
            {
                query.Add("max_loudness", MaxLoudness.Value);
            }

            if (MinLoudness.HasValue)
            {
                query.Add("min_loudness", MinLoudness.Value);
            }

            if (ArtistMaxFamiliarity.HasValue)
            {
                query.Add("artist_max_familiarity", ArtistMaxFamiliarity.Value);
            }

            if (ArtistMinFamiliarity.HasValue)
            {
                query.Add("artist_min_familiarity", ArtistMinFamiliarity.Value);
            }

            if (!string.IsNullOrEmpty(ArtistEndYearAfter))
            {
                query.Add("artist_end_year_after", ArtistEndYearAfter);
            }

            if (!string.IsNullOrEmpty(ArtistEndYearBefore))
            {
                query.Add("artist_end_year_before", ArtistEndYearBefore);
            }

            if (!string.IsNullOrEmpty(ArtistStartYearAfter))
            {
                query.Add("artist_start_year_after", ArtistStartYearAfter);
            }

            if (!string.IsNullOrEmpty(ArtistStartYearBefore))
            {
                query.Add("artist_start_year_before", ArtistStartYearBefore);
            }

            if (SongMaxHotttnesss.HasValue)
            {
                query.Add("song_max_hotttnesss", SongMaxHotttnesss.Value);
            }

            if (SongMinHotttnesss.HasValue)
            {
                query.Add("song_min_hotttnesss", SongMinHotttnesss.Value);
            }

            if (ArtistMaxHotttnesss.HasValue)
            {
                query.Add("artist_max_hotttnesss", ArtistMaxHotttnesss.Value);
            }

            if (ArtistMinHotttnesss.HasValue)
            {
                query.Add("artist_min_hotttnesss", ArtistMinHotttnesss.Value);
            }

            if (MaxLongitude.HasValue)
            {
                query.Add("max_longitude", MaxLongitude.Value);
            }

            if (MinLongitude.HasValue)
            {
                query.Add("min_longitude", MinLongitude.Value);
            }

            if (MaxLatitude.HasValue)
            {
                query.Add("max_latitude", MaxLatitude.Value);
            }

            if (MinLatitude.HasValue)
            {
                query.Add("min_latitude", MinLatitude.Value);
            }

            if (MaxDanceability.HasValue)
            {
                query.Add("max_danceability", MaxDanceability.Value);
            }

            if (MinDanceability.HasValue)
            {
                query.Add("min_danceability", MinDanceability.Value);
            }

            if (MaxEnergy.HasValue)
            {
                query.Add("max_energy", MaxEnergy.Value);
            }

            if (MinEnergy.HasValue)
            {
                query.Add("min_energy", MinEnergy.Value);
            }

            if (!string.IsNullOrEmpty(Mode))
            {
                query.Add("mode", Mode);
            }

            if (!string.IsNullOrEmpty(Key))
            {
                query.Add("key", Key);
            }

            if (!string.IsNullOrEmpty(Sort))
            {
                query.Add("sort", Sort);
            }

            return(query);
        }
예제 #8
0
        public override string ToString()
        {
            UriQuery query = new UriQuery(BaseUrl);

            query.Add("api_key", ApiKey);
            query.Add("format", "json");

            if (!string.IsNullOrEmpty(Title))
            {
                query.Add("title", Title);
            }

            if (!string.IsNullOrEmpty(Artist))
            {
                query.Add("artist", Artist);
            }

            if (!string.IsNullOrEmpty(Combined))
            {
                query.Add("combined", Combined);
            }

            if (Description.Any())
            {
                foreach (var description in Description)
                {
                    query.Add("description", description);
                }
            }

            if (Styles.Any())
            {
                foreach (var style in Styles)
                {
                    query.Add("style", style);
                }
            }

            if (Moods.Any())
            {
                foreach (var mood in Moods)
                {
                    query.Add("mood", mood);
                }
            }

            if (!string.IsNullOrEmpty(RankType))
            {
                query.Add("rank_type", RankType);
            }

            if (!string.IsNullOrEmpty(ArtistID))
            {
                query.Add("artist_id", ArtistID);
            }

            if (Results.HasValue)
            {
                query.Add("results", Results.Value);
            }

            if (Start.HasValue)
            {
                query.Add("start", Start.Value);
            }

            if (MaxTempo.HasValue)
            {
                query.Add("max_tempo", MaxTempo.Value);
            }

            if (MinTempo.HasValue)
            {
                query.Add("min_tempo", MinTempo.Value);
            }

            if (MaxLoudness.HasValue)
            {
                query.Add("max_loudness", MaxLoudness.Value);
            }

            if (MinLoudness.HasValue)
            {
                query.Add("min_loudness", MinLoudness.Value);
            }

            if (ArtistMaxFamiliarity.HasValue)
            {
                query.Add("artist_max_familiarity", ArtistMaxFamiliarity.Value);
            }

            if (ArtistMinFamiliarity.HasValue)
            {
                query.Add("artist_min_familiarity", ArtistMinFamiliarity.Value);
            }

            if (!string.IsNullOrEmpty(ArtistEndYearAfter))
            {
                query.Add("artist_end_year_after", ArtistEndYearAfter);
            }

            if (!string.IsNullOrEmpty(ArtistEndYearBefore))
            {
                query.Add("artist_end_year_before", ArtistEndYearBefore);
            }

            if (!string.IsNullOrEmpty(ArtistStartYearAfter))
            {
                query.Add("artist_start_year_after", ArtistStartYearAfter);
            }

            if (!string.IsNullOrEmpty(ArtistStartYearBefore))
            {
                query.Add("artist_start_year_before", ArtistStartYearBefore);
            }

            if (SongMaxHotttnesss.HasValue)
            {
                query.Add("song_max_hotttnesss", SongMaxHotttnesss.Value);
            }

            if (SongMinHotttnesss.HasValue)
            {
                query.Add("song_min_hotttnesss", SongMinHotttnesss.Value);
            }

            if (ArtistMaxHotttnesss.HasValue)
            {
                query.Add("artist_max_hotttnesss", ArtistMaxHotttnesss.Value);
            }

            if (ArtistMinHotttnesss.HasValue)
            {
                query.Add("artist_min_hotttnesss", ArtistMinHotttnesss.Value);
            }

            if (MaxLongitude.HasValue)
            {
                query.Add("max_longitude", MaxLongitude.Value);
            }

            if (MinLongitude.HasValue)
            {
                query.Add("min_longitude", MinLongitude.Value);
            }

            if (MaxLatitude.HasValue)
            {
                query.Add("max_latitude", MaxLatitude.Value);
            }

            if (MinLatitude.HasValue)
            {
                query.Add("min_latitude", MinLatitude.Value);
            }

            if (MaxDanceability.HasValue)
            {
                query.Add("max_danceability", MaxDanceability.Value);
            }

            if (MinDanceability.HasValue)
            {
                query.Add("min_danceability", MinDanceability.Value);
            }

            if (MaxEnergy.HasValue)
            {
                query.Add("max_energy", MaxEnergy.Value);
            }

            if (MinEnergy.HasValue)
            {
                query.Add("min_energy", MinEnergy.Value);
            }

            if (!string.IsNullOrEmpty(Mode))
            {
                query.Add("mode", Mode);
            }

            if (!string.IsNullOrEmpty(Key))
            {
                query.Add("key", Key);
            }

            if (Bucket.HasValue)
            {
                foreach (var bucket in Bucket.Value.GetBucketDescriptions())
                {
                    query.Add("bucket", bucket);
                }
            }

            if (!string.IsNullOrEmpty(Sort))
            {
                query.Add("sort", Sort);
            }

            if (Limit.HasValue)
            {
                query.Add("limit", Limit.Value.ToString().ToLower());
            }

            return(query.ToString());
        }