Exemple #1
0
        public void AddingSmartPartAtBeginningFiresOneActivatedEvent()
        {
            MockSmartPart smartPartA = new MockSmartPart();
            MockSmartPart smartPartB = new MockSmartPart();

            TabSmartPartInfo smartPartInfoA = new TabSmartPartInfo();

            smartPartInfoA.Title    = "Smart Part A";
            smartPartInfoA.Position = TabPosition.Beginning;

            TabSmartPartInfo smartPartInfoB = new TabSmartPartInfo();

            smartPartInfoB.Title = "Smart Part B";

            workspace.Show(smartPartB, smartPartInfoB);

            int activatedCalled = 0;

            workspace.SmartPartActivated += delegate(object sender, WorkspaceEventArgs e)
            {
                activatedCalled++;
                Assert.AreSame(e.SmartPart, smartPartA);
            };

            workspace.Show(smartPartA, smartPartInfoA);

            Assert.AreEqual(1, activatedCalled);
        }
        public void SPIsRemovedFromWorkspaceWhenDisposed1()
        {
            MockWPFSmartPart smartPartA = new MockWPFSmartPart();

            TabSmartPartInfo spInfoA = new TabSmartPartInfo();

            spInfoA.Title = "Smart Part A";

            workItem.SmartParts.Add(smartPartA);

            workspace.Show(smartPartA, spInfoA);

            Assert.AreEqual(1, workspace.TabPages.Count);

            //smartPartA.Dispose();
            IWPFUIElementAdapter catalog = workItem.Services.Get <IWPFUIElementAdapter>();
            Control wrapper = catalog.Wrap(smartPartA);

            wrapper.Dispose();

            Assert.AreEqual(0, workspace.TabPages.Count);

            // Returns 1
            Assert.AreEqual(0, workspace.SmartParts.Count);
        }
        private void CreateCommentsView()
        {
            commentsView = commentsView ?? Items.AddNew <CustomerCommentsView>();
            ISmartPartInfo info = new TabSmartPartInfo();

            info.Title = "Comments";
            RegisterSmartPartInfo(commentsView, info);
        }
        public void CanAvoidActivationTabInSPI()
        {
            TabSmartPartInfo info = new TabSmartPartInfo();

            info.ActivateTab = false;
            workspace.Show(sp);
            System.Windows.Controls.Control smartPart = new System.Windows.Controls.Control();
            workspace.Show(smartPart, info);

            Assert.AreEqual(0, workspace.SelectedIndex);
        }
Exemple #5
0
        protected override void OnActivated()
        {
            if (mapView == null)
            {
                mapView = WorkItem.Items.AddNew <CustomerMap>();

                TabSmartPartInfo info = new TabSmartPartInfo();
                info.Title       = "Customer Map";
                info.Description = "Map of the customer location";
                WorkItem.Workspaces[CustomerWorkItem.CUSTOMERDETAIL_TABWORKSPACE].Show(mapView, info);
            }
        }
Exemple #6
0
        public void CanConvertSmartPartInfo()
        {
            WPFSmartPartInfo info = new WPFSmartPartInfo();

            info.Title       = "Title";
            info.Description = "Description";

            TabSmartPartInfo copied = WPFSmartPartInfo.ConvertTo <TabSmartPartInfo>(info);

            Assert.AreEqual("Title", copied.Title);
            Assert.AreEqual("Description", copied.Description);
        }
Exemple #7
0
        public void ApplyTabInfoDoesNotOverrideTitleIfNull()
        {
            TabSmartPartInfo info = new TabSmartPartInfo();

            info.Title = "foo";
            workspace.Show(sp, info);

            info = new TabSmartPartInfo();
            workspace.ApplySmartPartInfo(sp, info);

            Assert.AreEqual("foo", workspace.TabPages[0].Text);
        }
Exemple #8
0
        public void CanActivateTabInSPI()
        {
            TabSmartPartInfo info = new TabSmartPartInfo();

            info.ActivateTab = true;
            workspace.Show(sp);
            Control smartPart = new Control();

            workspace.Show(smartPart, info);

            Assert.AreEqual(1, workspace.SelectedIndex);
        }
