Needed to Create a Scrolling Ticker with LinkLabel Functionality
-
Hi, In my project I use a ticker to display feeds which get displayed in a scrolling way. In this we are converting the string to be displayed in BitmapImage and adding it up to the ticker by drawing in it.. Attached is the needed code with the message.: What i need is the image which we are displaying on clicking on it will open up the URL (which is actually the string now converted to image). i.e. on clicking that scrolling tick will open the displayed URL. To create bitmap image of the string
private Image CreateBitMapImage(string upText, string downText, int trend)
{
Image trendImage;
ImageAttributes iaTrend;
if (trend > 0 && _ticker.UpTrendImage != null)
{
trendImage = (Image)_ticker.UpTrendImage.Clone();
iaTrend = _ticker.IaUpTrend;
}
else if (trend == 0 && _ticker.NoTrendImage != null)
{
trendImage = (Image)_ticker.NoTrendImage.Clone();
iaTrend = _ticker.IaNoTrend;
}
else
{
trendImage = (Image)_ticker.DownTrendImage.Clone();
iaTrend = _ticker.IaDownTrend;
}Bitmap b = new Bitmap(1, 1); Font f = \_ticker.Font; Graphics graphics; SolidBrush textBrush = new SolidBrush(\_ticker.ForeColor); graphics = Graphics.FromImage(b); try { int width = (int)graphics.MeasureString(upText + downText, f).Width + \_ticker.UpTrendImage.Width; //int height = Height - Padding.Bottom - Padding.Top; Rectangle \_rect = new Rectangle((int)graphics.MeasureString(upText + downText, f).Width, 0, trendImage.Width, \_ticker.Height); b = new Bitmap(b, new Size(width, \_ticker.Height)); graphics = Graphics.FromImage(b); graphics.DrawString(upText, f, textBrush, 0, 0); graphics.DrawString(downText, f, textBrush, (int)graphics.MeasureString(upText, f).Width, \_ticker.DownTrendRectY); graphics.DrawImage(trendImage, \_rect, 0, 0, trendImage.Width, trendImage.Height, GraphicsUnit.Pixel, iaTrend); return b; } catch (Exception \_e
-
Hi, In my project I use a ticker to display feeds which get displayed in a scrolling way. In this we are converting the string to be displayed in BitmapImage and adding it up to the ticker by drawing in it.. Attached is the needed code with the message.: What i need is the image which we are displaying on clicking on it will open up the URL (which is actually the string now converted to image). i.e. on clicking that scrolling tick will open the displayed URL. To create bitmap image of the string
private Image CreateBitMapImage(string upText, string downText, int trend)
{
Image trendImage;
ImageAttributes iaTrend;
if (trend > 0 && _ticker.UpTrendImage != null)
{
trendImage = (Image)_ticker.UpTrendImage.Clone();
iaTrend = _ticker.IaUpTrend;
}
else if (trend == 0 && _ticker.NoTrendImage != null)
{
trendImage = (Image)_ticker.NoTrendImage.Clone();
iaTrend = _ticker.IaNoTrend;
}
else
{
trendImage = (Image)_ticker.DownTrendImage.Clone();
iaTrend = _ticker.IaDownTrend;
}Bitmap b = new Bitmap(1, 1); Font f = \_ticker.Font; Graphics graphics; SolidBrush textBrush = new SolidBrush(\_ticker.ForeColor); graphics = Graphics.FromImage(b); try { int width = (int)graphics.MeasureString(upText + downText, f).Width + \_ticker.UpTrendImage.Width; //int height = Height - Padding.Bottom - Padding.Top; Rectangle \_rect = new Rectangle((int)graphics.MeasureString(upText + downText, f).Width, 0, trendImage.Width, \_ticker.Height); b = new Bitmap(b, new Size(width, \_ticker.Height)); graphics = Graphics.FromImage(b); graphics.DrawString(upText, f, textBrush, 0, 0); graphics.DrawString(downText, f, textBrush, (int)graphics.MeasureString(upText, f).Width, \_ticker.DownTrendRectY); graphics.DrawImage(trendImage, \_rect, 0, 0, trendImage.Width, trendImage.Height, GraphicsUnit.Pixel, iaTrend); return b; } catch (Exception \_e
Just an idea... but when you are adding the Image to the Ticker, why don't you pass along the URL that is associated with the Image and set the "Tag" attribute to the URL. That way when the Image is clicked you can get the URL from that.