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

custom listviewItem refresh not dispaly

1 Answer 135 Views
ListView
This is a migrated thread and some comments may be shown as answers.
cloud
Top achievements
Rank 1
cloud asked on 18 Jul 2012, 01:56 AM
I have a Problem 

Click the minimize button, then click the maximize button, list item is not displayed.

p1.jpg is normal .
p2 is click the minize button .
private void Form1_Load(object sender, EventArgs e)
     {
         this.radListView1.ItemSize = new Size(200, 300);
         this.radListView1.AllowArbitraryItemHeight = true;
         this.radListView1.ItemSpacing = 5;
         this.radListView1.EnableKineticScrolling = false;
         this.radListView1.ListViewElement.ViewElement.ViewElement.Margin = new Padding(1, 1, 0, 0);
         this.radListView1.ListViewElement.ViewElement.Orientation = Orientation.Vertical;
         this.radListView1.AllowEdit = false;
         this.radListView1.Width = 210;
         for (int i = 0; i < 5; i++)
         {
             ListViewDataItem t = new ListViewDataItem();
             t.Tag = new string[] {"Name " + i.ToString(), "23", "uiui"};
              
             this.radListView1.Items.Add(t);
         }
     }
 
     private void radListView1_VisualItemCreating(object sender, ListViewVisualItemCreatingEventArgs e)
     {
         e.VisualItem = new CustomVisualItem();
     }
namespace TestListView
{
    internal class CustomVisualItem : IconListViewVisualItem
    {
        private LightVisualElement imageElement;
         private LightVisualElement titleElement;
         private LightVisualElement artistElement;
        private StackLayoutPanel stackLayout;
 
         
 
        // the base image of the radar
        // this saves time/cycles, b/c we only have to draw the
        // background of the radar once (and update it as necessary)
        Image _baseImage;
        // the final rendered image of the radar
        Image _outputImage;
 
        // the azimuth of the radar
        int _az = 0;
        // some internally used points for drawing the fade
        // of the radar scanline
        PointF _pt = new PointF(0F, 0F);
        PointF _pt2 = new PointF(1F, 1F);
        PointF _pt3 = new PointF(2F, 2F);
 
        Color _topColor = Color.FromArgb(0, 120, 0);
        Color _bottomColor = Color.FromArgb(0, 40, 0);
        Color _lineColor = Color.FromArgb(0, 255, 0);
        int _size = 200;
        private Timer _timer;
 
        // do draw the scanline or not to draw the scanline?
        bool _scanLine = false;
 
 
        public CustomVisualItem()
        {
            _timer = new Timer();
            _timer.Tick += new EventHandler(_timer_Tick);
           // _timer.Interval = 40;
 
            _timer.Interval = 625;
            CreateBaseImage();
            DrawScanLine = false;
             
            Draw();
            _timer.Enabled = false;
        }
 
        public PointF AzEl2XY(int azimuth, int elevation)
        {
            // rotate coords... 90deg W = 180deg trig
            double angle = (270d + (double)azimuth);
 
            // turn into radians
            angle *= 0.0174532925d;
 
            double r, x, y;
 
            // determine the lngth of the radius
            r = (double)_size * 0.5d;
            r -= (r * (double)elevation / 90);
 
            x = (((double)_size * 0.5d) + (r * Math.Cos(angle)));
            y = (((double)_size * 0.5d) + (r * Math.Sin(angle)));
 
            return new PointF((float)x, (float)y);
        }
 
        void _timer_Tick(object sender, EventArgs e)
        {
            // increment the azimuth
            if (DrawScanLine)
            {
                 
          
            _az++;
 
            // reset the azimuth if needed
            // if not, this will cause an OverflowException
            if (_az >=360)
            {
                _az = 0;
                DrawScanLine = false;
            }
 
 
            // update the fade path coordinates
            _pt = AzEl2XY(_az, 0);
            _pt2 = AzEl2XY(_az - 20, 0);
            _pt3 = AzEl2XY(_az - 10, -10);
 
            // redraw the output image
            Draw();
            }
        }
 
        public bool DrawScanLine
        {
            get
            {
                return _scanLine;
            }
            set
            {
                _scanLine = value;
            }
        }
 
 
        private void  CreateBaseImage()
        {
             
            // create the drawing objects
            Image i = new Bitmap(_size, _size);
            Graphics g = Graphics.FromImage(i);
            Pen p = new Pen(_lineColor);
            // set a couple of graphics properties to make the
            // output image look nice
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.InterpolationMode = InterpolationMode.Bicubic;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            // draw the background of the radar
            g.FillEllipse(new LinearGradientBrush(new Point((int)(_size / 2), 0), new Point((int)(_size / 2), _size - 1), _topColor, _bottomColor), 0, 0, _size - 1, _size - 1);
        
            // release the graphics object
            g.Dispose();
            // update the base image
            _baseImage =  i;
        }
 
