// --------------------------------------------------------------------------------------------------------------------------------------------------------- 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> /// Applies a parallel move, respect the specified source and deltas, to the whole visual representation, including main-symbol and connectors. /// </summary> public void DoParallelMove(VisualSymbol Source, double DeltaX, double DeltaY, IList <VisualObject> RegionContainedObjects = null) { this.EditEngine.StartCommandVariation("Move Relationship Visual Representation"); if (RegionContainedObjects == null || !RegionContainedObjects.Contains(this.MainSymbol)) { this.MainSymbol.MoveTo(this.MainSymbol.BaseCenter.X + DeltaX, this.MainSymbol.BaseCenter.Y + DeltaY, false, false); // IMPORTANT: The Origin and Target Positions are moved by the Symbol's MoveTo method foreach (var VisConn in this.VisualConnectors) { if (VisConn.IntermediatePosition != Display.NULL_POINT) { VisConn.IntermediatePosition = new Point(VisConn.IntermediatePosition.X + DeltaX, VisConn.IntermediatePosition.Y + DeltaY); } } } this.MainSymbol.UpdateDependents(); this.Render(); this.DisplayingView.UpdateVersion(); this.EditEngine.CompleteCommandVariation(); }
public LocalDetailsEditor(Idea IdeaSource, VisualSymbol SymbolSource, bool AccessToGlobalDetails, bool AccessOnlyTables = false, DetailDesignator InitialDesignatorToEdit = null) : this() { this.IdeaSource = IdeaSource; this.SymbolSource = SymbolSource; this.AccessToGlobalDetails = AccessToGlobalDetails; if (AccessOnlyTables) { this.EntitlingPanel.SetVisible(false); } if (this.AccessToGlobalDetails) { this.VisualGlobalDetailsSource = DetailEditingCard.GenerateGlobalDetailsFor(this.IdeaSource, this.SymbolSource); this.GlobalDetailsMaintainer.SetDetailsSource(this.IdeaSource, this.SymbolSource, this.VisualGlobalDetailsSource, false, false, InitialDesignatorToEdit); this.GlobalDetailsMaintainer.ShowCustomLookZone = true; // (this.SymbolSource != null); } else { this.LocalDetailsMaintainer.Title = "Designations..."; this.AppearanceTitlePanel.SetVisible(false); this.BtnSwitchDetailsScopeOrder.SetVisible(false); this.GlobalDetailsMaintainer.SetVisible(false); } this.VisualLocalDetailsSource = DetailEditingCard.GenerateLocalDetailsFor(this.IdeaSource, this.SymbolSource, this.VisualGlobalDetailsSource); this.LocalDetailsMaintainer.SetDetailsSource(this.IdeaSource, this.SymbolSource, this.VisualLocalDetailsSource, true, AccessOnlyTables, InitialDesignatorToEdit); this.LocalDetailsMaintainer.ShowCustomLookZone = true; // (this.SymbolSource != null); }
private void ReappointReferences(RelationshipVisualRepresentation SourceRelVisRep, RelationshipVisualRepresentation ClonedRelVisRep, List <Capsule <VisualRepresentation, VisualRepresentation> > InterrelationsMap, double DeltaX, double DeltaY) { // NOTE: Each InterrelationsMap capsule contains: Value0=Original Representation, Value1=Cloned Representation. foreach (var SourceVisConn in SourceRelVisRep.VisualConnectors) { var InterRel = InterrelationsMap.FirstOrDefault( intrel => intrel.Value0.RepresentedIdea == SourceVisConn.RepresentedLink.AssociatedIdea); if (InterRel == null || InterRel.Value1 == null) { continue; } var ClonedRoleLink = new RoleBasedLink(ClonedRelVisRep.RepresentedRelationship, InterRel.Value1.RepresentedIdea, SourceVisConn.RepresentedLink.RoleDefinitor, SourceVisConn.RepresentedLink.RoleVariant); if (SourceVisConn.RepresentedLink.Descriptor != null) { ClonedRoleLink.Descriptor = (SimplePresentationElement)SourceVisConn.RepresentedLink.Descriptor.CreateClone(); } // Next, the origin and target symbols are pointed and eventually replaced by the cloned ones // (if they were within the pasted visual representations) VisualSymbol OriginSymbol = SourceVisConn.OriginSymbol; var OriginInterRel = InterrelationsMap.FirstOrDefault(intrel => intrel.Value0.MainSymbol == SourceVisConn.OriginSymbol); if (OriginInterRel != null) { OriginSymbol = OriginInterRel.Value1.MainSymbol; } VisualSymbol TargetSymbol = SourceVisConn.TargetSymbol; var TargetInterRel = InterrelationsMap.FirstOrDefault(intrel => intrel.Value0.MainSymbol == SourceVisConn.TargetSymbol); if (TargetInterRel != null) { TargetSymbol = TargetInterRel.Value1.MainSymbol; } var ClonedVisConn = new VisualConnector(ClonedRelVisRep, ClonedRoleLink, OriginSymbol, TargetSymbol, new Point(SourceVisConn.OriginPosition.X + DeltaX, SourceVisConn.OriginPosition.Y + DeltaY), new Point(SourceVisConn.TargetPosition.X + DeltaX, SourceVisConn.TargetPosition.Y + DeltaY)); ClonedVisConn.IntermediatePosition = (SourceVisConn.IntermediatePosition == Display.NULL_POINT ? Display.NULL_POINT : new Point(SourceVisConn.IntermediatePosition.X + DeltaX, SourceVisConn.IntermediatePosition.Y + DeltaY)); ClonedRelVisRep.RepresentedRelationship.AddLink(ClonedRoleLink); ClonedRelVisRep.AddVisualPart(ClonedVisConn); } ClonedRelVisRep.Render(); }
/// <summary> /// Constructor. /// </summary> public ViewSymbolManipulationAdorner(ViewManipulationManager OwnerManager, VisualSymbol TargetSymbol, AdornerLayer TargetLayer, Action <ViewManipulationAdorner, bool, bool, bool, bool, bool, bool, bool, bool> ManipulationOperation) : base(OwnerManager, TargetSymbol, TargetLayer) { DefaultAction_ = (byte)ESymbolManipulationAction.EditInPlace; ManipulatingHeadingRectangle = TargetSymbol.BaseArea; ManipulatingHeadingLabel = TargetSymbol.LabelingArea; ManipulatingDetailsRectangle = TargetSymbol.DetailsArea; this.ManipulationOperation = ManipulationOperation; }
/// <summary> /// Constructor. /// </summary> public VisualConnector(RelationshipVisualRepresentation OwnerRelationshipRepresentation, RoleBasedLink RepresentedLink, VisualSymbol OriginSymbol, VisualSymbol TargetSymbol, Point OriginPosition, Point TargetPosition) : base(EVisualRepresentationPart.RelationshipLinkConnector) { this.OwnerRelationshipRepresentation = OwnerRelationshipRepresentation; this.RepresentedLink = RepresentedLink; this.OriginSymbol = OriginSymbol; this.TargetSymbol = TargetSymbol; this.OriginPosition = OriginPosition; this.TargetPosition = TargetPosition; this.OriginSymbol.TargetConnections.Add(this); this.TargetSymbol.OriginConnections.Add(this); }
public void SetDetailsSource(Idea SourceIdea, VisualSymbol SourceSymbol, IList <DetailEditingCard> Source, bool IsLocal, bool AccessOnlyTables = false, DetailDesignator InitialDesignatorToEdit = null) { General.ContractRequires(SourceSymbol == null || SourceIdea == SourceSymbol.OwnerRepresentation.RepresentedIdea); this.SourceIdea = SourceIdea; this.SourceSymbol = SourceSymbol; this.DetailsSource = Source; this.IsLocal = IsLocal; this.AccessOnlyTables = AccessOnlyTables; this.InitialDesignatorToEdit = InitialDesignatorToEdit; this.SourceEngine = SourceIdea.EditEngine as CompositionEngine; this.DetailsListBox.ItemsSource = Source; this.DetailsToolPanel.TargetListBox = this.DetailsListBox; // Notice that selection is made (see applied style), but focus highlight is only applied when it happens. if (this.DetailsSource.Count > 0) { this.DetailsListBox.SelectedIndex = 0; } }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Reassign a Link, represented by the supplied Connector, to the specified new-target. /// </summary> public static void RelinkRelationship(VisualConnector Connector, VisualSymbol NewConnectedSymbol, Point RelinkingPosition, bool IsConnectingTarget) { // If ReLinking, not only changing connection position, from/to a non relationship central/main symbol... if ((IsConnectingTarget && Connector.TargetSymbol != NewConnectedSymbol && Connector.OwnerRelationshipRepresentation.MainSymbol != Connector.TargetSymbol) || (!IsConnectingTarget && Connector.OriginSymbol != NewConnectedSymbol && Connector.OwnerRelationshipRepresentation.MainSymbol != Connector.OriginSymbol)) { var CanLink = EvaluateLinkability( Connector.OwnerRelationshipRepresentation.RepresentedRelationship.RelationshipDefinitor.Value, (IsConnectingTarget ? Connector.OriginSymbol.OwnerRepresentation : NewConnectedSymbol.OwnerRepresentation /*- Connector.TargetSymbol.OwnerRepresentation*/), (IsConnectingTarget ? NewConnectedSymbol.OwnerRepresentation /*- Connector.TargetSymbol.OwnerRepresentation*/ : Connector.OriginSymbol.OwnerRepresentation), (IsConnectingTarget ? Connector.OwnerRelationshipRepresentation.RepresentedRelationship : NewConnectedSymbol.OwnerRepresentation.RepresentedIdea as Relationship), (IsConnectingTarget ? NewConnectedSymbol.OwnerRepresentation.RepresentedIdea as Relationship : Connector.OwnerRelationshipRepresentation.RepresentedRelationship), Connector.OwnerRelationshipRepresentation.RepresentedRelationship, true); if (!CanLink.Result) { Console.WriteLine("Cannot change link. Cause: " + CanLink.Message); return; } if (IsConnectingTarget) { Connector.TargetSymbol.OriginConnections.Remove(Connector); } else { Connector.OriginSymbol.TargetConnections.Remove(Connector); } Connector.RepresentedLink.AssociatedIdea.AssociatingLinks.Remove(Connector.RepresentedLink); Connector.RepresentedLink.AssociatedIdea = NewConnectedSymbol.OwnerRepresentation.RepresentedIdea; Connector.RepresentedLink.AssociatedIdea.AssociatingLinks.Add(Connector.RepresentedLink); if (IsConnectingTarget) { Connector.TargetSymbol = NewConnectedSymbol; Connector.TargetSymbol.OriginConnections.Add(Connector); } else { Connector.OriginSymbol = NewConnectedSymbol; Connector.OriginSymbol.TargetConnections.Add(Connector); } } else // else, if only changing position, then ensure that the target and origin symbol is the same if (NewConnectedSymbol != (IsConnectingTarget ? Connector.TargetSymbol : Connector.OriginSymbol)) { return; } if (IsConnectingTarget) { Connector.TargetPosition = RelinkingPosition; } else { Connector.OriginPosition = RelinkingPosition; } var NewEdgePos = RelinkingPosition.DetermineNearestIntersectingPoint( (IsConnectingTarget ? Connector.FinalOriginPoint : Connector.FinalTargetPoint), NewConnectedSymbol.OwnerRepresentation.DisplayingView.Presenter, NewConnectedSymbol.Graphic, NewConnectedSymbol.OwnerRepresentation.DisplayingView.VisualHitTestFilter); if (IsConnectingTarget) { Connector.TargetEdgePosition = NewEdgePos; } else { Connector.OriginEdgePosition = NewEdgePos; } NewConnectedSymbol.UpdateConnectorMiddleSymbolOfSimpleRel(Connector, !IsConnectingTarget, Enumerable.Empty <VisualSymbol>()); Connector.RenderElement(); Connector.OwnerRelationshipRepresentation.RepresentedRelationship.NotifyPropertyChange("DescriptiveCaption"); }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- public static OperationResult <Relationship> CreateRelationship(Idea DestinationComposite, RelationshipDefinition Definitor, View TargetView, VisualRepresentation OriginRepresentation, Point OriginPosition, VisualRepresentation TargetRepresentation, Point TargetPosition, bool ExtendFromOriginRelationship = true, // (Shift not pressed) Applicable only when origin and target are both relationships. Else (Shift pressed) create Rel. from Target to Origin. bool ExtendExistingRelationship = true) // (Right-Alt not pressed) Applicable only when origin is a not (simple and hiding-central-symbol) relationship. Else (Right-Alt pressed) created Rel. from Rel. { bool EditInPlace = false; General.ContractRequiresNotNull(DestinationComposite, Definitor, TargetView, OriginRepresentation); var MaxQuota = AppExec.CurrentLicenseEdition.TechName.SelectCorresponding(LicensingConfig.IdeasCreationQuotas); if (!ProductDirector.ValidateEditionLimit(DestinationComposite.OwnerComposition.DeclaredIdeas.Count() + 1, MaxQuota, "create", "Ideas (Concepts + Relationships)")) { return(OperationResult.Failure <Relationship>("This product edition cannot create more than " + MaxQuota + " Ideas.")); } if (!ExtendFromOriginRelationship && (TargetRepresentation == null || !(TargetRepresentation.RepresentedIdea is Relationship))) { ExtendFromOriginRelationship = true; } var PotentialOriginRelationship = OriginRepresentation.RepresentedIdea as Relationship; var PotentialTargetRelationship = (TargetRepresentation == null ? (Relationship)null : TargetRepresentation.RepresentedIdea as Relationship); bool CreatingNewRelationship = (/*?*/ !ExtendExistingRelationship || /*?*/ !((PotentialOriginRelationship != null && PotentialOriginRelationship.RelationshipDefinitor.Value == Definitor) || (PotentialTargetRelationship != null && PotentialTargetRelationship.RelationshipDefinitor.Value == Definitor))); bool?ExtensionFromOriginRelationship = (CreatingNewRelationship ? (bool?)null : (PotentialOriginRelationship != null && ExtendFromOriginRelationship)); if (!CreatingNewRelationship && TargetRepresentation == null) { if (OriginRepresentation is RelationshipVisualRepresentation) { return(OperationResult.Success(((RelationshipVisualRepresentation)OriginRepresentation).RepresentedRelationship, "Creating new Relationship.")); } else { return(OperationResult.Failure <Relationship>("There is no targeted Idea to relate.")); } } if (DestinationComposite.IdeaDefinitor.CompositeContentDomain == null) { return(OperationResult.Failure <Relationship>("Destination Container doest not accept Composite-Content.", DestinationComposite)); } if (DestinationComposite.CompositeContentDomain.GlobalId != Definitor.OwnerDomain.GlobalId) { return(OperationResult.Failure <Relationship>("The destination container only accepts content of the '" + DestinationComposite.CompositeContentDomain.Name + "' Domain.")); } Relationship WorkingRelationship = null; LinkRoleDefinition OriginLinkRoleDef = null; RoleBasedLink OriginLink = null; DestinationComposite.EditEngine.StartCommandVariation("Create Relationship"); if (CreatingNewRelationship) { if (TargetRepresentation != null) { var CanLink = Definitor.CanLink(OriginRepresentation.RepresentedIdea.IdeaDefinitor, TargetRepresentation.RepresentedIdea.IdeaDefinitor); if (!CanLink.Result) { DestinationComposite.EditEngine.DiscardCommandVariation(); return(OperationResult.Failure <Relationship>(CanLink.Message)); } } string NewName = Definitor.Name; var AppendNumToName = AppExec.GetConfiguration <bool>("IdeaEditing", "Relationship.OnCreationAppendDefNameAndNumber", true); if (AppendNumToName) { NewName = NewName + " (Idea " + (DestinationComposite.CompositeIdeas.Count + 1).ToString() + ")"; } WorkingRelationship = new Relationship(DestinationComposite.OwnerComposition, Definitor, NewName, NewName.TextToIdentifier()); if (Definitor.IsVersionable) { WorkingRelationship.Version = new VersionCard(); } WorkingRelationship.AddToComposite(DestinationComposite); OriginLinkRoleDef = Definitor.GetLinkForRole(ERoleType.Origin); OriginLink = new RoleBasedLink(WorkingRelationship, OriginRepresentation.RepresentedIdea, OriginLinkRoleDef, OriginLinkRoleDef.AllowedVariants[0]); WorkingRelationship.AddLink(OriginLink); PotentialOriginRelationship = WorkingRelationship; EditInPlace = true; } else { OperationResult <bool> CanLink = OperationResult.Success(true); if (ExtensionFromOriginRelationship.IsTrue()) { WorkingRelationship = PotentialOriginRelationship; } else { WorkingRelationship = (PotentialTargetRelationship != null ? PotentialTargetRelationship : PotentialOriginRelationship); } if (TargetRepresentation != null) { CanLink = EvaluateLinkability(Definitor, OriginRepresentation, TargetRepresentation, PotentialOriginRelationship, PotentialTargetRelationship, WorkingRelationship); if (!CanLink.Result) { DestinationComposite.EditEngine.DiscardCommandVariation(); return(OperationResult.Failure <Relationship>("Cannot create/extend Relationship. Cause: " + CanLink.Message)); } } } LinkRoleDefinition WorkingLinkRoleDef = null; RoleBasedLink WorkingLink = null; if (TargetRepresentation != null && (CreatingNewRelationship || (WorkingRelationship == PotentialOriginRelationship && ExtensionFromOriginRelationship.IsTrue()))) { WorkingLinkRoleDef = Definitor.GetLinkForRole(ERoleType.Target); if (WorkingRelationship.Links.Where(link => link.RoleDefinitor == WorkingLinkRoleDef && link.AssociatedIdea == TargetRepresentation.RepresentedIdea).Any()) { DestinationComposite.EditEngine.DiscardCommandVariation(); return(OperationResult.Failure <Relationship>("Cannot create Target Link. Cause: Already exists one of the same role-type associating the same Idea.")); } WorkingLink = new RoleBasedLink(WorkingRelationship, TargetRepresentation.RepresentedIdea, WorkingLinkRoleDef, WorkingLinkRoleDef.AllowedVariants[0]); WorkingRelationship.AddLink(WorkingLink); } if (OriginRepresentation != null && !CreatingNewRelationship && WorkingRelationship == PotentialTargetRelationship && !ExtensionFromOriginRelationship.IsTrue()) { WorkingLinkRoleDef = Definitor.GetLinkForRole(ERoleType.Origin); if (WorkingRelationship.Links.Where(link => link.RoleDefinitor == WorkingLinkRoleDef && link.AssociatedIdea == OriginRepresentation.RepresentedIdea).Any()) { DestinationComposite.EditEngine.DiscardCommandVariation(); return(OperationResult.Failure <Relationship>("Cannot create Origin Link. Cause: Already exists one of the same role-type associating the same Idea.")); } WorkingLink = new RoleBasedLink(WorkingRelationship, OriginRepresentation.RepresentedIdea, WorkingLinkRoleDef, WorkingLinkRoleDef.AllowedVariants[0]); WorkingRelationship.AddLink(WorkingLink); } RelationshipVisualRepresentation Representator = null; VisualSymbol CentralSymbol = null; if (TargetPosition != Display.NULL_POINT && OriginPosition != Display.NULL_POINT) { VisualConnector OriginConnector = null; var InitialPosition = OriginPosition; var EdgeOriginPosition = OriginPosition; var EdgeTargetPosition = TargetPosition; if (CreatingNewRelationship) { // Force connect from Symbols' centers. if (OriginRepresentation != null) { EdgeOriginPosition = OriginPosition.DetermineNearestIntersectingPoint(TargetPosition, TargetView.Presenter, OriginRepresentation.MainSymbol.Graphic, TargetView.VisualHitTestFilter); } if (TargetRepresentation == null) { InitialPosition = TargetPosition; } else { EdgeTargetPosition = TargetPosition.DetermineNearestIntersectingPoint(OriginPosition, TargetView.Presenter, TargetRepresentation.MainSymbol.Graphic, TargetView.VisualHitTestFilter); InitialPosition = EdgeOriginPosition.DetermineCenterRespect(EdgeTargetPosition); } // Create representation Representator = CreateRelationshipVisualRepresentation(WorkingRelationship, TargetView, InitialPosition); CentralSymbol = Representator.MainSymbol; // Notice that here the Origin connector is being drawn, so the Target plug is empty/none (because is connected to the Relationship Central/Main Symbol). OriginConnector = new VisualConnector(Representator, OriginLink, OriginRepresentation.MainSymbol, CentralSymbol, OriginPosition, CentralSymbol.BaseCenter); } else { if (WorkingRelationship == PotentialOriginRelationship) { Representator = (RelationshipVisualRepresentation)OriginRepresentation; } else { Representator = (RelationshipVisualRepresentation)TargetRepresentation; } CentralSymbol = OriginRepresentation.MainSymbol; InitialPosition = CentralSymbol.BaseCenter; } VisualConnector TargetConnector = null; VisualConnector OriginAutoRefConnector = null; if (TargetRepresentation != null) { TargetConnector = new VisualConnector(Representator, WorkingLink, CentralSymbol, TargetRepresentation.MainSymbol, InitialPosition, TargetPosition); if (WorkingRelationship == PotentialOriginRelationship) { OriginAutoRefConnector = CentralSymbol.OriginConnections.FirstOrDefault(conn => conn.OriginSymbol == TargetRepresentation.MainSymbol); } } if (CreatingNewRelationship) { Representator.AddVisualPart(OriginConnector); } if (TargetConnector != null) { Representator.AddVisualPart(TargetConnector); } if (OriginAutoRefConnector != null) { Representator.BendAutoRefConnectors(OriginAutoRefConnector, TargetConnector); } Representator.Render(); } DestinationComposite.UpdateVersion(); DestinationComposite.EditEngine.CompleteCommandVariation(); var InformedRelationship = WorkingRelationship; if (WorkingRelationship == PotentialTargetRelationship && PotentialOriginRelationship != null) { InformedRelationship = PotentialOriginRelationship; } return(OperationResult.Success(InformedRelationship, null, null, CentralSymbol.OwnerRepresentation, EditInPlace)); }
public override bool Continue(MouseEventArgs Parameter, bool IsDefinitive = true) { var Go = base.Continue(Parameter, IsDefinitive); if (!Go) { return(false); } TargetLocation = Parameter.GetPosition(this.ContextEngine.CurrentView.PresenterControl); if (this.ContextEngine.CurrentView.SnapToGrid) { TargetLocation = this.ContextEngine.CurrentView.GetGridSnappedPosition(TargetLocation, true); } TargetSymbol = this.ContextEngine.GetPointedVisualObject(TargetLocation) as VisualSymbol; var InitialWidth = 0.0; if (IsDefinitive) { var CreationResult = new OperationResult <VisualComplement>(); if (this.ComplementKind.TechName == Domain.ComplementDefCallout.TechName || this.ComplementKind.TechName == Domain.ComplementDefQuote.TechName) { if (TargetSymbol == null) { Console.WriteLine(this.ComplementKind.Name + " must point to a Symbol"); return(true); } if (this.ComplementKind.TechName == Domain.ComplementDefCallout.TechName) { TargetLocation = new Point(TargetSymbol.BaseCenter.X + 20 + VisualComplement.CALLOUT_INI_WIDTH / 2.0, TargetSymbol.BaseTop - 20 - VisualComplement.CALLOUT_INI_HEIGHT / 2.0); } else { TargetLocation = new Point(TargetSymbol.BaseCenter.X - 25 - VisualComplement.QUOTE_INI_WIDTH / 2.0, TargetSymbol.BaseTop - 15 - VisualComplement.QUOTE_INI_HEIGHT / 2.0); } if (this.ContextEngine.CurrentView.SnapToGrid) { TargetLocation = this.ContextEngine.CurrentView.GetGridSnappedPosition(TargetLocation, true); } } if (this.ComplementKind.TechName == Domain.ComplementDefGroupRegion.TechName || this.ComplementKind.TechName == Domain.ComplementDefGroupLine.TechName) { if (TargetSymbol == null) { Console.WriteLine(this.ComplementKind.Name + " must belong to a Symbol"); return(true); } /*- * if (this.ComplementKind.TechName == Domain.ComplementDefGroupRegion.TechName * && TargetSymbol.AttachedComplements.Count(comp => comp.IsComplementGroupRegion) > 0) * { * Console.WriteLine("Symbol cannot have more than one Group Region."); * return true; * } */ if (this.ComplementKind.TechName == Domain.ComplementDefGroupLine.TechName && TargetSymbol.AttachedComplements.Count(comp => comp.IsComplementGroupLine) > 1) { Console.WriteLine("Symbol cannot have more than two Group Lines."); return(true); } if (this.ComplementKind.TechName == Domain.ComplementDefGroupRegion.TechName) { var Params = VisualComplement.GetGroupRegionInitialParams(TargetSymbol); TargetLocation = Params.Item1; InitialWidth = Params.Item2; } else { TargetLocation = VisualComplement.GetGroupLineInitialPosition(TargetSymbol); } } CreationResult = CreateComplement(this.ContextEngine.CurrentView.VisualizedCompositeIdea, this.ComplementKind, this.ContextEngine.CurrentView, TargetSymbol as VisualSymbol, TargetLocation, InitialWidth); if (CreationResult.WasSuccessful) { this.ContextEngine.CurrentView.Manipulator.ApplySelection(CreationResult.Result); this.ContextEngine.CurrentView.Presenter .PostCall(pres => VisualComplement.Edit(CreationResult.Result, true)); if (this.ComplementKind.TechName == Domain.ComplementDefImage.TechName) { return(false); } } else { Console.WriteLine("Cannot create Complement: " + CreationResult.Message.AbsentDefault("?")); this.Terminate(); return(false); } } // // Stop the command... // this.Terminate(true, Parameter); // return false; // Continue the command... return(true); }
private Drawing DrawCentralSymbol() { var MaxDetPosterHeight = (this.BrdPreviewContainer.ActualHeight - (this.BrdPreviewContainer.Padding.Top + this.BrdPreviewContainer.Padding.Bottom)) - this.SymbolHeight; var LocalSymbolWidth = SymbolWidth; // Adjust of the WPF-Bug which incorrectly draws non-solid dash-styles of non-filled geometries. // 2020-07-25 -- Added StraightMidHorizLine to the list. if (this.SourceIdeaDef.DefaultSymbolFormat.LineDash != DashStyles.Solid && this.SourceIdeaDef.RepresentativeShape.IsOneOf(Shapes.XMark, Shapes.StraightParallelLines, Shapes.StraightUnderLine, Shapes.StraightMidHorizLine, Shapes.BracketsCurly, Shapes.BracketsCurved, Shapes.BracketsSquare)) { LocalSymbolWidth = LocalSymbolWidth * 1.5; } var SymDraw = MasterDrawer.CreateDrawingSymbol(this.SourceIdeaDef.RepresentativeShape, this.SourceIdeaDef.DefaultPictogram, this.SourceIdeaDef.DefaultPictogram, this.SourceIdeaDef.DefaultSymbolFormat.LineBrush, this.SourceIdeaDef.DefaultSymbolFormat.LineThickness, this.SourceIdeaDef.DefaultSymbolFormat.LineDash, this.SourceIdeaDef.DefaultSymbolFormat.LineJoin, this.SourceIdeaDef.DefaultSymbolFormat.LineCap, this.SourceIdeaDef.DefaultSymbolFormat.UsePictogramAsSymbol, this.SourceIdeaDef.DefaultSymbolFormat.MainBackground, this.SourceIdeaDef.DefaultSymbolFormat.DetailsPosterIsHanging, this.SourceIdeaDef.DefaultSymbolFormat.Opacity, this.GetSymbolCenter(), LocalSymbolWidth, SymbolHeight, (this.CbxDetailsPoster.IsChecked.IsTrue() && (LocalSymbolWidth >= VisualSymbol.MIN_SYMBOL_DISPLAY_SIZE.Width && MaxDetPosterHeight >= VisualSymbol.MIN_SYMBOL_DISPLAY_SIZE.Height) ? VisualSymbol.INITIAL_DETAILS_POSTER_HEIGHT .EnforceMaximum(MaxDetPosterHeight) .EnforceMinimum(VisualSymbol.MIN_SYMBOL_DISPLAY_SIZE.Height * 2.0) .SubstituteFor(VisualSymbol.MIN_SYMBOL_DISPLAY_SIZE.Height * 2.0, 0.0) : 0.0), this.SourceIdeaDef.DefaultSymbolFormat.AsMultiple, this.SourceIdeaDef.DefaultSymbolFormat.InitiallyFlippedHorizontally, this.SourceIdeaDef.DefaultSymbolFormat.InitiallyFlippedVertically, this.SourceIdeaDef.DefaultSymbolFormat.InitiallyTilted); var WorkingPictogram = (this.SourceIdeaDef.DefaultSymbolFormat.UseDefinitorPictogramAsNullDefault ? this.SourceIdeaDef.Pictogram : Display.GetAppImage("page_white.png")); var TitleFormat = this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.Title); MasterDrawer.GenerateHeadingContent(SymDraw.Item1, SymDraw.Item2, WorkingPictogram, this.SourceIdeaDef.DefaultSymbolFormat.UsePictogramAsSymbol, this.SourceIdeaDef.DefaultSymbolFormat.PictogramVisualDisposition, this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.Title), this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.Subtitle), this.SourceIdeaDef.DefaultSymbolFormat.SubtitleVisualDisposition, this.SourceIdeaDef.DefaultSymbolFormat.UseNameAsMainTitle, this.SourceIdeaDef.Name, this.SourceIdeaDef.TechName); if (SymDraw.Item3 != Rect.Empty) { using (var Context = SymDraw.Item1.Append()) { var TargetArea = new Rect(SymDraw.Item3.X, SymDraw.Item3.Y + VisualSymbol.DETS_MARGIN_SIZE, SymDraw.Item3.Width, (SymDraw.Item3.Height - VisualSymbol.DETS_MARGIN_SIZE)); if (TargetArea.IsValid() && TargetArea.Height > 0 && TargetArea.Width > 0) { var TitleDesignateArea = VisualSymbol.DrawDetailTitle(Context, "Detail Heading", true, this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.DetailHeading), TargetArea, VisualSymbol.DETS_PADDING_SIZE, this.SourceIdeaDef.DefaultSymbolFormat.DetailHeadingBackground, this.SourceIdeaDef.DefaultSymbolFormat.DetailHeadingForeground); TargetArea = new Rect(SymDraw.Item3.X, SymDraw.Item3.Y + TitleDesignateArea.Height + VisualSymbol.DETS_MARGIN_SIZE, SymDraw.Item3.Width, SymDraw.Item3.Height - (TitleDesignateArea.Height + VisualSymbol.DETS_MARGIN_SIZE)); if (TargetArea.IsValid() && TargetArea.Height > 0 && TargetArea.Width > 0) { var LabelArea = MasterDrawer.DrawTextLabel(Context, "Detail Caption", this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.DetailCaption), TargetArea, this.SourceIdeaDef.DefaultSymbolFormat.DetailCaptionBackground, new Pen(this.SourceIdeaDef.DefaultSymbolFormat.DetailCaptionForeground, 1.0), Padding.Top, Padding.Left, Padding.Right); TargetArea = new Rect(SymDraw.Item3.X, SymDraw.Item3.Y + (TitleDesignateArea.Height + VisualSymbol.DETS_MARGIN_SIZE + LabelArea.Height), SymDraw.Item3.Width, SymDraw.Item3.Height - (TitleDesignateArea.Height + VisualSymbol.DETS_MARGIN_SIZE + LabelArea.Height)); if (TargetArea.IsValid() && TargetArea.Height > 0 && TargetArea.Width > 0) { MasterDrawer.DrawTextLabel(Context, "Detail Content", this.SourceIdeaDef.DefaultSymbolFormat.GetTextFormat(ETextPurpose.DetailContent), TargetArea, this.SourceIdeaDef.DefaultSymbolFormat.DetailContentBackground, new Pen(this.SourceIdeaDef.DefaultSymbolFormat.DetailContentForeground, 1.0), Padding.Top, Padding.Left, Padding.Right, false); } } } } } var Result = SymDraw.Item1; // Compensates adjust of the WPF-Bug which incorrectly draws non-solid dash-styles of non-filled geometries. if (LocalSymbolWidth != SymbolWidth) { var CompensatedResult = new DrawingGroup(); CompensatedResult.Children.Add(Result); CompensatedResult.Transform = new TranslateTransform(-(LocalSymbolWidth / 1.5), 0); Result = CompensatedResult; } return(Result); }
public static LocalDetailsEditor CreateLocalDetailsEditor(Idea IdeaSource, VisualSymbol SymbolSource, bool AccessToGlobalDetails, bool AccessOnlyTables = false, DetailDesignator InitialDesignatorToEdit = null) { return(new LocalDetailsEditor(IdeaSource, SymbolSource, AccessToGlobalDetails, AccessOnlyTables, InitialDesignatorToEdit)); }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- public bool UpdateRelatedDetails(Idea CurrentIdeaInstance, VisualSymbol TargetSymbol) { // Here, all global details are preexistent (no adds or deletes are allowed while editing details from Symbol) if (this.VisualGlobalDetailsSource != null) { foreach (var GlobalDetailEdit in this.VisualGlobalDetailsSource) { var Index = CurrentIdeaInstance.Details.IndexOfMatch(condet => condet.Designation.IsEqual(GlobalDetailEdit.Designator.Value)); if (Index < 0) { if (!(GlobalDetailEdit.Designator.Value is LinkDetailDesignator) && GlobalDetailEdit.DetailContent != null) { CurrentIdeaInstance.Details.Add(GlobalDetailEdit.DetailContent); } } else { CurrentIdeaInstance.Details[Index] = GlobalDetailEdit.DetailContent; } // Remember that a custom detail can exist for a non-existent detail (internal-property links) if (TargetSymbol != null) { CurrentIdeaInstance.UpdateCustomLookFor(GlobalDetailEdit.Designator.Value, TargetSymbol, GlobalDetailEdit.EditingLook); } } } // Mantain local details (add, update, delete) foreach (var LocalDetailEdit in this.VisualLocalDetailsSource) { // Add the new details if (!LocalDetailEdit.IsPreexistent) { var LinkDsn = LocalDetailEdit.Designator.Value as LinkDetailDesignator; if (LocalDetailEdit.DetailContent != null && (!(LocalDetailEdit.DetailContent is Link) || (LocalDetailEdit.DetailContent is ResourceLink))) { LocalDetailEdit.Designator.Value.Name = LocalDetailEdit.Name; // Because of binding fail/misuse. CurrentIdeaInstance.Details.Add(LocalDetailEdit.DetailContent); if (TargetSymbol != null) { CurrentIdeaInstance.UpdateCustomLookFor(LocalDetailEdit.Designator.Value, TargetSymbol, LocalDetailEdit.EditingLook); } } } else { // Update the preexistent details var Index = CurrentIdeaInstance.Details.IndexOfMatch(condet => condet.Designation.IsEqual(LocalDetailEdit.Designator.Value)); if (Index >= 0) { CurrentIdeaInstance.Details[Index] = LocalDetailEdit.DetailContent; CurrentIdeaInstance.Details[Index].Designation.Name = LocalDetailEdit.Name; CurrentIdeaInstance.Details[Index].Designation.Summary = LocalDetailEdit.Summary; if (TargetSymbol != null) { CurrentIdeaInstance.UpdateCustomLookFor(LocalDetailEdit.Designator.Value, TargetSymbol, LocalDetailEdit.EditingLook); } } } } // Delete the no longer existent details var AllInternalDetailEdits = (this.VisualGlobalDetailsSource == null ? this.VisualLocalDetailsSource : this.VisualGlobalDetailsSource.Concat(this.VisualLocalDetailsSource)).ToList(); for (int Index = CurrentIdeaInstance.Details.Count - 1; Index >= 0; Index--) { var TargetDetailContent = CurrentIdeaInstance.Details[Index]; if (!AllInternalDetailEdits.Any(det => det.Designator.Value.IsEqual(TargetDetailContent.Designation))) { CurrentIdeaInstance.Details.RemoveAt(Index); CurrentIdeaInstance.DetailsCustomLooks.Remove(TargetDetailContent.Designation); } } // Detect the no longer used designations of custom-formats. var UnusedCustFmtDesignators = new List <DetailDesignator>(); foreach (var CustomFormat in CurrentIdeaInstance.DetailsCustomLooks) { if (!AllInternalDetailEdits.Any(det => (det.Designator.Value.IsEqual(CustomFormat.Key)))) { UnusedCustFmtDesignators.Add(CustomFormat.Key); } } // Delete the no longer used custom-formats by designation. foreach (var UnusedCustFmtAsn in UnusedCustFmtDesignators) { CurrentIdeaInstance.DetailsCustomLooks.Remove(UnusedCustFmtAsn); } // Update the sort of the details CurrentIdeaInstance.Details.UpdateSortFrom(this.VisualLocalDetailsSource, ((targetitem, sorteditem) => targetitem.Designation.IsEqual(sorteditem.Designator.Value))); return(true); }
/// <summary> /// Creates and returns a collection of global detail editing cards for the supplied Idea and Symbol. /// </summary> public static EditableList <DetailEditingCard> GenerateGlobalDetailsFor(Idea SourceIdea, VisualSymbol SourceSymbol) { General.ContractRequires(SourceSymbol == null || SourceSymbol.OwnerRepresentation.RepresentedIdea == SourceIdea); var GeneratedGlobalDetailEdits = new EditableList <DetailEditingCard>("GlobalDetailEdits", null); // First, populate considering the predefined designations of Global scope // IMPORTANT: This also concatenates non-local details (designations predefined in the previous Idea-Definition of a CONVERTED Source-Idea). var Designators = SourceIdea.IdeaDefinitor.DetailDesignators.Concat( SourceIdea.Details.Where(det => !det.AssignedDesignator.IsLocal).Select(det => det.Designation)).Distinct(); foreach (var Designator in Designators) { var NewDetEdit = new DetailEditingCard(true, new Assignment <DetailDesignator>(Designator, false), SourceIdea.Details.FirstOrDefault(det => det.Designation.IsEqual(Designator))); if (SourceSymbol != null && SourceIdea.DetailsCustomLooks.ContainsKey(Designator) && SourceIdea.DetailsCustomLooks[Designator].ContainsKey(SourceSymbol)) { NewDetEdit.SetLook(SourceIdea.DetailsCustomLooks[Designator][SourceSymbol]); } GeneratedGlobalDetailEdits.Add(NewDetEdit); } // Then, add the custom designated details (for this particular Idea) foreach (var Detail in SourceIdea.Details) { var MatchPredefDsnIndex = GeneratedGlobalDetailEdits.IndexOfMatch(PredefDsn => PredefDsn.Designator.Value.IsEqual(Detail.Designation)); } // Plus, set possible custom formats. foreach (var Detail in SourceIdea.Details) { var MatchPredefDsnIndex = GeneratedGlobalDetailEdits.IndexOfMatch(PredefDsn => PredefDsn.Designator.Value.IsEqual(Detail.Designation)); if (SourceSymbol != null && MatchPredefDsnIndex >= 0) { var TargetEditCard = GeneratedGlobalDetailEdits[MatchPredefDsnIndex]; // Set any possible custom format if (TargetEditCard != null && SourceIdea.DetailsCustomLooks.ContainsKey(TargetEditCard.Designator.Value)) { var FormattedDesignation = SourceIdea.DetailsCustomLooks[TargetEditCard.Designator.Value]; if (FormattedDesignation != null && FormattedDesignation.ContainsKey(SourceSymbol)) { TargetEditCard.SetLook(FormattedDesignation[SourceSymbol]); } } } } return(GeneratedGlobalDetailEdits); }
/// <summary> /// Creates and returns a collection of local detail editing cards for the supplied Idea and Symbol. /// </summary> public static EditableList <DetailEditingCard> GenerateLocalDetailsFor(Idea SourceIdea, VisualSymbol SourceSymbol, IEnumerable <DetailEditingCard> GeneratedGlobalDetails) { General.ContractRequires(SourceSymbol == null || SourceSymbol.OwnerRepresentation.RepresentedIdea == SourceIdea); var GeneratedLocalDetailEdits = new EditableList <DetailEditingCard>("LocalDetailEdits", null); // Add the custom designated details (for this particular Idea), plus its possible custom formats. foreach (var Detail in SourceIdea.Details.Where(det => det.ContentDesignator.IsLocal)) { var TargetEditCard = new DetailEditingCard(true, new Assignment <DetailDesignator>(Detail.Designation, true), Detail); GeneratedLocalDetailEdits.Add(TargetEditCard); // Set any possible custom format if (SourceSymbol != null && TargetEditCard != null && SourceIdea.DetailsCustomLooks.ContainsKey(TargetEditCard.Designator.Value)) { var FormattedDesignation = SourceIdea.DetailsCustomLooks[TargetEditCard.Designator.Value]; if (FormattedDesignation != null && FormattedDesignation.ContainsKey(SourceSymbol)) { TargetEditCard.SetLook(FormattedDesignation[SourceSymbol]); } } } // Finally, add custom formats of Local Internal/Property details (not related to an existent detail). // Notice that global-designators (those previously generated) are excluded. // IMPORTANT: Don't ask solely for Idea-Definitor's detail designators, because for a Converted Idea // can exist globally-defined detail designators which remain declared by the previous Idea-Definition. var AssignedCustomLooks = SourceIdea.DetailsCustomLooks .Where(cuslook => cuslook.Key is LinkDetailDesignator && !GeneratedLocalDetailEdits.Any(det => det.Designator.Value.IsEquivalent(cuslook.Key)) && (GeneratedGlobalDetails != null && !GeneratedGlobalDetails.Any( det => { if (!(det.Designator.Value is LinkDetailDesignator)) { return(det.Designator.Value.IsEqual(cuslook.Key)); } var dsnlink = det.Designator.Value.GetFinalContent(SourceIdea) as Link; var clklink = cuslook.Key.GetFinalContent(SourceIdea) as Link; var result = dsnlink.Target.IsEqual(clklink.Target); return(result); })) /*- && !SourceIdea.IdeaDefinitor.DetailDesignators.Any(dsn => dsn.IsEquivalent(cuslook.Key))*/); foreach (var CustLook in AssignedCustomLooks) { // Notice that no detail is supplied because Internal-Detail is just a designator-to-property reference. GeneratedLocalDetailEdits.Add(new DetailEditingCard(true, new Assignment <DetailDesignator>(CustLook.Key, true), null)); } return(GeneratedLocalDetailEdits); }