///<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;
            };
        }
Пример #2
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();
            };
        }