public void TestCreateReadOnlyGridButtonControl_GetControlUsingIndexer()
        {
            //---------------Set up test pack-------------------
            //---------------Execute Test ----------------------
            IControlHabanero grid = GetControlFactory().CreateReadOnlyGridButtonsControl();

            DisposeOnTearDown(grid);
            //---------------Test Result ----------------------

            IReadOnlyGridButtonsControl readOnlyGridButtonsControl = (IReadOnlyGridButtonsControl)grid;

            Assert.AreEqual(3, readOnlyGridButtonsControl.Controls.Count);

            //Delete Not Visible and Text Correct
            IButton btn = readOnlyGridButtonsControl["Delete"];

            Assert.IsNotNull(btn);
            Assert.AreEqual("Delete", btn.Name);
            Assert.IsFalse(btn.Visible);

            //Edit Visible and Text Correct
            btn = readOnlyGridButtonsControl["Edit"];
            Assert.IsNotNull(btn);
            Assert.AreEqual("Edit", btn.Text);
            Assert.IsTrue(btn.Visible);

            //Add Visible and Text Correct
            btn = readOnlyGridButtonsControl["Add"];
            Assert.IsNotNull(btn);
            Assert.AreEqual("Add", btn.Text);
            Assert.IsTrue(btn.Visible);
        }
        public void TestCreateReadOnlyGridButtonControl_TestButtonsAdded()
        {
            //---------------Set up test pack-------------------
            //---------------Execute Test ----------------------
            IControlHabanero grid = GetControlFactory().CreateReadOnlyGridButtonsControl();

            DisposeOnTearDown(grid);
            //---------------Test Result ----------------------
            IReadOnlyGridButtonsControl readOnlyGridButtonsControl = (IReadOnlyGridButtonsControl)grid;

            AddControlToForm(readOnlyGridButtonsControl);
            //Delete button should be first (This is right aligned so that means it will be furthest right if visible
            Assert.AreEqual(3, readOnlyGridButtonsControl.Controls.Count);
            IButton btn = (IButton)readOnlyGridButtonsControl.Controls[0];

            Assert.IsNotNull(btn);
            Assert.AreEqual("Delete", btn.Name);

            //Edit button should be second (This is right aligned so that means it will be second from left
            btn = (IButton)readOnlyGridButtonsControl.Controls[1];
            Assert.IsNotNull(btn);
            Assert.AreEqual("Edit", btn.Name);

            //Add button should be last (This is right aligned so that means it will be the first button from the left
            //(last from the right)
            btn = (IButton)readOnlyGridButtonsControl.Controls[2];
            Assert.IsNotNull(btn);
            Assert.AreEqual("Add", btn.Name);
        }
        ///<summary>
        /// Constructs a new instance of a <see cref="ReadOnlyGridControlWin"/>.
        ///</summary>
        ///<param name="controlFactory">The <see cref="IControlFactory"/> to use to construct the control.</param>
        public ReadOnlyGridControlWin(IControlFactory controlFactory)
        {
            _controlFactory             = controlFactory;
            _grid                       = new ReadOnlyGridWin();
            FilterControl               = _controlFactory.CreateFilterControl();
            _buttons                    = _controlFactory.CreateReadOnlyGridButtonsControl();
            _readOnlyGridControlManager = new ReadOnlyGridControlManager(this, _controlFactory);
            InitialiseButtons();
            InitialiseFilterControl();
            BorderLayoutManager borderLayoutManager = new BorderLayoutManagerWin(this, _controlFactory);

            borderLayoutManager.AddControl(_grid, BorderLayoutManager.Position.Centre);
            borderLayoutManager.AddControl(_buttons, BorderLayoutManager.Position.South);
            borderLayoutManager.AddControl(FilterControl, BorderLayoutManager.Position.North);
            FilterMode = FilterModes.Filter;
            Grid.Name  = "GridControl";

            _doubleClickEditsBusinessObject   = false;
            DoubleClickEditsBusinessObject    = true;
            this.Grid.BusinessObjectSelected += Grid_OnBusinessObjectSelected;

            this.OnAsyncOperationStarted += (sender, e) =>
            {
                lock (this)
                {
                    this._inAsyncOperation = true;
                }
                this.Enabled       = false;
                this.UseWaitCursor = true;
                var f = this.FilterControl as Control;
                if (f != null)
                {
                    f.UseWaitCursor = true;              // just to make sure
                }
                this.Cursor = Cursors.WaitCursor;
            };
            this.OnAsyncOperationComplete += (sender, e) =>
            {
                lock (this)
                {
                    this._inAsyncOperation = false;
                }
                this.Enabled       = true;
                this.UseWaitCursor = false;
                var f = this.FilterControl as Control;
                if (f != null)
                {
                    f.UseWaitCursor = false;                 // this is required to work around sometimes coming out of async but the wait cursor is left on the filter
                }
                this.Cursor = Cursors.Default;
            };
        }
        public void Test_ShowDefaultDeleteButton_MakesTheDeleteButtonVisible()
        {
            //---------------Set up test pack-------------------
            IReadOnlyGridButtonsControl readOnlyGridButtonsControl = GetControlFactory().CreateReadOnlyGridButtonsControl();

            DisposeOnTearDown(readOnlyGridButtonsControl);
            IButton btn = readOnlyGridButtonsControl["Delete"];

            //--------------verify Test pack -------------------
            Assert.IsFalse(btn.Visible);

            //---------------Execute Test ----------------------
            readOnlyGridButtonsControl.ShowDefaultDeleteButton = true;
            //---------------Verify Result ----------------------
            Assert.IsTrue(btn.Visible);
        }
        public void TestEditButtonClick()
        {
            //---------------Set up test pack-------------------
            IReadOnlyGridButtonsControl readOnlyGridButtonsControl = GetControlFactory().CreateReadOnlyGridButtonsControl();

            DisposeOnTearDown(readOnlyGridButtonsControl);
            AddControlToForm(readOnlyGridButtonsControl);
            IButton btn         = readOnlyGridButtonsControl["Edit"];
            bool    editClicked = false;

            readOnlyGridButtonsControl.EditClicked += delegate { editClicked = true; };
            //---------------Execute Test ----------------------
            btn.PerformClick();

            //---------------Test Result ----------------------
            Assert.IsTrue(editClicked);
        }
