Ejemplo n.º 1
0
        public void FocusOnInnerControlActivatesContainingSmartPart()
        {
            ZoneWorkspaceForm form = new ZoneWorkspaceForm();

            form.Show();

            ControlSmartPart sp1 = new ControlSmartPart();

            sp1.Size = new System.Drawing.Size(50, 50);
            TextBox tb1 = new TextBox();

            sp1.Controls.Add(tb1);

            ControlSmartPart sp2 = new ControlSmartPart();

            sp2.Size = new System.Drawing.Size(50, 50);
            TextBox tb2 = new TextBox();

            sp2.Controls.Add(tb2);

            form.Workspace.Show(sp1, new ZoneSmartPartInfo("LeftZone"));
            form.Workspace.Show(sp2, new ZoneSmartPartInfo("ContentZone"));

            Assert.AreSame(sp2, form.Workspace.ActiveSmartPart);
            tb1.Select();
            Assert.AreSame(sp1, form.Workspace.ActiveSmartPart);
            tb2.Select();
            Assert.AreSame(sp2, form.Workspace.ActiveSmartPart);
        }
Ejemplo n.º 2
0
        public void RenamingZoneDoesNotRegisterEventsMultipleTimes()
        {
            int activatedCalled        = 0;
            ZoneWorkspaceForm zoneForm = new ZoneWorkspaceForm();

            zoneForm.Workspace.WPFUIElementAdapter = workItem.Services.Get <IWPFUIElementAdapter>();
            zoneForm.Show();
            Control zone1 = new Control();

            zoneForm.Workspace.Controls.Add(zone1);
            zoneForm.Workspace.SetZoneName(zone1, "TestZone");

            //rename
            zoneForm.Workspace.SetZoneName(zone1, "NewZone");

            zoneForm.Workspace.SmartPartActivated += delegate(object sender, WorkspaceEventArgs e)
            {
                activatedCalled++;
            };

            zoneForm.Workspace.Show(new MockWPFSmartPart(), new ZoneSmartPartInfo("NewZone"));

            Assert.AreEqual("NewZone", zoneForm.Workspace.GetZoneName(zone1));
            Assert.AreEqual(1, activatedCalled);
        }
Ejemplo n.º 3
0
        public void ActivatingChildControlRaisesSmartPartActivatedForContainingSP()
        {
            ZoneWorkspaceForm zoneForm = new ZoneWorkspaceForm();

            zoneForm.Show();
            Control sp = new Control();

            sp.Size = new System.Drawing.Size(50, 50);
            sp.Text = "Foo";
            TextBox tb = new TextBox();

            sp.Controls.Add(tb);
            zoneForm.Workspace.Show(sp);
            zoneForm.Workspace.Show(new Control());

            Control received = null;

            zoneForm.Workspace.SmartPartActivated += delegate(object sender, WorkspaceEventArgs e)
            {
                received = (Control)e.SmartPart;
            };

            tb.Select();

            Assert.AreSame(sp, received);
        }
Ejemplo n.º 4
0
        public void ActivatedFiresCorrectNumberOfTimes()
        {
            ZoneWorkspaceForm form     = CreateFormAddWorkspace();
            Control           zone     = new Control();
            Control           zone1    = new Control();
            MockWPFSmartPart  control2 = new MockWPFSmartPart();

            workItem.Items.Add(control2);
            int activated = 0;

            AddZones(zone, zone1);
            workspace.SmartPartActivated +=
                delegate(object sender, WorkspaceEventArgs args) { activated++; };
            form.Show();

            workspace.Show(smartPart, new ZoneSmartPartInfo("Main"));
            workspace.Show(control2, new ZoneSmartPartInfo("Main1"));

            smartPart.ElementHost.Select();
            control2.ElementHost.Select();
            smartPart.ElementHost.Select();

            //Will fire five times because it fires when show is called.
            Assert.AreEqual(5, activated);
        }
Ejemplo n.º 5
0
        public void FocusingSmartPartFiresActivated()
        {
            ZoneWorkspaceForm form = CreateFormAddWorkspace();
            Control           zone = new Control();
            bool activated         = false;

            workspace.Controls.Add(zone);
            workspace.SetZoneName(zone, "Main");
            workspace.SmartPartActivated += delegate { activated = true; };
            form.Show();

            workspace.Show(control, new ZoneSmartPartInfo("Main"));
            workspace.Zones["Main"].Focus();

            Assert.IsTrue(activated);
        }
Ejemplo n.º 6
0
        public void FocusingSmartPartFiresActivatedWithSmartPart()
        {
            ZoneWorkspaceForm form          = CreateFormAddWorkspace();
            Control           zone          = new Control();
            object            argsSmartPart = null;

            workspace.Controls.Add(zone);
            workspace.SetZoneName(zone, "Main");
            workspace.SmartPartActivated +=
                delegate(object sender, WorkspaceEventArgs args) { argsSmartPart = args.SmartPart; };
            form.Show();

            workspace.Show(control, new ZoneSmartPartInfo("Main"));
            workspace.Zones["Main"].Focus();

            Assert.AreEqual(control, argsSmartPart);
        }
Ejemplo n.º 7
0
        public void ActivatingChildControlRaisesSmartPartActivatedForContainingSP()
        {
            ZoneWorkspaceForm zoneForm = new ZoneWorkspaceForm();

            workItem.Items.Add(zoneForm);
            zoneForm.Show();
            System.Windows.Controls.ContentControl sp = new System.Windows.Controls.ContentControl();
            System.Windows.Controls.TextBox        tb = new System.Windows.Controls.TextBox();

            sp.Content = tb;
            zoneForm.Workspace.Show(sp);
            zoneForm.Workspace.Show(new Control());

            System.Windows.Controls.Control received = null;
            zoneForm.Workspace.SmartPartActivated += delegate(object sender, WorkspaceEventArgs e)
            {
                received = (System.Windows.Controls.Control)e.SmartPart;
            };

            tb.Focus();

            Assert.AreSame(sp, received);
        }
Ejemplo n.º 8
0
        public void FocusOnInnerControlActivatesContainingSmartPart()
        {
            ZoneWorkspaceForm form = new ZoneWorkspaceForm();

            workItem.Items.Add(form);
            form.Show();

            System.Windows.Controls.ContentControl sp1 = new System.Windows.Controls.ContentControl();
            System.Windows.Controls.TextBox        tb  = new System.Windows.Controls.TextBox();
            sp1.Content = tb;

            System.Windows.Controls.ContentControl sp2 = new System.Windows.Controls.ContentControl();
            System.Windows.Controls.TextBox        tb2 = new System.Windows.Controls.TextBox();
            sp2.Content = tb2;

            form.Workspace.Show(sp1, new ZoneSmartPartInfo("LeftZone"));
            form.Workspace.Show(sp2, new ZoneSmartPartInfo("ContentZone"));

            Assert.AreSame(sp2, form.Workspace.ActiveSmartPart);
            tb.Focus();
            Assert.AreSame(sp1, form.Workspace.ActiveSmartPart);
            tb2.Focus();
            Assert.AreSame(sp2, form.Workspace.ActiveSmartPart);
        }