protected override void OnDownloadConfigXMLCompleted(object sender, DownloadStringCompletedEventArgs e) { string xmlConfig = e.Result; widgetConfig = (EditWidgetConfig)EditWidgetConfig.Deserialize(xmlConfig, typeof(EditWidgetConfig)); if (widgetConfig != null) { FeatureLayer agisFeatureLayer = null; foreach (EditFeatureLayer fLayer in widgetConfig.EditableLayers) { agisFeatureLayer = new FeatureLayer() { AutoSave = widgetConfig.AutoSave, Url = fLayer.RESTURL, Visible = fLayer.VisibleInitial, ProxyUrl = fLayer.ProxyURL }; agisFeatureLayer.ID = string.Format("edit_{0}", fLayer.ID.ToString()); agisFeatureLayer.Opacity = (fLayer.Opacity == 0.0) ? 1.0 : fLayer.Opacity; agisFeatureLayer.Initialized += new EventHandler <EventArgs>(FeatureLayer_Initialized); agisFeatureLayer.InitializationFailed += new EventHandler <EventArgs>(FeatureLayer_InitializationFailed); agisFeatureLayer.MouseLeftButtonUp += new ArcGIS.Client.GraphicsLayer.MouseButtonEventHandler(FeatureLayer_MouseLeftButtonUp); this.featureLayerIDs.Add(agisFeatureLayer.ID); this.MapControl.Layers.Add(agisFeatureLayer); } // Initialize Feature Editor InitializeFeatureEditor(); // Initialize Feature Data Editor Form dataEditorForm = new FeatureDataForm() { Margin = new Thickness(0, 0, 0, 0), Width = 400, MaxHeight = 300 }; dataEditorForm.EditEnded += new EventHandler <EventArgs>(DataEditorForm_EditEnded); dataEditorForm.IsReadOnly = false; // Initialize Attachment Editor Form attachmentEditor = new AttachmentEditor() { Margin = new Thickness(0, 4, 0, 0), Width = 400, Height = 100, FilterIndex = 1, Multiselect = true }; attachmentEditor.Filter = "All Files (*.*)|*.*|Image Files|*.tif;*.jpg;*.gif;*.png;*.bmp|Text Files (.txt)|*.txt"; attachmentEditor.Loaded += new RoutedEventHandler(AttachmentEditor_Loaded); StackPanel editorStack = new StackPanel() { Margin = new Thickness(4, 4, 4, 4), Orientation = Orientation.Vertical }; editorStack.Children.Add(dataEditorForm); editorStack.Children.Add(attachmentEditor); // Initialize a PopupWindow That Contains Data Editor Attachment Editor dataEditorWindow = new PopupWindow() { Background = this.Background, ShowArrow = false, IsResizable = false, IsFloatable = true }; //dataEditorWindow.TitleFormat = "Attributes Editor: {0}"; dataEditorWindow.Content = editorStack; } }
public void Execute(object parameter) { if (!string.IsNullOrWhiteSpace(StyleName) && AttachmentEditorStyle == null) { return; } FeatureLayer layer = GetFeatureLayer(parameter); if (layer == null) { return; } Graphic graphic = layer.SelectedGraphics != null?layer.SelectedGraphics.ElementAt(0) : null; if (graphic == null) { return; } if (_configuration == null) { _configuration = new AttachmentEditorConfiguration(); } if (_attachmentEditor == null) { _attachmentEditor = new AttachmentEditor(); _attachmentEditor.Width = _configuration.Width; _attachmentEditor.Height = _configuration.Height; _attachmentEditor.FilterIndex = _configuration.FilterIndex; _attachmentEditor.Filter = _configuration.Filter; _attachmentEditor.Multiselect = _configuration.MultiSelect; if (AttachmentEditorStyle != null) { _attachmentEditor.Style = AttachmentEditorStyle; } _window = new FloatingWindow(); _window.Content = _attachmentEditor; _window.Title = Resources.Strings.AttachmentEditorHeader; } _attachmentEditor.DataContext = _configuration; _attachmentEditor.GraphicSource = null; _attachmentEditor.FeatureLayer = null; if (graphic != null) { _attachmentEditor.FeatureLayer = layer; _attachmentEditor.GraphicSource = graphic; _window.Show(true); } }
public override void Execute(object parameter) { var popupInfo = parameter as OnClickPopupInfo; if (popupInfo != null) { AttachmentEditor ae = popupInfo.AttachmentContainer as AttachmentEditor; if (ae != null) { FrameworkElement root = VisualTreeHelper.GetChild(ae, 0) as FrameworkElement; if (root != null) { Button button = root.FindName("AddNewButton") as Button; if (button != null) { ButtonAutomationPeer buttonAutoPeer = new ButtonAutomationPeer(button); IInvokeProvider invokeProvider = buttonAutoPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; invokeProvider.Invoke(); } } } } }