We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Pointer: set value

Hello,

I am using the CircularGauge embedded in an ElementHost in a WinForms application. My knowledge on XAML is quite limited therefore I wrote everything in the code behind file.

My problem is that changes made to the Value property (in code) of the CircularPointer do not move the pointer on screen. Additionally the ValueChanged event is not executed when I move the pointer on screen.

Could you give me a hint on what I am doing wrong?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Syncfusion.Windows.Gauge;
using System.Windows.Media;
using System.ComponentModel;
using CIS.WinForms.Base;
using CIS.IS.Data.Bse;
using CIS.Data;

namespace CIS.IS.WinForms.SyncFusion
{
  internal class WPFCircularGauge : Syncfusion.Windows.Gauge.CircularGauge
  {


    #region Ctor
    internal WPFCircularGauge()
    {
      this.Background = Brushes.WhiteSmoke;
      this.SizeToContainer = true;
      this.FirstFrameThickness = new Thickness(2);
      this.SecondFrameThickness = new Thickness(0);

      #region Scale
      CircularScale m_scale = new CircularScale();
      m_scale.BorderWidth = 2;
      m_scale.GapSweepAngle = 300;
      m_scale.MajorIntervalValue = 10;
      m_scale.Maximum = 100;
      m_scale.Minimum = 0;
      m_scale.MinorIntervalValue = 5;
      m_scale.StartAngle = 120;
      m_scale.BackgroundBrush = Brushes.DimGray;
      m_scale.BorderBrush = Brushes.Transparent;
      m_scale.Radius = 120;
      m_scale.ScaleBarSize = 5;
      m_scale.ShadowOffset = 0;
      this.Scales.Add(m_scale);
      #endregion

      #region Minor Tick
      CircularMarkTick minorTick = new CircularMarkTick();
      minorTick.BackgroundBrush = new SolidColorBrush(System.Windows.Media.Colors.DimGray);
      minorTick.TickHeight = 7;
      minorTick.DistanceFromScale = 0;
      minorTick.TickStyle = TickStyle.MinorTick;
      minorTick.TickShape = TickShape.Rectangle;
      minorTick.TickPlacement = ScalePlacement.Inside;
      minorTick.TickWidth = 2;
      m_scale.Ticks.Add(minorTick);
      #endregion

      #region Major Tick
      CircularMarkTick majorTick = new CircularMarkTick();
      majorTick.Angle = 0;
      majorTick.Foreground = Brushes.Blue;
      majorTick.BackgroundBrush = new SolidColorBrush(System.Windows.Media.Colors.DimGray);
      majorTick.TickHeight = 10;
      majorTick.DistanceFromScale = 0;
      majorTick.TickShape = TickShape.Rectangle;
      majorTick.TickStyle = TickStyle.MajorTick;
      majorTick.TickPlacement = ScalePlacement.Inside;
      majorTick.TickWidth = 4;
      m_scale.Ticks.Add(majorTick);
      #endregion

      #region Major Tick Label
      CircularLabelTick majorLabelTick = new CircularLabelTick();
      majorLabelTick.DistanceFromScale = 10;
      majorLabelTick.FontSize = 16;
      majorLabelTick.BackgroundBrush = new SolidColorBrush(System.Windows.Media.Colors.DimGray);
      majorLabelTick.TickPlacement = ScalePlacement.Inside;
      majorLabelTick.TickStyle = TickStyle.MajorTick;
      m_scale.Ticks.Add(majorLabelTick);
      #endregion

      #region Pointer
      CircularPointer pointer1 = new CircularPointer();
      pointer1.IsAnimationEnabled = false;
      pointer1.Value = 5;
      pointer1.BorderWidth = 0;
      pointer1.PointerLength = 120;
      pointer1.BackgroundBrush = Brushes.DimGray;
      pointer1.PointerPlacement = ScalePlacement.Inside;
      pointer1.PointerWidth = 20;
      m_scale.Pointers.Add(pointer1);

      PointerCap pointercap = new PointerCap();
      pointercap.BorderWidth = 3;
      pointercap.CapOnTop = true;
      pointercap.BackgroundBrush = Brushes.WhiteSmoke;
      pointercap.BorderBrush = Brushes.DimGray;
      pointercap.Width = 10;
      pointercap.PointerCapType = PointerCapType.Default;
      m_scale.PointerCap = pointercap;
      #endregion

      // Creating and adding Range to Scale.
      CircularRange range = new CircularRange();
      range.BorderWidth = 1;
      range.DistanceFromScale = 0;
      range.StartValue = 650;
      range.EndValue = 1000;
      range.StartWidth = 8;
      range.EndWidth = 8;
      range.RangePosition = ScalePlacement.Outside;
      m_scale.Ranges.Add(range);


      // Creating and adding Custom label to Scale.
      CircularCustomLabel customlabel1 = new CircularCustomLabel();
      customlabel1.FontFamily = new FontFamily("Seagoe UI");
      customlabel1.FontSize = 16;
      customlabel1.TextAngle = 0;
      customlabel1.LabelValue = "Speedometer";
      this.CustomLabels.Add(customlabel1);

    }
    #endregion

    #region Properties

    #region public double ScaleRadius
    public double ScaleRadius
    {
      get { return this.FirstScale.Radius; }
      set
      {
        this.FirstScale.Radius = value;
        //this.Scales[0].Pointers[0].PointerLength = value;
      }
    }
    #endregion


    private CircularScale FirstScale
    {
      get { return this.Scales[0]; }
    }

    private CircularPointer Pointer
    {
      get { return this.FirstScale.Pointers[0]; }
    }

    public double Value
    {
      get
      {
        return this.Pointer.Value;
      }
      set
      {
        this.Pointer.Value = value;
      }

    }

    #endregion

    #region  public void SetValue(double val)
    public void SetValue(double val)
    {
      //this line does not move the Pointer
      this.Pointer.Value = val;

    }
    #endregion


  }
}


1 Reply

JO Joy Oyiess Rex  K Syncfusion Team March 19, 2013 10:44 AM UTC

Hi Werner,

Thanks for using Syncfusion products.

We are unable to reproduce the issue with” Circular Pointer value not changed while change the Value Property in code behind”, for that, we have attached a sample by changing the CircularPointer value through the Slider.

Regarding” triggering the Value changed event of CircularGauge pointer through Element Hosting”. We are able to reproduce the issue and we have logged it as an issue, in order to get the patch for it. You have to create an incident in our direct track support system in the following link.

http://www.syncfusion.com/support/directtrac/dtnewpost

Regards,

Joy Oyiess Rex.K



ElementHostSample_27de76b6.zip

Loader.
Live Chat Icon For mobile
Up arrow icon