private static void setupAttachments(AttachmentsPanel panel, AttachmentFieldValue attachmentFieldValue)
        {
            if (attachmentFieldValue != null && attachmentFieldValue.AttachmentsProvider != null)
            {
                if (attachmentFieldValue.AttachmentsProvider.HasAlreadyRetrievedAttachments())
                {
                    MultipleAttachmentsInfo attachments = attachmentFieldValue.AttachmentsProvider.GetAttachments();
                    panel.setAttachments(attachments);
                }
                else
                {
                    attachmentFieldValue.AttachmentsProvider.LoadAttachments(attachmentFieldValue.LinkUrl, (o, args) =>
                    {
                        panel.Dispatcher.BeginInvoke((Action)delegate
                        {
                            if (args == null)
                                return;
                            AttachmentsPanel pnl = args.UserState as AttachmentsPanel;
                            pnl.setAttachments(args.AttachmentInfo);
                        });

                    }, (o, args) =>
                    {
                        panel.Dispatcher.BeginInvoke((Action)delegate
                        {
                            if (args == null || args.Exception == null)
                                return;
                            AttachmentsPanel pnl = args.UserState as AttachmentsPanel;
                            pnl.Error = args.Exception.Message;
                            pnl.ErrorVisibility = Visibility.Visible;
                        });
                    }, panel);
                }
            }
        }
        private static StringBuilder GetFieldValueElement(FieldSettings field, object fieldValue, int rowNumber)
        {
            StringBuilder sb = null;

            switch (field.FieldType)
            {
            case FieldType.Attachment:
                #region
                AttachmentFieldValue attachmentFieldValue = fieldValue as AttachmentFieldValue;
                if (attachmentFieldValue != null && attachmentFieldValue.AttachmentsProvider != null)
                {
                    sb = new StringBuilder();
                    sb.AppendFormat("<mapping:AttachmentsPanel Grid.Column=\"2\" Grid.Row=\"{0}\" FieldValue=\"{{Binding PopupItem.Graphic.Attributes[{1}]}}\" />",
                                    rowNumber, field.Name);
                }
                #endregion
                break;

            case FieldType.Entity:
            case FieldType.Hyperlink:
                #region
                sb = new StringBuilder();
                sb.AppendFormat(@"<StackPanel Grid.Column=""2"" Grid.Row=""{0}"" Orientation=""Vertical"" 
                                      VerticalAlignment=""Center"" Margin=""5,2"" >",
                                rowNumber);
                sb.AppendFormat("<HyperlinkButton NavigateUri=\"{{Binding PopupItem, Converter={{StaticResource UrlLocationAttributeConverter}}, ConverterParameter={0}}}\" TargetName=\"_blank\" Background=\"Transparent\" VerticalAlignment=\"Top\" >",
                                field.Name);
                sb.AppendFormat("<TextBlock Text=\"{{Binding PopupItem, Converter={{StaticResource UrlDescriptionAttributeConverter}}, ConverterParameter={0}}}\" FontWeight=\"Normal\" Margin=\"0,0,0,5\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\" TextWrapping=\"Wrap\" Foreground=\"Blue\" TextDecorations=\"Underline\" />",
                                field.Name);
                sb.Append("</HyperlinkButton>");
                sb.Append("</StackPanel>");
                #endregion
                break;

            case FieldType.Image:
                #region
                sb = new StringBuilder();
                sb.AppendFormat(@"<StackPanel Grid.Column=""2"" Grid.Row=""{0}"" Orientation=""Vertical"">",
                                rowNumber);
                sb.AppendFormat("<Image Margin=\"8, -2, 5, 5\" Source=\"{{Binding PopupItem, Converter={{StaticResource UrlLocationAttributeConverter}}, ConverterParameter={0}}}\" ToolTipService.ToolTip=\"{{Binding PopupItem, Converter={{StaticResource UrlDescriptionAttributeConverter}}, ConverterParameter={1}}}\" />", field.Name, field.Name);
                sb.Append("</StackPanel>");
                #endregion
                break;

            default:
                #region
                sb = new StringBuilder();
                if (!string.IsNullOrEmpty(field.Name))
                {
                    sb.AppendFormat(@"<mapping:HyperlinkOrTextBlock Grid.Column=""2"" Grid.Row=""{0}"" Margin=""5,2""
FieldValue=""{{Binding PopupItem, Converter={{StaticResource LabelAttributeConverter}}, ConverterParameter={1} }}"" />",
                                    rowNumber, field.Name);
                }
                #endregion
                break;
            }

            return(sb);
        }
        public override bool Equals(object obj)
        {
            AttachmentFieldValue other = obj as AttachmentFieldValue;

            if (other != null)
            {
                return(other.DisplayText == DisplayText && other.LinkUrl == LinkUrl);
            }
            return(base.Equals(obj));
        }
