//--------------------------------------------------------------------------------------------------

        public void TouchMove(int id, Point pos)
        {
            if (ViewportController == null)
            {
                return;
            }

            if (_MultiTouch)
            {
                // Double touch, pan mode
                if (_FirstId == id)
                {
                    var dx = (pos.X - _FirstPos.X) / 2.0;
                    var dy = (pos.Y - _FirstPos.Y) / 2.0;
                    ViewportController.Pan(dx, -dy);
                    _FirstPos = pos;
                    _MoveCallCount++;
                }
                else if (_SecondId == id)
                {
                    var dx = (pos.X - _SecondPos.X) / 2.0;
                    var dy = (pos.Y - _SecondPos.Y) / 2.0;
                    ViewportController.Pan(dx, -dy);
                    _SecondPos = pos;
                    _MoveCallCount++;
                }
            }
            else
            {
                // Single touch, rotate mode
                if (_FirstId == id)
                {
                    var dx = (pos.X - _FirstPos.X) * 0.05;
                    var dy = (pos.Y - _FirstPos.Y) * 0.05;
                    ViewportController.Rotate(dy, -dx, 0.0);
                    _FirstPos = pos;
                    _MoveCallCount++;
                }
            }

            if (_MoveCallCount > 3)
            {
                // Touch events are propagated to mouse events. If we do not cancel selection,
                // the MouseUp event will select the body moved under the pointer.
                ViewportController.WorkspaceController.CancelSelection();
            }
        }
Пример #2
0
 public static void SetController(UIElement element, ViewportController value)
 {
     element.SetValue(ControllerProperty, value);
 }
Пример #3
0
        //--------------------------------------------------------------------------------------------------

        public void MoveTo(int x, int y)
        {
            ViewportController.MouseMove(new Point(x, y));
        }
Пример #4
0
        //--------------------------------------------------------------------------------------------------

        public void ClickAt(int x, int y, bool shiftSelect = false)
        {
            ViewportController.MouseMove(new Point(x, y));
            ViewportController.MouseDown();
            ViewportController.MouseUp(shiftSelect);
        }
Пример #5
0
        internal void NextPage(PlatformGraphics pg)
        {
            this.hasMorePages = false;

            var sheet = this.CurrentWorksheet;

            if (sheet == null)
            {
                return;
            }

            // out of print areas
            if (this.CurrentRowIndex >= sheet.pageBreakRows.Count &&
                this.CurrentColIndex >= sheet.pageBreakCols.Count)
            {
                return;
            }

            int row = sheet.pageBreakRows[this.CurrentRowIndex];
            int col = sheet.pageBreakCols[this.CurrentColIndex];

            int endRow = sheet.pageBreakRows[this.CurrentRowIndex + 1];
            int endCol = sheet.pageBreakCols[this.CurrentColIndex + 1];

            switch (this.CurrentPrintSettings.PageOrder)
            {
            default:
            case PrintPageOrder.DownThenOver:
            {
                if (this.CurrentRowIndex < sheet.pageBreakRows.Count - 2)
                {
                    this.CurrentRowIndex++;

                    this.hasMorePages = true;
                }
                else
                {
                    if (this.CurrentColIndex < sheet.pageBreakCols.Count - 2)
                    {
                        this.CurrentRowIndex = 0;
                        this.CurrentColIndex++;

                        this.hasMorePages = true;
                    }
                    else
                    {
                        this.hasMorePages = false;
                    }
                }
            }
            break;

            case PrintPageOrder.OverThenDown:
            {
                if (this.CurrentColIndex < sheet.pageBreakCols.Count - 2)
                {
                    this.CurrentColIndex++;

                    this.hasMorePages = true;
                }
                else
                {
                    if (this.CurrentRowIndex < sheet.pageBreakRows.Count - 2)
                    {
                        this.CurrentColIndex = 0;
                        this.CurrentRowIndex++;

                        this.hasMorePages = true;
                    }
                    else
                    {
                        this.hasMorePages = false;
                    }
                }
            }
            break;
            }

            if (this.DrawingContext.Graphics == null)
            {
#if WINFORM
                this.DrawingContext.Graphics = new unvell.ReoGrid.WinForm.GDIRenderer(pg);
#endif // WINFORM
            }
            else
            {
                this.DrawingContext.Graphics.Reset();
            }

            var ig = this.DrawingContext.Renderer;
            ig.PlatformGraphics = pg;

#if DEBUG
            Debug.WriteLine(string.Format("print page {0,3},{1,3} - {2,3},{3,3}", row, col, endRow, endCol));
#endif // DEBUG

            GridRegion gr = new GridRegion(row, col, endRow, endCol);

            if (this.printViewportController == null)
            {
                this.printViewportController = new ViewportController(sheet);
            }
            else
            {
                this.printViewportController.worksheet = sheet;
            }

            this.PrintViewport        = new SheetViewport(this.printViewportController);
            this.PrintViewport.Bounds = this.CurrentPaperBounds;

            // refresh cells text boundary
            sheet.IterateCells(gr.ToRange(), (_unused_r, _unused_c, cell) =>
            {
                sheet.UpdateCellTextBounds(ig, cell, DrawMode.Print, this.CurrentPrintSettings.PageScaling, Core.UpdateFontReason.ScaleChanged);
                return(true);
            });

            this.PrintViewport.VisibleRegion = gr;
            this.PrintViewport.ScaleFactor   = this.CurrentPrintSettings.PageScaling;
            this.PrintViewport.ViewStart     = new Point(sheet.cols[col].Left, sheet.rows[row].Top);
            this.PrintViewport.UpdateView();

            this.PrintViewport.Draw(this.DrawingContext);

            if (this.CurrentPrintSettings.ShowMargins)
            {
                var m = this.CurrentPaperBounds;

                var p = this.DrawingContext.Renderer.GetPen(SolidColor.Gray);

                lock (p)
                {
                    ig.DrawLine(p, m.X - 50, m.Y, m.X, m.Y);
                    ig.DrawLine(p, m.Right + 50, m.Y, m.Right, m.Y);

                    ig.DrawLine(p, m.X - 50, m.Bottom, m.X, m.Bottom);
                    ig.DrawLine(p, m.Right + 50, m.Bottom, m.Right, m.Bottom);

                    ig.DrawLine(p, m.X, m.Y - 50, m.X, m.Y);
                    ig.DrawLine(p, m.X, m.Bottom + 50, m.X, m.Bottom);

                    ig.DrawLine(p, m.Right, m.Y - 50, m.Right, m.Y);
                    ig.DrawLine(p, m.Right, m.Bottom + 50, m.Right, m.Bottom);
                }
            }

            if (!this.hasMorePages)
            {
                this.NextWorksheet();

                this.hasMorePages = this.CurrentWorksheet != null;
            }
        }
