コード例 #1
0
		public void BasicDragMove()
		{
			var styles = new AssembledStyles();
			var root = new RootBoxFdo(styles);
			var mock1 = new MockData1(23, 23);
			mock1.SimpleThree = "This is the day";
			var engine = new FakeRenderEngine() { Ws = 23, SegmentHeight = 13 };
			var factory = new FakeRendererFactory();
			factory.SetRenderer(23, engine);
			root.Builder.Show(Display.Of(() => mock1.SimpleThree, 23));
			var layoutArgs = MakeLayoutInfo(Int32.MaxValue / 2, m_gm.VwGraphics, factory);
			root.Layout(layoutArgs);
			PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96);
			MockSite site = new MockSite();
			site.m_transform = ptrans;
			site.m_vwGraphics = m_gm.VwGraphics;
			root.Site = site;

			SelectionBuilder.In(root).Offset("This ".Length).To.Offset("This is ".Length).Install();

			var dataObj = new DataObject(DataFormats.StringFormat, "is ");
			int x = FakeRenderEngine.SimulatedWidth("This is the ") + 2;
			var location = new Point(x, 8);

			// A drag to where we can drop, allowing both copy and move, no keys held
			var dragArgs = new DragEventArgs(dataObj, (int)DragDropKeyStates.None, 200, 300,
				DragDropEffects.Copy | DragDropEffects.Move,
				DragDropEffects.None);
			root.OnDragEnter(dragArgs, location, m_gm.VwGraphics, ptrans);
			Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.Move));
			Assert.That(root.DragState, Is.EqualTo(WindowDragState.DraggingHere));

			var qcdArgs = new QueryContinueDragEventArgs((int) DragDropKeyStates.None, false, DragAction.Drop);
			root.OnQueryContinueDrag(qcdArgs);
			Assert.That(root.DragState, Is.EqualTo(WindowDragState.InternalMove));
			root.OnDragLeave();
			Assert.That(root.DragState, Is.EqualTo(WindowDragState.InternalMove), "DragLeave should not clear InternalMove");

			root.OnDragDrop(dragArgs, location, m_gm.VwGraphics, ptrans);
			Assert.That(mock1.SimpleThree, Is.EqualTo("This the is day"));
			Assert.That(root.DragState, Is.EqualTo(WindowDragState.None));

			// Now let's drag the 'is' out to another window.
			SelectionBuilder.In(root).Offset("This the ".Length).To.Offset("This the is ".Length).Install();
			qcdArgs = new QueryContinueDragEventArgs((int)DragDropKeyStates.None, false, DragAction.Drop);
			root.OnQueryContinueDrag(qcdArgs);
			Assert.That(root.DragState, Is.EqualTo(WindowDragState.None),
				"We should only set InternalMove if this window is the destination");
			Assert.That(mock1.SimpleThree, Is.EqualTo("This the day"));

			// Check that we can't drag inside our own selection.
			SelectionBuilder.In(root).Offset("This ".Length).To.Offset("This the".Length).Install();
			x = FakeRenderEngine.SimulatedWidth("This t") + 2;
			location = new Point(x, 8);
			dragArgs = new DragEventArgs(dataObj, (int)DragDropKeyStates.None, 200, 300,
							DragDropEffects.Copy | DragDropEffects.Move,
							DragDropEffects.None);
			root.DragState = WindowDragState.InternalMove;
			root.OnDragDrop(dragArgs, location, m_gm.VwGraphics, ptrans);
			Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.None));
			Assert.That(mock1.SimpleThree, Is.EqualTo("This the day"));
		}
コード例 #2
0
        public void BasicDragMove()
        {
            var styles = new AssembledStyles();
            var root   = new RootBoxFdo(styles);
            var mock1  = new MockData1(23, 23);

            mock1.SimpleThree = "This is the day";
            var engine = new FakeRenderEngine()
            {
                Ws = 23, SegmentHeight = 13
            };
            var factory = new FakeRendererFactory();

            factory.SetRenderer(23, engine);
            root.Builder.Show(Display.Of(() => mock1.SimpleThree, 23));
            var layoutArgs = MakeLayoutInfo(Int32.MaxValue / 2, m_gm.VwGraphics, factory);

            root.Layout(layoutArgs);
            PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96);
            MockSite       site   = new MockSite();

            site.m_transform  = ptrans;
            site.m_vwGraphics = m_gm.VwGraphics;
            root.Site         = site;

            SelectionBuilder.In(root).Offset("This ".Length).To.Offset("This is ".Length).Install();

            var dataObj  = new DataObject(DataFormats.StringFormat, "is ");
            int x        = FakeRenderEngine.SimulatedWidth("This is the ") + 2;
            var location = new Point(x, 8);

            // A drag to where we can drop, allowing both copy and move, no keys held
            var dragArgs = new DragEventArgs(dataObj, (int)DragDropKeyStates.None, 200, 300,
                                             DragDropEffects.Copy | DragDropEffects.Move,
                                             DragDropEffects.None);

            root.OnDragEnter(dragArgs, location, m_gm.VwGraphics, ptrans);
            Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.Move));
            Assert.That(root.DragState, Is.EqualTo(WindowDragState.DraggingHere));

            var qcdArgs = new QueryContinueDragEventArgs((int)DragDropKeyStates.None, false, DragAction.Drop);

            root.OnQueryContinueDrag(qcdArgs);
            Assert.That(root.DragState, Is.EqualTo(WindowDragState.InternalMove));
            root.OnDragLeave();
            Assert.That(root.DragState, Is.EqualTo(WindowDragState.InternalMove), "DragLeave should not clear InternalMove");

            root.OnDragDrop(dragArgs, location, m_gm.VwGraphics, ptrans);
            Assert.That(mock1.SimpleThree, Is.EqualTo("This the is day"));
            Assert.That(root.DragState, Is.EqualTo(WindowDragState.None));

            // Now let's drag the 'is' out to another window.
            SelectionBuilder.In(root).Offset("This the ".Length).To.Offset("This the is ".Length).Install();
            qcdArgs = new QueryContinueDragEventArgs((int)DragDropKeyStates.None, false, DragAction.Drop);
            root.OnQueryContinueDrag(qcdArgs);
            Assert.That(root.DragState, Is.EqualTo(WindowDragState.None),
                        "We should only set InternalMove if this window is the destination");
            Assert.That(mock1.SimpleThree, Is.EqualTo("This the day"));

            // Check that we can't drag inside our own selection.
            SelectionBuilder.In(root).Offset("This ".Length).To.Offset("This the".Length).Install();
            x        = FakeRenderEngine.SimulatedWidth("This t") + 2;
            location = new Point(x, 8);
            dragArgs = new DragEventArgs(dataObj, (int)DragDropKeyStates.None, 200, 300,
                                         DragDropEffects.Copy | DragDropEffects.Move,
                                         DragDropEffects.None);
            root.DragState = WindowDragState.InternalMove;
            root.OnDragDrop(dragArgs, location, m_gm.VwGraphics, ptrans);
            Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.None));
            Assert.That(mock1.SimpleThree, Is.EqualTo("This the day"));
        }