Example #1
0
        /// <summary>
        /// Method change data model and grid size due to change of view size.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResizeTimerTick(object sender, EventArgs e)
        {
            _resizeTimer.Stop();

            if (ViewHeight == 0 || ViewWidth == 0)
            {
                return;
            }

            var newWidth  = System.Math.Max(1, (int)System.Math.Ceiling((double)ViewWidth / CellWidth));
            var newHeight = System.Math.Max(1, (int)System.Math.Ceiling((double)ViewHeight / CellHeight));

            if (CellSet != null &&
                GridWidth == newWidth &&
                GridHeight == newHeight)
            {
                // the same size, nothing to do
                return;
            }

            // preserve current points
            var currentPoints = CellSet?.GetPoints().Where(point => point.X < newWidth && point.Y < newHeight);

            CellSet    = new CellSet(newWidth, newHeight);
            GridWidth  = CellSet.Width;
            GridHeight = CellSet.Height;

            if (currentPoints != null)
            {
                CellSet.SetPoints(currentPoints);
            }
            CreateOrUpdateCellViewModels();
        }
Example #2
0
        /// <summary>
        /// Method change data model and grid size due to change of view size.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResizeTimerTick(object sender, EventArgs e)
        {
            _resizeTimer.Stop();

            if (ViewHeight == 0 || ViewWidth == 0)
            {
                return;
            }

            var newSize = GetNewSize();
            int newWidth = (int)newSize.Width, newHeight = (int)newSize.Height;

            if (CellSet != null &&
                GridWidth == newWidth &&
                GridHeight == newHeight)
            {
                // the same size, nothing to do
                return;
            }

            // prevent timer's start until cell set will be recreate
            SetCommandProviderMode(CommandProviderMode.None);
            PauseIteration();

            // preserve current points
            var currentPoints = CellSet?.GetPoints().Where(point => point.X < newWidth && point.Y < newHeight);

            CellSet    = new CellSet(newWidth, newHeight);
            GridWidth  = CellSet.Width;
            GridHeight = CellSet.Height;

            if (currentPoints != null)
            {
                CellSet.SetPoints(currentPoints);
            }
            CreateOrUpdateCellViewModels();

            // post recreating actions
            if (_postponedTimer)
            {
                StartTimer();
            }
            else
            {
                SetCommandProviderMode(CommandProviderMode.Init);
            }
        }