// --------------------------------------------------------------------------------------------------------------------------------------------------------- public static OperationResult <VisualComplement> CreateComplement(Idea DestinationComposite, SimplePresentationElement Kind, View TargetView, VisualSymbol TargetSymbol, Point Position, double InitialWidth = 0.0) { General.ContractRequiresNotNull(DestinationComposite, Kind, TargetView); if (DestinationComposite.IdeaDefinitor.CompositeContentDomain == null) { return(OperationResult.Failure <VisualComplement>("Destination Container doest not accept Composite-Content.", DestinationComposite)); } DestinationComposite.EditEngine.StartCommandVariation("Create Complement"); VisualComplement NewComplement = null; var Owner = (Kind.TechName.IsOneOf(Domain.ComplementDefCallout.TechName, Domain.ComplementDefQuote.TechName, Domain.ComplementDefGroupRegion.TechName, Domain.ComplementDefGroupLine.TechName) ? Ownership.Create <View, VisualSymbol>(TargetSymbol) : Ownership.Create <View, VisualSymbol>(TargetView)); NewComplement = new VisualComplement(Kind, Owner, Position, InitialWidth); if (!Owner.IsGlobal && TargetSymbol != null) { TargetSymbol.AddComplement(NewComplement); } TargetView.PutComplement(NewComplement); DestinationComposite.UpdateVersion(); DestinationComposite.EditEngine.CompleteCommandVariation(); return(OperationResult.Success(NewComplement)); }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Creates and returns a copy of the supplied original Relationship and its Visual Representation, for the specified target-view and position. /// </summary> public static OperationResult <RelationshipVisualRepresentation> CreateRelationshipAndRepresentationCopy(RelationshipVisualRepresentation OriginalRelationshipRep, View TargetView, Point Position) { // PENDING: SHOW A LITTLE CIRCLE FOR SIMPLE MAIN-SYMBOL HIDING RELATIONSHIPS. var NewRelationship = OriginalRelationshipRep.RepresentedRelationship.GenerateIndependentRelationshipDuplicate(); var NewRepresentator = CreateRelationshipVisualRepresentation(NewRelationship, TargetView, Position); NewRepresentator.MainSymbol.IsAutoPositionable = OriginalRelationshipRep.MainSymbol.IsAutoPositionable; NewRepresentator.MainSymbol.AreDetailsShown = OriginalRelationshipRep.MainSymbol.AreDetailsShown; NewRepresentator.MainSymbol.ResizeTo(OriginalRelationshipRep.MainSymbol.BaseWidth, OriginalRelationshipRep.MainSymbol.BaseHeight); NewRepresentator.MainSymbol.DetailsPosterHeight = OriginalRelationshipRep.MainSymbol.DetailsPosterHeight; foreach (var Complement in OriginalRelationshipRep.MainSymbol.AttachedComplements) { var NewComplementTarget = (Complement.Target.IsGlobal ? Ownership.Create <View, VisualSymbol>(TargetView) : Ownership.Create <View, VisualSymbol>(NewRepresentator.MainSymbol)); var NewComplement = Complement.GenerateIndependentDuplicate(NewComplementTarget); if (!NewComplement.Target.IsGlobal) { NewComplement.BaseCenter = new Point(NewComplement.BaseCenter.X + (NewComplementTarget.OwnerLocal.BaseCenter.X - OriginalRelationshipRep.MainSymbol.BaseCenter.X), NewComplement.BaseCenter.Y + (NewComplementTarget.OwnerLocal.BaseCenter.Y - OriginalRelationshipRep.MainSymbol.BaseCenter.Y)); } NewRepresentator.MainSymbol.AddComplement(NewComplement); TargetView.PutComplement(NewComplement); } return(OperationResult.Success(NewRepresentator)); }
public void PasteFileIntoIdea(Idea TargetIdea, string FilePath, bool AsDetail) { var InitialName = Path.GetFileNameWithoutExtension(FilePath); if (AsDetail) { var Route = new Uri(FilePath, UriKind.Absolute); var Detail = this.CreateIdeaDetailAttachment(Ownership.Create <IdeaDefinition, Idea>(TargetIdea), TargetIdea, InitialName, Route); if (Detail == null) { return; } TargetIdea.Details.AddNew(Detail); } else { var Content = General.BytesToAppropriateObject(General.FileToBytes(FilePath)); if (Content is ImageSource) { TargetIdea.Pictogram = (ImageSource)Content; } else { TargetIdea.Summary = (Content is byte[] ? ((byte[])Content).BytesToString() : Content.ToStringAlways()); } // PENDING: IF FILE IS .CSV OR .TSV (DETECT COMMA AND TAB SEPARATED CONTENT), THEN CREATE TABLE. // THIS ALSO WILL BE USEFUL FOR PASTING FROM EXCEL. } TargetIdea.UpdateVisualRepresentators(); }
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 VisualComplement AppendClone(View TargetView, VisualComplement OriginalComplement, double DeltaX, double DeltaY) { var NewPosition = new Point(OriginalComplement.BaseCenter.X + DeltaX, OriginalComplement.BaseCenter.Y + DeltaY); var Result = OriginalComplement.GenerateIndependentDuplicate(Ownership.Create <View, VisualSymbol>(TargetView)); Result.BaseCenter = NewPosition; TargetView.PutComplement(Result); return(Result); }
private void DetailsToolPanel_AddClicked(object arg1, RoutedEventArgs arg2) { var Owner = Ownership.Create <IdeaDefinition, Idea>(this.SourceIdea); var CreatedDetail = SourceEngine.CreateIdeaDetail(Owner, this.SourceIdea, this.DetailsSource.Select(card => card.Designator.Value), this.AccessOnlyTables); if (CreatedDetail == null) { return; } var NewEditCard = new DetailEditingCard(false, new Assignment <DetailDesignator>(CreatedDetail.Designation, this.IsLocal), CreatedDetail); this.DetailsSource.Add(NewEditCard); this.DetailsListBox.SelectedItem = NewEditCard; }
/// <summary> /// Constructor /// </summary> /// <param name="OwnerComposite">Composite IdeaDefinition owning this new one.</param> /// <param name="Name">Name of the IdeaDefinition.</param> /// <param name="TechName">Technical Name of the IdeaDefinition.</param> /// <param name="RepresentativeShape">Shape visually representing the IdeaDefinition.</param> /// <param name="Summary">Summary of the IdeaDefinition.</param> /// <param name="Pictogram">Image representing the IdeaDefinition.</param> public IdeaDefinition(IdeaDefinition OwnerComposite, string Name, string TechName, string RepresentativeShape, string Summary = "", ImageSource Pictogram = null) : base(Name, TechName, Summary, Pictogram, true) { General.ContractRequires(OwnerComposite != null || this is Domain); General.ContractRequiresNotAbsent(RepresentativeShape); this.RepresentativeShape = RepresentativeShape; this.ConceptDefinitions = new EditableList <ConceptDefinition>(__ConceptDefinitions.TechName, this); this.RelationshipDefinitions = new EditableList <RelationshipDefinition>(__RelationshipDefinitions.TechName, this); this.DetailDesignators = new EditableList <DetailDesignator>(__DetailDesignators.TechName, this); this.TableDefinitions = new EditableList <TableDefinition>(__TableDefinitions.TechName, this); this.OwnerDefinitor = OwnerComposite; if (OwnerComposite != null) { this.CompositeContentDomain = OwnerComposite.CompositeContentDomain; } // Default details designations... // In this case, the default detail shown will be the Summary property. this.DetailDesignators.Add(new LinkDetailDesignator(Ownership.Create <IdeaDefinition, Idea>(this), __Summary.Name, __Summary.TechName, __Summary.Summary, __Summary)); // Table for custom fields... this.CustomFieldsTableDef = new TableDefinition(this.OwnerDomain, "Custom-Fields Designator", "CustomFieldsDesignator", "User-defined fields for this particular Idea definition."); CustomFieldsTableDef.Alterability = EAlterability.System; CustomFieldsTableDef.AlterStructure(); var CustomFieldsTableDsn = new TableDetailDesignator(Ownership.Create <IdeaDefinition, Idea>(this), CustomFieldsTableDef, true, "Custom-Fields", SYSNAME_CUSTOM_FIELDS); CustomFieldsTableDsn.Alterability = EAlterability.System; CustomFieldsTableDsn.TableLook = new TableAppearance(ShowTitle: false, IsMultiRecord: false, Layout: ETableLayoutStyle.Transposed); this.DetailDesignators.Add(CustomFieldsTableDsn); this.DeclareOutputTemplatesCollection(); }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- 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); }
public static bool FieldDefinitionEdit(TableDefinition OwnerTableDef, IList <FieldDefinition> EditedList, FieldDefinition FieldDef) { var InstanceController = EntityInstanceController.AssignInstanceController(FieldDef); InstanceController.StartEdit(); var ExtraControls = new List <UIElement>(); MModelPropertyDefinitor ExposedProperty = null; // Declare expositor for hidden field var HideInDiagramExpositor = new EntityPropertyExpositor(FieldDefinition.__HideInDiagram.TechName); HideInDiagramExpositor.LabelMinWidth = 90; // Declare expositor for available values-sources var AvailableValuesSourcesExpositor = new EntityPropertyExpositor(); ExposedProperty = FieldDefinition.__ValuesSource; AvailableValuesSourcesExpositor.ExposedProperty = ExposedProperty.TechName; AvailableValuesSourcesExpositor.LabelMinWidth = 90; AvailableValuesSourcesExpositor.IsEnabled = (FieldDef.FieldType is NumberType || FieldDef.FieldType.IsOneOf(DataType.DataTypeTableRecordRef, DataType.DataTypeText)); // Initial setting // Declare expositor for available Ideas var IdeaReferencingPropertyExpositor = new EntityPropertyExpositor(); ExposedProperty = FieldDefinition.__IdeaReferencingProperty; IdeaReferencingPropertyExpositor.ExposedProperty = ExposedProperty.TechName; IdeaReferencingPropertyExpositor.LabelMinWidth = 90; IdeaReferencingPropertyExpositor.SetAvailable(FieldDef.FieldType.IsOneOf(DataType.DataTypeIdeaRef, DataType.DataTypeText)); // Initial setting // Declare button for table-definition assignation button var TableDefAssignationPanel = new StackPanel(); // TableDefAssignationPanel.Orientation = Orientation.Horizontal; var TableDefAssignSingleRecordCbx = new EntityPropertyExpositor(FieldDefinition.__ContainedTableIsSingleRecord.TechName); TableDefAssignSingleRecordCbx.LabelMinWidth = 90; /* var TableDefAssignSingleRecordCbx = new CheckBox(); * TableDefAssignSingleRecordCbx.Content = FieldDefinition.__ContainedTableIsSingleRecord.Name; // "Is Single-Record"; * TableDefAssignSingleRecordCbx.ToolTip = FieldDefinition.__ContainedTableIsSingleRecord.Summary; * TableDefAssignSingleRecordCbx.FontSize = 8; * TableDefAssignSingleRecordCbx.Margin = new Thickness(2); */ TableDefAssignSingleRecordCbx.IsEnabled = FieldDef.FieldType.IsEqual(DataType.DataTypeTable); var TableDefAssignationButtonArea = new StackPanel(); TableDefAssignationButtonArea.Orientation = Orientation.Horizontal; var TableDefAssignationButtonPrefix = new TextBlock(); TableDefAssignationButtonPrefix.Text = "Table-Structure"; TableDefAssignationButtonPrefix.TextAlignment = TextAlignment.Right; TableDefAssignationButtonPrefix.FontSize = 10; TableDefAssignationButtonPrefix.Width = 90; TableDefAssignationButtonPrefix.Margin = new Thickness(0, 6, 2, 2); TableDefAssignationButtonPrefix.SetAvailable(FieldDef.FieldType == DataType.DataTypeTable); // Initial setting var TableDefAssignationButton = new PaletteButton("Definition...", Display.GetAppImage("table.png")); TableDefAssignationButton.Margin = new Thickness(2 /*45*/, 2, 2, 2); TableDefAssignationButton.IsEnabled = FieldDef.FieldType.IsEqual(DataType.DataTypeTable); TableDefAssignationButtonArea.Children.Add(TableDefAssignationButtonPrefix); TableDefAssignationButtonArea.Children.Add(TableDefAssignationButton); TableDefAssignationButton.Click += ((sender, args) => { var DsnName = OwnerTableDef.Name + " - " + FieldDef.Name; if (FieldDef.ContainedTableDesignator == null) { var ContainedTableDef = new TableDefinition(OwnerTableDef.OwnerDomain, DsnName, DsnName.TextToIdentifier()); FieldDef.ContainedTableDesignator = new TableDetailDesignator(Ownership.Create <IdeaDefinition, Idea>(OwnerTableDef.OwnerDomain), ContainedTableDef, true /* Very important! */, DsnName, DsnName.TextToIdentifier(), "", null, FieldDef); } else if (FieldDef.ContainedTableDesignator.Name != DsnName) { FieldDef.ContainedTableDesignator.Name = DsnName; FieldDef.ContainedTableDesignator.TechName = DsnName.TextToIdentifier(); } var TableDefAssigner = new TableDetailDesignatorStructSubform(FieldDef.ContainedTableDesignator, null, true); DialogOptionsWindow TableDesfAssignationWindow = null; // Do not move outside this lambda OwnerTableDef.EditEngine.StartCommandVariation("Edit Field-Definition type assignment of Table-Structure Definition"); var Response = Display.OpenContentDialogWindow(ref TableDesfAssignationWindow, "Table-Structure for Field '" + FieldDef.Name + "'", TableDefAssigner); OwnerTableDef.EditEngine.CompleteCommandVariation(); if (Response.IsTrue()) { FieldDef.ContainedTableDesignator.DeclaringTableDefinition.AlterStructure(); } else { OwnerTableDef.EditEngine.Undo(); } }); // Declare expositor for field-type var FieldTypeExpositor = new EntityPropertyExpositor(); ExposedProperty = FieldDefinition.__FieldType; FieldDef.PropertyChanged += ((sender, args) => { if (args.PropertyName != FieldDefinition.__FieldType.TechName || FieldDef.FieldType == null) { return; } // Postcalls to be applied after the load initialization. var CanSelectValues = (FieldDef.FieldType is NumberType || FieldDef.FieldType.IsOneOf(DataType.DataTypeTableRecordRef, DataType.DataTypeText)); AvailableValuesSourcesExpositor.PostCall( expo => { expo.SetAvailable(CanSelectValues); if (!CanSelectValues) { FieldDef.ValuesSource = null; } }); var CanSelectIdeas = FieldDef.FieldType.IsOneOf(DataType.DataTypeIdeaRef, DataType.DataTypeText); IdeaReferencingPropertyExpositor.PostCall( expo => { expo.SetAvailable(CanSelectIdeas); if (!CanSelectIdeas) { FieldDef.IdeaReferencingProperty = null; } }); var CanAssignTableDef = FieldDef.FieldType.IsEqual(DataType.DataTypeTable); TableDefAssignationButton.PostCall( ctrl => { // ctrl.SetAvailable(CanAssignTableDef); ctrl.IsEnabled = CanAssignTableDef; /* Cancelled (better is to save user's data)... * if (!CanAssignTableDef) * { * FieldDef.DeclaringTableDefinition = null; * FieldDef.DeclaringTableDefIsOwned = false; * } */ }); TableDefAssignSingleRecordCbx.PostCall(ctrl => ctrl.IsEnabled = CanAssignTableDef); }); FieldTypeExpositor.ExposedProperty = ExposedProperty.TechName; FieldTypeExpositor.LabelMinWidth = 90; // Add the just created extra controls ExtraControls.Add(HideInDiagramExpositor); ExtraControls.Add(FieldTypeExpositor); ExtraControls.Add(AvailableValuesSourcesExpositor); ExtraControls.Add(IdeaReferencingPropertyExpositor); TableDefAssignationPanel.Children.Add(TableDefAssignationButtonArea); // POSTPONED: TableDefAssignationPanel.Children.Add(TableDefAssignSingleRecordCbx); ExtraControls.Add(TableDefAssignationPanel); var Result = InstanceController.Edit(Display.CreateEditPanel(FieldDef, null, true, null, null, true, false, false, true, ExtraControls.ToArray()), "Edit Field Definition - " + FieldDef.ToString(), InitialWidth: 700).IsTrue(); return(Result); }