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
						
					
					
						
							6.6 KiB
						
					
					
				
			
		
		
	
	
							220 lines
						
					
					
						
							6.6 KiB
						
					
					
				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 FormPointPlacementAngles : Form | 
						|
    { | 
						|
        private object source; | 
						|
        private object snode; | 
						|
        private object target; | 
						|
        private Array angles; | 
						|
        public Array Angles | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                return this.angles; | 
						|
            } | 
						|
            set | 
						|
            { | 
						|
                this.angles = value; | 
						|
            } | 
						|
        } | 
						|
        public FormPointPlacementAngles() | 
						|
        { | 
						|
            InitializeComponent(); | 
						|
        } | 
						|
        public void Init(Array angles) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                for (int i = 0; i < angles.Length; i++) | 
						|
                { | 
						|
                    double num = Convert.ToDouble(angles.GetValue(i)); | 
						|
                    this.listBoxControl1.Items.Add(num); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void btnAdd_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.StringCanUse()) | 
						|
                { | 
						|
                    this.listBoxControl1.Items.Add(double.Parse(this.txtNewAngle.Text)); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private bool StringCanUse() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                bool result; | 
						|
                if (this.txtNewAngle.Text == "") | 
						|
                { | 
						|
                    result = false; | 
						|
                    return result; | 
						|
                } | 
						|
                double num = 0.0; | 
						|
                if (!double.TryParse(this.txtNewAngle.Text, out num)) | 
						|
                { | 
						|
                    result = false; | 
						|
                    return result; | 
						|
                } | 
						|
                if (num > 360.0 || num < 0.0) | 
						|
                { | 
						|
                    result = false; | 
						|
                    return result; | 
						|
                } | 
						|
                if (this.listBoxControl1.Items.Contains(num)) | 
						|
                { | 
						|
                    result = false; | 
						|
                    return result; | 
						|
                } | 
						|
                result = true; | 
						|
                return result; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
            return false; | 
						|
        } | 
						|
        private void btnUp_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            if (this.snode == null) | 
						|
            { | 
						|
                return; | 
						|
            } | 
						|
            this.source = this.snode; | 
						|
            int num = this.listBoxControl1.Items.IndexOf(this.source); | 
						|
            if (num == 0) | 
						|
            { | 
						|
                return; | 
						|
            } | 
						|
            this.target = this.listBoxControl1.Items[num - 1]; | 
						|
            this.UpAndDown(); | 
						|
        } | 
						|
        private void UpAndDown() | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.source != this.target) | 
						|
                { | 
						|
                    this.listBoxControl1.Items.IndexOf(this.source); | 
						|
                    int num = this.listBoxControl1.Items.IndexOf(this.target); | 
						|
                    if (num != -1) | 
						|
                    { | 
						|
                        this.listBoxControl1.Items.Remove(this.source); | 
						|
                        this.listBoxControl1.Items.Insert(num, this.source); | 
						|
                        this.listBoxControl1.SelectedIndex = num; | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void ControlsEnable(bool enable) | 
						|
        { | 
						|
            this.btnDown.Enabled = enable; | 
						|
            this.btnRemove.Enabled = enable; | 
						|
            this.btnUp.Enabled = enable; | 
						|
        } | 
						|
        private void listBoxControl1_SelectedIndexChanged(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.listBoxControl1.SelectedIndex > -1) | 
						|
                { | 
						|
                    this.ControlsEnable(true); | 
						|
                } | 
						|
                if (this.listBoxControl1.SelectedIndex == 0) | 
						|
                { | 
						|
                    this.ControlsEnable(true); | 
						|
                    this.btnUp.Enabled = false; | 
						|
                } | 
						|
                if (this.listBoxControl1.SelectedIndex == this.listBoxControl1.ItemCount - 1) | 
						|
                { | 
						|
                    this.btnDown.Enabled = false; | 
						|
                } | 
						|
                if (this.listBoxControl1.SelectedItems.Count > 1) | 
						|
                { | 
						|
                    this.btnUp.Enabled = false; | 
						|
                    this.btnDown.Enabled = false; | 
						|
                } | 
						|
                this.snode = this.listBoxControl1.SelectedItem; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void btnDown_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                if (this.snode != null) | 
						|
                { | 
						|
                    this.source = this.snode; | 
						|
                    int num = this.listBoxControl1.Items.IndexOf(this.source); | 
						|
                    if (num != this.listBoxControl1.Items.Count - 1) | 
						|
                    { | 
						|
                        this.target = this.listBoxControl1.Items[num + 1]; | 
						|
                        this.UpAndDown(); | 
						|
                    } | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void btnRemove_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                int index = this.listBoxControl1.Items.IndexOf(this.snode); | 
						|
                this.listBoxControl1.Items.RemoveAt(index); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                //RdbUtil.AddException(ex); | 
						|
            } | 
						|
        } | 
						|
        private void btnOK_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            this.angles = new double[this.listBoxControl1.Items.Count]; | 
						|
            int num = 0; | 
						|
            foreach (object current in this.listBoxControl1.Items) | 
						|
            { | 
						|
                double num2 = Convert.ToDouble(current); | 
						|
                this.angles.SetValue(num2, num); | 
						|
                num++; | 
						|
            } | 
						|
            base.DialogResult = DialogResult.OK; | 
						|
            base.Close(); | 
						|
        } | 
						|
        private void btnCancel_Click(object sender, System.EventArgs e) | 
						|
        { | 
						|
            base.DialogResult = DialogResult.Cancel; | 
						|
            base.Close(); | 
						|
        } | 
						|
    } | 
						|
}
 | 
						|
 |