Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Needed to Create a Scrolling Ticker with LinkLabel Functionality

Needed to Create a Scrolling Ticker with LinkLabel Functionality

Scheduled Pinned Locked Moved C#
graphics
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honeyashu
    wrote on last edited by
    #1

    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
    
    J 1 Reply Last reply
    0
    • H honeyashu

      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
      
      J Offline
      J Offline
      Jacob D Dixon
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups