年度变更建库软件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.

220 lines
8.5 KiB

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using KGIS.Plugin.LayerProperty.Interface;
using KGIS.Plugin.LayerProperty.View.UC_Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KGIS.Plugin.LayerProperty.View
{
public partial class FormPlacmentProps : Form
{
private IBasicOverposterLayerProperties4 m_BasicOverposterLayerProperties;
private IPropertyPage ucPolygonLabelPlacementSet;
private IPropertyPage ucPolylineLabelPlacementSet;
private IPropertyPage ucPointLabelPlacementSet;
private List<IPropertyPage> PropertyList;
private esriBasicNumLabelsOption m_LabelsOption;
private IFields fields;
private bool isPageDirty;
public event System.EventHandler EditorChanged;
public IFields Fields
{
get
{
return this.fields;
}
set
{
this.fields = 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 bool IsPageDirty
{
get
{
return this.isPageDirty;
}
set
{
this.isPageDirty = value;
}
}
public FormPlacmentProps()
{
InitializeComponent();
}
public new int Activate()
{
throw new Exception("The method or operation is not implemented.");
}
public new 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.");
}
public void InitUC(object layerProperty)
{
try
{
this.PropertyList = new List<IPropertyPage>();
this.m_BasicOverposterLayerProperties = (layerProperty as IBasicOverposterLayerProperties4);
this.grpLabelSet.Controls.Clear();
switch (this.m_BasicOverposterLayerProperties.FeatureType)
{
case esriBasicOverposterFeatureType.esriOverposterPoint:
this.grpLabelSet.Text = "点状要素设置";
if (this.ucPointLabelPlacementSet == null)
{
this.ucPointLabelPlacementSet = new UCPointLabelPlacementSet();
this.ucPointLabelPlacementSet.EditorChanged += new System.EventHandler(this.ucPropertySet_EditorChanged);
}
this.ucPointLabelPlacementSet.Dock = DockStyle.Fill;
this.ucPointLabelPlacementSet.InitUC(layerProperty);
(this.ucPointLabelPlacementSet as UCPointLabelPlacementSet).Fields = this.fields;
this.grpLabelSet.Controls.Add(this.ucPointLabelPlacementSet as System.Windows.Forms.Control);
this.PropertyList.Add(this.ucPointLabelPlacementSet);
break;
case esriBasicOverposterFeatureType.esriOverposterPolyline:
this.grpLabelSet.Text = "线状要素设置";
if (this.ucPolylineLabelPlacementSet == null)
{
this.ucPolylineLabelPlacementSet = new UCPolylineLabelPlacementSet();
this.ucPolylineLabelPlacementSet.EditorChanged += new System.EventHandler(this.ucPropertySet_EditorChanged);
}
this.ucPolylineLabelPlacementSet.Dock = DockStyle.Fill;
this.ucPolylineLabelPlacementSet.InitUC(layerProperty);
this.grpLabelSet.Controls.Add(this.ucPolylineLabelPlacementSet as System.Windows.Forms.Control);
this.PropertyList.Add(this.ucPolylineLabelPlacementSet);
break;
case esriBasicOverposterFeatureType.esriOverposterPolygon:
this.grpLabelSet.Text = "面状要素设置";
if (this.ucPolygonLabelPlacementSet == null)
{
this.ucPolygonLabelPlacementSet = new UCPolygonLabelPlacementSet();
this.ucPolygonLabelPlacementSet.EditorChanged += new System.EventHandler(this.ucPropertySet_EditorChanged);
}
this.ucPolygonLabelPlacementSet.Dock = DockStyle.Fill;
this.ucPolygonLabelPlacementSet.InitUC(layerProperty);
this.grpLabelSet.Controls.Add(this.ucPolygonLabelPlacementSet as System.Windows.Forms.Control);
this.PropertyList.Add(this.ucPolygonLabelPlacementSet);
break;
}
this.m_LabelsOption = this.m_BasicOverposterLayerProperties.NumLabelsOption;
this.rgpDuplicateLabel.SelectedIndex = this.m_LabelsOption - esriBasicNumLabelsOption.esriOneLabelPerName;
this.txtBufferRatio.Text = this.m_BasicOverposterLayerProperties.BufferRatio.ToString();
this.cmbLabelWeight.SelectedIndex = (int)(esriBasicOverposterWeight.esriHighWeight - this.m_BasicOverposterLayerProperties.LabelWeight);
if (this.m_BasicOverposterLayerProperties.FeatureWeight == esriBasicOverposterWeight.esriNoWeight)
{
this.cmbFeatureWeight.SelectedIndex = 3;
}
else
{
this.cmbFeatureWeight.SelectedIndex = (int)(esriBasicOverposterWeight.esriHighWeight - this.m_BasicOverposterLayerProperties.FeatureWeight);
}
this.isPageDirty = false;
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void ucPropertySet_EditorChanged(object sender, System.EventArgs e)
{
this.InvokeEditorChanged();
}
public bool CanWrite2Prop()
{
return true;
}
public void Write2Prop()
{
try
{
foreach (IPropertyPage current in this.PropertyList)
{
if (current.CanWrite2Prop())
{
current.Write2Prop();
}
}
this.m_BasicOverposterLayerProperties.NumLabelsOption = this.m_LabelsOption;
this.isPageDirty = false;
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
public void SetDefaultValue(object value)
{
}
private void btnOK_Click(object sender, System.EventArgs e)
{
try
{
if (this.CanWrite2Prop())
{
this.Write2Prop();
}
base.DialogResult = DialogResult.OK;
base.Close();
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
base.DialogResult = DialogResult.Cancel;
base.Close();
}
private void rgpDuplicateLabel_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.m_LabelsOption = this.rgpDuplicateLabel.SelectedIndex + esriBasicNumLabelsOption.esriOneLabelPerName;
this.InvokeEditorChanged();
}
private void InvokeEditorChanged()
{
if (this.EditorChanged != null)
{
this.EditorChanged(null, null);
}
this.isPageDirty = true;
}
}
}