Exemple #1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            //if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            //	return;

            this.SizeChanged += Ruler_SizeChanged;
            _ScrollContainer  = (ScrollViewer)GetTemplateChild("PART_ScrollViewer");

            _hRuler = (RulerBar)GetTemplateChild("PART_HRuler");
            _vRuler = (RulerBar)GetTemplateChild("PART_VRuler");
            _cRuler = (RulerCorner)GetTemplateChild("PART_CRuler");

            AdornerLayer layer = AdornerLayer.GetAdornerLayer(_hRuler);

            HorizontalAnchorAdorner = new GuideAnchorAdorner(this, _hRuler);
            layer.Add(HorizontalAnchorAdorner);

            layer = AdornerLayer.GetAdornerLayer(_vRuler);
            VerticalAnchorAdorner = new GuideAnchorAdorner(this, _vRuler);
            layer.Add(VerticalAnchorAdorner);

            if (_ScrollContainer != null)
            {
                _ScrollContainer.Content = DrawingSurface;
            }

            PageManager = new PagingManager();
            PageManager.DrawingSurface = DrawingSurface;
        }
Exemple #2
0
        // A common way to implement an adorner's rendering behavior is to override the OnRender
        // method, which is called by the layout system as part of a rendering pass.
        protected override void OnRender(DrawingContext drawingContext)
        {
            RulerBar bar = this.AdornedElement as RulerBar;

            foreach (Guideline guide in RulerParent.GuideManager.Guides.Where(p => (int)p.Info.Orientation == (int)bar.Orientation))
            {
                guide.RenderAnchor(drawingContext, RulerParent);
            }
        }