This is a migrated thread and some comments may be shown as answers.

Rotator with sliding images

4 Answers 84 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Chandrak
Top achievements
Rank 1
Chandrak asked on 22 Jul 2015, 12:02 PM

Hi,

 I want to have rotator with sliding images (including animated GIFs) (like ticker - left to right rotation). Here is my scenario.

 (1) Receive continuous data from socket (no need to implement in sample code) in a thread. This thread in turn will add predefined images in the rotator based on data received. This means that this thread will keep on adding images to rotator 24X7 while rotator is rotating. 

(2) Will any overflow occur in rotator as end number of images will be added during day? If there is limit, code should remove items from rotator if limit breach. 

(3) I also want some label on top of each image where I can set some text.

 Can we add any control dynamically in rotator, and it rotate like ticker? If yes I need some sample code on that too please. 

 

Best Regards

Chandrak

4 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 27 Jul 2015, 11:48 AM
Hi ,

Thank you for writing.

RadRotator supports gif files and you can also add them at runtime by simply accessing RadRotator.Items collection. 

In order to add a label for each image, you would need to create a RadLabelElement and add it to the Children collection of the RotatorElement. The code snippet below should position a label element in the middle of the image: 
public Form1()
{
    InitializeComponent();

    PopulateRotator();
     
    label.Text = "label";
    label.StretchHorizontally = false;
    label.StretchVertically = false;
    CalcLabelLocation();
    radRotator1.RotatorElement.Children.Add(label);
     
    radRotator1.SizeChanged += new EventHandler(radRotator1_SizeChanged);
      
    radRotator1.Start();
}
  
void radRotator1_SizeChanged(object sender, EventArgs e)
{
    CalcLabelLocation();
}
  
private void CalcLabelLocation()
{
   int x = radRotator1.Location.X + radRotator1.Width / 2 - label.Size.Width /2;
   int y = radRotator1.Location.Y + radRotator1.Height / 2 - label.Size.Height/2;
   label.Location= new Point(x, y);
}

As to your other question about the end number of images, I tested with 5000 and RadRotator performed as expected. However I am not sure how you are going to handle these requests, and memory within your whole application, you can check the following resource providing additional information: Memory Management NET

I would also like to kindly ask you to restrain from posting the same question numerous times in order to avoid spamming the forums. Pick the correct product for your question and post in the appropriate forum.

I hope this information helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Chandrak
Top achievements
Rank 1
answered on 28 Jul 2015, 02:19 AM

Hi,

 First of all sorry for multiple same questions. My project deadline is near and I did not get answer in 1-2 days. I dont think that this is what I wanted (not tested but sure it wont satisfy my requirement). What I want is to have ticker effect (not just rotation one by one).

This post is what I needed.

http://www.telerik.com/forums/using-rotator-to-scroll-text

Rotating-items.zip

I have tried adding images and it works as expected.

public Form1()
        {
            InitializeComponent();

            for (int i = 0; i < 20; i++)
            {
                LightVisualElement li = new LightVisualElement();
                li.Image = new Bitmap(Image.FromFile("C:\\cbaxi1.jpg"));
                this.myNewsReader1.Items.Add(li);
                this.myNewsReader1.Items.Add(new LightVisualElement() { Text = " | "});
            }

        } 

 

Can you help me modify this one to add labels on top of images which I need to populate at run time. ​Also when user moves mouse over the control, it should pause and allow user to click on the image (with some unique value attached to every image) and cause one general click function to be executed where I can read which image (value of the image) was clicked.

Also some mechanism to remove image after 100 image and label load in the control. Say when I add 101 image it should remove the first one.. so total image count stay at 100. All these operation needs to be done in a worker thread. Images and labels will also be added on the fly on demand.

Your help is appreciated.

 

0
Chandrak
Top achievements
Rank 1
answered on 29 Jul 2015, 09:29 AM

Did it myself... thanks anyways.

0
Hristo
Telerik team
answered on 29 Jul 2015, 12:04 PM
Hi Chandrak,

Thank you for writing back.

If I understand correctly, you have managed to resolve your issue. 

Please let me know if you need additional information or further assistance.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Rotator
Asked by
Chandrak
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Chandrak
Top achievements
Rank 1
Share this question
or