Ejemplo n.º 1
0
        public FeedMs(Vector2 size, TextBlob tBlob, Shared.GetFont titleFont, Shared.GetFont dateFont, Shared.GetFont bodyFont)
            : base(size)
        {
            this.titleFont = titleFont;
            this.dateFont  = dateFont;
            this.bodyFont  = bodyFont;

            this.textBlob = tBlob;

            titleBlob = new TextBlob(titleFont, "", 160);
            dateBlob  = new TextBlob(dateFont, "", 160);

            size.Y  = (tBlob.NumLines - 1 + 1) * tBlob.TotalSpacing;
            size.Y += bodyFont().LineSpacing;
            if (titleBlob != null)
            {
                size.Y += titleBlob.TotalSpacing + titleFont().LineSpacing;
            }
            if (dateBlob != null)
            {
                size.Y += dateBlob.TotalSpacing + dateFont().LineSpacing;
            }
            base.Height = size.Y;

            titleBlob.Justification = UIGridElement.Justification.Left;
            dateBlob.Justification  = UIGridElement.Justification.Left;
        }
Ejemplo n.º 2
0
        public List <FeedMs> GetFeedList(int width, Shared.GetFont titleFont, Shared.GetFont dateFont, Shared.GetFont bodyFont)
        {
            TextBlob textBlob = new TextBlob(bodyFont, "label", width);

            //parse JSON string into List of Dictionaries.
            List <FeedMs> allFeeds = new List <FeedMs>();

            try
            {
#if NETFX_CORE
                // For some reason the WinRT Json Serializer doesn't want to
                // deserialize our objects so we'll just have to do it manually.
                //var items = Deserialize<List<Dictionary<string, string>>>(rawGetData);

                List <Dictionary <string, string> > items = HackDeserialize(rawGetData);
#else
                var js    = new System.Web.Script.Serialization.JavaScriptSerializer();
                var items = js.Deserialize <List <Dictionary <string, string> > >(rawGetData);
#endif

                //build news feed.
                foreach (var item in items)
                {
                    FeedMs feedItem = new FeedMs(new Vector2(24, 0), textBlob, titleFont, dateFont, bodyFont);
                    feedItem.Title      = item["Title"];
                    feedItem.Body       = item["Text"];
                    feedItem.DateString = item["Date"];
                    feedItem.CreateHyperlink(HyperlinkType.URL, Strings.Localize("mainMenu.readMoreHere"), item["URL"]);
                    allFeeds.Add(feedItem);
                }
            }
            catch { }
            return(allFeeds);
        }
Ejemplo n.º 3
0
        public bool AddFeed(string rawData, ref List <FeedMs> msFeed, int width, Shared.GetFont tFont, Shared.GetFont dFont, Shared.GetFont bFont)
        {
            char lastChar;
            char nextChar;

            TextBlobHL TextBlobHL = new TextBlobHL(bFont, "label", width);
            FeedMs     feedItem   = null;

            currentFeedSection = FeedSection.keyNone;
            if (rawData.StartsWith("\"" + keyTitle + "\""))
            {
                feedItem = new FeedMs(new Vector2(24, 0), TextBlobHL, tFont, dFont, bFont);
                string[] delimiterChars = { "\":\"", "\",\"" };
                string[] fields         = rawData.Split(delimiterChars, StringSplitOptions.None);
                foreach (string field in fields)
                {
                    nextChar = field[field.Length - 1];
                    if (currentFeedSection != FeedSection.keyNone)
                    {
                        ProcessKey(ref feedItem, field, currentFeedSection);
                        currentFeedSection = FeedSection.keyNone;
                    }
                    else if (field.Contains("\"" + keyTitle))
                    {
                        currentFeedSection = FeedSection.keyTitle;
                    }
                    else if (field.Contains(keyText))
                    {
                        currentFeedSection = FeedSection.keyText;
                    }
                    else if (field.Contains(keyLink))
                    {
                        currentFeedSection = FeedSection.keyLink;
                    }
                    else if (field.Contains(keyTwitter))
                    {
                        currentFeedSection = FeedSection.keyTwitter;
                    }
                    else if (field.Contains(keyDate))
                    {
                        currentFeedSection = FeedSection.keyDate;
                    }
                    lastChar = field[0];
                }
                msFeed.Add(feedItem);
            }


            return(true);
        }
