Example #1
0
        static void ScrollAdjustment(Adjustment adj, int pos, int max)
        {
            int delta = 30;

            if (pos <= delta)
            {
                double speed = 1.0 - (double)pos / delta;
                int    step  = (int)(adj.StepIncrement * speed * speed);
                if (adj.Value > adj.Lower + step)
                {
                    adj.Value -= step;
                }
                else
                {
                    adj.Value = adj.Lower;
                }
            }
            else if (max - pos <= delta)
            {
                double speed = 1.0 - (double)(max - pos) / delta;
                int    step  = (int)(adj.StepIncrement * speed * speed);
                if (adj.Value < adj.Upper - adj.PageSize - step)
                {
                    adj.Value += step;
                }
                else
                {
                    adj.Value = adj.Upper - adj.PageSize;
                }
            }
            adj.ChangeValue();
        }
Example #2
0
        public void ScrollTo(int cell_num, bool center)
        {
            if (!IsRealized)
            {
                return;
            }

            Adjustment adjustment = Vadjustment;
            int        x;
            int        y;

            CellPosition(cell_num, out x, out y);

            if (center)
            {
                y += cell_height / 2 - Allocation.Height / 2;
            }

            // the maximal possible adjustment value
            // (otherwise, we are scrolling to far ...)
            int max = (int)(Height - Allocation.Height);

            adjustment.Value = Math.Min(y, max);
            adjustment.ChangeValue();
        }
        private void Vadjustment_Changed(object sender, EventArgs e)
        {
            int sheets = 1;

            if (document.PageContexts.Count > 0)
            {
                sheets = (int)Math.Ceiling(TotalPages / ((double)(columns * rows)));
            }

            if (sheets > 1)
            {
                int sheetHeight  = VirtualSize.Height / rows;
                int currentSheet = ((int)scrollWindow.Vadjustment.Value - 1) / (sheetHeight + 2 * pageScrollGap);
                StartPage = columns * currentSheet;

                double value = scrollWindow.Vadjustment.Value % (sheetHeight + 2 * pageScrollGap);
                value = Math.Max(value - pageScrollGap, 0d);
                value = Math.Min(value, sheetHeight);

                myVAdjustment.Upper = sheetHeight;
                myVAdjustment.Value = value;
            }
            else
            {
                myVAdjustment.Upper = scrollWindow.Vadjustment.Upper;
                myVAdjustment.Value = scrollWindow.Vadjustment.Value;
            }

            myVAdjustment.Lower         = scrollWindow.Vadjustment.Lower;
            myVAdjustment.StepIncrement = scrollWindow.Vadjustment.StepIncrement;
            myVAdjustment.PageSize      = scrollWindow.Vadjustment.PageSize;
            myVAdjustment.PageIncrement = scrollWindow.Vadjustment.PageIncrement;
            myVAdjustment.Change();
            myVAdjustment.ChangeValue();
        }
Example #4
0
        private void ResetAdjustments()
        {
            if (hadj != null)
            {
                hadj.SetBounds(0, 0, 0, 0, 0);
                hadj.Value = 0;
                hadj.Change();
                hadj.ChangeValue();
            }

            if (vadj != null)
            {
                vadj.SetBounds(0, 0, 0, 0, 0);
                vadj.Value = 0;
                vadj.Change();
                vadj.ChangeValue();
            }
        }
Example #5
0
        /// <summary>
        /// Set an adjustment's value.
        /// </summary>
        /// <param name="adjustment">The adjustment to be adjusted.</param>
        /// <param name="value">The new value.</param>
        public static void SetValue(this Adjustment adjustment, double value)
        {
            if (value > 0 && value < adjustment.Upper)
            {
                adjustment.Value = value;
#if NETFRAMEWORK
                adjustment.ChangeValue();
#endif
            }
        }
Example #6
0
    void SetColRows(int c, int r)
    {
        visible_cols = c;
        visible_rows = r;

        QueueDrawArea(0, 0, Allocation.Width, Allocation.Height);

        int page_items = visible_cols * visible_rows;

        max_top = Math.Max(0, image_count - page_items);

        // add visible_cols+1 to force an extra "row" on the
        // adjustment, so that we can still scroll the
        // bottommost row to full visibility, even if it would
        // get rendered as cut off due to window size
        Console.WriteLine("Setting bounds: {0} {1} {2} {3}", 0, image_count + visible_cols + 1, visible_cols, page_items, page_items);
        adjustment.SetBounds(0, image_count + visible_cols + 1, visible_cols, page_items, page_items);
        adjustment.ChangeValue();
    }