Exemplo n.º 6
0
        ///<summary>
        /// Constructs a new instance of a <see cref="ReadOnlyGridControlVWG"/>.
        ///</summary>
        ///<param name="controlFactory">The <see cref="IControlFactory"/> to use to construct the control.</param>
        public ReadOnlyGridControlVWG(IControlFactory controlFactory)
        {
            _controlFactory             = controlFactory;
            _grid                       = new ReadOnlyGridVWG();
            _readOnlyGridControlManager = new ReadOnlyGridControlManager(this, _controlFactory);
            FilterControl               = _controlFactory.CreateFilterControl();
            _buttons                    = _controlFactory.CreateReadOnlyGridButtonsControl();
            InitialiseButtons();
            InitialiseFilterControl();
            BorderLayoutManager borderLayoutManager = new BorderLayoutManagerVWG(this, _controlFactory);

            borderLayoutManager.AddControl(_grid, BorderLayoutManager.Position.Centre);
            borderLayoutManager.AddControl(_buttons, BorderLayoutManager.Position.South);
            borderLayoutManager.AddControl(FilterControl, BorderLayoutManager.Position.North);
            FilterMode = FilterModes.Filter;
            _grid.Name = "GridControl";
            this.Grid.BusinessObjectSelected += Grid_OnBusinessObjectSelected;
            this.Buttons["Add"].Visible       = _allowUsersToAddBo;
            this.Buttons["Edit"].Visible      = _allowUsersToEditBo;
            this.BusinessObjectSelected      += (s, e) =>
            {
                this.SetButtonStatesForSelectedObject();
            };
        }
 ///<summary>
 /// Constructor for the <see cref="ReadOnlyGridButtonsControlManager"/>
 ///</summary>
 ///<param name="buttonsControl"></param>
 public ReadOnlyGridButtonsControlManager(IReadOnlyGridButtonsControl buttonsControl)
 {
     _buttonsControl = buttonsControl;
 }
 ///<summary>
 /// Constructor for the <see cref="ReadOnlyGridButtonsControlManager"/>
 ///</summary>
 ///<param name="buttonsControl"></param>
 public ReadOnlyGridButtonsControlManager(IReadOnlyGridButtonsControl buttonsControl)
 {
     _buttonsControl = buttonsControl;
 }