public void /* ITreeGridDesignerToolWindowContainer */ SetWatermarkInfo(TreeGridDesignerWatermarkInfo watermarkInfo) { _watermark.Text = watermarkInfo.WatermarkText; _watermark.Links.Clear(); foreach (var ld in watermarkInfo.WatermarkLinkData) { if (ld.LinkStart > 0) { _watermark.Links.Add(new LinkLabel.Link(ld.LinkStart, ld.LinkLength, ld.LinkClickedHandler)); } } }
public void SetWatermarkInfo(TreeGridDesignerWatermarkInfo watermarkInfo) { if (watermarkInfo == null) { Debug.Fail("Unexpected null value for watermarkInfo"); return; } SetHintColor(Color.Transparent); watermarkLabel.Links.Clear(); if (watermarkInfo.WatermarkText == null) { Debug.Fail("Unexpected null value for watermarkText"); return; } watermarkLabel.Text = watermarkInfo.WatermarkText; if (watermarkInfo.WatermarkLinkData == null) { Debug.Fail("Unexpected null value watermarkInfo.WatermarkLinkData"); return; } foreach (var ld in watermarkInfo.WatermarkLinkData.Where(ld => ld.LinkStart > 0)) { watermarkLabel.Links.Add(new LinkLabel.Link(ld.LinkStart, ld.LinkLength, ld.LinkClickedHandler)); } }
private static TreeGridDesignerWatermarkInfo CreateWatermarkInfoPKToFKRC_NoASM() { var watermarkInfo = new TreeGridDesignerWatermarkInfo( Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_NoASM); return watermarkInfo; }
private static TreeGridDesignerWatermarkInfo CreateWatermarkInfoPKToFKRC_WithASM(MappingDetailsWindowContainer windowContainer) { var errorMessage = String.Format( CultureInfo.CurrentCulture, Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_ASM, Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_ASM_Delete, Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_ASM_Display); var idx1 = errorMessage.IndexOf( Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_ASM_Delete, StringComparison.Ordinal); var idx2 = errorMessage.IndexOf( Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_ASM_Display, StringComparison.Ordinal); var watermarkInfo = new TreeGridDesignerWatermarkInfo( errorMessage, new TreeGridDesignerWatermarkInfo.LinkData( idx1, Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_ASM_Delete.Length, windowContainer.watermarkLabel_LinkClickedDeleteAssociation), new TreeGridDesignerWatermarkInfo.LinkData( idx2, Resources.MappingDetails_ReferentialConstraintOnAssociation_PKToFK_ASM_Display.Length, windowContainer.watermarkLabel_LinkClickedDisplayAssociation)); return watermarkInfo; }
internal static bool CanEditMappingsForAssociation( Association association, MappingDetailsWindowContainer windowContainer, ref TreeGridDesignerWatermarkInfo watermarkInfo, bool allowMappingEditWithFKs) { if (association == null) { throw new ArgumentNullException("association"); } // make sure that we have an EntitySet (or can find one) if (association.AssociationSet == null) { var errorMessage = String.Format( CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral, Resources.MappingDetails_ErrMslCantFindAssociationSet); watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage); return false; } var asms = association.AssociationSet.GetAntiDependenciesOfType<AssociationSetMapping>(); var rc = association.ReferentialConstraint; if (rc != null) { // allowMappingEditWithFKs is an override flag that suppresses the following watermarks. if (allowMappingEditWithFKs == false) { if (EdmFeatureManager.GetForeignKeysInModelFeatureState(association.Artifact.SchemaVersion) .IsEnabled()) { // set up watermarks association mapping window watermarks when FKs are supported if (rc.IsPrimaryKeyToPrimaryKey()) { if (asms.Count > 0) { watermarkInfo = CreateWatermarkInfoPKToPKRC_WithASM(windowContainer); } else { watermarkInfo = CreateWatermarkInfoPKToPKRC_NoASM(windowContainer); } return false; } else { if (asms.Count > 0) { watermarkInfo = CreateWatermarkInfoPKToFKRC_WithASM(windowContainer); } else { watermarkInfo = CreateWatermarkInfoPKToFKRC_NoASM(); } return false; } } else { // targeting netfx 3.5. FKs are not supported if (rc.IsPrimaryKeyToPrimaryKey() == false) { if (asms.Count > 0) { watermarkInfo = CreateWatermarkInfoPKToFKRC_WithASM(windowContainer); } else { watermarkInfo = CreateWatermarkInfoPKToFKRC_NoASM(); } return false; } } } } // make sure that there is just one AssociationSetMapping for our set if (asms.Count > 1) { var errorMessage = String.Format( CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral, Resources.MappingDetails_ErrMslTooManyAssociationSetMappings); watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage); return false; } else { foreach (var asm in asms) { // if AssociationSetMapping contains QueryView if (asm.HasQueryViewElement) { var errorMessage = String.Format( CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral, Resources.MappingDetails_ErrMslAssociationSetMappingHasQueryView); watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage); return false; } // make sure that we fully resolve var errorMsg = string.Empty; if (EnsureResolvedStatus(asm, ref errorMsg) == false) { var errorMessage = String.Format(CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral, errorMsg); watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage); return false; } // ensure that we don't have any C-side conditions foreach (var cond in asm.Conditions()) { if (cond.Name.RefName != null) { var errorMessage = String.Format( CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral, Resources.MappingDetails_ErrMslUnsupportedCondition); watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage); return false; } } } } foreach (var associationEnd in association.AssociationEnds()) { string duplicatePropertyName; var entityType = associationEnd.Type.Target; if (!CheckDuplicateEntityProperty(entityType, out duplicatePropertyName)) { var errorMessage = String.Format( CultureInfo.CurrentCulture, Resources.MappingDetails_ErrDuplicatePropertyNameForAssociationEndEntity, entityType.LocalName.Value, duplicatePropertyName); errorMessage = String.Format(CultureInfo.CurrentCulture, Resources.MappingDetails_ErrMslGeneral, errorMessage); watermarkInfo = new TreeGridDesignerWatermarkInfo(errorMessage); return false; } } return true; }
public void SetWatermarkInfo(TreeGridDesignerWatermarkInfo watermarkInfo) { Debug.Assert(watermarkInfo != null, "watermark info is null!"); if (watermarkInfo != null) { _watermarkInfo = watermarkInfo; ForceWatermarkTextChange(); } }
public void SetWatermarkInfo(string text) { var wm = new TreeGridDesignerWatermarkInfo(text); SetWatermarkInfo(wm); }
private void SetUpDefaultWatermarkInfo() { // set up default watermark info var watermarkText = String.Format(CultureInfo.CurrentCulture, Resources.MappingDetails_Watermark, Resources.ExplorerWindowTitle); // container will only be null when we initialize this through the constructor. if (MappingDetailsWindowContainer != null) { var linkStart = watermarkText.IndexOf(Resources.ExplorerWindowTitle, StringComparison.Ordinal); var linkLength = Resources.ExplorerWindowTitle.Length; _defaultWatermarkInfo = new TreeGridDesignerWatermarkInfo( watermarkText, new TreeGridDesignerWatermarkInfo.LinkData( linkStart, linkLength, MappingDetailsWindowContainer.watermarkLabel_LinkClickedShowExplorer)); } else { _defaultWatermarkInfo = new TreeGridDesignerWatermarkInfo(watermarkText); } _watermarkInfo = _defaultWatermarkInfo; }