private void CreateLabels() { double max = Maximum; double min = Minimum; for (double v = min; v <= max; v += MajorTickStep) { Tick tick = new Tick() { Value = v, TickType = TickType.Label }; labels.Add(tick); //also set the content and template for the label tick.ContentTemplate = GetTickTemplate(TickType.Label, v); tick.Content = v; Children.Insert(0, tick); } }
private void CreateTicks() { double max = Maximum; double min = Minimum; int num = 0;//the tick index double val = min;//the value of the tick while (val <= max) { DataTemplate template = null; Tick tick = new Tick(); tick.Value = val; if (num % MinorTickStep == 0) { tick.TickType = TickType.Minor; template = GetTickTemplate(TickType.Minor, val); } if (num % MajorTickStep == 0) { tick.TickType = TickType.Major; template = GetTickTemplate(TickType.Major, val); } tick.ContentTemplate = template; tick.Content = val; ticks.Add(tick); Children.Insert(0, tick); val += MinorTickStep; num += MinorTickStep; } }
private void PositionTick(Tick tick, double x, double y, double rad) { // Tick tick = ticks[i]; double tickW = tick.DesiredSize.Width; double tickH = tick.DesiredSize.Height; double angle = GetAngleFromValue(tick.Value); if (SweepDirection == SweepDirection.Counterclockwise) angle = -angle; //position the tick double px = x + (rad) * Math.Sin(angle * Math.PI / 180); double py = y - (rad) * Math.Cos(angle * Math.PI / 180); px -= tickW / 2; py -= tickH / 2; tick.Arrange(new Rect(new Point(px, py), tick.DesiredSize)); //rotate the tick (if not label or if it is label and has rotation enabled) if ((EnableLabelRotation && tick.TickType==TickType.Label) || tick.TickType!=TickType.Label) { RotateTransform tr = new RotateTransform(); tr.Angle = angle; tick.RenderTransformOrigin = new Point(0.5, 0.5); tick.RenderTransform = tr; } }