        /// <summary>
        /// Draws the output image and fire the event caller for ImageUpdate
        /// </summary>
        void Draw()
        {
            // create a copy of the base image to draw on
            Image i = (Image)_baseImage.Clone();
            // create the circular path for clipping the output
            Graphics g = Graphics.FromImage(i);
            GraphicsPath path = new GraphicsPath();
            path.FillMode = FillMode.Winding;
            path.AddEllipse(-1F, -1F, (float)(_size + 1), (float)(_size + 1));
            g.Clip = new Region(path);
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.InterpolationMode = InterpolationMode.Bicubic;
            g.SmoothingMode = SmoothingMode.AntiAlias;
      
            g.Dispose();
 
            _outputImage = i;
            this.imageElement.Image = _outputImage;
        }
        protected override void CreateChildElements()
        {
 
            base.CreateChildElements();
            stackLayout = new StackLayoutPanel();
            stackLayout.Orientation = System.Windows.Forms.Orientation.Vertical;
            imageElement = new LightVisualElement();
            imageElement.DrawText = false;
            imageElement.ImageLayout = System.Windows.Forms.ImageLayout.Zoom;
            imageElement.StretchVertically = false;
            imageElement.Margin = new System.Windows.Forms.Padding(10, 5, 10, 5);
             
            stackLayout.Children.Add(imageElement);
 
 
            titleElement = new LightVisualElement();
            titleElement.TextAlignment = ContentAlignment.MiddleLeft;
            titleElement.Margin = new Padding(10, 5, 10, 5);
            titleElement.Font = new System.Drawing.Font("Segoe UI", 12, FontStyle.Bold, GraphicsUnit.Point);
            titleElement.Text = "0";
            stackLayout.Children.Add(titleElement);
 
            artistElement = new LightVisualElement();
            artistElement.TextAlignment = ContentAlignment.MiddleLeft;
            artistElement.Margin = new Padding(10, 5, 10, 5);
            artistElement.Font = new System.Drawing.Font("Segoe UI", 9, FontStyle.Bold | FontStyle.Italic,GraphicsUnit.Point);
            artistElement.ForeColor = Color.FromArgb(255, 114, 118, 125);
            stackLayout.Children.Add(artistElement);
 
            this.Children.Add(stackLayout);
            this.Padding = new Padding(5);
            this.Shape = new RoundRectShape(3);
            this.BorderColor = Color.FromArgb(255, 110, 153, 210);
            this.BorderGradientStyle = GradientStyles.Solid;
            this.DrawBorder = true;
            this.DrawFill = true;
            this.BackColor = Color.FromArgb(255, 230, 238, 254);
            this.GradientStyle = GradientStyles.Solid;
        }
 
        protected override void SynchronizeProperties()
        {
            this.imageElement.Image = _outputImage;
            this.titleElement.Text = Convert.ToString(((string[])this.Data.Tag)[0]);
        }
 
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF measuredSize = base.MeasureOverride(availableSize);
            this.stackLayout.Measure(measuredSize);
            return measuredSize;
        }
 
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            base.ArrangeOverride(finalSize);
            this.stackLayout.Arrange(new RectangleF(PointF.Empty, finalSize));
            return finalSize;
        }
 
    }
}

help me!
thanks!!!

1 Answer, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 20 Jul 2012, 12:44 PM
Hello Cloud,

Thank you for contacting us.

This appears to be a very rare issue in our layouts which appears as a result from using RadDock and RadListView with a Margin setting to its inner view element. To overcome it, simply set the Margin of the outer ViewElement instead of the inner one:
//replace this:
this.radListView1.ListViewElement.ViewElement.ViewElement.Margin = new Padding(1, 1, 0, 0);
//with this:
this.radListView1.ListViewElement.ViewElement.Margin = new Padding(1, 1, 0, 0);

I have logged this issue in our Public Issue Tracking System and we will address it in a future release. Here you can find the PITS item.

Your Telerik points have been updated for bringing this issue to our attention.

Feel free to ask if you have any further questions.

Kind regards,
Ivan Todorov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
ListView
Asked by
cloud
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Share this question
or