POST
|
This code works for me 9.3.1 sp1 vista64 using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.Carto;
using System.Diagnostics;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ArcMapUI;
namespace Forums
{
public class AddLayerExtCmd : BaseCommand
{
IApplication m_app;
public AddLayerExtCmd()
{
m_caption = "Add LayerExtension";
}
public override void OnClick()
{
MyLayerExtension.AddExtensions(((IMxDocument)m_app.Document).FocusMap);
}
public override void OnCreate(object hook)
{
m_app = (IApplication)hook;
}
}
public class MyLayerExtension: ILayerExtensionDraw
{
public static void AddExtensions(IMap map)
{
if (map.LayerCount == 0)
throw new Exception("no layers in map");
IEnumLayer enumLayer = map.get_Layers(null, true);
ILayer layer;
while ((layer = enumLayer.Next()) != null)
{
ILayerExtensions exts = layer as ILayerExtensions;
if (exts == null)
continue;
for (int i = exts.ExtensionCount - 1; i > -1; i--)
{
if (exts.get_Extension(i) is MyLayerExtension)
{
Debug.Print("removing old extension from {0}", layer.Name);
exts.RemoveExtension(i);
}
}
exts.AddExtension(new MyLayerExtension());
}
}
#region ILayerExtensionDraw Members
public void AfterLayerDraw(ILayer pLayer, esriDrawPhase DrawPhase,
IDisplay pDisplay, ITrackCancel pTrackCancel)
{
Debug.Print("Afterlayerdraw {0} {1}", pLayer.Name, DrawPhase);
}
public void BeforeLayerDraw(ILayer pLayer, esriDrawPhase DrawPhase,
IDisplay pDisplay, ITrackCancel pTrackCancel)
{
Debug.Print("Beforelayerdraw {0} {1}", pLayer.Name, DrawPhase);
}
#endregion
}
}
... View more
04-15-2010
07:15 AM
|
0
|
0
|
510
|
POST
|
Are you sure you've added your layer extension to a layer via ILayerExtensions.AddExtension?
... View more
04-15-2010
06:08 AM
|
0
|
0
|
510
|
POST
|
Perhaps use the RecordSet class. It implements IXmlSerialize, but I've never tried it. Create a new empty recordset, then use IRecordSetInit.Insert to insert features.
... View more
04-15-2010
06:04 AM
|
0
|
0
|
496
|
POST
|
I would add an arcmap (or editor) extension (IExtension) and have all toolcontrols set a reference to the extension when OnCreate is called. Each toolcontrol would change a property exposed by the extension. If a toolcontrol needs to know when a property has changed, then it will need to subscribe to an event on the extension, and you'll need to raise an event when the setter of the property is called.
... View more
04-15-2010
05:57 AM
|
0
|
0
|
221
|
POST
|
Using IDisplayTable for any featurelayer (regardless of whether it was created as a selection layer) should return the rows that you see when you display the layer attribute window in arcmap.
... View more
04-09-2010
12:28 PM
|
0
|
0
|
475
|
POST
|
If you implement ILayerExtensionDraw, the parent layer gets passed as an arg, in either of the two methods. I found it unstable to keep a (strong) reference member varialbe to the parent layer, maybe some sort of weak reference strategy could be used though - I've never tried.
... View more
04-09-2010
12:19 PM
|
0
|
0
|
510
|
POST
|
How are you populating your attribute window? You should cast the featurelayer to an IDisplayTable, then load rows into your datagrid (or whatever) by looping through rows returned by the ICursor returned from IDisplayTable.SearchDisplayTable.
... View more
04-09-2010
06:30 AM
|
0
|
0
|
475
|
POST
|
When I run the code above with a path to the data in the attached file gdb, and open the attribute window, I only see one row. Right clicking on the layer and choosing zoom to extent will zoom to whatever features are present in the layer (created using code posted previously). However, I see that IGeoDataset.Extent for the layer is still the full extent of the layer, so I guess zoom to layer uses some other method. I wouldn't think it would loop through each feature to build an envelope, but I don't see what else it would use. Setting ILayer2.AreaOfInterest doesn't change the behavior of zoom to extent. 9.3.1 sp 1 Vista64
... View more
04-08-2010
11:23 AM
|
0
|
0
|
475
|
POST
|
Here's a command that toggles the extension: #region Overriden Class Methods
/// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
m_application = hook as IApplication;
}
/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
JITExtension1.SetEnabled(m_application, !JITExtension1.GetEnabled());
}
public override bool Checked
{
get
{
return JITExtension1.GetEnabled();
}
}
#endregion Here's the extension: using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ADF.CATIDs;
namespace Forums
{
[Guid("7c6aee7a-5e63-497d-a897-551ab8f6f761")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Forums.JITExtension1")]
public class JITExtension1 : IExtension
{
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType);
//
// TODO: Add any COM registration code here
//
}
[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType);
//
// TODO: Add any COM unregistration code here
//
}
#region ArcGIS Component Category Registrar generated code
/// <summary>
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryRegistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxExtensionJIT.Register(regKey);
}
/// <summary>
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryUnregistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxExtensionJIT.Unregister(regKey);
}
#endregion
#endregion
private IApplication m_application;
private bool m_Enabled;
private static JITExtension1 m_instance;
public bool Enabled
{
get { return m_Enabled; }
set { m_Enabled = value; }
}
public static bool GetEnabled()
{
if(m_instance == null)
return false;
else
return m_instance.Enabled;
}
public static void SetEnabled(IApplication app, bool enabled)
{
if (m_instance == null)
{
UID uid = new UIDClass();
uid.Value = "{7c6aee7a-5e63-497d-a897-551ab8f6f761}";
// this will cause instantiation (and Startup will get called)
JITExtension1 ext = app.FindExtensionByCLSID(uid) as JITExtension1;
ext.Enabled = enabled;
}
else
m_instance.Enabled = enabled;
}
#region IExtension Members
/// <summary>
/// Name of extension. Do not exceed 31 characters
/// </summary>
public string Name
{
get
{
//TODO: Modify string to uniquely identify extension
return "JITExtension1";
}
}
public void Shutdown()
{
//TODO: Clean up resources
m_application = null;
m_instance = null;
}
public void Startup(ref object initializationData)
{
m_instance = this;
m_application = initializationData as IApplication;
}
#endregion
}
}
... View more
04-08-2010
11:00 AM
|
0
|
0
|
675
|
POST
|
Have you tried this? Public Sub New(ByVal hookHelper As IHookHelper)
InitializeComponent()
m_hookHelper = hookHelper
m_pApp = m_hookHelper.hook
End Sub
... View more
04-08-2010
09:34 AM
|
1
|
0
|
289
|
POST
|
Just implement IExtension like you normally would, but instead of implementing IExtensionConfig - which would make it show up in the Extensions window - write a static method called Enabled. It would follow the singleton pattern, with a static member variable reference to to m_MyExtension. If the m_MyExtension == null, Enabled would return false, otherwise it would use another boolean member variable m_Enabled. You'll need to write a command to toggle it for you, since it won't appear in the Extensions window.
... View more
04-08-2010
09:28 AM
|
0
|
0
|
675
|
POST
|
If you don't implement IExtensionConfig, then I don't think it will show up in the Extension Manager window. Any tools/commands etc. that need to see if the extension is toggled on, should first check to see if it is loaded using IJITExtensionManager.IsLoaded, if it is not loaded I guess that means it isn't "on" - otherwise access access an Enabled method. This could be done as a static method on your extension.
... View more
04-08-2010
08:41 AM
|
0
|
0
|
675
|
POST
|
Are they exact intersections? If not you'll need to buffer them into polygons first. Otherwise, maybe try using a multipoint instead of a geometrybag. You probably should explicitly set the spatialreference of the multipoint to that of the points you are adding to it. Performance might be improved using ISpatialIndex.Invalidate on the multipoint before assigning it to the spatialfilter.
... View more
04-08-2010
08:34 AM
|
0
|
0
|
319
|
POST
|
IFeatureClassWrite.WriteFeature. You might also consider using a cursor and set IFeatureClassLoad.LoadOnlyMode
... View more
04-08-2010
07:03 AM
|
0
|
0
|
207
|
POST
|
Update: The SupportsMovingEditsToBase just tells you if it can be registered with the option to move edits to base - not if in fact it is registered with that option. To determine that use the bool returned by IVersionedObject3.GetVersionRegistrationInfo .
... View more
04-08-2010
05:54 AM
|
0
|
0
|
562
|
Title | Kudos | Posted |
---|---|---|
1 | 02-17-2015 10:41 AM | |
2 | 11-15-2012 05:22 AM | |
4 | 09-29-2011 08:20 AM | |
3 | 12-04-2015 08:50 AM | |
1 | 04-08-2010 09:34 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:22 AM
|