PageRenderTime 182ms CodeModel.GetById 35ms RepoModel.GetById 1ms app.codeStats 0ms

/Main/src/DynamicDataDisplay/Charts/Navigation/VerticalScrollBar.cs

#
C# | 68 lines | 54 code | 10 blank | 4 comment | 5 complexity | 42aac33d080b4f0dd0f60091dfaf621b MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using Microsoft.Research.DynamicDataDisplay.Common;
  8. namespace Microsoft.Research.DynamicDataDisplay.Charts.Navigation
  9. {
  10. [Obsolete("Working wrongly.", true)]
  11. public sealed class VerticalScrollBar : PlotterScrollBar
  12. {
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="VerticalScrollBar"/> class.
  15. /// </summary>
  16. public VerticalScrollBar()
  17. {
  18. ScrollBar.Orientation = Orientation.Vertical;
  19. }
  20. private Range<double> GetRange(Rect domain)
  21. {
  22. return new Range<double>(domain.Top, domain.Bottom);
  23. }
  24. protected override DataRect CreateVisibleRect(DataRect rect, double scrollValue)
  25. {
  26. rect.YMin = scrollValue;
  27. return rect;
  28. }
  29. protected override Panel GetHostPanel(Plotter plotter)
  30. {
  31. return plotter.LeftPanel;
  32. }
  33. protected override void UpdateScrollBar(Viewport2D viewport)
  34. {
  35. if (viewport != null && !viewport.Domain.IsEmpty)
  36. {
  37. if (ScrollBar.Track != null)
  38. {
  39. //ScrollBar.Track.IsDirectionReversed = true;
  40. }
  41. visibleRange = new Range<double>(viewport.Visible.YMin, viewport.Visible.YMax);
  42. domainRange = new Range<double>(viewport.Domain.YMin, viewport.Domain.YMax);
  43. double size = visibleRange.Max - visibleRange.Min;
  44. ScrollBar.ViewportSize = size;
  45. ScrollBar.Minimum = domainRange.Min + size;
  46. ScrollBar.Maximum = domainRange.Max;
  47. ScrollBar.Value = visibleRange.Min;
  48. ScrollBar.Visibility = Visibility.Visible;
  49. }
  50. else
  51. {
  52. ScrollBar.Visibility = Visibility.Collapsed;
  53. }
  54. }
  55. private Range<double> visibleRange;
  56. private Range<double> domainRange;
  57. }
  58. }