Esempio n. 4
0
        private void writeAttachmentFieldValue(AttachmentFieldValue attFieldValue)
        {
            if (attFieldValue == null)
            {
                return;
            }

            writer.WriteStartElement("AttachmentFieldValue", Namespaces[Constants.esriMappingPrefix]);
            if (!string.IsNullOrEmpty(attFieldValue.DisplayText))
            {
                writer.WriteAttributeString("DisplayText", attFieldValue.DisplayText);
            }
            if (!string.IsNullOrEmpty(attFieldValue.LinkUrl))
            {
                writer.WriteAttributeString("LinkUrl", attFieldValue.LinkUrl);
            }
            writer.WriteEndElement();
        }
Esempio n. 5
0
        private void writeUniqueValueObj(object uniqueValueInfo)
        {
            if (uniqueValueInfo == null)
            {
                return;
            }

            NumericFieldValue numericFieldValue = uniqueValueInfo as NumericFieldValue;

            if (numericFieldValue != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj.SerializedValue", Namespaces[Constants.esriMappingPrefix]);
                writeNumericFieldValue(numericFieldValue);
                writer.WriteEndElement();
                return;
            }

            AttachmentFieldValue attFieldValue = uniqueValueInfo as AttachmentFieldValue;

            if (attFieldValue != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj.SerializedValue", Namespaces[Constants.esriMappingPrefix]);
                writeAttachmentFieldValue(attFieldValue);
                writer.WriteEndElement();
                return;
            }

            CurrencyFieldValue currFieldValue = uniqueValueInfo as CurrencyFieldValue;

            if (currFieldValue != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj.SerializedValue", Namespaces[Constants.esriMappingPrefix]);
                writeCurrencyFieldValue(currFieldValue);
                writer.WriteEndElement();
                return;
            }

            EntityFieldValue entityFieldValue = uniqueValueInfo as EntityFieldValue;

            if (entityFieldValue != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj.SerializedValue", Namespaces[Constants.esriMappingPrefix]);
                writeEntityFieldValue(entityFieldValue);
                writer.WriteEndElement();
                return;
            }

            HyperlinkFieldValue hyperlinkFieldValue = uniqueValueInfo as HyperlinkFieldValue;

            if (hyperlinkFieldValue != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj.SerializedValue", Namespaces[Constants.esriMappingPrefix]);
                writeHyperlinkFieldValue(hyperlinkFieldValue);
                writer.WriteEndElement();
                return;
            }

            HyperlinkImageFieldValue hyperlinkImageFieldValue = uniqueValueInfo as HyperlinkImageFieldValue;

            if (hyperlinkImageFieldValue != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj.SerializedValue", Namespaces[Constants.esriMappingPrefix]);
                writeHyperlinkImageFieldValue(hyperlinkImageFieldValue);
                writer.WriteEndElement();
                return;
            }

            LookupFieldValue lookupFieldValue = uniqueValueInfo as LookupFieldValue;

            if (lookupFieldValue != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj.SerializedValue", Namespaces[Constants.esriMappingPrefix]);
                writeLookupFieldValue(lookupFieldValue);
                writer.WriteEndElement();
                return;
            }

            DateTimeFieldValue dateTimeFieldValue = uniqueValueInfo as DateTimeFieldValue;

            if (dateTimeFieldValue != null)
            {
                writer.WriteStartElement("UniqueValueInfoObj.SerializedValue", Namespaces[Constants.esriMappingPrefix]);
                writeDateTimeFieldValue(dateTimeFieldValue);
                writer.WriteEndElement();
                return;
            }

            if (uniqueValueInfo is double)
            {
                writer.WriteAttributeString("SerializedValue", ((double)uniqueValueInfo).ToString(CultureInfo.InvariantCulture));
            }
            else
            {
                writer.WriteAttributeString("SerializedValue", uniqueValueInfo.ToString());
            }
        }
        private void writeAttachmentFieldValue(AttachmentFieldValue attFieldValue)
        {
            if (attFieldValue == null)
                return;

            writer.WriteStartElement("AttachmentFieldValue", Namespaces[Constants.esriMappingPrefix]);
            if (!string.IsNullOrEmpty(attFieldValue.DisplayText))
                writer.WriteAttributeString("DisplayText", attFieldValue.DisplayText);
            if (!string.IsNullOrEmpty(attFieldValue.LinkUrl))
                writer.WriteAttributeString("LinkUrl", attFieldValue.LinkUrl);
            writer.WriteEndElement();
        }