Пример #1
0
		public override void FinishInit()
		{
			m_chorusSystem = new ChorusSystem(Cache.ProjectId.ProjectFolder);
			m_chorusSystem.InitWithoutHg(SendReceiveUser);
			// This is a required object for CreateNotesBar. It specifies delegates for getting the information
			// the bar requires about the current object.
			var notesToRecordMapping = new NotesToRecordMapping()
				{
					FunctionToGetCurrentUrlForNewNotes = GetCurrentUrlForNewNotes,
					FunctionToGoFromObjectToItsId = GetIdForObject,
					FunctionToGoFromObjectToAdditionalIds = GetAdditionalIdsForObject
				};
			var dataFilePath = GetDataFilePath(Cache);
			var additionalPaths = GetAdditionalLexiconFilePaths(Cache);
			const string idAttrForOtherFiles = "guid"; // .lexdb chorus notes files identify FLEx object with a url attr of "guid".
			m_notesBar = m_chorusSystem.WinForms.CreateNotesBar(dataFilePath, additionalPaths, idAttrForOtherFiles, notesToRecordMapping, new NullProgress());
			m_notesBar.SetTargetObject(m_obj);
			// Set the writing systems for the NoteDetailDialog.  (See FWNX-1239.)
			var vernWs = Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;
			var labelWs = new ChorusWritingSystem(vernWs.LanguageName, vernWs.RFC5646, vernWs.DefaultFontName, 12);
			m_notesBar.LabelWritingSystem = labelWs;
			var analWs = Cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem;
			var msgWs = new ChorusWritingSystem (analWs.LanguageName, analWs.RFC5646, analWs.DefaultFontName, 12);
			m_notesBar.MessageWritingSystem = msgWs;
			this.Control = m_notesBar;
		}
Пример #2
0
        public DataEditor(ChorusSystem chorusSystem, string dataFilePath)
        {
            _chorusSystem = chorusSystem;
            _dataFilePath = dataFilePath;
            InitializeComponent();

            var notesToRecordMapping = new NotesToRecordMapping()
                                           {
                                               FunctionToGetCurrentUrlForNewNotes = GetCurrentUrlForNewNotes,
                                               FunctionToGoFromObjectToItsId = GetIdForObject
                                           };

            _notesBar = _chorusSystem.WinForms.CreateNotesBar(dataFilePath, notesToRecordMapping, new NullProgress());
            _notesBar.Location = new Point(10, 6);
            this.Controls.Add(_notesBar);

            XmlDocument doc = new XmlDocument();
            doc.Load(dataFilePath);

            var areas = doc.SelectNodes("//area");

            _area1Text.Tag = _area1Label.Text = areas[0].Attributes["id"].Value;
            _area1Text.Text = areas[0].InnerText.Trim();

            _area2Text.Tag = _area2Label.Text = areas[1].Attributes["id"].Value;
            _area2Text.Text = areas[1].InnerText.Trim();
        }
Пример #3
0
            /// <summary>
            /// Get the model that would be needed if we go on to create a NotesBarView.
            /// FLEx (at least) needs this to help it figure out, before we go to create the actual NotesBar,
            /// whether there are any notes to show for the current entry.
            /// </summary>
            /// <param name="pathToAnnotatedFile"></param>
            /// <param name="mapping"></param>
            /// <param name="progress"></param>
            /// <returns></returns>
            public NotesBarModel CreateNotesBarModel(string pathToAnnotatedFile, NotesToRecordMapping mapping, IProgress progress)
            {
                var repo  = _parent.GetNotesRepository(pathToAnnotatedFile, progress);
                var model = _container.Resolve <NotesBarModel.Factory>()(repo, mapping);

                return(model);
            }
Пример #4
0
 internal static NotesToRecordMapping SimpleForTest()
 {
     var m = new NotesToRecordMapping();
     m.FunctionToGoFromObjectToItsId = DefaultIdGeneratorUsingObjectToStringAsId;
     m.FunctionToGetCurrentUrlForNewNotes = DefaultUrlGenerator;
     return m;
 }
