public void AddTabPageTest()
        {
            _eventSink.ExpectedSelectedIndexChanged = 3;

            NuGenTabPage tabPage  = _tabControl.TabPages.Add("0");
            NuGenTabPage tabPage1 = _tabControl.TabPages.Add("1");
            NuGenTabPage tabPage2 = _tabControl.TabPages.Add("2");

            _eventSink.ExpectedTabPageAdded = 3;

            _eventSink.AddExpectedTabPageAddedIndex(0);
            _eventSink.AddExpectedTabPageAddedIndex(1);
            _eventSink.AddExpectedTabPageAddedIndex(2);

            _eventSink.AddExpectedTabPageAddedObject(tabPage);
            _eventSink.AddExpectedTabPageAddedObject(tabPage1);
            _eventSink.AddExpectedTabPageAddedObject(tabPage2);

            for (int i = 0; i < _tabControl.TabPages.Count; i++)
            {
                Assert.AreEqual(i.ToString(), _tabControl.TabButtons[i].Text);
            }

            _eventSink.Verify();
        }
Example #2
0
        private void _tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService));

            if (service != null)
            {
                ICollection selectedComponents = service.GetSelectedComponents();
                bool        flag = false;

                foreach (object selectedComponent in selectedComponents)
                {
                    NuGenTabPage tabPageOfComponent = NuGenTabControlDesigner.GetTabPageOfComponent(selectedComponent);

                    if (
                        tabPageOfComponent != null &&
                        tabPageOfComponent.Parent == _tabControl &&
                        tabPageOfComponent == _tabControl.SelectedTab
                        )
                    {
                        flag = true;
                        break;
                    }
                }

                if (!flag)
                {
                    service.SetSelectedComponents(new object[] { base.Component });
                }
            }
        }
Example #3
0
        public void InsertTest()
        {
            NuGenTabPage tabPage  = _collection.Insert(0, "");
            NuGenTabPage tabPage2 = _collection.Insert(0, "");

            Assert.AreEqual(2, _collection.Count);
            Assert.AreEqual(tabPage, _collection[1]);
            Assert.AreEqual(tabPage2, _collection[0]);
        }
Example #4
0
        public void IndexOfTest()
        {
            NuGenTabPage tabPage  = _collection.Insert(0, "");
            NuGenTabPage tabPage2 = _collection.Insert(0, "");

            Assert.AreEqual(0, _collection.IndexOf(tabPage2));
            Assert.AreEqual(1, _collection.IndexOf(tabPage));
            Assert.AreEqual(-1, _collection.IndexOf(null));
        }
