I've built an add-in with several buttons which initiate an editing session to perform their actions. I would like to push the operation to ArcMap's operation stack so the undo/redo buttons are enabled, but I can't figure out how.
Here is a snippet of the action of one button. This one reduces the font size of all selected features. Is it possible to add this operation to the stack after it is used?
IFeatureLayer currLayer <SPAN class="operator token">=</SPAN> currMap<SPAN class="punctuation token">.</SPAN>Layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">as</SPAN> IFeatureLayer<SPAN class="punctuation token">;</SPAN>
ISelectionSet ss <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>IFeatureSelection<SPAN class="punctuation token">)</SPAN>currLayer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>SelectionSet<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN><SPAN class="punctuation token">(</SPAN>ss<SPAN class="punctuation token">.</SPAN>Count <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN> <SPAN class="operator token">&&</SPAN> currLayer<SPAN class="punctuation token">.</SPAN>FeatureClass<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindField</SPAN><SPAN class="punctuation token">(</SPAN>attributeName<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
IWorkspaceEdit wse <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>IDataset<SPAN class="punctuation token">)</SPAN>currLayer<SPAN class="punctuation token">.</SPAN>FeatureClass<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>Workspace <SPAN class="keyword token">as</SPAN> IWorkspaceEdit<SPAN class="punctuation token">;</SPAN>
wse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartEditing</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
wse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartEditOperation</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//Update all annotations in the selection set</SPAN>
IFeature currFeature<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">int</SPAN> attributeIndex<SPAN class="punctuation token">;</SPAN>
IEnumIDs ids <SPAN class="operator token">=</SPAN> ss<SPAN class="punctuation token">.</SPAN>IDs<SPAN class="punctuation token">;</SPAN>
ids<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Reset</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">int</SPAN> id <SPAN class="operator token">=</SPAN> ids<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Next</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">while</SPAN><SPAN class="punctuation token">(</SPAN>id <SPAN class="operator token">></SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
currFeature <SPAN class="operator token">=</SPAN> currLayer<SPAN class="punctuation token">.</SPAN>FeatureClass<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetFeature</SPAN><SPAN class="punctuation token">(</SPAN>id<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
attributeIndex <SPAN class="operator token">=</SPAN> currFeature<SPAN class="punctuation token">.</SPAN>Class<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindField</SPAN><SPAN class="punctuation token">(</SPAN>attributeName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
currFeature<SPAN class="punctuation token">.</SPAN>Value<SPAN class="punctuation token">[</SPAN>attributeIndex<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> currFeature<SPAN class="punctuation token">.</SPAN>Value<SPAN class="punctuation token">[</SPAN>attributeIndex<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">-</SPAN> <SPAN class="number token">0.5</SPAN><SPAN class="punctuation token">;</SPAN>
currFeature<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Store</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
id <SPAN class="operator token">=</SPAN> ids<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Next</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
mxd<SPAN class="punctuation token">.</SPAN>ActiveView<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Refresh</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
wse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StopEditOperation</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
wse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StopEditing</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>