|
|
|
|
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 KGIS.Plugin.LayerProperty.Utils;
|
|
|
|
|
|
|
|
|
|
namespace KGIS.Plugin.LayerProperty.View.UC_Controls
|
|
|
|
|
{
|
|
|
|
|
public partial class UCScaleCombox : UserControl
|
|
|
|
|
{
|
|
|
|
|
public delegate void ValueChangedHandler(double scale);
|
|
|
|
|
private ItemInfo<double, string> pnone = new ItemInfo<double, string>(0.0, "<none>");
|
|
|
|
|
private IList<ItemInfo<double, string>> scales = new List<ItemInfo<double, string>>();
|
|
|
|
|
public event UCScaleCombox.ValueChangedHandler ScaleValueChanged;
|
|
|
|
|
public double ScaleValue
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return (this.comboBoxEdit1.EditValue as ItemInfo<double, string>).InnerValue;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this.comboBoxEdit1.Text = value.ToString();
|
|
|
|
|
this.comboBoxEdit1_Validated(null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public UCScaleCombox()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
|
|
|
|
this.scales.Clear();
|
|
|
|
|
this.scales.Add(this.pnone);
|
|
|
|
|
this.scales.Add(new ItemInfo<double, string>(1000.0, "1:1000"));
|
|
|
|
|
this.scales.Add(new ItemInfo<double, string>(5000.0, "1:5000"));
|
|
|
|
|
this.scales.Add(new ItemInfo<double, string>(10000.0, "1:10000"));
|
|
|
|
|
this.scales.Add(new ItemInfo<double, string>(50000.0, "1:50000"));
|
|
|
|
|
this.scales.Add(new ItemInfo<double, string>(100000.0, "1:100000"));
|
|
|
|
|
this.scales.Add(new ItemInfo<double, string>(250000.0, "1:250000"));
|
|
|
|
|
this.scales.Add(new ItemInfo<double, string>(500000.0, "1:500000"));
|
|
|
|
|
this.scales.Add(new ItemInfo<double, string>(1000000.0, "1:1000000"));
|
|
|
|
|
DevExpressControlInitList<double, string>.InitComboBoxEdit(ref this.comboBoxEdit1, this.scales, this.pnone);
|
|
|
|
|
}
|
|
|
|
|
private bool IsContains(ItemInfo<double, string> newItem)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
foreach (ItemInfo<double, string> current in this.scales)
|
|
|
|
|
{
|
|
|
|
|
if (current == newItem)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//RdbUtil.AddException(ex);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
private void comboBoxEdit1_EditValueChanged(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//RdbUtil.AddException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void comboBoxEdit1_Validated(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string text = this.comboBoxEdit1.Text;
|
|
|
|
|
if (text.Contains("1:"))
|
|
|
|
|
{
|
|
|
|
|
double num;
|
|
|
|
|
if (double.TryParse(text.Substring(2), out num))
|
|
|
|
|
{
|
|
|
|
|
if (num == 0.0)
|
|
|
|
|
{
|
|
|
|
|
this.comboBoxEdit1.EditValue = this.pnone;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ItemInfo<double, string> itemInfo = new ItemInfo<double, string>(num, text);
|
|
|
|
|
if (!this.IsContains(itemInfo))
|
|
|
|
|
{
|
|
|
|
|
this.scales.Add(itemInfo);
|
|
|
|
|
this.comboBoxEdit1.EditValue = itemInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.comboBoxEdit1.EditValue = this.pnone;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
double num2;
|
|
|
|
|
if (double.TryParse(text.Trim(), out num2))
|
|
|
|
|
{
|
|
|
|
|
if (num2 == 0.0)
|
|
|
|
|
{
|
|
|
|
|
this.comboBoxEdit1.EditValue = this.pnone;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ItemInfo<double, string> itemInfo2 = new ItemInfo<double, string>(num2, "1:" + text);
|
|
|
|
|
if (!this.IsContains(itemInfo2))
|
|
|
|
|
{
|
|
|
|
|
this.scales.Add(itemInfo2);
|
|
|
|
|
}
|
|
|
|
|
this.comboBoxEdit1.EditValue = itemInfo2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.comboBoxEdit1.EditValue = this.pnone;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ItemInfo<double, string> itemInfo3 = this.comboBoxEdit1.EditValue as ItemInfo<double, string>;
|
|
|
|
|
if (itemInfo3 != null && this.ScaleValueChanged != null)
|
|
|
|
|
{
|
|
|
|
|
this.ScaleValueChanged(itemInfo3.InnerValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
//RdbUtil.AddException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|