Exemple #1
0
        private Target GetTarget()
        {
            Target target;

            if (
                Type == TargetType.UNASSIGNED
                )
            {
                var info = InitializeTarget.GetInfo(Type, false);

                switch (info.type)
                {
                case TargetType.DROP:
                    target = new DropTarget();
                    break;

                case TargetType.LETTER:
                    target = new LetterTarget(info.letter);
                    break;

                case TargetType.UNKNOWN:
                    target = new UnknownTarget(info.desc);
                    break;

                // Shouldn't get here, as InitializeTarget.GetInfo() doesn't return TargetType.UNASSIGNED
                default:
                    target = null;
                    break;
                }
            }
            else if (Type == TargetType.DROP)
            {
                target = new DropTarget();
            }
            else if (Type == TargetType.LETTER)
            {
                target = new LetterTarget(Letter);
            }
            else if (Type == TargetType.UNKNOWN)
            {
                target = new UnknownTarget(UnknownDescription);
            }
            else
            {
                // Shouldn't get here, covers all cases of TargetType
                target = null;
            }

            target.Latitude  = Latitudes.Sum() / Latitudes.Count;
            target.Longitude = Longitudes.Sum() / Longitudes.Count;

            return(target);
        }
Exemple #2
0
        private void addRow(DropTarget target, int index)
        {
            // The index above is the index in the array of targets
            // The index will be used as a display index, and row 0 is used by the 'generate' and 'cancel' buttons
            index++;

            this.selected.Add(false);

            var addButton = new Controls.MyButton {
                Location = new Point(12, 12 + 45 * index),
                Name     = $"addButton_{index}",
                Size     = new Size(60, 21),
                TabIndex = index * 2,
                Text     = "Add",
                UseVisualStyleBackColor = true
            };

            // Convert between display index and data index
            addButton.Click += GetAddClickHandler(index - 1);

            this.addButtons.Add(addButton);
            this.Controls.Add(addButton);

            var removeButton = new Controls.MyButton {
                Location = new Point(84, 12 + 45 * index),
                Name     = $"removeButton_{index}",
                Size     = new Size(60, 21),
                TabIndex = index * 2 + 1,
                Text     = "Remove",
                Enabled  = false,
                UseVisualStyleBackColor = true
            };

            // Convert between display index and data index
            removeButton.Click += GetRemoveClickHandler(index - 1);

            this.Controls.Add(removeButton);
            this.removeButtons.Add(removeButton);

            var dropTargetIndexLabel = new Label {
                Location  = new Point(156, 12 + 45 * index),
                Size      = new Size(20, 21),
                Name      = $"indexLabel_{index}",
                Text      = $"{index}",
                TextAlign = ContentAlignment.MiddleLeft
            };

            this.Controls.Add(dropTargetIndexLabel);
        }