public static string FromElementBuilder(ElementBuilder elemBuilder) { DateTime now = DateTime.Now; string collectionPath = Svc.SMA.Collection.Path; int parentId = elemBuilder.Parent?.Id ?? 1; string title = elemBuilder.Title ?? string.Empty; /*elemBuilder.Content.Substring(0, * 10);*/ string lastRepDate1 = DateTime.Today.ToString("dd.MM.yy", CultureInfo.InvariantCulture); string lastRepDate2 = DateTime.Today.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture); double lastRepTime = now.Hour + (now.Minute * 60 + now.Second) / 3600.0; string type; switch (elemBuilder.Type) { case ElementType.Topic: type = "Topic"; break; case ElementType.Item: type = "Item"; break; case ElementType.ConceptGroup: case ElementType.Task: case ElementType.Unknown3: default: throw new NotImplementedException(); } return(string.Format(CultureInfo.InvariantCulture, ElementFmt, collectionPath, parentId, elemBuilder.Priority, title, type, lastRepDate1, elemBuilder.Reference?.ToString() ?? string.Empty, GenerateComponentsStr(elemBuilder), lastRepDate2, lastRepTime)); }
public static string FromElementBuilder(ElementBuilder elemBuilder) { DateTime now = DateTime.Now; string collectionPath = Svc.SMA.Collection.Path; int parentId = elemBuilder.Parent?.Id ?? 1; string title = elemBuilder.Title ?? string.Empty; /*elemBuilder.Content.Substring(0, * 10);*/ string type = elemBuilder.Type == Models.ElementType.Topic ? "Topic" : "Item"; string lastRep = DateTime.Today.ToString("dd.MM.yy"); double lastRepTime = Math.Floor((now.Minute * 60 + now.Second) * 1000 / 3600.0); return(string.Format(ElementClipboardFormat, collectionPath, parentId, title, type, lastRep, lastRepTime)); }
private static string GenerateComponentsStr(ElementBuilder elemBuilder) { var components = new List <IComponent>(); var txtContents = GetTextContents(elemBuilder); var imgContents = GetImageContents(elemBuilder); switch (elemBuilder.ContentType) { case ElementBuilder.ContentTypeEnum.Html: case ElementBuilder.ContentTypeEnum.RawText: if (imgContents.Any()) { throw new InvalidCastException("ElementBuilder ContentTypeEnum.Text contains non-text IContent"); } if (txtContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeEnum.Text does not contain any text IContent"); } BuildTextComponents(0, txtContents.Count, CorsFull.Left, CorsFull.Top, CorsFull.Right, CorsFull.Bottom, txtContents, components); break; case ElementBuilder.ContentTypeEnum.Image: if (txtContents.Any()) { throw new InvalidCastException("ElementBuilder ContentTypeEnum.Image contains non-image IContent"); } if (imgContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeEnum.Image does not contain any image IContent"); } BuildImageComponents(0, imgContents.Count, CorsFull.Left, CorsFull.Top, CorsFull.Right, CorsFull.Bottom, imgContents, components); break; case ElementBuilder.ContentTypeEnum.ImageAndRawText: case ElementBuilder.ContentTypeEnum.ImageAndHtml: if (txtContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeEnum.ImageAndText does not contain any text IContent"); } if (imgContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeEnum.ImageAndText does not contain any image IContent"); } BuildTextComponents(0, txtContents.Count, CorsVSplitLeft.Left, CorsVSplitLeft.Top, CorsVSplitLeft.Right, CorsVSplitLeft.Bottom, txtContents, components); BuildImageComponents(components.Count, imgContents.Count, CorsVSplitRight.Left, CorsVSplitRight.Top, CorsVSplitRight.Right, CorsVSplitRight.Bottom, imgContents, components); break; default: throw new NotImplementedException(); } var compsText = components.Select(c => c.ToString()) .ToList(); return(string.Format(ComponentsSkeleton, compsText.Count, string.Join("\n", compsText))); }