コード例 #1
0
        /// ------------------------------------------------------------------------------------
        public ContributorsEditor(ComponentFile file, string imageKey,
                                  AutoCompleteValueGatherer autoCompleteProvider, PersonInformant personInformant) :
            base(file, null, imageKey)
        {
            InitializeComponent();
            Name = "Contributors";

            _model = new ContributorsListControlViewModel(autoCompleteProvider, SaveContributors);

            // ReSharper disable once UseObjectOrCollectionInitializer
            _contributorsControl      = new ContributorsListControl(_model);
            _contributorsControl.Dock = DockStyle.Fill;
            _contributorsControl.ValidatingContributor += HandleValidatingContributor;

            InitializeGrid();

            Controls.Add(_contributorsControl);

            file.AfterSave += file_AfterSave;

            SetComponentFile(file);

            if (personInformant != null)
            {
                personInformant.PersonUiIdChanged += HandlePersonsUiIdChanged;
            }
        }
コード例 #2
0
        /// ------------------------------------------------------------------------------------
        private KeyValuePair <string, string> HandleValidatingContributor(ContributorsListControl sender,
                                                                          Contribution contribution, CancelEventArgs e)
        {
            var kvp = CheckIfContributorIsValid(contribution);

            e.Cancel = !string.IsNullOrEmpty(kvp.Key);

            if (!e.Cancel)
            {
                SaveContributors();
            }

            return(kvp);
        }
コード例 #3
0
        /// ------------------------------------------------------------------------------------
        public ContributorsEditor(ComponentFile file, string imageKey,
                                  AutoCompleteValueGatherer autoCompleteProvider, PersonInformant personInformant) :
            base(file, null, imageKey)
        {
            InitializeComponent();
            Name = "Contributors";

            _model = new ContributorsListControlViewModel(autoCompleteProvider, SaveContributors);
            var dataGridView = new DataGridView();

            dataGridView.Columns[dataGridView.Columns.Add("date", "date")].Visible = false;
            _model.ContributorsGridSettings = GridSettings.Create(dataGridView);

            // ReSharper disable once UseObjectOrCollectionInitializer
            _contributorsControl      = new ContributorsListControl(_model);
            _contributorsControl.Dock = DockStyle.Fill;
            _contributorsControl.ValidatingContributor += HandleValidatingContributor;

            InitializeGrid();

            // imageKey == "Contributor" when ContributorsEditor is lazy loaded for the session file type
            if (imageKey != null)
            {
                AddSessionControls();
            }
            else
            {
                Controls.Add(_contributorsControl);
            }

            file.AfterSave += file_AfterSave;

            SetComponentFile(file);

            if (personInformant != null)
            {
                personInformant.PersonUiIdChanged += HandlePersonsUiIdChanged;
            }
        }