<esri:FeatureLayer ID="IncidentsLayer" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/0" MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" AutoSave="False" DisableClientCaching="True" OutFields="*" Mode="OnDemand" />
private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e) { FeatureLayer featureLayer = sender as FeatureLayer; for (int i = 0; i < featureLayer.SelectionCount; i++) featureLayer.SelectedGraphics.ToList().UnSelect(); e.Graphic.Select(); MyAttachmentEditor.GraphicSource = e.Graphic; }
if (e.Action == Editor.EditAction.ClearSelection || e.Action == Editor.EditAction.Select) { MyAttachmentEditor.GraphicSource = null; } else if (e.Action == Editor.EditAction.Add || e.Action == Editor.EditAction.Select) { foreach (var edit in e.Edits) { if (e.Action == Editor.EditAction.Add || edit.Graphic.Selected) { MyAttachmentEditor.GraphicSource = edit.Graphic; break; } } }
<Button x:Name="ViewAttribute" Command="{Binding Select}" CommandParameter="new" Style="{StaticResource ButtonStyle}" ToolTipService.ToolTip="View Attachments" Click="ViewAttribute_Click"> <Image Source="Images/AttImage.png" Stretch="None"/> </Button>
<esri:FeatureLayer ID="TPOINTS" DisableClientCaching="True" AutoSave="False" Url="http://myserver.com/ArcGIS/rest/services/edittest/FeatureServer/0" OutFields="*" Mode="OnDemand" />
<!-- Editing Tools --> <userControls:CollapsiblePanel x:Name="EditorTool" IsExpanded="True" RenderTransformOrigin="1,0" VerticalContentAlignment="Top" HorizontalContentAlignment="Right" Margin="0,75,10,0" Effect="{StaticResource dropShadow}" > <Grid x:Name="EditorToolStripGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" > <Border Background="{StaticResource CommonPanelBorderBackgroundBrush}" BorderBrush="{StaticResource CommonBorderBrush}" BorderThickness="1" CornerRadius="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Border Effect="{StaticResource miniDropShadow}" Style="{StaticResource RibbonElementBorder}" Padding="15" Margin="10" > <StackPanel x:Name="EditorToolStrip" Margin="0,5,5,0" > <Border Background="#00919191" CornerRadius="5" HorizontalAlignment="Right" VerticalAlignment="Top" Padding="5" BorderBrush="Transparent"> <Border.Effect> <DropShadowEffect Color="Black" Direction="-45" BlurRadius="20" Opacity=".75" /> </Border.Effect> <StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="0,5,5,0" VerticalAlignment="Top" > <esri:EditorWidget x:Name="MyEditorWidget" Map="{Binding ElementName=Map}" Width="300" AutoSelect="False" AlwaysDisplayDefaultTemplates="True" GeometryServiceUrl="http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" ShowAttributesOnAdd="True" Loaded="EditorWidget_Loaded" Style="{StaticResource EditorWidgetStyle1}" EditCompleted="EditorWidget_EditCompleted"/> </StackPanel> </Border> </StackPanel> </Border> </Border> <Image Source="images/CloseX.png" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="3" Stretch="None" Cursor="Hand" ToolTipService.ToolTip="Close" > <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown" > <actions:ToggleCollapseAction TargetName="EditorTool" /> </i:EventTrigger> </i:Interaction.Triggers> </Image> </Grid> </userControls:CollapsiblePanel> <!-- END Editing Tools--> <!-- Attachment Tools --> <Grid x:Name="AttachmentGrid" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,20,15,0" Visibility="Collapsed"> <Border Background="{StaticResource CommonPanelBorderBackgroundBrush}" BorderBrush="{StaticResource CommonBorderBrush}" BorderThickness="1" CornerRadius="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Border Effect="{StaticResource miniDropShadow}" Style="{StaticResource RibbonElementBorder}" Padding="15" Margin="10" > <StackPanel Orientation="Vertical"> <TextBlock Text="Click on a point feature to select it, and click the 'Add' button to attach a file." Width="275" TextAlignment="Left" Margin="20,20,20,5" TextWrapping="Wrap" FontWeight="Bold"/> <esri:AttachmentEditor x:Name="MyAttachmentEditor" VerticalAlignment="Top" Margin="20,5,20,20" Background="WhiteSmoke" Width="280" Height="190" HorizontalAlignment="Right" FeatureLayer="{Binding Layers[TPOINTS], ElementName=Map}" Filter="All Files (*.*)|*.*|Image Files|*.tif;*.jpg;*.gif;*.png;*.bmp|Text Files (.txt)|*.txt" FilterIndex="1" Multiselect="True" UploadFailed="MyAttachmentEditor_UploadFailed"> </esri:AttachmentEditor> </StackPanel> </Border> </Border> <Image Source="images/CloseX.png" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="3" Stretch="None" Cursor="Hand" ToolTipService.ToolTip="Close" > <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown" > <actions:ToggleCollapseAction TargetName="AttachmentTool" /> </i:EventTrigger> </i:Interaction.Triggers> </Image> </Grid> <!-- END Attachment Tools-->
#region Edit Tools private void EditorWidget_Loaded(object sender, RoutedEventArgs e) { string[] myLayerIDs = { "TPOINTS" }; MyEditorWidget.LayerIDs = myLayerIDs; } #endregion #region Attachment Tool private void MyAttachmentEditor_UploadFailed(object sender, ESRI.ArcGIS.Client.Toolkit.AttachmentEditor.UploadFailedEventArgs e) { MessageBox.Show(e.Result.Message); } private void ViewAttribute_Click(object sender, RoutedEventArgs e) { if (AttachmentGrid.Visibility == Visibility.Visible) { AttachmentGrid.Visibility = Visibility.Collapsed; attachmentEditorActive = false; } else { AttachmentGrid.Visibility = Visibility.Visible; attachmentEditorActive = !attachmentEditorActive; } } //public event EventHandler<Editor.EditEventArgs> EditCompleted //{ //} private void EditorWidget_EditCompleted(object sender, Editor.EditEventArgs e) { if (e.Action == Editor.EditAction.Select && attachmentEditorActive) { foreach (var edit in e.Edits) { MyAttachmentEditor.GraphicSource = edit.Graphic; break; } } } #endregion
Command="{Binding Select}" CommandParameter="new" Click="Button_Click"
bool attachmentEditorActive = false; private void Button_Click(object sender, RoutedEventArgs e) { attachmentEditorActive = !attachmentEditorActive; } private void EditorWidget_EditCompleted(object sender, Editor.EditEventArgs e) { if (e.Action == Editor.EditAction.Select && attachmentEditorActive) { foreach (var edit in e.Edits) { MyAttachmentEditor.GraphicSource = edit.Graphic; break; } } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.