Exemple #9
0
        public void ShowTabWithNewInfo()
        {
            MockSmartPart part = new MockSmartPart();

            workItem.Items.Add(part);
            TabSmartPartInfo info = new TabSmartPartInfo();

            info.Title = "Updated";

            workspace.Show(part, info);

            Assert.AreEqual("Updated", workspace.SelectedTab.Text);
        }
Exemple #10
0
        public void ShowAddsTabsSelectsTabAndSetsText()
        {
            TabSmartPartInfo spInfo = new TabSmartPartInfo();

            spInfo.Title       = "Title";
            spInfo.Description = "Description";
            workItem.RegisterSmartPartInfo(sp, spInfo);

            workspace.Show(sp);

            Assert.AreEqual(1, workspace.TabPages.Count);
            Assert.AreEqual("Title", workspace.SelectedTab.Text);
        }
Exemple #11
0
        /// <summary>
        /// Generate the Drinks view (smart part).
        /// </summary>
        /// <param name="parentWorkspace">Tab workspace</param>
        public void Generate(IWorkspace parentWorkspace)
        {
            // TabSmartPart
            _smartPart             = new TabSmartPartInfo();
            _smartPart.Title       = "Drinks";
            _smartPart.ActivateTab = false;

            _drinksView = this.SmartParts.AddNew <DrinksView>();
            this.Workspaces["DrinksDistributorWorkspace"].Show(_drinksView, _smartPart);

            _drinksView.LoadDrinks();

            this.Activate();
        }
Exemple #12
0
        public void CanShowTabPositionAtEnd()
        {
            TabPage page = new TabPage();

            workspace.TabPages.Add(page);

            TabSmartPartInfo info = new TabSmartPartInfo();

            info.Position = TabPosition.End;
            workspace.Show(sp, info);

            Assert.AreEqual(2, workspace.TabPages.Count);
            Assert.AreEqual(1, workspace.SelectedIndex);
        }
Exemple #13
0
        public void TabPositionWithInfoIsSetCorrectly()
        {
            TabPage page = new TabPage();

            workspace.TabPages.Add(page);

            TabSmartPartInfo info = new TabSmartPartInfo();

            info.Position = TabPosition.Beginning;
            workspace.Show(sp, info);

            Assert.AreEqual(2, workspace.TabPages.Count);
            Assert.AreSame(workspace.TabPages[0], workspace.SelectedTab);
        }
        protected override void OnActivated()
        {
            if (mapView != null)
            {
                return;
            }

            mapView = WorkItem.Items.AddNew <CustomerMap>();
            var info = new TabSmartPartInfo
            {
                Title       = "Customer Map",
                Description = "Map of the customer location"
            };

            WorkItem.Workspaces[CustomerWorkItem.CUSTOMERDETAIL_TABWORKSPACE].Show(mapView, info);
        }
Exemple #15
0
        public void ActivatingMultipleTimesRaisesActivatedEventOnlyOnce()
        {
            int activateCalls     = 0;
            TabSmartPartInfo info = new TabSmartPartInfo();

            info.ActivateTab              = true;
            workspace.SmartPartActivated += delegate { activateCalls++; };

            // First call to event should happen here.
            workspace.Show(sp);
            Control smartPart = new Control();

            // Second call to event here.
            workspace.Show(smartPart, info);

            // No further calls should happen.
            workspace.Activate(smartPart);
            workspace.Activate(smartPart);

            Assert.AreEqual(2, activateCalls);
        }
Exemple #16
0
        public void SPIsRemovedFromWorkspaceWhenDisposed1()
        {
            MockSmartPart smartPartA = new MockSmartPart();

            TabSmartPartInfo spInfoA = new TabSmartPartInfo();

            spInfoA.Title = "Smart Part A";

            workItem.SmartParts.Add(smartPartA);

            workspace.Show(smartPartA, spInfoA);

            Assert.AreEqual(1, workspace.TabPages.Count);

            smartPartA.Dispose();

            Assert.AreEqual(0, workspace.TabPages.Count);

            // Returns 1
            Assert.AreEqual(0, workspace.SmartParts.Count);
        }