Пример #5
0
        static internal NotesToRecordMapping SimpleForTest()
        {
            var m = new NotesToRecordMapping();

            m.FunctionToGoFromObjectToItsId      = DefaultIdGeneratorUsingObjectToStringAsId;
            m.FunctionToGetCurrentUrlForNewNotes = DefaultUrlGenerator;
            return(m);
        }
Пример #6
0
 /// <summary>
 /// Get the model that would be needed if we go on to create a NotesBarView.
 /// FLEx (at least) needs this to help it figure out, before we go to create the actual NotesBar,
 /// whether there are any notes to show for the current entry.
 /// New annotations will be created in primaryAnnotationsFilePath.
 /// Annotations from all paths will be displayed.
 /// </summary>
 /// <param name="pathToPrimaryFile"></param>
 /// <param name="pathsToOtherFiles"></param>
 /// <param name="idAttrForOtherFiles">Attr in url that identifies the target of the annotation.</param>
 /// <param name="mapping"></param>
 /// <param name="progress"></param>
 /// <returns></returns>
 public NotesBarModel CreateNotesBarModel(string pathToPrimaryFile, IEnumerable<string> pathsToOtherFiles, string idAttrForOtherFiles, NotesToRecordMapping mapping, IProgress progress)
 {
     var repo = _parent.GetNotesRepository(pathToPrimaryFile, pathsToOtherFiles, idAttrForOtherFiles, progress);
     var model = _container.Resolve<NotesBarModel.Factory>()(repo, mapping);
     return model;
 }
Пример #7
0
 /// <summary>
 /// Get the model that would be needed if we go on to create a NotesBarView.
 /// FLEx (at least) needs this to help it figure out, before we go to create the actual NotesBar,
 /// whether there are any notes to show for the current entry.
 /// </summary>
 /// <param name="pathToAnnotatedFile"></param>
 /// <param name="mapping"></param>
 /// <param name="progress"></param>
 /// <returns></returns>
 public NotesBarModel CreateNotesBarModel(string pathToAnnotatedFile, NotesToRecordMapping mapping, IProgress progress)
 {
     var repo = _parent.GetNotesRepository(pathToAnnotatedFile, progress);
     var model = _container.Resolve<NotesBarModel.Factory>()(repo, mapping);
     return model;
 }
Пример #8
0
 /// <summary>
 /// Get a UI control designed to live near some data (e.g., a lexical entry);
 /// it provides buttons
 /// to let users see and open and existing notes attached to that data,
 /// or create new notes related to the data.
 /// New annotations will be created in primaryAnnotationsFilePath.
 /// Annotations from all paths will be displayed.
 /// idAttrForOtherFiles specifies the attr in annotation urls that identifies the target of the annotation for those files (in primary, hard-coded to "id")
 /// </summary>
 public NotesBarView CreateNotesBar(string pathToPrimaryFile, IEnumerable<string> pathsToOtherFiles, string idAttrForOtherFiles, NotesToRecordMapping mapping, IProgress progress)
 {
     var model = CreateNotesBarModel(pathToPrimaryFile, pathsToOtherFiles, idAttrForOtherFiles, mapping, progress);
     return new NotesBarView(model, _container.Resolve<AnnotationEditorModel.Factory>());
 }
Пример #9
0
 /// <summary>
 /// Get a UI control designed to live near some data (e.g., a lexical entry);
 /// it provides buttons
 /// to let users see and open and existing notes attached to that data,
 /// or create new notes related to the data.
 /// </summary>
 public NotesBarView CreateNotesBar(string pathToAnnotatedFile, NotesToRecordMapping mapping, IProgress progress)
 {
     var model = CreateNotesBarModel(pathToAnnotatedFile, mapping, progress);
     return new NotesBarView(model, _container.Resolve<AnnotationEditorModel.Factory>());
 }
