/// ------------------------------------------------------------------------------------ public BasicFieldGridEditor(ComponentFile file, string imageKey, AutoCompleteValueGatherer autoCompleteProvider, FieldGatherer fieldGatherer) : base(file, null, imageKey) { InitializeComponent(); Name = "BasicFieldGridEditor"; InitializeGrid(autoCompleteProvider, fieldGatherer); }
/// ------------------------------------------------------------------------------------ public MediaComponentEditor(ComponentFile file, string tabText, string imageKey, AutoCompleteValueGatherer autoCompleteProvider, FieldGatherer fieldGatherer) : base(file, tabText, imageKey) { InitializeComponent(); InitializeGrid(autoCompleteProvider, fieldGatherer); _toolStrip.Renderer = new NoToolStripBorderRenderer(); _buttonPresets.DropDownItems.Add("HIDE"); }
/// ------------------------------------------------------------------------------------ protected virtual void InitializeGrid(IMultiListDataProvider autoCompleteProvider, FieldGatherer fieldGatherer) { _gridViewModel = new FieldsValuesGridViewModel(_file, autoCompleteProvider, fieldGatherer, key => key != "notes"); _grid = new FieldsValuesGrid(_gridViewModel, "BasicFieldGridEditor._grid"); _grid.Dock = DockStyle.Fill; Controls.Add(_grid); }
/// ------------------------------------------------------------------------------------ public FieldUpdater(FieldGatherer fieldGatherer, IDictionary <string, IXmlFieldSerializer> fieldSerializers) { _xmlFileSerializer = new XmlFileSerializer(fieldSerializers); _fieldGatherer = fieldGatherer; if (_fieldGatherer != null) { _rootProjectFolder = _fieldGatherer.RootDirectoryPath; } }
/// ------------------------------------------------------------------------------------ protected virtual void InitializeGrid(AutoCompleteValueGatherer autoCompleteProvider, FieldGatherer fieldGatherer) { _gridViewModel = new FieldsValuesGridViewModel(_file, autoCompleteProvider, fieldGatherer, key => !"notes contributions".Contains(key)); _grid = new FieldsValuesGrid(_gridViewModel, "MediaComponentEditor._grid"); _grid.Dock = DockStyle.Fill; _tableLayout.Controls.Add(_grid, 0, 1); _grid.BringToFront(); }
/// ------------------------------------------------------------------------------------ private void InitializeGrid(IMultiListDataProvider autoCompleteProvider, FieldGatherer fieldGatherer) { _gridViewModel = new CustomFieldsValuesGridViewModel(_file, autoCompleteProvider, fieldGatherer); _gridCustomFields = new FieldsValuesGrid(_gridViewModel, "PersonBasicEditor._gridCustomFields") { Dock = DockStyle.Top }; _panelGrid.AutoSize = true; _panelGrid.Controls.Add(_gridCustomFields); }
/// ------------------------------------------------------------------------------------ public FieldsValuesGridViewModel(ComponentFile file, IMultiListDataProvider autoCompleteProvider, FieldGatherer fieldGatherer, Func <string, bool> includedFieldFilterFunction) { _fieldGatherer = fieldGatherer; _includedFieldFilterFunction = includedFieldFilterFunction; if (autoCompleteProvider != null) { _autoCompleteProvider = autoCompleteProvider; _autoCompleteProvider.NewDataAvailable += HandleNewAutoCompleteDataAvailable; _autoCompleteLists = _autoCompleteProvider.GetValueLists(true); } SetComponentFile(file); }
/// ------------------------------------------------------------------------------------ public PersonBasicEditor(ComponentFile file, string imageKey, AutoCompleteValueGatherer autoCompleteProvider, FieldGatherer fieldGatherer, ImageFileType imgFileType) : base(file, null, imageKey) { Logger.WriteEvent("PersonBasicEditor constructor. file = {0}", file); InitializeComponent(); Name = "PersonEditor"; _imgFileType = imgFileType; _fatherButtons.AddRange(new[] { _pbPrimaryLangFather, _pbOtherLangFather0, _pbOtherLangFather1, _pbOtherLangFather2, _pbOtherLangFather3 }); _motherButtons.AddRange(new[] { _pbPrimaryLangMother, _pbOtherLangMother0, _pbOtherLangMother1, _pbOtherLangMother2, _pbOtherLangMother3 }); _pbPrimaryLangFather.Tag = _primaryLanguage; _pbPrimaryLangMother.Tag = _primaryLanguage; _pbOtherLangFather0.Tag = _otherLanguage0; _pbOtherLangMother0.Tag = _otherLanguage0; _pbOtherLangFather1.Tag = _otherLanguage1; _pbOtherLangMother1.Tag = _otherLanguage1; _pbOtherLangFather2.Tag = _otherLanguage2; _pbOtherLangMother2.Tag = _otherLanguage2; _pbOtherLangFather3.Tag = _otherLanguage3; _pbOtherLangMother3.Tag = _otherLanguage3; HandleStringsLocalized(); _binder.TranslateBoundValueBeingSaved += HandleBinderTranslateBoundValueBeingSaved; _binder.TranslateBoundValueBeingRetrieved += HandleBinderTranslateBoundValueBeingRetrieved; _binder.SetComponentFile(file); InitializeGrid(autoCompleteProvider, fieldGatherer); SetBindingHelper(_binder); _autoCompleteHelper.SetAutoCompleteProvider(autoCompleteProvider); _id.Enter += delegate { EnsureFirstRowLabelIsVisible(_labelFullName); }; _birthYear.Enter += delegate { EnsureFirstRowLabelIsVisible(_labelBirthYear); }; LoadAndValidatePersonInfo(); _binder.OnDataSaved += _binder_OnDataSaved; }
/// ------------------------------------------------------------------------------------ public ProjectContext(string projectSettingsPath, IContainer parentContainer) { var rootDirectoryPath = Path.GetDirectoryName(projectSettingsPath); BuildSubContainerForThisProject(rootDirectoryPath, parentContainer); Project = _scope.Resolve <Func <string, Project> >()(projectSettingsPath); SetContributorsListToSession(Project.SessionsFolder); var peopleRepoFactory = _scope.Resolve <ElementRepository <Person> .Factory>(); peopleRepoFactory(rootDirectoryPath, Person.kFolderName, _scope.Resolve <PersonFileType>()); var sessionRepoFactory = _scope.Resolve <ElementRepository <Session> .Factory>(); sessionRepoFactory(rootDirectoryPath, Session.kFolderName, _scope.Resolve <SessionFileType>()); // Create background operations _presetGatherer = _scope.Resolve <PresetGatherer>(); _autoCompleteValueGatherer = _scope.Resolve <AutoCompleteValueGatherer>(); _audioVideoDataGatherer = _scope.Resolve <AudioVideoDataGatherer>(); _fieldGatherer = _scope.Resolve <FieldGatherer>(); // Start background operations _presetGatherer.Start(); _autoCompleteValueGatherer.Start(); _audioVideoDataGatherer.Start(); _fieldGatherer.Start(); var view1 = _scope.Resolve <ProjectScreen>(); var view2 = _scope.Resolve <SessionsListScreen>(); var view3 = _scope.Resolve <PersonListScreen>(); var views = new ISayMoreView[] { view1, view2, view3 }; ProjectWindow = _scope.Resolve <ProjectWindow.Factory>()(projectSettingsPath, views); }
/// ------------------------------------------------------------------------------------ private void InitializeGrid(IMultiListDataProvider autoCompleteProvider, FieldGatherer fieldGatherer) { // additional fields grid _additionalFieldsGridViewModel = new AdditionalFieldsValuesGridViewModel(_file, autoCompleteProvider, fieldGatherer) { AllowUserToAddRows = false }; _gridAdditionalFields = new FieldsValuesGrid(_additionalFieldsGridViewModel, "SessionBasicEditor._gridAdditionalFields") { Dock = DockStyle.Top }; // to get a more helpful exception output than the default DataGrid error message _gridAdditionalFields.DataError += _gridAdditionalFields_DataError; _panelAdditionalGrid.AutoSize = true; _panelAdditionalGrid.Controls.Add(_gridAdditionalFields); for (int i = 0; i < _gridAdditionalFields.RowCount; i++) { var listType = _additionalFieldsGridViewModel.GetListType(i); if (listType != null) { AddDropdownCell(listType, i); } } _gridAdditionalFields.EditingControlShowing += _gridAdditionalFields_EditingControlShowing; // custom fields grid _gridViewModel = new CustomFieldsValuesGridViewModel(_file, autoCompleteProvider, fieldGatherer); _gridCustomFields = new FieldsValuesGrid(_gridViewModel, "SessionBasicEditor._gridCustomFields") { Dock = DockStyle.Top }; _panelGrid.AutoSize = true; _panelGrid.Controls.Add(_gridCustomFields); }
public static RenderedProjectionDefinition <TProjection> Translate <TDocument, TProjection>(Expression <Func <TDocument, TProjection> > projector, IBsonSerializer <TDocument> parameterSerializer) { var parameterSerializationInfo = new BsonSerializationInfo(null, parameterSerializer, parameterSerializer.ValueType); var parameterExpression = new SerializationExpression(projector.Parameters[0], parameterSerializationInfo); var binder = new SerializationInfoBinder(BsonSerializer.SerializerRegistry); binder.RegisterParameterReplacement(projector.Parameters[0], parameterExpression); var normalizedBody = Normalizer.Normalize(projector.Body); var evaluatedBody = PartialEvaluator.Evaluate(normalizedBody); var boundExpression = binder.Bind(evaluatedBody); var candidateFields = FieldGatherer.Gather(boundExpression); var fields = GetUniqueFieldsByHierarchy(candidateFields); var serializationInfo = fields.Select(x => x.SerializationInfo).ToList(); var replacementParameter = Expression.Parameter(typeof(ProjectedObject), "document"); var translator = new FindProjectionTranslator(projector.Parameters[0], replacementParameter, fields); var newProjector = Expression.Lambda <Func <ProjectedObject, TProjection> >( translator.Visit(boundExpression), replacementParameter); BsonDocument projectionDocument; IBsonSerializer <TProjection> serializer; if (translator._fullDocument) { projectionDocument = null; serializer = new ProjectingDeserializer <TDocument, TProjection>(parameterSerializer, projector.Compile()); } else { projectionDocument = GetProjectionDocument(serializationInfo); var projectedObjectSerializer = new ProjectedObjectDeserializer(serializationInfo); serializer = new ProjectingDeserializer <ProjectedObject, TProjection>(projectedObjectSerializer, newProjector.Compile()); } return(new RenderedProjectionDefinition <TProjection>(projectionDocument, serializer)); }
/// ------------------------------------------------------------------------------------ public SessionBasicEditor(ComponentFile file, string imageKey, AutoCompleteValueGatherer autoCompleteProvider, FieldGatherer fieldGatherer, PersonInformant personInformant) : base(file, null, imageKey) { Logger.WriteEvent("PersonBasicEditor constructor. file = {0}", file); InitializeComponent(); Name = "SessionEditor"; _personInformant = personInformant; _autoCompleteProvider = autoCompleteProvider; _autoCompleteProvider.NewDataAvailable += LoadGenreList; _binder.TranslateBoundValueBeingRetrieved += HandleBinderTranslateBoundValueBeingRetrieved; _binder.TranslateBoundValueBeingSaved += HandleBinderTranslateBoundValueBeingSaved; SetBindingHelper(_binder); _autoCompleteHelper.SetAutoCompleteProvider(autoCompleteProvider); _id.Enter += delegate { EnsureFirstRowLabelIsVisible(_labelId); }; _date.Enter += delegate { EnsureFirstRowLabelIsVisible(_labelDate); }; _genre.Enter += delegate { _genreFieldEntered = true; }; _genre.Leave += delegate { _genreFieldEntered = false; }; _genre.KeyPress += HandleGenreKeyPress; InitializeGrid(autoCompleteProvider, fieldGatherer); file.AfterSave += file_AfterSave; if (_personInformant != null) { _personInformant.PersonUiIdChanged += HandlePersonsUiIdChanged; } }
/// ------------------------------------------------------------------------------------ public CustomFieldsValuesGridViewModel(ComponentFile file, IMultiListDataProvider autoCompleteProvider, FieldGatherer fieldGatherer) : base(file, autoCompleteProvider, fieldGatherer, key => key.StartsWith(XmlFileSerializer.kCustomFieldIdPrefix)) { }
/// ------------------------------------------------------------------------------------ public VideoComponentEditor(ComponentFile file, string imageKey, AutoCompleteValueGatherer autoCompleteProvider, FieldGatherer fieldGatherer) : base(file, null, imageKey, autoCompleteProvider, fieldGatherer) { Name = "Video File Information"; }
/// ------------------------------------------------------------------------------------ public AdditionalFieldsValuesGridViewModel(ComponentFile file, IMultiListDataProvider autoCompleteProvider, FieldGatherer fieldGatherer) : base(file, autoCompleteProvider, fieldGatherer, IncludeField) { }