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

202 lines
6.7 KiB

6 months ago
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.Display;
using DevExpress.XtraEditors.Controls;
using KGIS.Plugin.LayerProperty.Utils;
using ESRI.ArcGIS.ADF;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Carto;
namespace KGIS.Plugin.LayerProperty.View.UC_Controls
{
public partial class UCMarkSymbolAtrribute : XtraUserControl, IUCSymbolAtrribute
{
private ISymbol m_Symbol;
private IDoStyleGalleryItem m_DoStyleGalleryItem;
private IStyleGalleryClass m_StyleGalleryClass;
private IMarkerSymbol m_MarkerSymbol;
public event System.EventHandler SymbolEdited;
public UCMarkSymbolAtrribute()
{
InitializeComponent();
}
public bool Init(ref ISymbol symbol)
{
try
{
this.m_MarkerSymbol = null;
this.m_Symbol = null;
this.m_Symbol = symbol;
this.m_StyleGalleryClass = new MarkerSymbolStyleGalleryClassClass();
this.m_MarkerSymbol = (symbol as IMarkerSymbol);
bool result;
if (this.m_MarkerSymbol == null)
{
result = false;
return result;
}
if (this.m_MarkerSymbol.Color != null)
{
if (!this.m_MarkerSymbol.Color.NullColor)
{
this.clrFillColor.Color = ColorTranslator.FromOle(this.m_MarkerSymbol.Color.RGB);
}
else
{
this.clrFillColor.Color = Color.Transparent;
}
}
else
{
this.clrFillColor.Color = Color.Empty;
}
this.spAngle.EditValue = this.m_MarkerSymbol.Angle;
this.spSize.EditValue = this.m_MarkerSymbol.Size;
this.PreviewGalleryItem();
result = true;
return result;
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
return false;
}
public bool Init(ref IDoStyleGalleryItem symbol)
{
try
{
this.m_MarkerSymbol = null;
this.m_DoStyleGalleryItem = null;
this.m_DoStyleGalleryItem = symbol;
IClone clone = symbol.Item.Item as IClone;
this.m_MarkerSymbol = (clone.Clone() as IMarkerSymbol);
bool result;
if (this.m_MarkerSymbol == null)
{
result = false;
return result;
}
this.clrFillColor.Color = Converter.FromRGBColor(this.m_MarkerSymbol.Color as IRgbColor);
this.spAngle.EditValue = this.m_MarkerSymbol.Angle;
this.spSize.EditValue = this.m_MarkerSymbol.Size;
result = true;
return result;
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
return false;
}
public void SetPicture(PictureEdit pic)
{
this.m_PictureEdit = pic;
}
private void clrFillColor_EditValueChanged(object sender, System.EventArgs e)
{
try
{
if (this.m_MarkerSymbol != null)
{
IColor color = this.m_MarkerSymbol.Color;
color = Converter.ToRGBColor(this.clrFillColor.Color);
color.Transparency = this.clrFillColor.Color.A;
this.m_MarkerSymbol.Color = color;
}
this.PreviewGalleryItem();
if (this.SymbolEdited != null)
{
this.SymbolEdited(null, null);
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void PreviewGalleryItem()
{
try
{
if (this.m_Symbol != null)
{
this.m_PictureEdit.Image = StyleGalleryItemView.GetSymbolBitMap(this.m_PictureEdit.Width - 1, this.m_PictureEdit.Height - 1, this.m_StyleGalleryClass, this.m_Symbol);
}
else
{
if (this.m_DoStyleGalleryItem != null)
{
this.m_PictureEdit.Image = this.m_DoStyleGalleryItem.StyleGalleryClass.StyleGalleryItemToBmp(this.m_DoStyleGalleryItem, this.m_PictureEdit.Height);
}
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void spSize_EditValueChanging(object sender, ChangingEventArgs e)
{
try
{
if (Convert.ToDouble(e.NewValue) < 0.0)
{
e.Cancel = true;
}
else
{
if (this.m_MarkerSymbol != null)
{
this.m_MarkerSymbol.Size = Math.Abs(Convert.ToDouble(e.NewValue));
}
this.PreviewGalleryItem();
if (this.SymbolEdited != null)
{
this.SymbolEdited(null, null);
}
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void spAngle_EditValueChanging(object sender, ChangingEventArgs e)
{
try
{
if (Math.Abs(Convert.ToDouble(e.NewValue)) > 360.0)
{
e.Cancel = true;
}
else
{
if (this.m_MarkerSymbol != null)
{
this.m_MarkerSymbol.Angle = Math.Abs(Convert.ToDouble(e.NewValue));
}
this.PreviewGalleryItem();
if (this.SymbolEdited != null)
{
this.SymbolEdited(null, null);
}
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
}
}