WPF Matrix helper methods.
Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="panelSize"></param>
        /// <param name="elementSize"></param>
        public void Fill(Size panelSize, Size elementSize)
        {
            if (_element != null)
            {
                double pw = panelSize.Width;
                double ph = panelSize.Height;
                double ew = elementSize.Width;
                double eh = elementSize.Height;
                double zx = pw / ew;
                double zy = ph / eh;

                _matrix = MatrixHelper.ScaleAt(zx, zy, ew / 2.0, eh / 2.0);

                Invalidate();
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="panelSize"></param>
        /// <param name="elementSize"></param>
        public void Extent(Size panelSize, Size elementSize)
        {
            if (_element != null)
            {
                double pw   = panelSize.Width;
                double ph   = panelSize.Height;
                double ew   = elementSize.Width;
                double eh   = elementSize.Height;
                double zx   = pw / ew;
                double zy   = ph / eh;
                double zoom = Min(zx, zy);
                double cx   = ew / 2.0;
                double cy   = eh / 2.0;

                _matrix = MatrixHelper.ScaleAt(zoom, zoom, cx, cy);

                Invalidate();
            }
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="zoom"></param>
        /// <param name="point"></param>
        public void ZoomTo(double zoom, Point point)
        {
            _matrix = MatrixHelper.ScaleAtPrepend(_matrix, zoom, zoom, point.X, point.Y);

            Invalidate();
        }