コード例 #1
0
ファイル: FinderForm.cs プロジェクト: sungaoyong/ProSuite
        private FinderForm([NotNull] IEnumerable <ColumnDescriptor> columnDescriptors,
                           bool allowMultipleSelection              = false,
                           bool keepFindTextBetweenCalls            = true,
                           [CanBeNull] string filterSettingsContext = null)
        {
            Assert.ArgumentNotNull(columnDescriptors, nameof(columnDescriptors));

            InitializeComponent();

            KeepFindTextBetweenCalls = keepFindTextBetweenCalls;

            _toolStripStatusLabelMessage.Text = string.Empty;

            Type   type     = typeof(T);
            string typeName = Assert.NotNull(type.FullName,
                                             "type has no name: {0}", type);

            _formStateManager = new FormStateManager <FinderFormState>(this, typeName);

            _formStateManager.RestoreState();

            if (!StringUtils.IsNullOrEmptyOrBlank(filterSettingsContext))
            {
                _contextSettingsPersister = CreateContextSettingsPersister(typeName,
                                                                           filterSettingsContext);
                _restoredContextSpecificSettings = _contextSettingsPersister.Read();
            }

            _gridHandler = new BoundDataGridHandler <T>(
                _dataGridView,
                restoreSelectionAfterUserSort: true);
            _gridHandler.SelectionChanged += _gridHandler_SelectionChanged;

            // configure the datagrid
            _dataGridView.SuspendLayout();

            _dataGridView.MultiSelect = allowMultipleSelection;

            _gridHandler.AddColumns(columnDescriptors);

            _dataGridView.AutoGenerateColumns = false;

            _findController = new DataGridViewFindController(_dataGridView,
                                                             _dataGridViewFindToolStrip);
            _findController.FindResultChanged += _findController_FindResultChanged;

            if (allowMultipleSelection)
            {
                _toolStripButtonSelectFindResultRows =
                    new ToolStripButton(LocalizableStrings.FinderForm_SelectRows)
                {
                    Enabled      = false,
                    ImageScaling = ToolStripItemImageScaling.None,
                    Image        = Resources.SelectAll
                };

                _toolStripButtonSelectFindResultRows.Click +=
                    _toolStripButtonSelectFindResultRows_Click;

                _dataGridViewFindToolStrip.Items.Add(
                    _toolStripButtonSelectFindResultRows);
            }
        }