public void CanShowNonModal() { TestableRootWorkItem workItem = new TestableRootWorkItem(); WindowWorkspace workspace = workItem.Workspaces.AddNew <WindowWorkspace>(); MockSmartPart smartPart = workItem.SmartParts.AddNew <MockSmartPart>(); WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; info.Modal = false; workspace.Show(smartPart, info); Assert.IsTrue(workspace.Windows[smartPart].Visible); }
public void ShowingSmartPartISPInfoProviderSetFormText() { TestableRootWorkItem workItem = new TestableRootWorkItem(); WindowWorkspace workspace = workItem.Workspaces.AddNew <WindowWorkspace>(); MockSmartPart smartPart = workItem.SmartParts.AddNew <MockSmartPart>(); ISmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Smart Part"; workItem.RegisterSmartPartInfo(smartPart, info); workspace.Show(smartPart); Assert.AreEqual("Smart Part", workspace.Windows[smartPart].Text); }
public void ShowingSetFormTextFromWindowSmartPartInfo() { TestableRootWorkItem workItem = new TestableRootWorkItem(); WindowWorkspace workspace = workItem.Workspaces.AddNew <WindowWorkspace>(); MockWPFSmartPart smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>(); WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; workItem.RegisterSmartPartInfo(smartPart, info); workspace.Show(smartPart, info); Assert.AreEqual("Mock Smart Part", workspace.Windows[smartPart.ElementHost].Text); workspace.Windows[smartPart.ElementHost].Close(); }
public void CanSpecifyLocation() { TestableRootWorkItem workItem = new TestableRootWorkItem(); WindowWorkspace workspace = workItem.Workspaces.AddNew <WindowWorkspace>(); MockSmartPart smartPart = workItem.SmartParts.AddNew <MockSmartPart>(); WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; info.Location = new Point(10, 50); workspace.Show(smartPart, info); Assert.AreEqual(10, workspace.Windows[smartPart].Location.X); Assert.AreEqual(50, workspace.Windows[smartPart].Location.Y); }
public void ShowSetTextFromWindowSPInfo() { TestableRootWorkItem workItem = new TestableRootWorkItem(); Form parentForm = workItem.Items.AddNew <Form>(); MdiWorkspace workspace = new MdiWorkspace(parentForm); workItem.Workspaces.Add(workspace); MockSmartPart smartPart = workItem.SmartParts.AddNew <MockSmartPart>(); WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "SP"; workspace.Show(smartPart, info); Assert.AreEqual("SP", workspace.ParentMdiForm.MdiChildren[0].Text); }
public void CanSpecifySize() { TestableRootWorkItem workItem = new TestableRootWorkItem(); WindowWorkspace workspace = workItem.Workspaces.AddNew <WindowWorkspace>(); MockSmartPart smartPart = workItem.SmartParts.AddNew <MockSmartPart>(); WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; info.Width = 300; info.Height = 400; workspace.Show(smartPart, info); Assert.AreEqual(300, workspace.Windows[smartPart].Width); Assert.AreEqual(400, workspace.Windows[smartPart].Height); }
public void CanSpecifyLocationOnShow() { TestableRootWorkItem workItem = new TestableRootWorkItem(); Form parentForm = workItem.Items.AddNew <Form>(); MdiWorkspace workspace = new MdiWorkspace(parentForm); workItem.Workspaces.Add(workspace); MockSmartPart smartPart = workItem.SmartParts.AddNew <MockSmartPart>(); WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; info.Location = new Point(10, 50); workspace.Show(smartPart, info); Assert.AreEqual(10, workspace.Windows[smartPart].Location.X); Assert.AreEqual(50, workspace.Windows[smartPart].Location.Y); }
/// <summary> /// Gotoes the specified address. /// </summary> /// <param name="address">The address.</param> public void Goto(string address) { Uri uri = new Uri(address); WindowSmartPartInfo spi = new WindowSmartPartInfo(); spi.Title = "我的浏览器"; spi.WindowState = FormWindowState.Maximized; BrowserView view = ShowViewInWorkspace <BrowserView>(SmartPartNames.SmartPart_Shell_BrowserView, UIExtensionSiteNames.Shell_Workspace_Main, spi); Browser = view; try { view.Goto(uri); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }
public void CanSpecifySizeOnShow() { TestableRootWorkItem workItem = new TestableRootWorkItem(); Form parentForm = workItem.Items.AddNew <Form>(); MdiWorkspace workspace = new MdiWorkspace(parentForm); workItem.Workspaces.Add(workspace); MockSmartPart smartPart = workItem.SmartParts.AddNew <MockSmartPart>(); WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; info.Width = 300; info.Height = 400; workspace.Show(smartPart, info); Assert.AreEqual(300, workspace.Windows[smartPart].Width); Assert.AreEqual(400, workspace.Windows[smartPart].Height); }
public void CanApplyWindowOptions() { TestableRootWorkItem workItem = new TestableRootWorkItem(); WindowWorkspace workspace = workItem.Workspaces.AddNew <WindowWorkspace>(); MockSmartPart smartPart = workItem.SmartParts.AddNew <MockSmartPart>(); WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; info.Width = 400; workspace.Show(smartPart, info); Assert.AreEqual(400, workspace.Windows[smartPart].Width); info.Width = 500; workspace.ApplySmartPartInfo(smartPart, info); Assert.AreEqual(500, workspace.Windows[smartPart].Width); }
public void CanShowModalWithOwner() { TestableRootWorkItem workItem = new TestableRootWorkItem(); Form owner = new Form(); WindowWorkspace workspace = new WindowWorkspace(owner); workItem.Workspaces.Add(workspace); MockWPFSmartPart smartPart = null; WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; info.Modal = true; IWPFUIElementAdapter catalog = workItem.Services.Get <IWPFUIElementAdapter>(); Thread thread = new Thread(new ThreadStart(delegate { smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>(); workspace.Show(smartPart, info); })); #pragma warning disable CA1416 // Validate platform compatibility thread.SetApartmentState(ApartmentState.STA); #pragma warning restore CA1416 // Validate platform compatibility try { thread.Start(); Thread.Sleep(10000); Assert.IsTrue(workspace.Windows[catalog.Wrap(smartPart)].Visible); Assert.AreSame(owner, workspace.Windows[catalog.Wrap(smartPart)].Owner); } finally { SendMessage(workspace.Windows[catalog.Wrap(smartPart)].Handle, WM_SYSCOMMAND, SC_CLOSE, 0); thread.Join(); } }
public void HidingSmartPartDoesNotAutomaticallyShowPreviousForm() { TestableRootWorkItem workItem = new TestableRootWorkItem(); WindowWorkspace workspace = workItem.Workspaces.AddNew <WindowWorkspace>(); MockWPFSmartPart smartPartA = workItem.SmartParts.AddNew <MockWPFSmartPart>(); smartPartA.Visibility = System.Windows.Visibility.Hidden; MockWPFSmartPart smartPartB = workItem.SmartParts.AddNew <MockWPFSmartPart>(); smartPartB.Visibility = System.Windows.Visibility.Hidden; WindowSmartPartInfo smartPartInfoB = new WindowSmartPartInfo(); smartPartInfoB.Title = "Window SmartPart B"; WindowSmartPartInfo smartPartInfoA = new WindowSmartPartInfo(); smartPartInfoA.Title = "Window SmartPart A"; workspace.Show(smartPartA, smartPartInfoA); //Assert.IsTrue(smartPartA.Visible); Assert.AreNotEqual(System.Windows.Visibility.Hidden, smartPartA.Visibility); // Force the form to non-visible so it doesn't fire // his own Activated event after we hide the following // smart part, therefore making the condition impossible // to test. workspace.Windows[smartPartA.ElementHost].Hide(); workspace.Show(smartPartB, smartPartInfoB); //Assert.IsTrue(smartPartB.Visible); Assert.AreNotEqual(System.Windows.Visibility.Hidden, smartPartB.Visibility); workspace.Hide(smartPartB); Assert.IsNull(workspace.ActiveSmartPart); }
public void CanShowModal() { TestableRootWorkItem workItem = new TestableRootWorkItem(); WindowWorkspace workspace = workItem.Workspaces.AddNew <WindowWorkspace>(); MockWPFSmartPart smartPart = null; WindowSmartPartInfo info = new WindowSmartPartInfo(); info.Title = "Mock Smart Part"; info.Modal = true; IWPFUIElementAdapter catalog = workItem.Services.Get <IWPFUIElementAdapter>(); Thread thread = new Thread(new ThreadStart(delegate { // smartPart need to be created by the same thread that creates ElementHost smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>(); workspace.Show(smartPart, info); })); // needed to create ElementHost, calling thread must be STA. #pragma warning disable CA1416 // Validate platform compatibility thread.SetApartmentState(ApartmentState.STA); #pragma warning restore CA1416 // Validate platform compatibility try { thread.Start(); Thread.Sleep(10000); Assert.IsTrue(workspace.Windows[catalog.Wrap(smartPart)].Visible); } finally { SendMessage(workspace.Windows[catalog.Wrap(smartPart)].Handle, WM_SYSCOMMAND, SC_CLOSE, 0); thread.Join(); } }