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

274 lines
9.5 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.Display;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.ADF;
using KGIS.Plugin.LayerProperty.Utils;
using DevExpress.XtraEditors.Controls;
using stdole;
namespace KGIS.Plugin.LayerProperty.View.UC_Controls
{
public partial class UCTextSymbolAtrribute : XtraUserControl, IUCSymbolAtrribute
{
private PictureEdit m_PictureEdit;
private ISymbol m_Symbol;
private IDoStyleGalleryItem m_DoStyleGalleryItem;
private IStyleGalleryClass m_StyleGalleryClass;
private ITextSymbol m_TextSymbol;
public event System.EventHandler SymbolEdited;
public UCTextSymbolAtrribute()
{
InitializeComponent();
}
public bool Init(ref ISymbol symbol)
{
try
{
this.m_TextSymbol = null;
this.m_Symbol = null;
this.m_Symbol = symbol;
this.m_StyleGalleryClass = new TextSymbolStyleGalleryClassClass();
this.m_TextSymbol = (symbol as ITextSymbol);
bool result;
if (this.m_TextSymbol == null)
{
result = false;
return result;
}
if (this.m_TextSymbol.Color != null)
{
if (this.m_TextSymbol.Color.NullColor)
{
this.clrFontColor.Color = ColorTranslator.FromOle(this.m_TextSymbol.Color.RGB);
}
else
{
this.clrFontColor.Color = Color.Transparent;
}
}
else
{
this.clrFontColor.Color = Color.Transparent;
}
this.fontEdit2.Text = this.m_TextSymbol.Font.Name;
this.spSize.EditValue = this.m_TextSymbol.Font.Size;
this.chkItalic.Checked = this.m_TextSymbol.Font.Italic;
this.chkUnderline.Checked = this.m_TextSymbol.Font.Underline;
this.chkBold.Checked = this.m_TextSymbol.Font.Bold;
this.PreviewGalleryItem();
result = true;
return result;
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
return false;
}
public bool Init(ref IDoStyleGalleryItem symbol)
{
try
{
this.m_TextSymbol = null;
this.m_DoStyleGalleryItem = null;
this.m_DoStyleGalleryItem = symbol;
IClone clone = symbol.Item.Item as IClone;
this.m_TextSymbol = (clone.Clone() as ITextSymbol);
bool result;
if (this.m_TextSymbol == null)
{
result = false;
return result;
}
this.clrFontColor.Color = Converter.FromRGBColor(this.m_TextSymbol.Color as IRgbColor);
this.fontEdit2.Text = this.m_TextSymbol.Font.Name;
this.spSize.EditValue = this.m_TextSymbol.Font.Size;
this.chkItalic.Checked = this.m_TextSymbol.Font.Italic;
this.chkUnderline.Checked = this.m_TextSymbol.Font.Underline;
this.chkBold.Checked = this.m_TextSymbol.Font.Bold;
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_TextSymbol != null)
{
IColor color = this.m_TextSymbol.Color;
color = Converter.ToRGBColor(this.clrFontColor.Color);
color.Transparency = this.clrFontColor.Color.A;
this.m_TextSymbol.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_TextSymbol != null)
{
IFontDisp font = this.m_TextSymbol.Font;
font.Size = Math.Abs(Convert.ToDecimal(e.NewValue));
this.m_TextSymbol.Font = font;
}
this.PreviewGalleryItem();
if (this.SymbolEdited != null)
{
this.SymbolEdited(null, null);
}
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void fontEdit2_SelectedValueChanged(object sender, System.EventArgs e)
{
try
{
if (this.m_TextSymbol != null)
{
IFontDisp fontDisp = this.m_TextSymbol.Font;
System.Drawing.Font font = new System.Drawing.Font(this.fontEdit2.Text, Math.Abs(Convert.ToSingle(this.spSize.EditValue)));
fontDisp = Converter.ToStdFont(font);
fontDisp.Size = Math.Abs(Convert.ToDecimal(this.spSize.EditValue));
fontDisp.Italic = this.chkItalic.Checked;
fontDisp.Bold = this.chkBold.Checked;
fontDisp.Underline = this.chkUnderline.Checked;
this.m_TextSymbol.Font = fontDisp;
}
this.PreviewGalleryItem();
if (this.SymbolEdited != null)
{
this.SymbolEdited(null, null);
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void chkBold_CheckedChanged(object sender, System.EventArgs e)
{
try
{
if (this.m_TextSymbol != null)
{
IFontDisp font = this.m_TextSymbol.Font;
font.Bold = this.chkBold.Checked;
this.m_TextSymbol.Font = font;
}
this.PreviewGalleryItem();
if (this.SymbolEdited != null)
{
this.SymbolEdited(null, null);
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void chkItalic_CheckedChanged(object sender, System.EventArgs e)
{
try
{
if (this.m_TextSymbol != null)
{
IFontDisp font = this.m_TextSymbol.Font;
font.Italic = this.chkItalic.Checked;
this.m_TextSymbol.Font = font;
}
this.PreviewGalleryItem();
if (this.SymbolEdited != null)
{
this.SymbolEdited(null, null);
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
private void chkUnderline_CheckedChanged(object sender, System.EventArgs e)
{
try
{
if (this.m_TextSymbol != null)
{
IFontDisp font = this.m_TextSymbol.Font;
font.Underline = this.chkUnderline.Checked;
this.m_TextSymbol.Font = font;
}
this.PreviewGalleryItem();
if (this.SymbolEdited != null)
{
this.SymbolEdited(null, null);
}
}
catch (Exception ex)
{
//RdbUtil.AddException(ex);
}
}
}
}