Пример #1
0
        /// <summary>
        /// IsConfigurableProperty property changed handler.
        /// </summary>
        /// <param name="d">MapApplication that changed its IsConfigurable.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnIsConfigurablePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FrameworkElement elem = d as FrameworkElement;

            if (elem != null && MapApplication.Current != null && (bool)e.NewValue)
            {
                IApplicationAdmin appAdmin = MapApplication.Current as IApplicationAdmin;
                if (appAdmin != null && appAdmin.ConfigurableControls != null)
                {
                    appAdmin.ConfigurableControls.Add(elem);
                }
            }
        }
Пример #2
0
        public override void Execute(object parameter)
        {
            // Create UI control
            configureControlsControl = new ConfigureControlsControl();

            // Create view model that interacts with UI and associate it as the data context so all elements
            // of the UI can use XAML binding to utilize the view model.
            ConfigureControlsViewModel vm = new ConfigureControlsViewModel();

            IApplicationAdmin appAdmin = MapApplication.Current as IApplicationAdmin;

            if (appAdmin != null && appAdmin.ConfigurableControls != null)
            {
                // Process each element in the configurable controls collection, looking for those that support configuration
                foreach (FrameworkElement elem in appAdmin.ConfigurableControls)
                {
                    if (string.IsNullOrWhiteSpace(elem.Name))
                    {
                        continue;
                    }

                    ISupportsConfiguration supportsConfig = elem as ISupportsConfiguration;
                    if (supportsConfig != null)
                    {
                        string displayName            = ElementExtensions.GetDisplayName(elem);
                        ConfigureControlDataItem ccdi = new ConfigureControlDataItem()
                        {
                            Label   = displayName ?? elem.Name.InsertSpaces(),
                            Element = elem
                        };

                        // Add this element to the list within the view model
                        vm.ConfigurableItems.Add(ccdi);
                    }
                }
            }

            // Associate close command with method that will hide the UI
            vm.Closed += new System.EventHandler(vm_Closed);

            // Assign view model as data context for UI
            configureControlsControl.DataContext = vm;

            // Display UI
            BuilderApplication.Instance.ShowWindow(ESRI.ArcGIS.Mapping.Builder.Resources.Strings.ConfigureControls,
                                                   configureControlsControl, true);
        }