Example #1
0
		public LexExampleSentence(WeSayDataObject parent): base(parent)
		{
			_sentence = new MultiText(this);
			_translation = new MultiText(this);

			WireUpEvents();
		}
		internal override int AddWidgets(WeSayDataObject wsdo, int insertAtRow)
		{
			LexExampleSentence example = (LexExampleSentence) wsdo;

			DetailList.SuspendLayout();
			int rowCount = 0;
			try
			{
				Field field =
						ActiveViewTemplate.GetField(Field.FieldNames.ExampleSentence.ToString());
				if (field != null && field.GetDoShow(example.Sentence, ShowNormallyHiddenFields))
				{
					Control control = MakeBoundControl(example.Sentence, field);
					DetailList.AddWidgetRow(
							StringCatalog.Get("~Example",
											  "This is the field containing an example sentence of a sense of a word."),
							false,
							control,
							insertAtRow,
							false);
					++rowCount;
					insertAtRow = DetailList.GetRow(control);
				}

				field = ActiveViewTemplate.GetField(Field.FieldNames.ExampleTranslation.ToString());
				if (field != null && field.GetDoShow(example.Translation, ShowNormallyHiddenFields))
				{
					Control entry = MakeBoundControl(example.Translation, field);
					DetailList.AddWidgetRow(
							StringCatalog.Get("~Translation",
											  "This is the field for putting in a translation of an example sentence."),
							false,
							entry,
							insertAtRow + rowCount,
							false);
					++rowCount;
				}

				rowCount += AddCustomFields(example, insertAtRow + rowCount);
			}
			catch (ConfigurationException e)
			{
				ErrorReport.ReportNonFatalMessage(e.Message);
			}

			DetailList.ResumeLayout();
			return rowCount;
		}
Example #3
0
		private static LexRelation AddRelation(WeSayDataObject source,
											   string fieldName,
											   string targetId)
		{
			LexRelationCollection relationColection =
					source.GetOrCreateProperty<LexRelationCollection>(fieldName);

			LexRelation relation = new LexRelation(fieldName, targetId, source);
			relationColection.Relations.Add(relation);
			return relation;
		}
Example #4
0
		public LexSense(WeSayDataObject parent): base(parent)
		{
			//   _gloss = new SenseGlossMultiText(this);
			_exampleSentences = new BindingList<LexExampleSentence>();
			WireUpEvents();
		}
