年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

490 lines
22 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using KGIS.Plugin.LayerProperty.Interface;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;
using KGIS.Plugin.LayerProperty.Utils;
using ESRI.ArcGIS.esriSystem;
using KGIS.Plugin.LayerProperty.Enum;
using ESRI.ArcGIS.ADF;
namespace KGIS.Plugin.LayerProperty.View.UC_Controls
{
public partial class UCAnnotationSymbologyPropertyPage : XtraUserControl, IUCPropertyPageEx, IPropertyPage
{
private class SubstitutionSymbol
{
public int Index;
public string SubstituteState = string.Empty;
public string SymbolName = string.Empty;
public ISymbol Symbol;
public bool BeSubstituted;
}
private IFDOGraphicsLayer m_FDOGraphicsLayer;
private IAnnotationLayer m_AnnotationLayer;
private ISymbolSubstitution m_SymbolSubstitution;
private Dictionary<int, UCAnnotationSymbologyPropertyPage.SubstitutionSymbol> m_SubstitutionSymbolColl;
private esriSymbolSubstituteType m_SymbolSubstituteType;
private IColor m_MassColor;
private IColor m_InlineColor;
private bool m_DrawUnplacedAnnotation;
private bool m_UseUnplacedAnnotationColor;
private bool m_UseInlineColor;
private IColor m_UnplacedAnnotationColor;
private bool isDirty;
public event System.EventHandler EditorChanged;
public bool IsPageDirty
{
get
{
return this.isDirty;
}
set
{
this.isDirty = value;
}
}
public int Priority
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
public string Title
{
get
{
throw new Exception("The method or operation is not implemented.");
}
set
{
throw new Exception("The method or operation is not implemented.");
}
}
public UCAnnotationSymbologyPropertyPage()
{
InitializeComponent();
}
public void InitUC(object layerProperty)
{
try
{
this.btnRestoreAll.Enabled = false;
this.btnRestore.Enabled = false;
this.m_FDOGraphicsLayer = (layerProperty as IFDOGraphicsLayer);
this.m_AnnotationLayer = (layerProperty as IAnnotationLayer);
this.m_SymbolSubstitution = (layerProperty as ISymbolSubstitution);
if (this.m_AnnotationLayer != null)
{
this.chkDrawUnplacedAnnotation.Checked = this.m_AnnotationLayer.DrawUnplacedAnnotation;
if (this.m_AnnotationLayer.UnplacedAnnotationColor != null)
{
this.chkUnplacedAnnotationColor.Checked = true;
if (!this.m_AnnotationLayer.UnplacedAnnotationColor.NullColor)
{
this.clrUnplacedAnnotationColor.Color = ColorTranslator.FromOle(this.m_AnnotationLayer.UnplacedAnnotationColor.RGB);
}
else
{
this.clrUnplacedAnnotationColor.Color = Color.Transparent;
}
}
else
{
this.chkUnplacedAnnotationColor.Checked = false;
this.clrUnplacedAnnotationColor.Color = Color.Red;
}
}
if (this.m_SymbolSubstitution != null)
{
this.ReadSymbolCollection();
this.SetInlineColor();
this.SetMassColor();
switch (this.m_SymbolSubstitution.SubstituteType)
{
case esriSymbolSubstituteType.esriSymbolSubstituteNone:
this.chkSymbolSubstituteNone.Checked = true;
this.chkIndividualDominant.Checked = true;
break;
case esriSymbolSubstituteType.esriSymbolSubstituteColor:
this.chkSymbolSubstituteColor.Checked = true;
break;
case esriSymbolSubstituteType.esriSymbolSubstituteIndividualSubordinate:
this.chkSymbolSubstituteIndividual.Checked = true;
this.chkIndividualDominant.Checked = false;
break;
case esriSymbolSubstituteType.esriSymbolSubstituteIndividualDominant:
this.chkSymbolSubstituteIndividual.Checked = true;
this.chkIndividualDominant.Checked = true;
break;
}
this.m_SymbolSubstituteType = this.m_SymbolSubstitution.SubstituteType;
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void ReadSymbolCollection()
{
this.m_SubstitutionSymbolColl = new Dictionary<int, UCAnnotationSymbologyPropertyPage.SubstitutionSymbol>();
if (this.m_FDOGraphicsLayer != null)
{
IAnnoClass annoClass = (IAnnoClass)(this.m_FDOGraphicsLayer as IFeatureLayer).FeatureClass.Extension;
ISymbolCollection symbolCollection = annoClass.SymbolCollection;
if (symbolCollection == null)
{
this.lvSymbolView.Items.Clear();
this.chkSymbolSubstituteIndividual.Checked = false;
this.chkSymbolSubstituteIndividual.Enabled = false;
return;
}
this.chkSymbolSubstituteIndividual.Enabled = true;
symbolCollection.Reset();
for (ISymbolIdentifier2 symbolIdentifier = symbolCollection.Next() as ISymbolIdentifier2; symbolIdentifier != null; symbolIdentifier = (symbolCollection.Next() as ISymbolIdentifier2))
{
UCAnnotationSymbologyPropertyPage.SubstitutionSymbol substitutionSymbol = new UCAnnotationSymbologyPropertyPage.SubstitutionSymbol();
substitutionSymbol.Index = symbolIdentifier.ID;
substitutionSymbol.Symbol = symbolIdentifier.Symbol;
ISymbol arg_A8_0 = substitutionSymbol.Symbol;
substitutionSymbol.SubstituteState = "未替换";
substitutionSymbol.BeSubstituted = false;
substitutionSymbol.SymbolName = symbolIdentifier.Name;
this.m_SubstitutionSymbolColl.Add(symbolIdentifier.ID, substitutionSymbol);
}
symbolCollection = this.m_SymbolSubstitution.SubstituteSymbolCollection;
symbolCollection.Reset();
for (ISymbolIdentifier2 symbolIdentifier = symbolCollection.Next() as ISymbolIdentifier2; symbolIdentifier != null; symbolIdentifier = (symbolCollection.Next() as ISymbolIdentifier2))
{
UCAnnotationSymbologyPropertyPage.SubstitutionSymbol substitutionSymbol2;
if (this.m_SubstitutionSymbolColl.TryGetValue(symbolIdentifier.ID, out substitutionSymbol2))
{
substitutionSymbol2.SubstituteState = "已替换";
substitutionSymbol2.BeSubstituted = true;
substitutionSymbol2.Symbol = symbolIdentifier.Symbol;
substitutionSymbol2.SymbolName = symbolIdentifier.Name;
this.btnRestoreAll.Enabled = true;
}
}
}
this.InitView();
}
private void InitView()
{
try
{
this.lvSymbolView.Items.Clear();
this.lvSymbolView.Columns.Clear();
this.lvSymbolView.Groups.Clear();
ImageList imageList = new ImageList();
int num = 210;
int num2 = 50;
imageList.ImageSize = new Size(num, num2);
this.lvSymbolView.Items.Clear();
this.lvSymbolView.Columns.Clear();
this.lvSymbolView.Columns.Add("名称", num, HorizontalAlignment.Left);
int num3 = 0;
foreach (KeyValuePair<int, UCAnnotationSymbologyPropertyPage.SubstitutionSymbol> current in this.m_SubstitutionSymbolColl)
{
UCAnnotationSymbologyPropertyPage.SubstitutionSymbol value = current.Value;
Bitmap value2 = StyleGalleryItemView.SymbolToBitmap(num, num2, value.Symbol);
imageList.Images.Add(value2);
ListViewItem listViewItem = new ListViewItem(new string[]
{
value.SymbolName + "-" + value.SubstituteState
}, num3);
listViewItem.Tag = value;
this.lvSymbolView.Items.Add(listViewItem);
num3++;
}
this.lvSymbolView.LargeImageList = imageList;
if (this.lvSymbolView.Items.Count > 0)
{
this.lvSymbolView.Items[0].Focused = true;
this.lvSymbolView.Items[0].Selected = true;
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void SetInlineColor()
{
if (this.m_SymbolSubstitution != null)
{
if (this.m_SymbolSubstitution.InlineColor != null)
{
this.m_InlineColor = this.m_SymbolSubstitution.InlineColor;
this.chkUseInlineColor.Checked = true;
if (!this.m_SymbolSubstitution.InlineColor.NullColor)
{
this.clrInlineColor.Color = ColorTranslator.FromOle(this.m_SymbolSubstitution.InlineColor.RGB);
return;
}
this.clrInlineColor.Color = Color.Transparent;
return;
}
else
{
this.chkUseInlineColor.Checked = false;
this.clrInlineColor.Color = Color.Red;
}
}
}
private void SetMassColor()
{
if (this.m_SymbolSubstitution != null)
{
if (this.m_SymbolSubstitution.MassColor != null)
{
this.m_MassColor = this.m_SymbolSubstitution.MassColor;
if (!this.m_SymbolSubstitution.MassColor.NullColor)
{
this.clrMassColor.Color = ColorTranslator.FromOle(this.m_SymbolSubstitution.MassColor.RGB);
return;
}
this.clrMassColor.Color = Color.Transparent;
return;
}
else
{
this.chkUseInlineColor.Checked = false;
this.clrMassColor.Color = Color.Blue;
}
}
}
public void Write2Prop()
{
try
{
ISymbolCollection substituteSymbolCollection = this.m_SymbolSubstitution.SubstituteSymbolCollection;
substituteSymbolCollection.RemoveAll();
foreach (KeyValuePair<int, UCAnnotationSymbologyPropertyPage.SubstitutionSymbol> current in this.m_SubstitutionSymbolColl)
{
UCAnnotationSymbologyPropertyPage.SubstitutionSymbol value = current.Value;
if (value.BeSubstituted)
{
substituteSymbolCollection.set_Symbol(value.Index, value.Symbol);
}
}
this.m_SymbolSubstitution.SubstituteType = this.m_SymbolSubstituteType;
this.m_SymbolSubstitution.MassColor = this.m_MassColor;
if (this.m_UseInlineColor)
{
this.m_SymbolSubstitution.InlineColor = this.m_InlineColor;
}
else
{
this.m_SymbolSubstitution.InlineColor = null;
}
this.m_AnnotationLayer.DrawUnplacedAnnotation = this.m_DrawUnplacedAnnotation;
if (this.m_UseUnplacedAnnotationColor)
{
this.m_AnnotationLayer.UnplacedAnnotationColor = this.m_UnplacedAnnotationColor;
}
else
{
this.m_AnnotationLayer.UnplacedAnnotationColor = null;
}
this.isDirty = false;
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
public bool CanWrite2Prop()
{
return this.isDirty;
}
private void InvokeEditValueChanged(object sender, System.EventArgs e)
{
if (this.EditorChanged != null)
{
this.EditorChanged(sender, e);
}
this.isDirty = true;
}
public void SetDefaultValue(object value)
{
}
public int Activate()
{
throw new Exception("The method or operation is not implemented.");
}
public void Deactivate()
{
throw new Exception("The method or operation is not implemented.");
}
public void Cancel()
{
throw new Exception("The method or operation is not implemented.");
}
private void chkDrawUnplacedAnnotation_CheckedChanged(object sender, System.EventArgs e)
{
this.panelControl1.Enabled = this.chkDrawUnplacedAnnotation.Checked;
this.m_DrawUnplacedAnnotation = this.chkDrawUnplacedAnnotation.Checked;
}
private void chkUnplacedAnnotationColor_CheckedChanged(object sender, System.EventArgs e)
{
this.clrUnplacedAnnotationColor.Enabled = this.chkUnplacedAnnotationColor.Checked;
this.m_UseUnplacedAnnotationColor = this.chkUnplacedAnnotationColor.Checked;
}
private void chkSymbolSubstituteColor_CheckedChanged(object sender, System.EventArgs e)
{
this.clrMassColor.Enabled = this.chkSymbolSubstituteColor.Checked;
if (this.chkSymbolSubstituteColor.Checked)
{
this.m_SymbolSubstituteType = esriSymbolSubstituteType.esriSymbolSubstituteColor;
}
}
private void chkSymbolSubstituteIndividual_CheckedChanged(object sender, System.EventArgs e)
{
this.pnlSymbolset.Enabled = this.chkSymbolSubstituteIndividual.Checked;
if (this.chkSymbolSubstituteIndividual.Checked)
{
if (this.chkIndividualDominant.Checked)
{
this.m_SymbolSubstituteType = esriSymbolSubstituteType.esriSymbolSubstituteIndividualDominant;
return;
}
this.m_SymbolSubstituteType = esriSymbolSubstituteType.esriSymbolSubstituteIndividualSubordinate;
}
}
private void chkUseInlineColor_CheckedChanged(object sender, System.EventArgs e)
{
this.clrInlineColor.Enabled = this.chkUseInlineColor.Checked;
this.m_UseInlineColor = this.chkUseInlineColor.Checked;
}
private void btnSymbolProperty_Click(object sender, System.EventArgs e)
{
try
{
int index = this.lvSymbolView.SelectedItems[0].Index;
if (this.lvSymbolView.SelectedItems[0].Tag is UCAnnotationSymbologyPropertyPage.SubstitutionSymbol)
{
UCAnnotationSymbologyPropertyPage.SubstitutionSymbol substitutionSymbol = this.lvSymbolView.SelectedItems[0].Tag as UCAnnotationSymbologyPropertyPage.SubstitutionSymbol;
ISymbol symbol = substitutionSymbol.Symbol;
ISymbol symbol2 = (symbol as IClone).Clone() as ISymbol;
symbol2 = (RenderUtil.OpenStyleSelector(esriStyleClass.TextSymbols, symbol2) as ISymbol);
if (symbol2 != null)
{
substitutionSymbol.Symbol = symbol2;
substitutionSymbol.SubstituteState = "已替换";
substitutionSymbol.BeSubstituted = true;
this.InitView();
this.lvSymbolView.FocusedItem = this.lvSymbolView.Items[index];
this.InvokeEditValueChanged(sender, e);
}
}
}
catch
{
}
}
private void lvSymbolView_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (this.lvSymbolView.FocusedItem != null && this.lvSymbolView.FocusedItem.Tag is UCAnnotationSymbologyPropertyPage.SubstitutionSymbol)
{
this.btnSymbolProperty.Enabled = true;
UCAnnotationSymbologyPropertyPage.SubstitutionSymbol substitutionSymbol = this.lvSymbolView.FocusedItem.Tag as UCAnnotationSymbologyPropertyPage.SubstitutionSymbol;
this.btnRestore.Enabled = substitutionSymbol.BeSubstituted;
this.btnRestoreAll.Enabled = substitutionSymbol.BeSubstituted;
}
}
private void lvSymbolView_DoubleClick(object sender, System.EventArgs e)
{
if (this.btnSymbolProperty.Enabled)
{
this.btnSymbolProperty_Click(sender, e);
}
}
private void btnRestore_Click(object sender, System.EventArgs e)
{
int index = this.lvSymbolView.FocusedItem.Index;
if (this.lvSymbolView.FocusedItem.Tag is UCAnnotationSymbologyPropertyPage.SubstitutionSymbol)
{
UCAnnotationSymbologyPropertyPage.SubstitutionSymbol substitutionSymbol = this.lvSymbolView.FocusedItem.Tag as UCAnnotationSymbologyPropertyPage.SubstitutionSymbol;
if (this.m_FDOGraphicsLayer != null)
{
IAnnoClass annoClass = (IAnnoClass)(this.m_FDOGraphicsLayer as IFeatureLayer).FeatureClass.Extension;
ISymbolCollection symbolCollection = annoClass.SymbolCollection;
symbolCollection.Reset();
substitutionSymbol.Symbol = symbolCollection.get_Symbol(substitutionSymbol.Index);
substitutionSymbol.SubstituteState = "未替换";
substitutionSymbol.BeSubstituted = false;
this.InvokeEditValueChanged(sender, e);
}
this.InitView();
this.lvSymbolView.FocusedItem = this.lvSymbolView.Items[index];
}
}
private void btnRestoreAll_Click(object sender, System.EventArgs e)
{
this.ReadSymbolCollection();
this.InvokeEditValueChanged(sender, e);
}
private void chkSymbolSubstituteNone_CheckedChanged(object sender, System.EventArgs e)
{
if (this.chkSymbolSubstituteNone.Checked)
{
this.m_SymbolSubstituteType = esriSymbolSubstituteType.esriSymbolSubstituteNone;
}
}
private void clrMassColor_EditValueChanged(object sender, System.EventArgs e)
{
IColor color = Converter.ToRGBColor(this.clrMassColor.Color);
color.Transparency = this.clrMassColor.Color.A;
this.m_MassColor = color;
this.InvokeEditValueChanged(sender, e);
}
private void clrInlineColor_EditValueChanged(object sender, System.EventArgs e)
{
IColor color = Converter.ToRGBColor(this.clrInlineColor.Color);
color.Transparency = this.clrInlineColor.Color.A;
this.m_InlineColor = color;
this.InvokeEditValueChanged(sender, e);
}
private void clrUnplacedAnnotationColor_EditValueChanged(object sender, System.EventArgs e)
{
IColor color = Converter.ToRGBColor(this.clrUnplacedAnnotationColor.Color);
color.Transparency = this.clrUnplacedAnnotationColor.Color.A;
this.m_UnplacedAnnotationColor = color;
this.InvokeEditValueChanged(sender, e);
}
private void lvSymbolView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
if (e.Item != null && e.Item.Tag is UCAnnotationSymbologyPropertyPage.SubstitutionSymbol)
{
this.btnSymbolProperty.Enabled = true;
UCAnnotationSymbologyPropertyPage.SubstitutionSymbol substitutionSymbol = e.Item.Tag as UCAnnotationSymbologyPropertyPage.SubstitutionSymbol;
this.btnRestore.Enabled = substitutionSymbol.BeSubstituted;
this.btnRestoreAll.Enabled = substitutionSymbol.BeSubstituted;
}
}
private void chkIndividualDominant_CheckedChanged(object sender, System.EventArgs e)
{
if (this.chkIndividualDominant.Checked)
{
this.m_SymbolSubstituteType = esriSymbolSubstituteType.esriSymbolSubstituteIndividualDominant;
return;
}
this.m_SymbolSubstituteType = esriSymbolSubstituteType.esriSymbolSubstituteIndividualSubordinate;
}
}
}