Ejemplo n.º 1
0
        public GroupDialog(Map.GroupData groupData)
        {
            InitializeComponent();

            groups = new List <MapGroup>();
            foreach (var g in groupData.Values)
            {
                var mg = new MapGroup(g.name, g.id, (int)g.type, g.ExtentsToString());
                groups.Add(mg);
            }
            ReloadUI();
        }
Ejemplo n.º 2
0
        private void newButton_Click(object sender, EventArgs e)
        {
            // First see if user typed in a name, otherwise make one up
            var newName = txtGroupName.Text.Trim();

            if ((newName == "") || (lstGroups.Items.Contains(newName)))
            {
                var i = 1;
                while (lstGroups.Items.Contains("NewGroup" + i))
                {
                    i++;
                }
                newName = "NewGroup" + i;
            }

            var newGroup = new MapGroup(newName, GetNextGroupID(), GetGroupType(), "");

            groups.Add(newGroup);
            ReloadUI();
            lstGroups.SelectedIndex = lstGroups.Items.Count - 1;
        }
Ejemplo n.º 3
0
        private Map.Group GenerateGroup(MapGroup g)
        {
            // MapGroup ==> Map.Group
            var newGroup = new Map.Group(g.Name, (Map.Group.GroupTypes)g.Type, g.ID);
            var extents  = g.Extents.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var extent in extents)
            {
                try
                {
                    switch (g.Type)
                    {
                    case 0:
                    case 1:
                        newGroup.Add(int.Parse(extent.Trim()));
                        break;

                    case 2:
                        var point = extent.Trim().Split(',');
                        newGroup.Add(new Point(int.Parse(point[0]), int.Parse(point[1])));
                        break;
                    }
                }
                catch
                {
                    if (lstGroups.Items.Contains(g.Name))
                    {
                        lstGroups.SelectedItem = g.Name;
                    }
                    MessageBox.Show("Failed to parse extents:\n\nGroup: " + g.Name + "\nExtent: " + extent, "Invalid Argument", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(null);
                }
            }

            return(newGroup);
        }