コード例 #1
0
ファイル: frmTravelPath.cs プロジェクト: dbeattie71/ak
        public frmTravelPath(PatrolAreas patrolareas, AutoKillerScript.clsAutoKillerScript ak)
        {
            _patrolareas = patrolareas;
            _ak          = ak;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            this.lvwPatrolArea.Validated += new EventHandler(lvwPatrolArea_Validated);

            //we have our PatrolAreas class, lets load the comboBox with the area names
            foreach (string patrolareaname in _patrolareas.GetAllPatrolAreas())
            {
                if (_patrolareas.GetPatrolArea(patrolareaname).Type == PatrolType.TravelPath)
                {
                    cbxPatrolAreas.Items.Add(patrolareaname);
                }
            }

            // set up our timer for recording waypoints as the player runs
            AutoWaypointsTimer          = new System.Windows.Forms.Timer();
            AutoWaypointsTimer.Interval = 1000;
            AutoWaypointsTimer.Tick    += new EventHandler(AutoWaypointsTimer_Expired);
            AutoWaypointsTimer.Enabled  = true;
            AutoWaypointsTimer.Stop();
        }
コード例 #2
0
ファイル: frmTravel.cs プロジェクト: dbeattie71/ak
        /// <summary>
        /// This allows us to make sure our comboBox contents AND SELECTION dont show
        /// a patrol area or travel path that have meanwhile been deleted by the user
        /// switching to another form, deleting, and then switching back here.
        /// </summary>
        private void cbxPatrolAreas_GotFocus(object sender, EventArgs e)
        {
            string oldSelect = "";

            //store what is selected before we reload the comboBox
            if (cbxPatrolAreas.SelectedIndex != -1)
            {
                oldSelect = cbxPatrolAreas.SelectedItem.ToString();
            }

            //clear and reload
            cbxPatrolAreas.Items.Clear();
            cbxPatrolAreas.Text = "";
            foreach (string patrolareaname in _patrolareas.GetAllPatrolAreas())
            {
                cbxPatrolAreas.Items.Add(patrolareaname);
            }

            //if something had been selected, and its still a valid item, select it
            if (oldSelect != "" && cbxPatrolAreas.Items.Contains(oldSelect))
            {
                cbxPatrolAreas.SelectedIndex = cbxPatrolAreas.Items.IndexOf(oldSelect);
            }
        }