Exemple #1
0
        /// <summary>
        /// This is to help Lexique Pro (or anyone else reading it) get the right urls to pictures, when the lift is down in Export.
        /// </summary>
        /// <param name="pictureRef"></param>
        protected override void WriteIllustrationElement(PictureRef pictureRef)
        {
            //base does this:             WriteURLRef("illustration", pictureRef.Value, pictureRef.Caption);
            //base.WriteIllustrationElement(pictureRef);

            string url = pictureRef.Value;

            if (url == null)             // Fixes WS-34480 PLIFT-exporting actions don't work after going in Browse & Edit if image is missing
            {
                return;
            }
            if (_path != null)              //it's null during some tests
            {
                var dirWeAreWritingTo = Path.GetDirectoryName(_path);

                string parentDir = Directory.GetParent(dirWeAreWritingTo).FullName;
                if (!File.Exists(Path.Combine(dirWeAreWritingTo, url)))                 //something needs fixing
                {
                    string upOne = Path.Combine(parentDir, url);
                    if (File.Exists(upOne))
                    {
                        url = "..".CombineForPath(url);
                    }
                    else
                    {
                        string addPicturesDir = parentDir.CombineForPath("pictures", url);
                        if (File.Exists(addPicturesDir))
                        {
                            url = "..".CombineForPath("pictures", url);
                        }
                    }
                }
            }
            WriteURLRef("illustration", url, pictureRef.Caption);
        }
Exemple #2
0
 private void WriteCustomProperties(PalasoDataObject item,
                                    ICollection <string> propertiesAlreadyOutput)
 {
     foreach (KeyValuePair <string, IPalasoDataObjectProperty> 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)
         {
             WriteIllustrationElement(pictureRef);
             continue;
         }
         throw new ApplicationException(
                   string.Format(
                       "The LIFT exporter was surprised to find a property '{0}' of type: {1}",
                       pair.Key,
                       pair.Value.GetType()));
     }
 }
        public void MergeInPicture(LexSense sense, string href, LiftMultiText caption)
        {
            //nb 1:  we're limiting ourselves to one picture per sense, here:
            //nb 2: the name and case must match the fieldName
            PictureRef pict = sense.GetOrCreateProperty <PictureRef>("Picture");

            pict.Value = href;
            if (caption != null)
            {
                pict.Caption = MultiText.Create(caption.AsSimpleStrings);
            }
        }
Exemple #4
0
        public void SenseGetsPictureNoCaption()
        {
            Extensible extensibleInfo = new Extensible();
            LexEntry   e = MakeSimpleEntry();
            LexSense   s = _builder.GetOrMakeSense(e, extensibleInfo, string.Empty);

            _builder.MergeInPicture(s, "testPicture.png", null);
            PictureRef pict = s.GetProperty <PictureRef>("Picture");

            Assert.AreEqual("testPicture.png", pict.Value);
            Assert.IsNull(pict.Caption);
        }
Exemple #5
0
        //Not fixed yet       [Test]
        public void SenseWithAPicture_ReadyForDeletion()
        {
            Assert.IsFalse(_sense.IsEmptyForPurposesOfDeletion);
            ClearSenseMeaning();
            ClearSenseExample();
            ClearSenseCustom();
            Assert.IsTrue(_sense.IsEmpty);
            PictureRef pict =
                _sense.GetOrCreateProperty <PictureRef>(LexSense.WellKnownProperties.Picture);

            pict.Value = "dummy.png";
            Assert.IsFalse(_sense.IsEmpty);
            Assert.IsTrue(_sense.IsEmptyForPurposesOfDeletion);
        }
Exemple #6
0
        public void SenseGetsPictureWithCaption()
        {
            Extensible extensibleInfo = new Extensible();
            LexEntry   e = MakeSimpleEntry();
            LexSense   s = _builder.GetOrMakeSense(e, extensibleInfo, string.Empty);

            LiftMultiText caption = new LiftMultiText();

            caption["aa"] = new LiftString("acaption");
            _builder.MergeInPicture(s, "testPicture.png", caption);
            PictureRef pict = s.GetProperty <PictureRef>("Picture");

            Assert.AreEqual("testPicture.png", pict.Value);
            Assert.AreEqual("acaption", pict.Caption["aa"]);
        }
Exemple #7
0
        protected override Control MakePictureWidget(PalasoDataObject target, Field field, DetailList detailList)
        {
            PictureRef pictureRef = target.GetOrCreateProperty <PictureRef>(field.FieldName);

            PictureControl control = _serviceProvider.GetService(typeof(PictureControl)) as PictureControl;

            control.SearchTermProvider = new SenseSearchTermProvider(target as LexSense);
            if (!String.IsNullOrEmpty(pictureRef.Value))
            {
                control.Value = pictureRef.Value;
            }
            SimpleBinding <string> binding = new SimpleBinding <string>(pictureRef, control);

            binding.CurrentItemChanged += detailList.OnBinding_ChangeOfWhichItemIsInFocus;
            return(control);
        }
Exemple #8
0
 protected virtual void WriteIllustrationElement(PictureRef pictureRef)
 {
     WriteURLRef("illustration", pictureRef.Value, pictureRef.Caption);
 }