Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Commit

Permalink
fixed issue #8, #13, and #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Haoliang Yu committed Apr 19, 2015
1 parent 14f28d7 commit eb5037a
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 46 deletions.
Binary file modified ARES.suo
Binary file not shown.
11 changes: 6 additions & 5 deletions ARES/ArcMapApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ public static IRasterLayer GetRasterLayer(int index = 0)
for (int i = 0; i < ArcMap.Document.FocusMap.LayerCount; i++)
{
ILayer layer = ArcMap.Document.FocusMap.get_Layer(i);
if ((layer is IRasterLayer) && (layerCount == index))
{
return (IRasterLayer)layer;
}
else
if (layer is IRasterLayer)
{
if(layerCount == index)
{
return (IRasterLayer)layer;
}

layerCount++;
}
}
Expand Down
Binary file modified ARES/Config.Designer.cs
Binary file not shown.
2 changes: 1 addition & 1 deletion ARES/Config.esriaddinx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Image>Images\ARES.png</Image>
<Author>Haoliang Yu, Xuan Wang, Jian Qing, Hancheng Nie</Author>
<Company>Haoliang Yu, Xuan Wang, Jian Qing, Hancheng Nie</Company>
<Date>2015-3-7</Date>
<Date>2015-4-19</Date>
<Targets>
<Target name="Desktop" version="10.0" />
</Targets>
Expand Down
91 changes: 54 additions & 37 deletions ARES/Painter/ValueSymbolForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,27 @@ private bool ValueValidate(string value, out object validValue)
return Raster.CSharpValue2PixelValue(value, rasterProp.PixelType, out validValue);
}

/// <summary>
/// Add new value to the value symbol list.
/// </summary>
/// <param name="valueStr"></param>
private void AddNewValueSymbol(string valueStr)
{
ListViewItem layerItem = new ListViewItem();

layerItem.Text = valueStr;
layerItem.SubItems.Add(" ");

layerItem.SubItems[1].BackColor = Color.FromArgb(randomRGB.Next(0, 255),
randomRGB.Next(0, 255),
randomRGB.Next(0, 255));

layerItem.UseItemStyleForSubItems = false;
valueListBox.Items.Add(layerItem);

listedValue.Add(valueStr);
}

#endregion

#region Events
Expand All @@ -155,47 +176,48 @@ private void addValueButton_Click(object sender, EventArgs e)
return;
}

// Get value list
IDataset rasterDataset = (IDataset)Painter.ActiveLayer;
ITable table = (ITable)rasterDataset;
List<string> unlistedValues = new List<string>();
for (int x = 0; x < table.RowCount(null); x++)
if (Raster.IsCategorical(Painter.ActiveLayer))
{
string value = table.GetRow(x).get_Value(1).ToString();
if(!listedValue.Contains(value))
// If this data is a categorical data, we are able to get access
// to its attribute table and get the value list.

IDataset rasterDataset = (IDataset)Painter.ActiveLayer;
ITable table = (ITable)rasterDataset;
List<string> unlistedValues = new List<string>();
for (int x = 0; x < table.RowCount(null); x++)
{
unlistedValues.Add(value);
string value = table.GetRow(x).get_Value(1).ToString();
if (!listedValue.Contains(value))
{
unlistedValues.Add(value);
}
}
}

SelectValueForm selectValueForm = new SelectValueForm();
selectValueForm.InitializeValues(unlistedValues.ToArray());
selectValueForm.ValueName = "Value";
selectValueForm.NewValue = false;
selectValueForm.MultiSelect = true;
selectValueForm.Text = "Add Values";
SelectValueForm selectValueForm = new SelectValueForm();
selectValueForm.InitializeValues(unlistedValues.ToArray());
selectValueForm.ValueName = "Value";
selectValueForm.NewValue = false;
selectValueForm.MultiSelect = true;
selectValueForm.Text = "Add Values";

if (selectValueForm.ShowDialog() == DialogResult.OK)
{
string[] selectedValues = selectValueForm.SelectedValues;

foreach (string value in selectedValues)
if (selectValueForm.ShowDialog() == DialogResult.OK)
{
ListViewItem layerItem = new ListViewItem();

layerItem.Text = value;
layerItem.SubItems.Add(" ");

layerItem.SubItems[1].BackColor = Color.FromArgb(randomRGB.Next(0, 255),
randomRGB.Next(0, 255),
randomRGB.Next(0, 255));
string[] selectedValues = selectValueForm.SelectedValues;

layerItem.UseItemStyleForSubItems = false;
valueListBox.Items.Add(layerItem);

listedValue.Add(value);
foreach (string value in selectedValues)
{
AddNewValueSymbol(value);
}
}
}
else
{
// If it is a data with continuous data type, we are not able to
// get a value list. We can only add new data without using a
// value list.

addNewValueToolStripMenuItem.PerformClick();
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -265,11 +287,6 @@ private void ValueListBox_SelectedIndexChanged(object sender, EventArgs e)
}
}

private void valueListBox_MouseDown(object sender, MouseEventArgs e)
{

}

private void changeColorToolStripMenuItem_Click_1(object sender, EventArgs e)
{
if (colorDialog.ShowDialog() == DialogResult.OK)
Expand Down
3 changes: 1 addition & 2 deletions ARES/Painter/ValueSymbolForm.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion ARES/Raster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public static double GetValue(Position pos, IRaster raster)

double[,] values = new double[colCount, rowCount];
for (int x = 0; x < colCount; x++)
{
{
for (int y = 0; y < rowCount; y++)
{
values[x, y] = Convert.ToDouble(pixelBlock.GetVal(0, x, y));
Expand All @@ -215,6 +215,17 @@ public static double GetValue(Position pos, IRaster raster)
return values;
}

/// <summary>
/// Indicates whether the input raster data is a categorical data.
/// </summary>
/// <param name="rasterLayer"></param>
/// <returns></returns>
public static bool IsCategorical(IRasterLayer rasterLayer)
{
IRasterProps rasterProps = (IRasterProps)rasterLayer.Raster;
return !((rasterProps.PixelType == rstPixelType.PT_FLOAT) || (rasterProps.PixelType == rstPixelType.PT_DOUBLE));
}

/// <summary>
/// Convert the csharp value to the ArcObject pixel value.
/// </summary>
Expand Down
Binary file modified ARES/bin/Debug/ARES.dll
Binary file not shown.
Binary file modified ARES/bin/Debug/ARES.esriAddIn
Binary file not shown.
Binary file modified ARES/bin/Debug/ARES.pdb
Binary file not shown.
Binary file modified ARES/obj/Debug/ARES.dll
Binary file not shown.
Binary file modified ARES/obj/Debug/ARES.pdb
Binary file not shown.
Binary file modified ARES/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Binary file not shown.

0 comments on commit eb5037a

Please sign in to comment.