Пример #6
0
        internal void NextPage(PlatformGraphics pg)
        {
            this.hasMorePages = false;

            var sheet = this.CurrentWorksheet;

            if (sheet == null)
            {
                return;
            }

            // out of print areas
            if (this.CurrentRowIndex >= sheet.pageBreakRows.Count &&
                this.CurrentColIndex >= sheet.pageBreakCols.Count)
            {
                return;
            }

            int row = sheet.pageBreakRows[this.CurrentRowIndex];
            int col = sheet.pageBreakCols[this.CurrentColIndex];

            int endRow = sheet.pageBreakRows[this.CurrentRowIndex + 1];
            int endCol = sheet.pageBreakCols[this.CurrentColIndex + 1];

            switch (this.CurrentPrintSettings.PageOrder)
            {
            default:
            case PrintPageOrder.DownThenOver:
            {
                if (this.CurrentRowIndex < sheet.pageBreakRows.Count - 2)
                {
                    this.CurrentRowIndex++;

                    this.hasMorePages = true;
                }
                else
                {
                    if (this.CurrentColIndex < sheet.pageBreakCols.Count - 2)
                    {
                        this.CurrentRowIndex = 0;
                        this.CurrentColIndex++;

                        this.hasMorePages = true;
                    }
                    else
                    {
                        this.hasMorePages = false;
                    }
                }
            }
            break;

            case PrintPageOrder.OverThenDown:
            {
                if (this.CurrentColIndex < sheet.pageBreakCols.Count - 2)
                {
                    this.CurrentColIndex++;

                    this.hasMorePages = true;
                }
                else
                {
                    if (this.CurrentRowIndex < sheet.pageBreakRows.Count - 2)
                    {
                        this.CurrentColIndex = 0;
                        this.CurrentRowIndex++;

                        this.hasMorePages = true;
                    }
                    else
                    {
                        this.hasMorePages = false;
                    }
                }
            }
            break;
            }

#if WINFORM
            // Always need a fresh GDIRenderer because the cachedGraphics of the used one is disposed
            if (this.DrawingContext.Graphics is WinForm.GDIRenderer renderer)
            {
                renderer.Dispose();
            }
            this.DrawingContext.Graphics = new WinForm.GDIRenderer(pg);
#else
            if (this.DrawingContext.Graphics != null)
#endif // WINFORM
            {
                this.DrawingContext.Graphics.Reset();
            }

            var ig = this.DrawingContext.Renderer;
            ig.PlatformGraphics = pg;

#if DEBUG
            Debug.WriteLine(string.Format("print page {0,3},{1,3} - {2,3},{3,3}", row, col, endRow, endCol));
#endif // DEBUG

            GridRegion gr = new GridRegion(row, col, endRow, endCol);

            if (this.printViewportController == null)
            {
                this.printViewportController = new ViewportController(sheet);
            }
            else
            {
                this.printViewportController.worksheet = sheet;
            }

            this.PrintViewport        = new SheetViewport(this.printViewportController);
            this.PrintViewport.Bounds = this.CurrentPaperBounds;

            this.PrintViewport.VisibleRegion = gr;
            this.PrintViewport.ScaleFactor   = this.CurrentPrintSettings.PageScaling;
            this.PrintViewport.ViewStart     = new Point(sheet.cols[col].Left, sheet.rows[row].Top);
            this.PrintViewport.UpdateView();

            this.PrintViewport.Draw(this.DrawingContext);

            if (this.CurrentPrintSettings.ShowMargins)
            {
                var m = this.CurrentPaperBounds;

                var p = this.DrawingContext.Renderer.GetPen(SolidColor.Gray);

                lock (p)
                {
                    ig.DrawLine(p, m.X - 50, m.Y, m.X, m.Y);
                    ig.DrawLine(p, m.Right + 50, m.Y, m.Right, m.Y);

                    ig.DrawLine(p, m.X - 50, m.Bottom, m.X, m.Bottom);
                    ig.DrawLine(p, m.Right + 50, m.Bottom, m.Right, m.Bottom);

                    ig.DrawLine(p, m.X, m.Y - 50, m.X, m.Y);
                    ig.DrawLine(p, m.X, m.Bottom + 50, m.X, m.Bottom);

                    ig.DrawLine(p, m.Right, m.Y - 50, m.Right, m.Y);
                    ig.DrawLine(p, m.Right, m.Bottom + 50, m.Right, m.Bottom);
                }
            }

            if (!this.hasMorePages)
            {
                this.NextWorksheet();

                this.hasMorePages = this.CurrentWorksheet != null;
            }
        }