Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapApplicationBindingSource"/> object
        /// </summary>
        public MapApplicationBindingSource()
        {
            if (!DesignerProperties.IsInDesignTool && MapApplication.Current != null)
            {
                // try-catch is required for when MapApplicationBindingSource is used in applications that don't
                // fully implement IMapApplication, such as Builder.
                try
                {
                    Binding b = new Binding("SelectedLayer")
                    {
                        Source = MapApplication.Current
                    };
                    BindingOperations.SetBinding(this, SelectedLayerProperty, b);

                    b = new Binding("Map")
                    {
                        Source = MapApplication.Current
                    };
                    BindingOperations.SetBinding(this, MapProperty, b);

                    b = new Binding("Urls")
                    {
                        Source = MapApplication.Current
                    };
                    BindingOperations.SetBinding(this, UrlsProperty, b);

                    b = XamlReader.Load(
                        @"<Binding xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                               xmlns:esri=""http://schemas.esri.com/arcgis/client/extensibility/2010""        
                               Path=""SelectedLayer.(esri:MapApplication.LayerName)"" />") as Binding;
                    b.Source = MapApplication.Current;
                    BindingOperations.SetBinding(this, SelectedLayerNameProperty, b);

                    b = new Binding("Portal")
                    {
                        Source = MapApplication.Current
                    };
                    BindingOperations.SetBinding(this, PortalProperty, b);

                    MapApplication.Current.SelectedLayerChanged += OnSelectedLayerChanged;
                    MapApplication.Current.Initialized          += OnInitialized;
                    MapApplication.Current.InitializationFailed += OnInitializationFailed;
                }
                catch
                {
                }
            }
            else
            {
                SelectedLayer     = createDesignTimeLayer();
                SelectedLayerName = MapApplication.GetLayerName(SelectedLayer);
                Map = new Map();
                Map.Layers.Add(SelectedLayer);
            }
        }
 public void ShowWindow(MapApplication mapApplication, string windowTitle, FrameworkElement windowContents, bool isModal = false, EventHandler<CancelEventArgs> onHidingHandler = null, EventHandler onHideHandler = null)
 {
     if (! windowsBeingShown.Contains(windowContents))
     {
         mapApplication.ShowWindow(windowTitle, windowContents, isModal, onHidingHandler, (sender, args) =>
         {
             if (onHideHandler != null)
                 onHideHandler(sender, args);
             windowsBeingShown.Remove(windowContents); 
         });
         windowsBeingShown.Add(windowContents);
     }
 }
Exemple #3
0
        private GraphicsLayer createDesignTimeLayer()
        {
            GraphicsLayer designTimeLayer = new GraphicsLayer()
            {
                ID = "SampleDataLayer"
            };

            for (int i = 0; i < 20; i++)
            {
                addSampleGraphic(designTimeLayer);
            }
            MapApplication.SetLayerName(designTimeLayer, "Sample Layer");
            return(designTimeLayer);
        }
        public static void SetApplication(IMapApplication applicationHost)
        {
            if (_applicationContext == null)
            {
                lock (lockObject)
                {
                    if (_applicationContext == null)
                    {
                        _applicationContext = new MapApplication();
                    }
                }
            }

            _appHost = applicationHost;

            FrameworkElement appHostElement = applicationHost as FrameworkElement;

            if (appHostElement != null)
            {
                registerForNotification("SelectedLayer", appHostElement, SelectedLayerPropertyChanged);
            }
        }
        public static void SetApplication(IMapApplication applicationHost)
        {
            if (_applicationContext == null)
            {
                lock (lockObject)
                {
                    if (_applicationContext == null)
                    {
                        _applicationContext = new MapApplication();
                    }
                }
            }

            _appHost = applicationHost;

            FrameworkElement appHostElement = applicationHost as FrameworkElement;
            if (appHostElement != null)
                registerForNotification("SelectedLayer", appHostElement, SelectedLayerPropertyChanged);
        }