public override void Bind(IEditorService service) { service.RegisterCustomNotifier(this); _init = true; _edSvc = service; try { _wmd = (IWatermarkDefinition)service.GetEditedResource(); _sym = (ISimpleSymbolDefinition)_wmd.Content; //NOTE: We are assuming there is only one graphic element here. foreach (var g in _sym.Graphics) { if (g.Type == GraphicElementType.Text) { _text = (ITextGraphic)g; } else if (g.Type == GraphicElementType.Image) { _image = (IImageGraphic)g; } } if (_text != null || _image != null) { if (_text != null) { rdText.Checked = true; } else if (_image != null) { rdImage.Checked = true; } CheckEditStates(); } else { //Text, I choose you rdText.Checked = true; CheckEditStates(); _text = _sym.CreateTextGraphics(); _image = _sym.CreateImageGraphics(); SetActiveGraphicElement(_text); } } finally { _init = false; } }
public ImageDialog(EditorBindableCollapsiblePanel parent, IServerConnection conn, ISimpleSymbolDefinition ssd, IImageGraphic image) { InitializeComponent(); _ed = parent; _ssd = ssd; _image = image; _conn = conn; try { _init = true; if (_image.Item.Type == ImageType.Reference) { _imageRef = (IImageReference)_image.Item; rdResourceRef.Checked = true; } else { _imageInline = (IInlineImage)_image.Item; rdInline.Checked = true; } if (_imageRef == null) { _imageRef = ssd.CreateImageReference(string.Empty, string.Empty); } else { rdResourceRef.Checked = true; } if (_imageInline == null) { _imageInline = ssd.CreateInlineImage(new byte[0]); } else { rdInline.Checked = true; } txtResourceId.Text = _imageRef.ResourceId; txtResData.Text = _imageRef.LibraryItemName; txtImageBase64.Text = Convert.ToBase64String(_imageInline.Content); txtImageBase64.Tag = _imageInline.Content; imageType_CheckedChanged(this, null); } finally { _init = false; } }
public override void Bind(IEditorService service) { service.RegisterCustomNotifier(this); _init = true; _edSvc = service; try { _wmd = (IWatermarkDefinition)service.GetEditedResource(); _sym = (ISimpleSymbolDefinition)_wmd.Content; //NOTE: We are assuming there is only one graphic element here. foreach (var g in _sym.Graphics) { if (g.Type == GraphicElementType.Text) _text = (ITextGraphic)g; else if (g.Type == GraphicElementType.Image) _image = (IImageGraphic)g; } if (_text != null || _image != null) { if (_text != null) rdText.Checked = true; else if (_image != null) rdImage.Checked = true; CheckEditStates(); } else { //Text, I choose you rdText.Checked = true; CheckEditStates(); _text = _sym.CreateTextGraphics(); _image = _sym.CreateImageGraphics(); SetActiveGraphicElement(_text); } } finally { _init = false; } }
public ImageDialog(EditorBindableCollapsiblePanel parent, IResourceService resSvc, ISimpleSymbolDefinition ssd, IImageGraphic image) { InitializeComponent(); _ed = parent; _ssd = ssd; _image = image; _resSvc = resSvc; try { _init = true; if (_image.Item.Type == ImageType.Reference) { _imageRef = (IImageReference)_image.Item; rdResourceRef.Checked = true; } else { _imageInline = (IInlineImage)_image.Item; rdInline.Checked = true; } if (_imageRef == null) _imageRef = ssd.CreateImageReference("", ""); else rdResourceRef.Checked = true; if (_imageInline == null) _imageInline = ssd.CreateInlineImage(new byte[0]); else rdInline.Checked = true; txtResourceId.Text = _imageRef.ResourceId; txtResData.Text = _imageRef.LibraryItemName; txtImageBase64.Text = Convert.ToBase64String(_imageInline.Content); txtImageBase64.Tag = _imageInline.Content; imageType_CheckedChanged(this, null); } finally { _init = false; } }
/// <summary> /// Validates the simple symbol definition. /// </summary> /// <param name="ssym">The ssym.</param> /// <param name="context">The context.</param> /// <returns></returns> protected IEnumerable <ValidationIssue> ValidateSimpleSymbolDefinition(ISimpleSymbolDefinition ssym, ResourceValidationContext context) { //Check that one geometry usage context has been specified if (ssym.AreaUsage == null && ssym.LineUsage == null && ssym.PointUsage == null) { yield return(new ValidationIssue(ssym, ValidationStatus.Error, ValidationStatusCode.Error_SymbolDefinition_NoGeometryUsageContexts, Strings.SSDF_NoGeometryUsageContext)); } //Validate image graphics foreach (var graphic in ssym.Graphics) { if (graphic.Type == GraphicElementType.Image) { IImageGraphic image = (IImageGraphic)graphic; if (image.Item != null) { if (image.Item.Type == ImageType.Reference) { IImageReference imgRef = (IImageReference)image.Item; if (!context.ResourceExists(imgRef.ResourceId)) { yield return(new ValidationIssue(ssym, ValidationStatus.Error, ValidationStatusCode.Error_SymbolDefinition_ImageGraphicReferenceResourceIdNotFound, Strings.SSDF_ImageGraphicReferenceResourceIdNotFound)); } else { var res = context.GetResource(imgRef.ResourceId); var resData = this.Connection.ResourceService.EnumerateResourceData(res.ResourceID); bool found = false; foreach (var item in resData.ResourceData) { if (item.Name == imgRef.LibraryItemName) { found = true; } } if (!found) { yield return(new ValidationIssue(ssym, ValidationStatus.Error, ValidationStatusCode.Error_SymbolDefinition_ImageGraphicReferenceResourceDataNotFound, string.Format(Strings.SSDF_ImageGraphicReferenceResourceDataNotFound, imgRef.ResourceId, imgRef.LibraryItemName))); } } } else //inline { //TODO: Validate inline image content } } } } string xml = ObjectFactory.SerializeAsString(ssym); //Check non existent symbol parameters foreach (var paramDef in ssym.ParameterDefinition.Parameter) { string name = "%" + paramDef.Identifier + "%"; //NOXLATE if (!xml.Contains(name) && string.IsNullOrEmpty(paramDef.DefaultValue)) { yield return(new ValidationIssue(ssym, ValidationStatus.Warning, ValidationStatusCode.Warning_SymbolDefinition_SymbolParameterNotUsed, string.Format(Strings.SSDF_SymbolParameterNotUsed, paramDef.Identifier))); } } //TODO: Do the reverse check. Placeholders not pointing to a symbol parameter }