コード例 #1
0
        /// <summary>
        /// Subscribes to the Selected item changed event. ItemInfo of the selected item is instantiated.
        /// </summary>
        /// <param name="obj"></param>
        private async void OnSelectedItemChanged(ProjectWindowSelectedItemsChangedEventArgs obj)
        {
            //The viewmodel
            MetadataViewerViewModel vm = FrameworkApplication.DockPaneManager.Find("MetadataViewer_MetadataViewer") as MetadataViewerViewModel;

            if (vm != null)
            {
                //ItemInfo info = new ItemInfo(null, "");
                var item = Project.Current.SelectedItems?.FirstOrDefault();
                if (item != null)
                {
                    var xml = await ItemInfo.GetXML(item);

                    if (!string.IsNullOrEmpty(xml)) //Item has xml
                    {
                        vm.ItemInformation = new ItemInfo(item, xml);
                        vm.DockpaneVisible = System.Windows.Visibility.Visible;
                    }

                    else
                    {
                        vm.DockpaneVisible = System.Windows.Visibility.Collapsed;
                    }
                }
                else
                {
                    vm.DockpaneVisible = System.Windows.Visibility.Collapsed;
                }
            }
        }
コード例 #2
0
        private void OnAppStartupReady(EventArgs obj)
        {
            //The viewmodel
            MetadataViewerViewModel vm = FrameworkApplication.DockPaneManager.Find("MetadataViewer_MetadataViewer") as MetadataViewerViewModel;
            //get the selected item
            var item = Project.Current?.SelectedItems?.FirstOrDefault();

            if (item != null && item.GetXml() != null)                  //Item selected and it has metadata
            {
                vm.DockpaneVisible = System.Windows.Visibility.Visible; //Visibility is set
            }
            else //No item selected
            {
                vm.DockpaneVisible = System.Windows.Visibility.Collapsed; //Visibility hidden
            }
        }
コード例 #3
0
        /// <summary>
        /// Saves the edited xml
        /// </summary>
        private async void SaveXML()
        {
            MetadataViewerViewModel vm = FrameworkApplication.DockPaneManager.Find("MetadataViewer_MetadataViewer") as MetadataViewerViewModel;

            if (vm != null)
            {
                var  selectedItem = vm.ItemInformation?.ProPrjItem; //get the selected project item
                var  xml          = this.AvalonXML.Text;
                bool IsXMLValid   = IsValidated();

                if (!IsXMLValid)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Metadata XML not valid. See the Validation section for more info.");
                }
                await QueuedTask.Run(() =>
                {
                    if (selectedItem.CanEdit() && IsXMLValid) //check if metadata is editable
                    {
                        selectedItem?.SetXml(xml);
                    }
                });
            }
        }
 protected override void OnClick()
 {
     MetadataViewerViewModel.Show();
 }