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 pnone = new ItemInfo(0.0, ""); private IList> scales = new List>(); public event UCScaleCombox.ValueChangedHandler ScaleValueChanged; public double ScaleValue { get { try { return (this.comboBoxEdit1.EditValue as ItemInfo).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(1000.0, "1:1000")); this.scales.Add(new ItemInfo(5000.0, "1:5000")); this.scales.Add(new ItemInfo(10000.0, "1:10000")); this.scales.Add(new ItemInfo(50000.0, "1:50000")); this.scales.Add(new ItemInfo(100000.0, "1:100000")); this.scales.Add(new ItemInfo(250000.0, "1:250000")); this.scales.Add(new ItemInfo(500000.0, "1:500000")); this.scales.Add(new ItemInfo(1000000.0, "1:1000000")); DevExpressControlInitList.InitComboBoxEdit(ref this.comboBoxEdit1, this.scales, this.pnone); } private bool IsContains(ItemInfo newItem) { try { foreach (ItemInfo 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 itemInfo = new ItemInfo(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 itemInfo2 = new ItemInfo(num2, "1:" + text); if (!this.IsContains(itemInfo2)) { this.scales.Add(itemInfo2); } this.comboBoxEdit1.EditValue = itemInfo2; } } else { this.comboBoxEdit1.EditValue = this.pnone; } } ItemInfo itemInfo3 = this.comboBoxEdit1.EditValue as ItemInfo; if (itemInfo3 != null && this.ScaleValueChanged != null) { this.ScaleValueChanged(itemInfo3.InnerValue); } } catch (Exception ex) { //RdbUtil.AddException(ex); } } } }