コード例 #1
0
        /// <summary>
        /// Installs the scroll director and adds the appropriate handlers.
        /// </summary>
        /// <param name="scrollableControl">
        /// The scrollable control on which this director directs.
        /// </param>
        /// <param name="view">The PCanvas that the scrollable control scrolls.</param>
        public virtual void Install(PScrollableControl scrollableControl, PCanvas view)
        {
            this.scrollableControl = scrollableControl;
            this.view = view;

            if (view != null)
            {
                this.camera = view.Camera;
                this.root   = view.Root;
            }

            if (camera != null)
            {
                camera.ViewTransformChanged += new PPropertyEventHandler(camera_ViewTransformChanged);
                camera.BoundsChanged        += new PPropertyEventHandler(camera_BoundsChanged);
                camera.FullBoundsChanged    += new PPropertyEventHandler(camera_FullBoundsChanged);
            }
            if (root != null)
            {
                root.BoundsChanged     += new PPropertyEventHandler(root_BoundsChanged);
                root.FullBoundsChanged += new PPropertyEventHandler(root_FullBoundsChanged);
            }

            if (scrollableControl != null)
            {
                scrollableControl.UpdateScrollbars();
            }
        }
コード例 #2
0
        /// <summary>
        /// Uninstalls the scroll director from the scrollable control.
        /// </summary>
        public virtual void UnInstall()
        {
            scrollableControl = null;
            view = null;

            if (camera != null)
            {
                camera.ViewTransformChanged -= new PPropertyEventHandler(camera_ViewTransformChanged);
                camera.BoundsChanged        -= new PPropertyEventHandler(camera_BoundsChanged);
                camera.FullBoundsChanged    -= new PPropertyEventHandler(camera_FullBoundsChanged);
            }
            if (root != null)
            {
                root.BoundsChanged     -= new PPropertyEventHandler(root_BoundsChanged);
                root.FullBoundsChanged -= new PPropertyEventHandler(root_FullBoundsChanged);
            }

            camera = null;
            root   = null;
        }