private static ZoneWorkspaceForm CreateFormAddWorkspace() { ZoneWorkspaceForm form = new ZoneWorkspaceForm(); form.Controls.Add(workspace); return(form); }
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); }
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); }
public void ShowNoParamsShowsInDefaultZoneDesigner() { ZoneWorkspaceForm form = new ZoneWorkspaceForm(); workItem.Items.Add(form.Workspace); MonthCalendar calendar = new MonthCalendar(); workItem.RegisterSmartPartInfo(calendar, new ZoneSmartPartInfo("ContentZone")); form.Workspace.Show(calendar); Assert.AreEqual(1, form.Workspace.Zones["ContentZone"].Controls.Count); }
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); }
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); }
public void ActivatedFiresCorrectNumberOfTimes() { ZoneWorkspaceForm form = CreateFormAddWorkspace(); Control zone = new Control(); Control zone1 = new Control(); Control control2 = new Control(); int activated = 0; AddZones(zone, zone1); workspace.SmartPartActivated += delegate(object sender, WorkspaceEventArgs args) { activated++; }; form.Show(); workspace.Show(control, new ZoneSmartPartInfo("Main")); workspace.Show(control2, new ZoneSmartPartInfo("Main1")); control.Select(); control2.Select(); control.Select(); //Will fire five times because it fires when show is called. Assert.AreEqual(5, activated); }
public void RenamingZoneDoesNotRegisterEventsMultipleTimes() { int activatedCalled = 0; ZoneWorkspaceForm zoneForm = new ZoneWorkspaceForm(); 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 Control(), new ZoneSmartPartInfo("NewZone")); Assert.AreEqual("NewZone", zoneForm.Workspace.GetZoneName(zone1)); Assert.AreEqual(1, activatedCalled); }