UI Winforms RadTrackBar- Extension

4 posts, 0 answers
  1. Ian
    Ian avatar
    3 posts
    Member since:
    Jun 2015

    Posted 08 Jun 2015 Link to this post

    Hi

    I am using the RadTrackBar to navigate a series of measurement data

    I need to add an extra colour bar parrrallel to the RadTrackBar control

    The Extra bar must highlight any data exceptions or tolerance warnings (the user must manually navigate to these areas and verify the data)

     tolerance exceptions in a colourized way

    I would hope to find a control that does something similar to the way:

    a)  BeyondCompare uses vertical bars with red&blue lines when comparing two source files)

    b) DNA Sequences are displayed in a chain

    c) if a small icon could also be over layed at critical points this would also be useful

    Any suggestions welcome

    Sincerely IanF

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 09 Jun 2015 Link to this post

    Hello Ian,

    Thank you for writing.

    It is possible to create such custom control. For example you can use LinePrimitives and add them to a custom control based on Telerik Presentation Framework. For example:
    public class MyPanelElement : RadElement
    {
        FillPrimitive background;
        List<LinePrimitive> items;
     
        public List<LinePrimitive> Items
        {
            get
            {
                return this.items;
            }
        }
     
        protected override void CreateChildElements()
        {
            base.CreateChildElements();
            items = new List<LinePrimitive>();
     
            this.background = new FillPrimitive();
            this.background.BackColor = Color.White;
            this.background.GradientStyle = GradientStyles.Solid;
            
            this.Children.Add(this.background);
           
            for (int i = 0; i < 300; i++)
            {
                LinePrimitive linePrimitive = new LinePrimitive();
                linePrimitive.SeparatorOrientation = SepOrientation.Vertical;
                linePrimitive.GradientStyle = GradientStyles.Solid;
                linePrimitive.BackColor = Color.Blue;
                linePrimitive.Alignment = ContentAlignment.TopRight;            
                linePrimitive.LineWidth = 10;//default width
             
                this.Children.Add(linePrimitive);
                items.Add(linePrimitive);
            }
        }
     
        protected override SizeF ArrangeOverride(SizeF finalSize)
        {
            base.ArrangeOverride(finalSize);
            float y = 0f;
            foreach (var line in items)
            {
                line.Arrange(new RectangleF(new PointF(0,y), new SizeF(line.LineWidth, 2)));
                y += 2f;
            }
     
            return finalSize;
        }
    }
     
    [ToolboxItem(true)]
    public class MyPanel : RadControl
        {
            private MyPanelElement panelElement;
     
            public MyPanel()
            {
            }
     
            public MyPanelElement PanelElement
            {
                get
                {
                    return this.panelElement;
                }
            }
     
            protected override Size DefaultSize
            {
                get
                {
                    return new Size(40, 600);
                }
            }
     
            protected override void CreateChildItems(RadElement parent)
            {
                this.panelElement = new MyPanelElement();
                this.RootElement.Children.Add(panelElement);
                base.CreateChildItems(parent);
            }
        }

    Then you can initialize the control and set the line values like this:
    Random random = new Random();
     
    public RadForm1()
    {
        InitializeComponent();
        MyPanel panel = new MyPanel();
        panel.Parent = this;
        panel.Location = new Point(10, 10);
     
        foreach (LinePrimitive item in panel.PanelElement.Items)
        {
            item.LineWidth = random.Next(10, 40);
     
            if (item.LineWidth > 30)
            {
                item.BackColor = Color.Red;
            }
            else
            {
                item.BackColor = Color.Blue;
            }
        }
    }

    The attached image shows the result. For b) and c) I am not exactly sure how you expect this to work. However the above solution can be customized to draw the lines in any desired position (look the ArrangeOverride method). In addition you can add other elements to the control if you want, for icons you can use LightVisualElement.

    Let me know if you have additional questions.
     
    Regards,
    Dimitar
    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ian
    Ian avatar
    3 posts
    Member since:
    Jun 2015

    Posted 09 Jun 2015 in reply to Dimitar Link to this post

    Dimitar, Thanks

    Your graphic is a perfect representation of what I need

    Application: Its for highlighting which sections of rail track have certain critical defect notcies placed on them

  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 10 Jun 2015 Link to this post

    Hello Ian,

    I am glad I could be of help. Let us know if you have any other questions.
     
    Regards,
    Dimitar
    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
Back to Top