예제 #1
0
        protected virtual void grid_MouseDown(GridVirtual sender, MouseEventArgs e)
        {
            if (sender.Selection.BorderRange.IsEmpty() == false)
            {
                Position mousePos = sender.PositionAtPoint(new System.Drawing.Point(e.X, e.Y));

                if (mousePos.IsEmpty() == false)
                {
                    int distance;
                    DevAge.Drawing.RectanglePartType partType = sender.Selection.Border.PointToPartType(sender.Selection.GetDrawingRectangle(),
                                                                                                        new System.Drawing.Point(e.X, e.Y), out distance);
                    if (partType == DevAge.Drawing.RectanglePartType.BottomBorder ||
                        partType == DevAge.Drawing.RectanglePartType.TopBorder ||
                        partType == DevAge.Drawing.RectanglePartType.RightBorder ||
                        partType == DevAge.Drawing.RectanglePartType.LeftBorder)
                    {
                        RangeData data = new RangeData();
                        data.LoadData(sender, sender.Selection.BorderRange, mousePos, mCutMode);
                        if (mCutMode == CutMode.None)
                        {
                            sender.DoDragDrop(data, DragDropEffects.Copy);
                        }
                        else
                        {
                            sender.DoDragDrop(data, DragDropEffects.Move);
                        }
                    }
                }
            }
        }
예제 #2
0
        public void ShouldPaseIntoColumnsWith_VisibleFalse()
        {
            Grid grid1 = new Grid();

            grid1.Redim(6, 4);

            grid1[0, 0] = new SourceGrid.Cells.Cell("a");
            grid1[0, 1] = new SourceGrid.Cells.Cell("b");
            grid1[0, 2] = new SourceGrid.Cells.Cell("c");
            grid1[0, 3] = new SourceGrid.Cells.Cell("d");


            RangeData data = RangeData.LoadData(grid1, new Range(0, 0, 0, 3), CutMode.None);


            grid1.Columns[1].Visible = false;
            grid1[1, 0] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[1, 1] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[1, 2] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[1, 3] = new SourceGrid.Cells.Cell("x", typeof(string));

            data.WriteData(grid1, new Position(1, 0));
            Assert.AreEqual("a", grid1[1, 0].Value);
            Assert.AreEqual("b", grid1[1, 1].Value);
            Assert.AreEqual("c", grid1[1, 2].Value);
            Assert.AreEqual("d", grid1[1, 3].Value);
        }
예제 #3
0
        private void grid_KeyDown(GridVirtual sender, KeyEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            Range rng = sender.Selection.BorderRange;

            if (rng.IsEmpty())
            {
                return;
            }

            //Paste
            if (e.Control && e.KeyCode == Keys.V)
            {
                RangeData rngData = RangeData.ClipboardGetData();

                if (rngData != null)
                {
                    Range destinationRange = rngData.FindDestinationRange(sender, rng.Start);
                    if (ExpandSelection == false)
                    {
                        destinationRange = destinationRange.Intersect(rng);
                    }

                    rngData.WriteData(sender, destinationRange);
                    e.Handled = true;
                    sender.Selection.Clear();
                    sender.Selection.Add(destinationRange);
                }
            }
            //Copy
            else if (e.Control && e.KeyCode == Keys.C)
            {
                RangeData data = new RangeData();
                data.LoadData(sender, rng, rng.Start, CutMode.None);
                RangeData.ClipboardSetData(data);

                e.Handled = true;
            }
            //Cut
            else if (e.Control && e.KeyCode == Keys.X && EnableCutData)
            {
                RangeData data = new RangeData();
                data.LoadData(sender, rng, rng.Start, CutMode.CutImmediately);
                RangeData.ClipboardSetData(data);

                e.Handled = true;
            }
        }
예제 #4
0
        public void ShouldNotCopyColumnsWith_VisibleFalse()
        {
            Grid grid1 = new Grid();

            grid1.Redim(6, 2);

            grid1[0, 0] = new SourceGrid.Cells.Cell("a");
            grid1[0, 1] = new SourceGrid.Cells.Cell("b");
            grid1.Columns[1].Visible = false;

            RangeData data = RangeData.LoadData(grid1, new Range(0, 0, 0, 1), CutMode.None);

            Assert.AreEqual(1, data.SourceValues.Length);
            Assert.AreEqual("a", data.SourceValues[0, 0]);
        }
예제 #5
0
        public void PasteVertically()
        {
            Grid grid1 = new Grid();

            grid1.Redim(6, 3);

            grid1[0, 0] = new SourceGrid.Cells.Cell("a");
            grid1[1, 0] = new SourceGrid.Cells.Cell("b");
            grid1[2, 0] = new SourceGrid.Cells.Cell("c");


            RangeData data = RangeData.LoadData(grid1, new Range(0, 0, 2, 0), CutMode.None);


            grid1.Columns[1].Visible = false;
            grid1[0, 1] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[1, 1] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[2, 1] = new SourceGrid.Cells.Cell("x", typeof(string));

            data.WriteData(grid1, new Position(0, 1));
            Assert.AreEqual("a", grid1[0, 1].Value);
            Assert.AreEqual("b", grid1[1, 1].Value);
            Assert.AreEqual("c", grid1[2, 1].Value);
        }