private void DrawRulerImperialMeasure(int start, int end, ImperialTick tick) { if(tick == ImperialTick.None) { return; } int midPoint = (start + end) / 2; DrawRulerImperialMeasure(start, midPoint, tick - 1); DrawRulerImperialMark(midPoint, tick); DrawRulerImperialMeasure(midPoint, end, tick - 1); }
private void DrawRulerImperialMark(int position, ImperialTick tick, string label = "") { Line line = new Line() { Style = (Style)this.LayoutRoot.Resources[tick.ToString()], Y1 = position, Y2 = position }; if(tick == ImperialTick.Inch) { line.Name = "tick_inch_" + label; TextBlock textBlock = new TextBlock() { Name = "label_" + line.Name, Text = label, FontSize = 24, Foreground = new SolidColorBrush(Colors.Black), RenderTransform = new RotateTransform() { Angle = 90 } }; textBlock.Margin = new Thickness(line.X2 + 36, line.Y1 - 6, 0, 0); this.RulerGrid.Children.Add(textBlock); } Debug.WriteLine("Drawing line {0} at {1}", tick.ToString(), line.Y1); this.RulerGrid.Children.Add(line); }