private void DetailsToolPanel_AddClicked(object arg1, RoutedEventArgs arg2) { /*- if (!ProductDirector.ConfirmImmediateApply("IdeaEditing.DetailAdd", "ApplyDialogChangesDirectly")) * return; */ var DetailOptions = new List <IRecognizableElement>(); DetailOptions.Add(new SimplePresentationElement(AttachmentDetailDesignator.KindTitle, AttachmentDetailDesignator.KindName, AttachmentDetailDesignator.KindSummary, AttachmentDetailDesignator.KindPictogram)); DetailOptions.Add(new SimplePresentationElement(LinkDetailDesignator.KindTitle, LinkDetailDesignator.KindName, LinkDetailDesignator.KindSummary, LinkDetailDesignator.KindPictogram)); if (ProductDirector.ValidateEditionPermission(AppExec.LIC_EDITION_LITE, "designate Table detail", false)) { DetailOptions.Add(new SimplePresentationElement(TableDetailDesignator.KindTitle, TableDetailDesignator.KindName, TableDetailDesignator.KindSummary, TableDetailDesignator.KindPictogram)); } var DetailToCreate = Display.DialogMultiOption("Designation of Detail", "Select the type of detail to be designated...", "", null, true, TableDetailDesignator.KindName, DetailOptions.ToArray()); if (DetailToCreate == null) { return; } var SelectedDetailOption = DetailOptions.FirstOrDefault(det => det.TechName == DetailToCreate); var DesignationName = SelectedDetailOption.Name + " - Detail Definition " + (this.DetailsSource.Count + 1).ToString(); DetailDefinitionCard NewEditCard = null; var Owner = Ownership.Create <IdeaDefinition, Idea>(this.SourceDefinitor); DetailDesignator CreatedDesignation = null; if (DetailToCreate == TableDetailDesignator.KindName) { CreatedDesignation = DomainServices.CreateTableDesignation(this.SourceEngine, Owner, DesignationName); } else if (DetailToCreate == AttachmentDetailDesignator.KindName) { CreatedDesignation = DomainServices.CreateAttachmentDesignation(Owner, DesignationName); } else if (DetailToCreate == LinkDetailDesignator.KindName) { CreatedDesignation = DomainServices.CreateLinkDesignation(Owner, DesignationName); } if (CreatedDesignation == null) { return; } NewEditCard = new DetailDefinitionCard(false, new Assignment <DetailDesignator>(CreatedDesignation, this.DetailsSourceIsGlobal)); this.DetailsSource.Add(NewEditCard); this.DetailsListBox.SelectedItem = NewEditCard; }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- public bool AppendPastedDetail(Idea Target, string DetailName, string MimeType, byte[] DetailContent) { if (DetailName.IsAbsent() || MimeType.IsAbsent() || DetailContent == null || DetailContent.Length < 1) { return(false); } ContainedDetail Detail = null; if (MimeType.StartsWith("text/")) { var Owner = Ownership.Create <IdeaDefinition, Idea>(Target); var Content = DetailContent.BytesToString(); if (Content.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase)) { var NewLink = new ResourceLink(Target, new Assignment <DetailDesignator>( DomainServices.CreateLinkDesignation( Owner, DetailName), true)); NewLink.TargetLocation = Content; Detail = NewLink; } else if (MimeType.EndsWith("/tsv") || MimeType.EndsWith("/csv")) { var Delimiter = (MimeType.EndsWith("/csv") ? General.GetCurrentTextListDelimiter() : "\t"); var TextRecords = General.LoadStreamDelimitedIntoStrings(Content.StringToStream(), Delimiter); var TypingResult = DomainServices.GenerateTypedRecordsList(TextRecords.Item1); var TableDef = DomainServices.CreateCompatibleTableDefinition(Target.OwnerComposition.CompositeContentDomain, DetailName + " - TableDef", TypingResult.Item2, TextRecords.Item2); var Designator = new TableDetailDesignator(Owner, TableDef, true, DetailName, DetailName.TextToIdentifier()); var NewTable = new Table(Target, Designator.Assign <DetailDesignator>(true)); foreach (var DataRecord in TypingResult.Item1) { NewTable.Add(new TableRecord(NewTable, DataRecord)); } Detail = NewTable; } } if (Detail == null) { var Route = new Uri(DetailName, UriKind.RelativeOrAbsolute); Detail = this.CreateIdeaDetailAttachment(Ownership.Create <IdeaDefinition, Idea>(Target), Target, DetailName, Route, DetailContent, MimeType); if (Detail == null) { return(false); } } Target.Details.AddNew(Detail); return(true); }