Example #5
0
		internal override int AddWidgets(WeSayDataObject wsdo, int insertAtRow)
		{
			LexSense sense = (LexSense) wsdo;
			int rowCount = 0;
			DetailList.SuspendLayout();
			try
			{
#if GlossMeaning
				Field field = ActiveViewTemplate.GetField(Field.FieldNames.SenseGloss.ToString());
				if (field != null && field.GetDoShow(sense.Gloss, this.ShowNormallyHiddenFields))
				{
					Control meaningControl = MakeBoundControl(sense.Gloss, field);
#else
				Field field = ActiveViewTemplate.GetField(LexSense.WellKnownProperties.Definition);
				if (field != null && field.GetDoShow(sense.Definition, ShowNormallyHiddenFields))
				{
					Control meaningControl = MakeBoundControl(sense.Definition, field);
#endif
					string label = StringCatalog.Get("~Meaning");
					LexEntry entry = sense.Parent as LexEntry;
					if (entry != null) // && entry.Senses.Count > 1)
					{
						label += " " + (entry.Senses.IndexOf(sense) + 1);
					}
					Control meaningRowControl = DetailList.AddWidgetRow(label,
																		true,
																		meaningControl,
																		insertAtRow,
																		false);
					++rowCount;
					insertAtRow = DetailList.GetRow(meaningRowControl);
				}

				//#if GlossMeaning
				//#else
				//                Field glossfield = ActiveViewTemplate.GetField(Field.FieldNames.SenseGloss.ToString());
				//                if (glossfield != null && glossfield.GetDoShow(sense.Gloss, this.ShowNormallyHiddenFields))
				//                {
				//                    Control control = MakeBoundControl(sense.Gloss, glossfield);
				//                    DetailList.AddWidgetRow(
				//                        StringCatalog.Get("~Gloss",
				//                                          "This is the field that normally has just a single word translation, not a full definition. Mostly used with interlinear text displays."),
				//                        false,
				//                        control, insertAtRow + rowCount, false);
				//                    ++rowCount;
				//                    insertAtRow = DetailList.GetRow(control);
				//                }
				//#endif

				rowCount += AddCustomFields(sense, insertAtRow + rowCount);

				LexExampleSentenceLayouter exampleLayouter =
						new LexExampleSentenceLayouter(DetailList, ActiveViewTemplate);
				exampleLayouter.ShowNormallyHiddenFields = ShowNormallyHiddenFields;

				rowCount = AddChildrenWidgets(exampleLayouter,
											  sense.ExampleSentences,
											  insertAtRow,
											  rowCount);

				//add a ghost for another example if we don't have one or we're in the "show all" mode
				//removed because of its effect on the Add Examples task, where
				//we'd like to be able to add more than one
				//if (ShowNormallyHiddenFields || sense.ExampleSentences.Count == 0)
				{
					rowCount += exampleLayouter.AddGhost(sense.ExampleSentences,
														 insertAtRow + rowCount);
				}
			}
			catch (ConfigurationException e)
			{
				ErrorReport.ReportNonFatalMessage(e.Message);
			}
			DetailList.ResumeLayout();
			return rowCount;
		}
Example #6
0
		public TestClass(WeSayDataObject parent): base(parent) {}
Example #7
0
		internal override int AddWidgets(WeSayDataObject wsdo, int insertAtRow)
		{
			return AddWidgets((LexEntry) wsdo, insertAtRow);
		}
		private static void AssertPropertyHasExpectedMultiText(WeSayDataObject dataObject,
															   string name)
		{
			//must match what is created by MakeBasicLiftMultiText()
			MultiText mt = dataObject.GetProperty<MultiText>(name);
			Assert.AreEqual(2, mt.Forms.Length);
			Assert.AreEqual("dos", mt["ws-two"]);
		}
Example #9
0
		private void WriteCustomProperties(WeSayDataObject item,
										   ICollection<string> propertiesAlreadyOutput)
		{
			foreach (KeyValuePair<string, object> pair in item.Properties)
			{
				if (propertiesAlreadyOutput.Contains(pair.Key))
				{
					continue;
				}
				if (!ShouldOutputProperty(pair.Key))
				{
					continue;
				}
				if (pair.Value is EmbeddedXmlCollection)
				{
					WriteEmbeddedXmlCollection(pair.Value as EmbeddedXmlCollection);
					continue;
				}
				if (pair.Value is MultiText)
				{
					WriteCustomMultiTextField(pair.Key, pair.Value as MultiText);
					continue;
				}
				if (pair.Value is OptionRef)
				{
					WriteOptionRef(pair.Key, pair.Value as OptionRef);
					continue;
				}
				if (pair.Value is OptionRefCollection)
				{
					WriteOptionRefCollection(pair.Key, pair.Value as OptionRefCollection);
					continue;
				}
				if (pair.Value is LexRelationCollection)
				{
					WriteRelationCollection(pair.Key, pair.Value as LexRelationCollection);
					continue;
				}
				if (pair.Value is FlagState)
				{
					WriteFlagState(pair.Key, pair.Value as FlagState);
					continue;
				}
				PictureRef pictureRef = pair.Value as PictureRef;
				if (pictureRef != null)
				{
					WriteURLRef("illustration", pictureRef.Value, pictureRef.Caption);
					continue;
				}
				throw new ApplicationException(
						string.Format(
								"The LIFT exporter was surprised to find a property '{0}' of type: {1}",
								pair.Key,
								pair.Value.GetType()));
			}
		}
Example #10
0
		private void WriteWellKnownCustomMultiText(WeSayDataObject item,
												   string property,
												   ICollection<string> propertiesAlreadyOutput)
		{
			if (ShouldOutputProperty(property))
			{
				MultiText m = item.GetProperty<MultiText>(property);
				if (WriteMultiWithWrapperIfNonEmpty(property, property, m))
				{
					propertiesAlreadyOutput.Add(property);
				}
			}
		}