Beispiel #1
0
        /// <summary>
        ///  Creates a ContentPresent that shows the given content with the given static resource.
        /// </summary>
        private static ContentPresenter CreateControlUsingResource(object contentToShow,
                                                                   string staticResourceName)
        {
            var controlForSection = new ContentPresenter()
            {
                Content = contentToShow,
            };

            controlForSection.SetResourceReference(ContentPresenter.ContentTemplateProperty,
                                                   staticResourceName);
            return(controlForSection);
        }
Beispiel #2
0
        public FrameworkElement GetSmile(string id)
        {
            ContentPresenter cp = new ContentPresenter();
            Smile            bi = null;

            if (!SmilesBmp.TryGetValue(id, out bi))
            {
                if (SmilesUri.ContainsKey(id))
                {
                    bi = new Smile()
                    {
                        Image = new BitmapImage(SmilesUri[id]),
                        Uri   = SmilesUri[id],
                        Id    = id
                    };
                    //bi.ta
                    SmilesBmp[id] = bi;
                }
                else
                {
                    return(null);
                }
            }

            cp.Content = bi;
            cp.SetResourceReference(ContentPresenter.ContentTemplateProperty, "SmileStyle2");
            return(cp);



            //Image img = new Image();// { Height = 24.0, IsHitTestVisible = false };
            //BitmapImage bi;

            //if (SmilesBmp.TryGetValue(id, out bi)) {
            //    img.Source = bi;
            //} else
            //    if (SmilesUri.ContainsKey(id)) {
            //        bi = new BitmapImage(SmilesUri[id]);
            //        img.Source = bi;

            //        SmilesBmp[id] = bi;
            //    } else
            //        return null;

            //img.SetResourceReference(Image.StyleProperty, "SmileStyle");
            //return img;
        }
Beispiel #3
0
        public FrameworkElement GetSmile(string id)
        {
            ContentPresenter cp = new ContentPresenter();
            Smile            bi = null;

            for (int j = 0; j < Smiles.Length; ++j)
            {
                if (Smiles[j].Regex.IsMatch(id))
                {
                    bi = new Smile()
                    {
                        Image = new BitmapImage(Smiles[j].Uri),
                        Uri   = Smiles[j].Uri,
                        Id    = id
                    };

                    cp.Content = bi;
                    cp.SetResourceReference(ContentPresenter.ContentTemplateProperty, "SmileStyle2");
                    return(cp);
                }
            }

            return(null);
        }