Ejemplo n.º 4
0
        public FeedMs(Vector2 size, string text, Shared.GetFont tFont, Shared.GetFont dFont, Shared.GetFont bFont)
            : base(size)
        {
            titleFont = tFont;
            dateFont  = dFont;
            bodyFont  = bFont;

            textBlob       = new TextBlob(bodyFont, text, 150);
            textBlob.Width = (int)size.X;

            titleBlob = new TextBlob(titleFont, "", 160);
            dateBlob  = new TextBlob(dateFont, "", 160);

            size.Y      = (textBlob.NumLines - 1) * textBlob.TotalSpacing;
            size.Y     += bodyFont().LineSpacing;
            size.Y     += GetTitleHeightOffset();
            size.Y     += GetDateHeightOffset();
            base.Height = size.Y;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Long for c'tor for use with a drop shadow.
 /// </summary>
 public UIGridModularIntegerSliderElement(float width, float height, float edgeSize, string normalMapName, Color baseColor, string label, Shared.GetFont font, Justification justify, Color textColor, Color dropShadowColor, bool invertDropShadow)
     : base(width, height, edgeSize, normalMapName, baseColor, label, font, justify, textColor, dropShadowColor, invertDropShadow)
 {
 }
        /// <summary>
        /// Long for c'tor for use with a drop shadow.
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="edgeSize"></param>
        /// <param name="normalMapName"></param>
        /// <param name="baseColor"></param>
        /// <param name="label"></param>
        /// <param name="justify"></param>
        /// <param name="textColor"></param>
        /// <param name="dropShadowColor"></param>
        /// <param name="invertDropShadow"></param>
        public UIGridPictureListElement(float width, float height, float edgeSize, string normalMapName, Color baseColor, string label, Shared.GetFont font, Justification justify, Color textColor, Color dropShadowColor, bool invertDropShadow)
        {
            this.width     = width;
            this.height    = height;
            this.edgeSize  = edgeSize;
            this.baseColor = baseColor.ToVector4();

            this.normalMapName = normalMapName;

            this.Font             = font;
            this.label            = label;
            this.justify          = justify;
            this.textColor        = textColor;
            this.dropShadowColor  = dropShadowColor;
            useDropShadow         = true;
            this.invertDropShadow = invertDropShadow;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Long form c'tor for use with no drop shadow.
 /// </summary>
 public UIGridModularFloatSliderElement(float width, float height, float edgeSize, string normalMapName, Color baseColor, string label, Shared.GetFont font, Justification justify, Color textColor)
     : base(width, height, edgeSize, normalMapName, baseColor, label, font, justify, textColor)
 {
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Long form c'tor for use with no drop shadow.
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="edgeSize"></param>
        /// <param name="normalMapName"></param>
        /// <param name="baseColor"></param>
        /// <param name="label"></param>
        /// <param name="justify"></param>
        /// <param name="textColor"></param>
        public UIGrid2DTextElement2(float width, float height, float edgeSize, string normalMapName, Color baseColor, string label, Shared.GetFont font, Justification justify, Color textColor)
        {
            this.width     = width;
            this.height    = height;
            this.edgeSize  = edgeSize;
            this.baseColor = baseColor.ToVector4();

            this.normalMapName = normalMapName;

            this.Font      = font;
            this.label     = label;
            this.justify   = justify;
            this.textColor = textColor;
            useDropShadow  = false;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Long for c'tor for use with a drop shadow.
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="edgeSize"></param>
        /// <param name="normalMapName"></param>
        /// <param name="baseColor"></param>
        /// <param name="label"></param>
        /// <param name="justify"></param>
        /// <param name="textColor"></param>
        /// <param name="dropShadowColor"></param>
        /// <param name="invertDropShadow"></param>
        public UIGridBaseModularSliderElement(float width, float height, float edgeSize, string normalMapName, Color baseColor, string label, Shared.GetFont font, Justification justify, Color textColor, Color dropShadowColor, bool invertDropShadow)
        {
            this.width    = width;
            this.height   = height;
            this.edgeSize = edgeSize;
            //this.baseColor = baseColor.ToVector4();

            this.normalMapName = normalMapName;

            this.Font             = font;
            this.label            = TextHelper.FilterInvalidCharacters(label);
            this.justify          = justify;
            this.textColor        = textColor;
            this.dropShadowColor  = dropShadowColor;
            useDropShadow         = true;
            this.invertDropShadow = invertDropShadow;
        }