Hi,
I am trying to create Half Circle gauge control in Code behind(In C#.Net) But not able to create it... Referred lots of links but still my problem is unresolved. Please guide me to create half circle in code behind. In the below code I also have written code for putting needle in the Gauge.. But it is also not getting displayed when I run the code.
I m also posting my code here..:
public Telerik.Windows.Controls.Gauges.LinearGauge CreateLineargauge(Telerik.Windows.Controls.Gauges.LinearGauge lineargauge)
{
lineargauge.Background = Brushes.Gray;
lineargauge.Width = 150;
lineargauge.Height = 250;
lineargauge.Foreground = Brushes.Red;
LinearScale ls = new LinearScale();
ls.Name = "Scale1";
ls.Min = 0;
ls.Max = 40;
ls.EndWidth = 0.1;
ls.StartWidth = 0.1;
ls.MiddleTicks = 3;
ls.MinorTicks = 5;
ls.Background = Brushes.DimGray;
lineargauge.Items.Add(ls);
return lineargauge;
}
public Telerik.Windows.Controls.Gauges.RadialGauge CreateRadialGauge(Telerik.Windows.Controls.Gauges.RadialGauge RGauge)
{
RGauge.Height = 100;
RGauge.Width = 100;
RGauge.Foreground = Brushes.Black;
RadialScale rs = new RadialScale();
rs.Name = "sc1";
rs.Min = 0;
rs.HorizontalAlignment = HorizontalAlignment.Center;
rs.StartAngle = 0;
rs.SweepAngle = 180;
rs.Max = 100;
rs.Radius = 1.2d;
rs.StartWidth = 0.1;
rs.EndWidth = 0.1;
rs.MiddleTicks = 5;
rs.MinorTicks = 5;
rs.Height = 100;
rs.Width = 100;
Needle needle = new Needle();
needle.Name = "needleN";
needle.Value = 6;
needle.Width = 10;
needle.Height = 500;
needle.Foreground = Brushes.Red;
needle.Background = Brushes.Red;
needle.IsAnimated = true;
needle.Location = ScaleObjectLocation.Inside;
needle.Duration = new Duration(TimeSpan.FromSeconds(2));
RGauge.Items.Add(rs);
rs.Indicators.Add(needle);
rs.Radius = 0.2d;
var uri = new Uri("/Telerik.Windows.Controls.Gauge;component/Themes/generic.xaml", UriKind.Relative);
var dictionalry = new ResourceDictionary();
dictionalry.Source = uri;
if (dictionalry.Contains("RadialGaugeHalfCircleNStyle"))
{
RGauge.Style = dictionalry["RadialGaugeHalfCircleNStyle"] as Style;
}
if (dictionalry.Contains("RadialScaleHalfCircleNStyle"))
{
rs.Style = dictionalry["RadialScaleHalfCircleNStyle"] as Style;
}
//RGauge.Margin = new Thickness(e.GetPosition(this.Gr).X, e.GetPosition(this.Gr).Y, 0, 0);
this.Gr.Children.Add(RGauge);
return null;
}
Best regards,
Swati.