コード例 #1
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);
        }
コード例 #2
0
 void vm_Closed(object sender, System.EventArgs e)
 {
     BuilderApplication.Instance.HideWindow(configureControlsControl);
     configureControlsControl = null;
 }