Example #5
0
        public void AddTest()
        {
            string tabPageText = "abc";

            NuGenTabPage tabPage = _collection.Add(tabPageText);

            Assert.AreEqual(tabPageText, tabPage.Text);
            Assert.AreEqual(1, _collection.Count);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenTabCancelEventArgs"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="tabPage"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public NuGenTabCancelEventArgs(NuGenTabPage tabPage, bool cancel)
        {
            if (tabPage == null)
            {
                throw new ArgumentNullException("tabPage");
            }

            _tabPage = tabPage;
            _cancel  = cancel;
        }
        public void TabPageEnabledTest()
        {
            NuGenTabPage tabPage  = _tabControl.TabPages.Add("0");
            NuGenTabPage tabPage2 = _tabControl.TabPages.Add("1");
            NuGenTabPage tabPage3 = _tabControl.TabPages.Add("2");

            Assert.IsTrue(_tabControl.TabButtons[1].Enabled);
            tabPage2.Enabled = false;
            Assert.IsFalse(_tabControl.TabButtons[1].Enabled);
        }
        public void TabPageImageTest()
        {
            Image img = new Bitmap(1, 1);

            NuGenTabPage tabPage = _tabControl.TabPages.Add("0");

            tabPage.TabButtonImage = img;

            Assert.AreSame(img, _tabControl.TabButtons[0].Image);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenTabCancelEventArgs"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="tabPage"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public NuGenTabCancelEventArgs(NuGenTabPage tabPage, bool cancel)
		{
			if (tabPage == null)
			{
				throw new ArgumentNullException("tabPage");
			}

			_tabPage = tabPage;
			_cancel = cancel;
		}
        public void ControlRemoveTest()
        {
            NuGenTabPage tabPage  = _tabControl.TabPages.Add("");
            NuGenTabPage tabPage2 = _tabControl.TabPages.Add("");

            _tabControl.Controls.Remove(tabPage2);

            Assert.AreEqual(1, _tabControl.TabPages.Count);
            Assert.AreEqual(1, _tabControl.TabButtons.Count);
            Assert.AreEqual(tabPage, _tabControl.TabPages[0]);
        }
Example #11
0
        public void RemoveTest()
        {
            NuGenTabPage tabPage  = _collection.Add("");
            NuGenTabPage tabPage2 = _collection.Add("");

            Assert.AreEqual(2, _collection.Count);

            _collection.Remove(tabPage);
            Assert.AreEqual(1, _collection.Count);

            _collection.Remove(tabPage2);
            Assert.AreEqual(0, _collection.Count);
        }
        public void EnabledTest()
        {
            NuGenTabPage tabPage  = _tabControl.TabPages.Add("");
            NuGenTabPage tabPage2 = _tabControl.TabPages.Add("");

            _tabControl.Enabled = false;

            NuGenTabPage tabPage3 = _tabControl.TabPages.Add("");

            foreach (NuGenTabButton tabButton in _tabControl.TabButtons)
            {
                Assert.IsFalse(tabButton.Enabled);
            }
        }
        public void AddRemoveTest()
        {
            NuGenTabPage tabPage  = _tabControl.TabPages.Add("");
            NuGenTabPage tabPage2 = _tabControl.TabPages.Add("");

            Assert.AreEqual(2, _tabControl.TabPages.Count);

            _tabControl.TabPages.Remove(tabPage2);
            Assert.AreEqual(1, _tabControl.TabPages.Count);

            NuGenTabPage tabPage3 = _tabControl.TabPages.Add("");

            Assert.AreEqual(2, _tabControl.TabPages.Count);
        }
Example #14
0
        /*
         * FindCanvasOnTabPage
         */

        public Canvas FindCanvasOnTabPage(NuGenTabPage tabPage)
        {
            Canvas canvas = null;

            foreach (Control ctrl in tabPage.Controls)
            {
                if (ctrl is Canvas)
                {
                    canvas = (Canvas)ctrl;
                    break;
                }
            }

            return(canvas);
        }
Example #15
0
        /*
         * GetSelectedTabPageDesigner
         */

        /// <summary>
        /// </summary>
        /// <returns></returns>
        protected NuGenTabPageDesigner GetSelectedTabPageDesigner()
        {
            NuGenTabPageDesigner tabPageDesigner = null;
            NuGenTabPage         selectedTabPage = _tabControl.SelectedTab;

            if (selectedTabPage != null)
            {
                IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

                if (host != null)
                {
                    tabPageDesigner = host.GetDesigner(selectedTabPage) as NuGenTabPageDesigner;
                }
            }

            return(tabPageDesigner);
        }
Example #16
0
        /*
         * AddTabPage
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="pageContent"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="text"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public NuGenTabPage AddTabPage(Control pageContent, String text, Image tabButtonImage)
        {
            if (pageContent == null)
            {
                throw new ArgumentNullException("pageContent");
            }

            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            NuGenTabPage tabPage = this.TabPages.Add(text, tabButtonImage);

            tabPage.Controls.Add(pageContent);
            return(tabPage);
        }
Example #17
0
        /*
         * AddTabPage
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="pageContent"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="text"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public NuGenTabPage AddTabPage(Canvas canvas, String text, Image tabButtonImage)
        {
            if (canvas == null)
            {
                throw new ArgumentNullException("canvas");
            }

            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            NuGenTabPage tabPage = TabPages.Add(text, tabButtonImage);

            tabPage.Controls.Add(canvas);
            canvas.ParentTabPage = tabPage;
            return(tabPage);
        }
        /*
         * AddTabPage
         */

        public void AddTabPage()
        {
            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                DesignerTransaction transaction = null;

                try
                {
                    try
                    {
                        transaction = host.CreateTransaction("NuGenTabControl.AddTabPage");
                    }
                    catch (CheckoutException e)
                    {
                        if (e != CheckoutException.Canceled)
                        {
                            throw e;
                        }

                        return;
                    }

                    NuGenTabPage tabPage = (NuGenTabPage)host.CreateComponent(typeof(NuGenTabPage));
                    _tabControl.TabPages.Add(tabPage);


                    PropertyDescriptor textDescriptor = TypeDescriptor.GetProperties(tabPage)["Text"];

                    if (textDescriptor != null)
                    {
                        textDescriptor.SetValue(tabPage, Resources.BlankText);
                    }
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
Example #19
0
        private void _selectionService_SelectionChanged(object sender, EventArgs e)
        {
            ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService));

            if (service != null)
            {
                ICollection selectedComponents = service.GetSelectedComponents();

                foreach (object selectedComponent in selectedComponents)
                {
                    NuGenTabPage tabPageOfComponent = NuGenTabControlDesigner.GetTabPageOfComponent(selectedComponent);

                    if (tabPageOfComponent != null && tabPageOfComponent.Parent == _tabControl)
                    {
                        _tabControl.SelectedTab = tabPageOfComponent;
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="tabPageToDestroy"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        protected void DestroyTabPage(NuGenTabPage tabPageToDestroy)
        {
            if (tabPageToDestroy == null)
            {
                throw new ArgumentNullException("tabPageToDestroy");
            }

            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                DesignerTransaction transaction = null;

                try
                {
                    try
                    {
                        transaction = host.CreateTransaction("NuGenTabControl.RemoveTabPage");
                    }
                    catch (CheckoutException e)
                    {
                        if (e != CheckoutException.Canceled)
                        {
                            throw;
                        }

                        return;
                    }

                    _tabControl.TabPages.Remove(tabPageToDestroy);
                    host.DestroyComponent(tabPageToDestroy);
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
        public void RemoveAllTest()
        {
            NuGenTabPage tabPage  = _tabControl.TabPages.Add("");
            NuGenTabPage tabPage2 = _tabControl.TabPages.Add("");

            _eventSink.ExpectedTabPageRemoved = 2;

            _eventSink.AddExpectedTabPageRemovedIndex(1);
            _eventSink.AddExpectedTabPageRemovedIndex(0);

            _eventSink.AddExpectedTabPageRemovedObject(tabPage2);
            _eventSink.AddExpectedTabPageRemovedObject(tabPage);

            _tabControl.TabPages.Remove(tabPage2);
            Assert.AreEqual(1, _tabControl.TabButtons.Count);
            Assert.IsNotNull(_tabControl.SelectedTabButton);

            _tabControl.TabPages.Remove(tabPage);
            Assert.AreEqual(0, _tabControl.TabButtons.Count);
            Assert.IsNull(_tabControl.SelectedTabButton);

            _eventSink.Verify();
        }
        public void SelectTabTest()
        {
            NuGenTabPage tabPage  = _tabControl.TabPages.Add("0");
            NuGenTabPage tabPage2 = _tabControl.TabPages.Add("1");

            Assert.AreEqual(tabPage2, _tabControl.SelectedTab);
            Assert.AreEqual(1, _tabControl.SelectedIndex);
            Assert.AreEqual("1", _tabControl.TabButtons[1].Text);
            Assert.IsTrue(_tabControl.TabButtons[1].Selected);
            Assert.IsFalse(_tabControl.TabButtons[0].Selected);

            _tabControl.SelectTab(tabPage);
            Assert.AreEqual(tabPage, _tabControl.SelectedTab);
            Assert.AreEqual(0, _tabControl.SelectedIndex);
            Assert.AreEqual("0", _tabControl.TabButtons[0].Text);
            Assert.IsFalse(_tabControl.TabButtons[1].Selected);
            Assert.IsTrue(_tabControl.TabButtons[0].Selected);

            _tabControl.SelectedTab = tabPage2;
            Assert.AreEqual(tabPage2, _tabControl.SelectedTab);

            _tabControl.SelectedIndex = 0;
            Assert.AreEqual(tabPage, _tabControl.SelectedTab);
        }
			public void AddExpectedTabPageRemovedObject(NuGenTabPage tabPage)
			{
				_tabPageRemovedObjectList.AddExpected(tabPage);
			}
		/// <summary>
		/// </summary>
		/// <param name="tabPageToDestroy"></param>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="tabPageToDestroy"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		protected void DestroyTabPage(NuGenTabPage tabPageToDestroy)
		{
			if (tabPageToDestroy == null)
			{
				throw new ArgumentNullException("tabPageToDestroy");
			}

			IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

			if (host != null)
			{
				DesignerTransaction transaction = null;

				try
				{
					try
					{
						transaction = host.CreateTransaction("NuGenTabControl.RemoveTabPage");
					}
					catch (CheckoutException e)
					{
						if (e != CheckoutException.Canceled)
						{
							throw e;
						}

						return;
					}

					_tabControl.TabPages.Remove(tabPageToDestroy);
					host.DestroyComponent(tabPageToDestroy);
				}
				finally
				{
					if (transaction != null)
					{
						transaction.Commit();
					}
				}
			}
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenTabCancelEventArgs"/> class.<para/>
		/// Cancel = <see langword="false"/>.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="tabPage"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		public NuGenTabCancelEventArgs(NuGenTabPage tabPage)
			: this(tabPage, false)
		{
		}
Example #26
0
        public void IndexerTest()
        {
            NuGenTabPage tabPage = _collection.Insert(0, "");

            Assert.AreEqual(tabPage, _collection[0]);
        }
Example #27
0
 public void IndexerArgumentOutOfRangeExceptionTest()
 {
     NuGenTabPage tabPage = _collection[0];
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NuGenTabCancelEventArgs"/> class.<para/>
 /// Cancel = <see langword="false"/>.
 /// </summary>
 /// <exception cref="ArgumentNullException">
 /// <para>
 ///		<paramref name="tabPage"/> is <see langword="null"/>.
 /// </para>
 /// </exception>
 public NuGenTabCancelEventArgs(NuGenTabPage tabPage)
     : this(tabPage, false)
 {
 }
Example #29
0
 public void AddExpectedTabPageRemovedObject(NuGenTabPage tabPage)
 {
     _tabPageRemovedObjectList.AddExpected(tabPage);
 }
        public void TabPageContentTest()
        {
            NuGenTabPage tabPage = _tabbedMdi.AddTabPage(_ctrl, "", null);

            Assert.AreEqual(1, _tabbedMdi.TabPages.Count);
        }