public void StartOfInput() { _lineParsingSession = _lineParser.StartLineParsingSession(); _extendedStreamReader = _fileHelper.GetExtendedStreamReader(_originalFilePath); _totalNumberOfLines = _fileHelper.GetExtendedStreamReader(_originalFilePath) .GetLinesWithEofLine() .Count(); var dependencyFileProperties = PropertiesFactory.CreateDependencyFileProperties(_fileConversionProperties.OriginalFilePath); dependencyFileProperties.PreferredLinkage = DependencyFileLinkOption.Embed; _fileConversionProperties.DependencyFiles.Add(dependencyFileProperties); ProgressInPercent = 0; }
private void RecreateSyntaxFrame() { RemoveSyntaxFrame(); var syntaxProps = _connection.ConnectionDescriptor.SyntaxProperties; if (syntaxProps == null) { return; } var container = PropertiesFactory.GetPropertiesContainer(syntaxProps); (pbSyntax as IPropertiesControl).SetProperties(container); cbLoadFromDefaultDatabase.Visibility = _connection.ConnectionDescriptor.SyntaxProvider.IsSupportDatabases() ? Visibility.Visible : Visibility.Hidden; }
private FrameworkElement CreateSyntaxEditControl(BaseConnectionDescriptor connection) { var properties = connection.SyntaxProperties; if (properties == null) { return(null); } properties.PropertiesEditors.Clear(); var propsContainer = PropertiesFactory.GetPropertiesContainer(properties); var propertiesBar = new PropertiesBar(); var propertiesControl = (IPropertiesControl)propertiesBar; propertiesControl.SetProperties(propsContainer); return(propertiesBar); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, int tagNo, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = string.Format("{{{0}}}", tagNo); phTagProperties.CanHide = false; //determine tag id if (source) { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; //check for source with the same Id and different properties if (CheckForIdAndPropertiesNotEqual(thisId, phTagProperties)) { _totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } //check for source with the same Id and same properties if (!CheckForIdAndPropertiesEqual(thisId, phTagProperties)) { _dictionaryTags.Add(int.Parse(thisId.Id), phTagProperties); } } else { var thisId = new TagId(_totalTagCount.ToString(CultureInfo.InvariantCulture)); phTagProperties.TagId = thisId; if (CheckForIdAndPropertiesNotEqual(thisId, phTagProperties)) { _totalTagCount = CreatePlaceholderTagHelper(thisId, phTagProperties); } } return(phTag); }
private void RecreateSyntaxFrame() { pbSyntax.ClearProperties(); var syntxProps = _connection.ConnectionDescriptor.SyntaxProperties; if (syntxProps == null) { pbSyntax.Visibility = Visibility.Collapsed; return; } pbSyntax.Visibility = Visibility.Visible; ClearProperties(syntxProps); var container = PropertiesFactory.GetPropertiesContainer(syntxProps); (pbSyntax as IPropertiesControl).SetProperties(container); }
private UserControl CreateConnectionEditControl(BaseConnectionDescriptor connection) { _metadataProperties = connection.MetadataProperties; if (_metadataProperties != null) { _metadataProperties.PropertiesEditors.Clear(); var propsContainer = PropertiesFactory.GetPropertiesContainer(_metadataProperties); var propertiesBar = new PropertiesBar(); propertiesBar.EditorsOptions.NarrowEditControlsMinWidth = 160; propertiesBar.EditorsOptions.MultiLineEditorsMaxWidth = 570; var propertiesControl = (IPropertiesControl)propertiesBar; propertiesControl.SetProperties(propsContainer); return(propertiesBar); } return(null); }
private void RecreateSyntaxFrame() { RemoveSyntaxFrame(); var syntxProps = _connection.ConnectionDescriptor.SyntaxProperties; if (syntxProps == null) { pbSyntax.Height = 0; return; } ClearProperties(syntxProps); var container = PropertiesFactory.GetPropertiesContainer(syntxProps); (pbSyntax as IPropertiesControl).SetProperties(container); pbSyntax.Height = pbSyntax.Controls[0].Bottom + 5; }
private ITagPair CreateTagPair(XmlNode item) { // create the start and the end tag IStartTagProperties startTag = PropertiesFactory.CreateStartTagProperties(item.Name); #region "formatting" // apply character formatting to the start tag IFormattingGroup formattingGroup = PropertiesFactory.FormattingItemFactory.CreateFormatting(); startTag.Formatting = new FormattingGroup(); switch (item.Name) { case "b": formattingGroup.Add(new Bold(true)); break; case "i": formattingGroup.Add(new Italic(true)); break; case "u": formattingGroup.Add(new Underline(true)); break; default: break; } startTag.Formatting = formattingGroup; #endregion startTag.DisplayText = item.Name; startTag.CanHide = true; IEndTagProperties endTag = PropertiesFactory.CreateEndTagProperties(item.Name); endTag.DisplayText = item.Name; endTag.CanHide = true; // create a tag pair out of the start and the end tag ITagPair tagPair = ItemFactory.CreateTagPair(startTag, endTag); // add text enclosed in the tag pair tagPair.Add(CreateText(item.InnerText)); return(tagPair); }
private void RecreateSyntaxFrame() { RemoveSyntaxFrame(); var syntxProps = _connection.SyntaxProperties; if (syntxProps == null) { pbSyntax.Height = 0; return; } ClearProperties(syntxProps); var container = PropertiesFactory.GetPropertiesContainer(syntxProps); (pbSyntax as IPropertiesControl).SetProperties(container); cbLoadFromDefaultDatabase.Visible = _connection.SyntaxProvider.IsSupportDatabases(); pbSyntax.Height = pbSyntax.Controls[0].Bottom + 5; }
public IAbstractMarkupData CreateTagPair(string tagId, string tagContent) { var tagName = GetStartTagName(tagContent, out var refId); // Dev Notes: the tagContent is switched with the Display text to align with how the tags are // recreated by the XLIFF 1.2 parser from the framework var startTagProperties = PropertiesFactory.CreateStartTagProperties("<bpt id=\"" + tagId + "\">"); startTagProperties.DisplayText = tagContent; startTagProperties.SetMetaData("localName", "bpt"); startTagProperties.SetMetaData("displayText", tagContent); startTagProperties.SetMetaData("attribute:id", tagId); if (ExistingTagIds.Contains(startTagProperties.TagId.Id)) { startTagProperties.TagId = !ExistingTagIds.Contains(tagId) ? new TagId(tagId) : new TagId(GetUniqueTagPairId()); } if (!ExistingTagIds.Contains(startTagProperties.TagId.Id)) { ExistingTagIds.Add(startTagProperties.TagId.Id); } var endTagProperties = PropertiesFactory.CreateEndTagProperties("<ept id=\"" + tagId + "\">"); endTagProperties.DisplayText = "</" + tagName + ">"; endTagProperties.SetMetaData("localName", "ept"); endTagProperties.SetMetaData("displayText", "</" + tagName + ">"); endTagProperties.SetMetaData("attribute:id", tagId); //TODO formatting example //var xItem = _formattingFactory.CreateFormattingItem("italic", "True"); //x.Formatting = _formattingFactory.CreateFormatting(); //x.Formatting.Add(xItem); var tagPair = ItemFactory.CreateTagPair(startTagProperties, endTagProperties); return(tagPair); }
private IContextProperties CreateContext(string unitId) { IContextProperties contextProperties = PropertiesFactory.CreateContextProperties(); IContextInfo contextInfo = PropertiesFactory.CreateContextInfo(StandardContextTypes.Paragraph); contextInfo.Purpose = ContextPurpose.Information; // add unit id as metadata IContextInfo contextId = PropertiesFactory.CreateContextInfo("UnitId"); contextId.SetMetaData("UnitID", unitId); contextId.Description = "Original paragraph unit id"; contextId.DisplayCode = "ID"; contextProperties.Contexts.Add(contextInfo); contextProperties.Contexts.Add(contextId); return(contextProperties); }
private ICommentProperties CreateComment(XmlNode item) { ICommentProperties commentProperties = PropertiesFactory.CreateCommentProperties(); var xmlNodeList = item.SelectNodes("comment"); if (xmlNodeList != null) { foreach (XmlNode commentNode in xmlNodeList) { var commentSeverity = Severity.Undefined; var selectSingleNode = commentNode.SelectSingleNode("./@type"); if (selectSingleNode != null) { if (selectSingleNode.InnerText == "text") { commentSeverity = Severity.Low; } if (selectSingleNode.InnerText == "question") { commentSeverity = Severity.Medium; } if (selectSingleNode.InnerText == "important") { commentSeverity = Severity.High; } } var singleNode = commentNode.SelectSingleNode("./@creationid"); if (singleNode != null) { IComment comment = PropertiesFactory.CreateComment(commentNode.InnerText, singleNode.InnerText, commentSeverity); commentProperties.Add(comment); } } } return(commentProperties); }
private IContextProperties CreateContext(string id, string paraId) { IContextProperties contextProperties = PropertiesFactory.CreateContextProperties(); IContextInfo contextId = PropertiesFactory.CreateContextInfo("id"); contextId.SetMetaData("ID", id); contextId.Description = "Trans-unit id"; contextId.DisplayCode = "ID"; IContextInfo contextParaId = PropertiesFactory.CreateContextInfo("para-id"); contextParaId.SetMetaData("PARA ID", paraId); contextParaId.Description = "Para-id"; contextParaId.DisplayCode = "PARA ID"; contextProperties.Contexts.Add(contextId); contextProperties.Contexts.Add(contextParaId); return(contextProperties); }
public ITagPair CreateTagPair(string tagId, string tagContent, ref List <string> existingTagIds) { var tagName = GetStartTagName(tagContent, out var refId); var startTagProperties = PropertiesFactory.CreateStartTagProperties("<" + tagName + " id=\"" + tagId + "\">"); startTagProperties.DisplayText = tagContent; startTagProperties.SetMetaData("localName", tagName); startTagProperties.SetMetaData("displayText", tagContent); startTagProperties.SetMetaData("attribute:id", tagId); if (existingTagIds.Contains(startTagProperties.TagId.Id)) { startTagProperties.TagId = !existingTagIds.Contains(tagId) ? new TagId(tagId) : new TagId(GetUniqueTagPairId(existingTagIds)); } if (!existingTagIds.Contains(startTagProperties.TagId.Id)) { existingTagIds.Add(startTagProperties.TagId.Id); } var endTagProperties = PropertiesFactory.CreateEndTagProperties("</" + tagName + ">"); endTagProperties.DisplayText = "</" + tagName + ">"; endTagProperties.SetMetaData("localName", tagName); endTagProperties.SetMetaData("displayText", "</" + tagName + ">"); endTagProperties.SetMetaData("attribute:id", tagId); //TODO formatting example //var xItem = _formattingFactory.CreateFormattingItem("italic", "True"); //x.Formatting = _formattingFactory.CreateFormatting(); //x.Formatting.Add(xItem); var tagPair = ItemFactory.CreateTagPair(startTagProperties, endTagProperties); return(tagPair); }
private IContextProperties CreateContext(string spec, string unitID) { // context info for type information, e.g. heading, paragraph, etc. IContextProperties contextProperties = PropertiesFactory.CreateContextProperties(); IContextInfo contextInfo = PropertiesFactory.CreateContextInfo(StandardContextTypes.Paragraph); contextInfo.Purpose = ContextPurpose.Information; // add unit id as metadata IContextInfo contextId = PropertiesFactory.CreateContextInfo("UnitId"); contextId.SetMetaData("UnitID", unitID); switch (spec) { case "Heading": contextInfo = PropertiesFactory.CreateContextInfo(StandardContextTypes.Topic); contextInfo.DisplayColor = Color.Green; break; case "Box": contextInfo = PropertiesFactory.CreateContextInfo(StandardContextTypes.TextBox); contextInfo.DisplayColor = Color.Gold; break; case "Paragraph": contextInfo = PropertiesFactory.CreateContextInfo(StandardContextTypes.Paragraph); contextInfo.DisplayColor = Color.Silver; break; default: break; } contextProperties.Contexts.Add(contextInfo); contextProperties.Contexts.Add(contextId); return(contextProperties); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, int tagNo) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); string cont; if (item.NextSibling == null) { cont = ""; } else { cont = item.NextSibling.Value; } phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = item.Name; phTagProperties.CanHide = false; return(phTag); }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, bool source) { var phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); var phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); var cont = item.NextSibling != null ? item.NextSibling.Value : string.Empty; phTagProperties.SegmentationHint = SegmentationHint.IncludeWithText; phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = item.Name; phTagProperties.CanHide = false; //determine tag id if (source) { _totalTagCount += 1; _tmpTotalTagCount += 1; _srcSegmentTagCount += 1; } return(phTag); }
public override void ProcessParagraphUnit(IParagraphUnit paragraphUnit) { // ignore structure segment if (!paragraphUnit.IsStructure) { foreach (var segmentPair in paragraphUnit.SegmentPairs) { if (IsTargetEmpty(segmentPair)) { // copy source if (Settings.CopyTargetContent.Value) { Implementation.SourceToTargetCopy.Copy(segmentPair, ItemFactory); } else // generate random text { Implementation.RandomTargetGenerator.Generate(segmentPair, ItemFactory); } SetConformationLevel(segmentPair); } if (!string.IsNullOrEmpty(Settings.AppendStart.Value)) { segmentPair.Target.Insert(0, ItemFactory.CreateText( PropertiesFactory.CreateTextProperties(Settings.AppendStart.Value))); } if (!string.IsNullOrEmpty(Settings.AppendEnd.Value)) { segmentPair.Target.Insert(segmentPair.Target.Count, ItemFactory.CreateText( PropertiesFactory.CreateTextProperties(Settings.AppendEnd.Value))); } } } base.ProcessParagraphUnit(paragraphUnit); }
private void RegisterPropertyPage(Control link, ObjectProperties propertiesObject) { var propertiesContainer = PropertiesFactory.GetPropertiesContainer(propertiesObject); // create property page control var propertyPage = new PropertiesBar { EditorsOptions = { WideEditControlsMaxWidth = 225, WideEditControlsMinWidth = 100, ShowDescriptions = true } }; // set properties to property page var propertiesControl = (IPropertiesControl)propertyPage; propertiesControl.SetProperties(propertiesContainer); // register link -> propertyPage mapping _linkToPage1.Add(link, propertyPage); }
// this function outputs an opening or a closing <b> tag // and applies bold character formatting to the strings // that the tags enclose private void WriteInlineTag(string tagContent, bool isStart) { _fBold = new FormattingGroup(); _fBold.Add(new Bold(true)); if (isStart) { IStartTagProperties startTag = PropertiesFactory.CreateStartTagProperties(tagContent); startTag.DisplayText = "b"; startTag.TagContent = tagContent; startTag.Formatting = _fBold; startTag.CanHide = true; Output.InlineStartTag(startTag); } else { IEndTagProperties endTag = PropertiesFactory.CreateEndTagProperties(tagContent); endTag.DisplayText = "b"; endTag.TagContent = tagContent; endTag.CanHide = true; Output.InlineEndTag(endTag); } }
private IPlaceholderTag CreatePhTag(string tagContent, XmlNode item, bool source) { IPlaceholderTagProperties phTagProperties = PropertiesFactory.CreatePlaceholderTagProperties(tagContent); IPlaceholderTag phTag = ItemFactory.CreatePlaceholderTag(phTagProperties); string cont; if (item.NextSibling == null) { cont = ""; } else { cont = item.NextSibling.Value; } phTagProperties.SegmentationHint = SegmentationHint.IncludeWithText; phTagProperties.TagContent = item.OuterXml; phTagProperties.DisplayText = item.Name; phTagProperties.CanHide = false; //determine tag id if (source) { /*Sdl.FileTypeSupport.Framework.NativeApi.TagId thisId = * new Sdl.FileTypeSupport.Framework.NativeApi.TagId(totalTagCount.ToString()); * * phTagProperties.TagId = thisId;*/ totalTagCount += 1; tmpTotalTagCount += 1; srcSegmentTagCount += 1; } return(phTag); }
private FrameworkElement CreateConnectionEditControl(BaseConnectionDescriptor connection) { _metadataProperties = connection.MetadataProperties; if (_metadataProperties == null) { return(null); } _metadataProperties.PropertiesEditors.Clear(); var propsContainer = PropertiesFactory.GetPropertiesContainer(_metadataProperties); var propertiesBar = new PropertiesBar { EditorsOptions = { NarrowEditControlsMinWidth = 160, MultiLineEditorsMaxWidth = 570 } }; var propertiesControl = (IPropertiesControl)propertiesBar; propertiesControl.SetProperties(propsContainer); return(propertiesBar); }
// output translatable text private void WriteText(string TextContent) { ITextProperties textProperties = PropertiesFactory.CreateTextProperties(TextContent); Output.Text(textProperties); }
public IAbstractMarkupData Text(string text) { var textProperties = PropertiesFactory.CreateTextProperties(text); return(ItemFactory.CreateText(textProperties)); }
private ICommentProperties CreateComment(XmlNode item) { ICommentProperties commentProperties = PropertiesFactory.CreateCommentProperties(); return(commentProperties); }
public ISegment GetUpdatedSegment(ISegment targetSegment, IEnumerable <Token> tokens, ISegment sourceSegment) { var vector = new List <int>(); var lockedContentId = 0; //store original segment var originalSegment = (ISegment)targetSegment.Clone(); //remove old content targetSegment.Clear(); foreach (var item in tokens) { switch (item.Type) { case Token.TokenType.TagOpen: var tagPairOpen = (IAbstractMarkupDataContainer)GetElement( GetTagID(item.Content), originalSegment, sourceSegment, item.Type); tagPairOpen.Clear(); InsertItemOnLocation(vector, ref targetSegment, (IAbstractMarkupData)tagPairOpen); vector.Add(((ITagPair)tagPairOpen).IndexInParent); break; case Token.TokenType.TagClose: vector.RemoveAt(vector.Count - 1); break; case Token.TokenType.TagPlaceholder: InsertItemOnLocation(vector, ref targetSegment, GetElement(GetTagID(item.Content), originalSegment, sourceSegment, item.Type)); break; case Token.TokenType.Text: InsertItemOnLocation(vector, ref targetSegment, ItemFactory.CreateText( PropertiesFactory.CreateTextProperties(item.Content))); break; case Token.TokenType.LockedContent: InsertItemOnLocation(vector, ref targetSegment, GetElement(lockedContentId.ToString(), originalSegment, sourceSegment, item.Type)); lockedContentId++; break; case Token.TokenType.CommentStart: var commentContainer = GetComment(item); InsertItemOnLocation(vector, ref targetSegment, (IAbstractMarkupData)commentContainer); vector.Add(((ICommentMarker)commentContainer).IndexInParent); break; case Token.TokenType.CommentEnd: if (vector.Count > 0) { vector.RemoveAt(vector.Count - 1); } break; case Token.TokenType.RevisionMarker: //hasTrackedChanges = true; if (item.RevisionType == Token.RevisionMarkerType.InsertStart) { var insertContainer = GetRevisionMarker(item, RevisionType.Insert); InsertItemOnLocation(vector, ref targetSegment, (IAbstractMarkupData)insertContainer); vector.Add(((IRevisionMarker)insertContainer).IndexInParent); } else if (item.RevisionType == Token.RevisionMarkerType.DeleteStart) { var insertContainer = GetRevisionMarker(item, RevisionType.Delete); InsertItemOnLocation(vector, ref targetSegment, (IAbstractMarkupData)insertContainer); vector.Add(((IRevisionMarker)insertContainer).IndexInParent); } else { if (vector.Count > 0) { vector.RemoveAt(vector.Count - 1); } } break; } } return(targetSegment); }
private int PerformReplaceIterator(Location textLocation, int textIndexStart, int textLength, ref int textIndex) { bool isWarning = false; _lockedCharactersCount = 0; TextCharacterCountingIterator iterator = new TextCharacterCountingIterator(textLocation); do { // if (iterator.CharacterCount + iterator.CharactersToNextLocation > textIndexStart) if (iterator.CharacterCount + iterator.CharactersToNextLocation + _charactersShift > textIndexStart) { // text with tags - do not replace, report warning //if (iterator.CharacterCount + iterator.CharactersToNextLocation < textIndexStart + textLength) if (iterator.CharacterCount + iterator.CharactersToNextLocation + _charactersShift < textIndexStart + textLength) { //textIndex = (iterator.CharacterCount + iterator.CharactersToNextLocation) - (textIndexStart + textLength); textIndex = (iterator.CharacterCount + iterator.CharactersToNextLocation + _charactersShift) - (textIndexStart + textLength); isWarning = true; } #region IText IText text = iterator.CurrentLocation.ItemAtLocation as IText; if (text != null && !isWarning) { // real index in IText textIndex = textIndexStart - (iterator.CharacterCount + _charactersShift); // replace the text of IText string replacedText = TextReplace(text.Properties.Text, textIndex, textLength); iterator.CurrentLocation.ItemAtLocation.Parent[iterator.CurrentLocation.ItemAtLocation.IndexInParent] = ItemFactory.CreateText(PropertiesFactory.CreateTextProperties(replacedText)); return(0); } #endregion #region Tags if (isWarning) { IPlaceholderTag phTag = iterator.CurrentLocation.ItemAtLocation as IPlaceholderTag; ITagPair tagPair = iterator.CurrentLocation.ItemAtLocation as ITagPair; if (phTag != null || tagPair != null) { return(-1); } tagPair = iterator.CurrentLocation.BottomLevel.Parent as ITagPair; if (iterator.CurrentLocation.BottomLevel.IsAtEndOfParent && tagPair != null) { return(-1); } } #endregion #region Comment if (isWarning) { ICommentMarker comment = iterator.CurrentLocation.ItemAtLocation as ICommentMarker; if (comment != null) { return(-3); } comment = iterator.CurrentLocation.BottomLevel.Parent as ICommentMarker; if (iterator.CurrentLocation.BottomLevel.IsAtEndOfParent && comment != null) { return(-3); } } #endregion } #region LockedContent ILockedContent content = iterator.CurrentLocation.ItemAtLocation as ILockedContent; if (content != null) { if (isWarning) { return(-2); } // real index in ILockedContent textIndex = textIndexStart - (iterator.CharacterCount + _charactersShift); // call the iterator for Locked Content Location lockedLocation = new Location((IAbstractMarkupDataContainer)content.Content, true); int sts = PerformReplaceIterator(lockedLocation, textIndex, textLength, ref textIndex); // CODE TO FIX TextCharacterCountingIterator BUG !!! >> // if TextCharacterCountingIterator failed to get CharactersToNextLocation, // we calculate it manually and save as _charactersShift if (iterator.CharactersToNextLocation == 0) { _charactersShift += _lockedCharactersCount; } if (sts != -4) { return(sts); } } content = iterator.CurrentLocation.BottomLevel.Parent as ILockedContent; if (iterator.CurrentLocation.BottomLevel.IsAtEndOfParent && content != null) { if (isWarning) { return(-1); } } #endregion } while (iterator.MoveNext()); _lockedCharactersCount = iterator.CharacterCount; return(-4); }