Пример #1
0
 /// <summary>
 /// Searches ILayer's layerextensions for any PropertySets that contain name/value combo
 /// and this method uses a default string comparison value of CurrentCultureIgnoreCase
 /// </summary>
 /// <param name="layer">The ILayer</param>
 /// <param name="propertysetname">The propertyset name.</param>
 /// <param name="propertysetvalue">The propertyset value.</param>
 /// <returns>List of IPropertySet</returns>
 public static List <IPropertySet> FindExtensionPropertySet(this ILayer layer, string propertysetname, string propertysetvalue)
 {
     return(layer.FindExtensionPropertySet(propertysetname, propertysetvalue, StringComparison.CurrentCultureIgnoreCase));
 }
Пример #2
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper != null)
            {
                try
                {
                    IApplication appArcMap = (IApplication)m_hookHelper.Hook;
                    IMxDocument  doc       = (IMxDocument)appArcMap.Document;

                    if (doc.SelectedLayer != null)
                    {
                        ILayer       layer       = doc.SelectedLayer;
                        IPropertySet propertySet = null;

                        bool newPropertySet = false;

                        ILayerExtensions layerExtensions = (ILayerExtensions)layer;

                        Trace.WriteLine(layerExtensions.ExtensionCount.ToString());

                        List <IPropertySet> psets = layer.FindExtensionPropertySet("layerextension", "umbriel");



                        if (!LayerExtHelper.UmbrielPropertySetExists(layerExtensions))
                        {
                            propertySet    = LayerExtHelper.CreateUmbrielPropertySet();
                            newPropertySet = true;
                        }
                        else
                        {
                            propertySet = LayerExtHelper.GetUmbrielPropertySet(layerExtensions);
                        }

                        if (propertySet != null)
                        {
                            if (this.propertySetForm == null)
                            {
                                this.propertySetForm = new CustomLayerPropertiesForm(propertySet);
                            }

                            DialogResult res = this.propertySetForm.ShowDialog();

                            if (res == DialogResult.OK)
                            {
                                if (this.propertySetForm.PropertySet != null)
                                {
                                    LayerExtHelper.RemovePropertySet(layerExtensions);
                                    layerExtensions.AddExtension(this.propertySetForm.PropertySet);
                                }
                            }

                            this.propertySetForm.Dispose();
                            this.propertySetForm = null;
                        }
                    }
                    else
                    {
                        MessageBox.Show("No layer highlighted in the table of contents.", "Ooops.", MessageBoxButtons.OK);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "Umbriel Custom Layer Properties Error", System.Windows.Forms.MessageBoxButtons.OK);
                }
            }
            else if (m_sceneHookHelper != null)
            {
                throw new NotImplementedException();
            }
            else if (m_globeHookHelper != null)
            {
                throw new NotImplementedException();
            }
        }