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; }
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; }
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; }