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;
            }
        }
예제 #2
0
        internal static void ShowAttributeForm(FeatureLayer featureLayer, Graphic graphic)
        {
#if SILVERLIGHT
            ChildWindow window = new ChildWindow();
#else
            Window window = new Window();
            window.Owner = Application.Current.MainWindow;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.SizeToContent         = SizeToContent.WidthAndHeight;
            window.ResizeMode            = ResizeMode.NoResize;
#endif
            FeatureDataForm form = new FeatureDataForm()
            {
                GraphicSource = graphic,
                FeatureLayer  = featureLayer,
                IsReadOnly    = !featureLayer.IsUpdateAllowed(graphic),
                MaxWidth      = 500,
                MaxHeight     = 500
            };
            window.Content  = form;
            form.EditEnded += (s, e) => { window.Close(); };
#if SILVERLIGHT
            window.Show();
#else
            window.ShowDialog();
#endif
        }
        public override void Execute(object parameter)
        {
            if (!CanExecute(parameter)) return;

            var popupInfo = PopupInfo as OnClickPopupInfo;
            if (popupInfo == null) return;

            InfoWindow win = popupInfo.Container as InfoWindow;
            if (win != null)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        FeatureLayer featureLayer = popupInfo.PopupItem.Layer as FeatureLayer;
                        if (featureLayer == null) return;

                        FeatureDataForm form = new FeatureDataForm
                            {
                                Width = win.ActualWidth,
                                Height = win.ActualHeight,
                                Style = PopupFeatureDataFormStyleHelper.Instance.GetStyle("PopupFeatureDataFormStyle"),
								CommitButtonContent = Resources.Strings.Apply,
                                GraphicSource = popupInfo.PopupItem.Graphic,
                                FeatureLayer = featureLayer,
                                DataContext = popupInfo,
                            };

                        form.Loaded += (s, e) =>
                            {
                                // enable switching back to the original popup content when the 'Back' button is clicked
                                List<Button> buttons = ControlTreeHelper.FindChildrenOfType<Button>(form, int.MaxValue);
                                if (buttons != null && buttons.Count > 0)
                                {
                                    Button backButton = buttons.Where(b => b.Name == "BackButton").FirstOrDefault();
                                    if (backButton != null)
                                    {
                                        backButton.Content = Resources.Strings.EditValuesCommandEditorBackButtonContent;
                                        backButton.Click +=(ss, ee) => BackToOriginalContent(popupInfo);
                                    }
                                    Button closeButton = buttons.Where(b => b.Name == "CloseButton").FirstOrDefault();
                                    if (closeButton != null)
                                    {
                                        closeButton.Click +=(ss, ee) =>BackToOriginalContent(popupInfo);
                                    }
                                }
                                PopupHelper.SetDisplayMode(PopupHelper.DisplayMode.EditValues);
                            };
                        win.Content = null;
                        win.Content = form;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FeatureDataField&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="featureDataForm">The feature data form.</param>
        /// <param name="layerInfo">The feature layer info.</param>
        /// <param name="field">The field.</param>
        /// <param name="propertyType">Type of the property.</param>
        /// <param name="propertyValue">The property value.</param>
        internal FeatureDataField(FeatureDataForm featureDataForm, FeatureLayerInfo layerInfo, Field field, Type propertyType, T propertyValue)
        {
            this._featureDataForm  = featureDataForm;
            this._field            = field;
            this._layerInfo        = layerInfo;
            this._codedValueDomain = null;
            Domain domain = field.Domain;

            if (domain != null && !Toolkit.Utilities.FieldDomainUtils.IsDynamicDomain(_field, _layerInfo))
            {
                this._codedValueDomain = domain as CodedValueDomain;

                if (propertyType == typeof(DateTime) || propertyType == typeof(DateTime?))
                {
                    this._dateRangeDomain = domain as RangeDomain <DateTime>;
                }
                else if (propertyType == typeof(double) || propertyType == typeof(double?))
                {
                    this._doubleRangeDomain = domain as RangeDomain <double>;
                }
                else if (propertyType == typeof(float) || propertyType == typeof(float?))
                {
                    this._floatRangeDomain = domain as RangeDomain <float>;
                }
                else if (propertyType == typeof(int) || propertyType == typeof(int?))
                {
                    this._intRangeDomain = domain as RangeDomain <int>;
                }
                else if (propertyType == typeof(short) || propertyType == typeof(short?))
                {
                    this._shortRangeDomain = domain as RangeDomain <short>;
                }
                else if (propertyType == typeof(long) || propertyType == typeof(long?))
                {
                    this._longRangeDomain = domain as RangeDomain <long>;
                }
                else if (propertyType == typeof(byte) || propertyType == typeof(byte?))
                {
                    this._byteRangeDomain = domain as RangeDomain <byte>;
                }
            }
            this._propertyType  = propertyType;
            this._propertyValue = propertyValue;
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FeatureDataField&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="featureDataForm">The feature data form.</param>
        /// <param name="field">The field.</param>
        /// <param name="propertyType">Type of the property.</param>
        /// <param name="propertyValue">The property value.</param>
        internal FeatureDataField(FeatureDataForm featureDataForm, Field field, Type propertyType, T propertyValue)
        {
            this._featureDataForm  = featureDataForm;
            this._codedValueDomain = null;
            Domain domain = field.Domain;

            if (domain != null)
            {
                this._codedValueDomain = domain as CodedValueDomain;
                if (propertyType == typeof(DateTime) || propertyType == typeof(DateTime?))
                {
                    this._dateRangeDomain = domain as RangeDomain <DateTime>;
                }
                else if (propertyType == typeof(double) || propertyType == typeof(double?))
                {
                    this._doubleRangeDomain = domain as RangeDomain <double>;
                }
                else if (propertyType == typeof(float) || propertyType == typeof(float?))
                {
                    this._floatRangeDomain = domain as RangeDomain <float>;
                }
                else if (propertyType == typeof(int) || propertyType == typeof(int?))
                {
                    this._intRangeDomain = domain as RangeDomain <int>;
                }
                else if (propertyType == typeof(short) || propertyType == typeof(short?))
                {
                    this._shortRangeDomain = domain as RangeDomain <short>;
                }
                else if (propertyType == typeof(long) || propertyType == typeof(long?))
                {
                    this._longRangeDomain = domain as RangeDomain <long>;
                }
                else if (propertyType == typeof(byte) || propertyType == typeof(byte?))
                {
                    this._byteRangeDomain = domain as RangeDomain <byte>;
                }
            }

            this._field         = field;
            this._propertyType  = propertyType;
            this._propertyValue = propertyValue;
        }
		internal static void ShowAttributeForm(FeatureLayer featureLayer, Graphic graphic)
		{
#if SILVERLIGHT
			ChildWindow window = new ChildWindow();
#else
            Window window = new Window();
            window.Owner = Application.Current.MainWindow;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.SizeToContent = SizeToContent.WidthAndHeight;
            window.ResizeMode = ResizeMode.NoResize;
#endif
			FeatureDataForm form = new FeatureDataForm()
			{
				GraphicSource = graphic,
				FeatureLayer = featureLayer,
				IsReadOnly = featureLayer.IsReadOnly
			};
			window.Content = form;
			form.EditEnded += (s, e) => { window.Close(); };
#if SILVERLIGHT
			window.Show();
#else           
            window.ShowDialog();
#endif
		}
예제 #7
0
        public override void Execute(object parameter)
        {
            if (!CanExecute(parameter))
            {
                return;
            }

            var popupInfo = PopupInfo as OnClickPopupInfo;

            if (popupInfo == null)
            {
                return;
            }

            InfoWindow win = popupInfo.Container as InfoWindow;

            if (win != null)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        FeatureLayer featureLayer = popupInfo.PopupItem.Layer as FeatureLayer;
                        if (featureLayer == null)
                        {
                            return;
                        }

                        FeatureDataForm form = new FeatureDataForm
                        {
                            Width  = win.ActualWidth,
                            Height = win.ActualHeight,
                            Style  = PopupFeatureDataFormStyleHelper.Instance.GetStyle("PopupFeatureDataFormStyle"),
                            CommitButtonContent = Resources.Strings.Apply,
                            GraphicSource       = popupInfo.PopupItem.Graphic,
                            FeatureLayer        = featureLayer,
                            DataContext         = popupInfo,
                        };

                        form.Loaded += (s, e) =>
                        {
                            // enable switching back to the original popup content when the 'Back' button is clicked
                            List <Button> buttons = ControlTreeHelper.FindChildrenOfType <Button>(form, int.MaxValue);
                            if (buttons != null && buttons.Count > 0)
                            {
                                Button backButton = buttons.Where(b => b.Name == "BackButton").FirstOrDefault();
                                if (backButton != null)
                                {
                                    backButton.Content = Resources.Strings.EditValuesCommandEditorBackButtonContent;
                                    backButton.Click  += (ss, ee) => BackToOriginalContent(popupInfo);
                                }
                                Button closeButton = buttons.Where(b => b.Name == "CloseButton").FirstOrDefault();
                                if (closeButton != null)
                                {
                                    closeButton.Click += (ss, ee) => BackToOriginalContent(popupInfo);
                                }
                            }
                            PopupHelper.SetDisplayMode(PopupHelper.DisplayMode.EditValues);
                        };
                        win.Content = null;
                        win.Content = form;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });
            }
        }