Пример #10
0
		/// <summary>
		/// Determine if the object really has data to be shown in the slice. This method is called by reflection
		/// from DataTree.AddSimpleNode, to determine whether to create the slice when visibility is "ifdata".
		/// </summary>
		/// <param name="obj">object to check; should be an ILexEntry</param>
		/// <returns>true if there are chorus notes for this object; false otherwise</returns>
		public static bool ShowSliceForVisibleIfData(XmlNode node, ICmObject obj)
		{
			using (var chorusSystem = new ChorusSystem(obj.Cache.ProjectId.ProjectFolder))
			{
				chorusSystem.InitWithoutHg(SendReceiveUser);
				// This is a required object for CreateNotesBar. It specifies delegates for getting the information
				// the bar requires about the current object. For this model the FunctionToGetCurrentUrlForNewNotes will not be used.
				var notesToRecordMapping = new NotesToRecordMapping()
				{
					FunctionToGetCurrentUrlForNewNotes = DummyGetCurrentUrlForNewNotes,
					FunctionToGoFromObjectToItsId = GetIdForObject
				};
				var dataFilePath = GetDataFilePath(obj.Cache);
				var notesmodel = chorusSystem.WinForms.CreateNotesBarModel(dataFilePath, notesToRecordMapping, new NullProgress());
				notesmodel.SetTargetObject(obj);
				return notesmodel.GetAnnotationsToShow().Any();
			}
		}
Пример #11
0
            /// <summary>
            /// Get the model that would be needed if we go on to create a NotesBarView.
            /// FLEx (at least) needs this to help it figure out, before we go to create the actual NotesBar,
            /// whether there are any notes to show for the current entry.
            /// New annotations will be created in primaryAnnotationsFilePath.
            /// Annotations from all paths will be displayed.
            /// </summary>
            /// <param name="pathToPrimaryFile"></param>
            /// <param name="pathsToOtherFiles"></param>
            /// <param name="idAttrForOtherFiles">Attr in url that identifies the target of the annotation.</param>
            /// <param name="mapping"></param>
            /// <param name="progress"></param>
            /// <returns></returns>
            public NotesBarModel CreateNotesBarModel(string pathToPrimaryFile, IEnumerable <string> pathsToOtherFiles, string idAttrForOtherFiles, NotesToRecordMapping mapping, IProgress progress)
            {
                var repo  = _parent.GetNotesRepository(pathToPrimaryFile, pathsToOtherFiles, idAttrForOtherFiles, progress);
                var model = _container.Resolve <NotesBarModel.Factory>()(repo, mapping);

                return(model);
            }
Пример #12
0
            /// <summary>
            /// Get a UI control designed to live near some data (e.g., a lexical entry);
            /// it provides buttons
            /// to let users see and open and existing notes attached to that data,
            /// or create new notes related to the data.
            /// New annotations will be created in primaryAnnotationsFilePath.
            /// Annotations from all paths will be displayed.
            /// idAttrForOtherFiles specifies the attr in annotation urls that identifies the target of the annotation for those files (in primary, hard-coded to "id")
            /// </summary>
            public NotesBarView CreateNotesBar(string pathToPrimaryFile, IEnumerable <string> pathsToOtherFiles, string idAttrForOtherFiles, NotesToRecordMapping mapping, IProgress progress)
            {
                var model = CreateNotesBarModel(pathToPrimaryFile, pathsToOtherFiles, idAttrForOtherFiles, mapping, progress);

                return(new NotesBarView(model, _container.Resolve <AnnotationEditorModel.Factory>()));
            }
Пример #13
0
            /// <summary>
            /// Get a UI control designed to live near some data (e.g., a lexical entry);
            /// it provides buttons
            /// to let users see and open and existing notes attached to that data,
            /// or create new notes related to the data.
            /// </summary>
            public NotesBarView CreateNotesBar(string pathToAnnotatedFile, NotesToRecordMapping mapping, IProgress progress)
            {
                var model = CreateNotesBarModel(pathToAnnotatedFile, mapping, progress);

                return(new NotesBarView(model, _container.Resolve <AnnotationEditorModel.Factory>()));
            }