コード例 #1
0
        /// <summary>
        /// Handler to change the control layout when FittingPhotoToWindow changes so that
        /// fit to window does indeed cause the photo to fit to window.
        /// </summary>
        /// <param name="newValue">The new FittingPhotoToWindow value.</param>
        protected static void OnScaleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            TagTarget tag = (TagTarget)sender;

            if (tag != null)
            {
                double factor = (double)e.NewValue;

                // Set size according to zoom factor
                tag.Width  = DEFAULT_SIZE * factor;
                tag.Height = DEFAULT_SIZE * factor;
                tag.Margin = new Thickness(-tag.Width / 2);
            }
        }
コード例 #2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _photoDisplay = this.Template.FindName("PART_PhotoDisplay", this) as PhotoDisplayControl;
            Assert.IsNotNull(_photoDisplay);
            _tagTarget = this.Template.FindName("PART_TagTargetElement", this) as TagTarget;
            Assert.IsNotNull(_tagTarget);
            _photoDisplayGrid = this.Template.FindName("PART_PhotoDisplayGrid", this) as Grid;
            Assert.IsNotNull(_photoDisplayGrid);
            _photoTagger = this.Template.FindName("PART_PhotoTaggerControl", this) as PhotoTaggerControl;
            Assert.IsNotNull(_photoTagger);
            _fitPhotoControl = this.Template.FindName("PART_FitPhotoFrame", this) as Control;
            //Assert.IsNotNull(_fitPhotoControl);

            _photoDisplay.FitControl = _fitPhotoControl;

            //_photoScrollViewer.PreviewMouseWheel += new MouseWheelEventHandler(OnPhotoScrollViewerPreviewMouseWheel);
            _photoDisplay.PhotoStateChanged += new PhotoStateChangedEventHandler(PhotoDisplay_PhotoStateChanged);

            // Focus the control so that we can grab keyboard events.
            this.Focus();
        }