예제 #1
0
        private void setVisuals()
        {
            //Height
            relativeScrollingY = LinkedScrollViewerHeight / VisualRealSize.Height > 0.7
                                      ? 0.7 : LinkedScrollViewerHeight / VisualRealSize.Height;
            double heightToUse = ActualHeight < TextHeight ? ActualHeight : TextHeight;

            relativeHeightTransform = ActualHeight / VisualRealSize.Height > 0.7
                                      ? 0.7 : ActualHeight / VisualRealSize.Height;
            VisualRectangle.Height    = VisualRealSize.Height * relativeHeightTransform;
            NavigatorRectangle.Height = (relativeScrollingY * VisualRealSize.Height) * relativeHeightTransform;
            //Width
            double relativeWidthTransform = NavigatorCanvas.Width / VisualRealSize.Width > 1
                                      ? 1 : NavigatorCanvas.Width / VisualRealSize.Width;
            //Transform and add the visuals
            ScaleTransform transform = new ScaleTransform(Math.Round(relativeWidthTransform, 2),
                                                          Math.Round(relativeHeightTransform, 2));
            VisualBrush brush = new VisualBrush(drawing);

            brush.Transform      = transform;
            brush.AlignmentX     = AlignmentX.Left;
            brush.AlignmentY     = AlignmentY.Top;
            brush.TileMode       = TileMode.None;
            brush.Viewport       = new Rect(0, 0, NavigatorCanvas.Width, VisualRectangle.Height);
            brush.Stretch        = Stretch.None;
            VisualRectangle.Fill = brush;
            //Set the current scrolling
            CanvasTop = (double)NavigatorRectangle.GetValue(Canvas.TopProperty);
            CanvasTop = CanvasTop * relativeScrollingY;
            NavigatorRectangle.SetValue(Canvas.TopProperty, CanvasTop);
        }
예제 #2
0
        private void VisualRectangle_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            double MouseY = e.GetPosition(NavigatorCanvas).Y;

            CanvasTop = Math.Max(0, Math.Min(MouseY, NavigatorCanvas.Height
                                             - NavigatorRectangle.Height));
            NavigatorRectangle.SetValue(Canvas.TopProperty, CanvasTop);
            ScrollMethod(CanvasTop / relativeScrollingY);
        }
예제 #3
0
 private void Border_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     if (drag)
     {
         var    newY   = e.GetPosition(NavigatorCanvas).Y;
         double offset = startPt.Y - lastTop;
         CanvasTop = Math.Max(0, Math.Min(newY - offset, NavigatorCanvas.Height - NavigatorRectangle.Height));
         NavigatorRectangle.SetValue(Canvas.TopProperty, CanvasTop);
         ScrollMethod(CanvasTop / relativeScrollingY);
     }
 }
예제 #4
0
        public void UpdateText(FormattedText formattedText, Point textPos, double verticalOffset)
        {
            DrawingContext dc = drawing.RenderOpen();

            dc.DrawText(formattedText, textPos);
            dc.Close();
            TextHeight     = formattedText.Height;
            VisualRealSize = new Size(formattedText.Width, drawing.ContentBounds.Height);
            NavigatorRectangle.SetValue(Canvas.TopProperty, verticalOffset);
            setVisuals();
        }
예제 #5
0
        public CodeNavigator(FormattedText formattedText, Point textPos)
        {
            InitializeComponent();
            DrawingContext dc = drawing.RenderOpen();

            dc.DrawText(formattedText, textPos);
            dc.Close();
            TextHeight     = formattedText.Height;
            VisualRealSize = new Size(formattedText.Width, drawing.ContentBounds.Height);
            //Set properties to make them exist
            NavigatorRectangle.SetValue(Canvas.TopProperty, 0.0);
            NavigatorRectangle.SetValue(Canvas.LeftProperty, 0.0);
        }
예제 #6
0
 public void setScrolling(double verticalOffset)
 {
     CanvasTop = verticalOffset * relativeScrollingY;
     NavigatorRectangle.SetValue(Canvas.TopProperty, CanvasTop);
 }