POST
|
I have solved the problem by adding the following code in advance: ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop);
... View more
01-20-2014
10:03 AM
|
0
|
0
|
174
|
POST
|
Hi, here is the code to get an addin button in C#
// Enable the save button
SaveEditingButton saveButton = AddIn.FromID<SaveEditingButton>(ThisAddIn.IDs.RasterEditor_EditorMenu_Edition_SaveEditingButton);
saveButton.IsEnabled = true;
IDs of addin controls are defined at Config.esriaddinx in your solution folder. I think it can solve your problem. Haoliang
... View more
01-15-2014
06:05 PM
|
0
|
0
|
357
|
POST
|
Hi, I am writing a raster editor toolbar for interactive raster edition. It is almost done but I meet an error when I try to save the modification to file finally. My method is to copy the loaded raster and write the modification to the new file. Here is my code:
// Code to get the new raster
IRasterWorkspace newRasterWorkspace = (IRasterWorkspace)newWorkspace;
IRasterDataset newRasterDataset = newRasterWorkspace.OpenRasterDataset(System.IO.Path.GetFileNameWithoutExtension(saveFileDialog.FileName));
IRasterBandCollection newRasterBandCollection = (IRasterBandCollection)newRasterDataset;
IRasterBand newRasterBand = newRasterBandCollection.Item(0);
IRasterDataset2 newRasterDataset2 = (IRasterDataset2)newRasterBand.RasterDataset;
IRaster newRaster = newRasterDataset2.CreateFullRaster();
IRasterProps newRasterProp = (IRasterProps)newRaster;
// I omit some code to get the extent of modified region
IPnt pos = new PntClass();
pos.SetCoords(maxCol - minCol + 1, maxRow - minRow + 1);
IPixelBlock pixelBlock = newRaster.CreatePixelBlock(pos);
pos.SetCoords(minCol, minRow);
newRaster.Read(pos, pixelBlock);
// Set new values
IPixelBlock3 pixelBlock3 = (IPixelBlock3)pixelBlock;
Array pixels = (Array)pixelBlock3.get_PixelData(0);
for (int i = 0; i < Editor.EditRecord.Count; i++)
{
pixels.SetValue(Convert.ToByte(Editor.EditRecord.NewValue),
Editor.EditRecord.Position.Column - minCol,
Editor.EditRecord.Position.Row - minRow);
}
pixelBlock3.set_PixelData(0, (System.Object)pixels);
IRasterEdit newRasterEdit = (IRasterEdit)newRaster;
// Here comes the error:
newRasterEdit.Write(pos, (IPixelBlock)pixelBlock3);
I get the error information: Exception from HRESULT: 0x80041029. I do not find any information about the error code at ESRI help. The code looks very correct and I have no idea of the error. btw, is there a way to directly save modification to the raster loaded at ArcMap? Haoliang
... View more
01-15-2014
05:58 PM
|
0
|
1
|
721
|
POST
|
Hi, Jörg I use the follow C# code to get other addin buttons in my toolbar:
using ESRI.ArcGIS.Desktop.AddIns;
// Enable the save button
SaveEditingButton saveButton = ddIn.FromID<SaveEditingButton>(ThisAddIn.IDs.RasterEditor_EditorMenu_Edition_SaveEditingButton);
saveButton.IsEnabled = true;
IDs of addins are deifned at the Config.esriaddinx file of your solution folder. I am not sure whether it works for extension too but I think it should be similar. I hope it helps. Joe
... View more
01-15-2014
05:34 PM
|
0
|
0
|
312
|
POST
|
It is my mistake. The cookie that the ComboBox.Add() returns does not start from 0. It is not a normal index.
... View more
12-23-2013
09:35 AM
|
0
|
0
|
165
|
POST
|
Hello, I am using C# to develop an Arcmap addin. I wonder whether there is a bug at the function ComboBox.GetItem(). I tried to run the following code when the combobox was initialized: (an item is already added) MessageBox.Show(this.GetItem(0).Caption) but it failed to popup a messagebox. So I used this.items(0).Caption instead and it worked. So I guess there is difference between ComboBox.GetItem(index) and ComboBox.items[index]. Or there may be a bug. btw, is there a way that the add-in can get access to events of controls at ArcMap? For example, directly response to the layer addition or deletion.
... View more
12-22-2013
09:02 PM
|
0
|
1
|
702
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|