private void groupList_SelectedValueChanged(object sender, EventArgs e) { itemList.Clear(); if (groupList.Text.Length > 0) { selected = groupData.ContainsKey((string)groupList.Text) ? groupData[(string)groupList.Text] : new Map.Group((string)groupList.Text, Map.Group.GroupTypes.objects, 0); switch (selected.type) { case Map.Group.GroupTypes.objects: foreach (Int32 i in selected) { itemList.Text += String.Format("{0}\r\n", i); } wallRadio.Checked = false; objectRadio.Checked = true; waypointRadio.Checked = false; break; case Map.Group.GroupTypes.waypoint: foreach (Int32 i in selected) { itemList.Text += String.Format("{0}\r\n", i); } wallRadio.Checked = false; objectRadio.Checked = false; waypointRadio.Checked = true; break; case Map.Group.GroupTypes.walls: foreach (Point pt in selected) { itemList.Text += String.Format("{0},{1}\r\n", pt.X, pt.Y); } wallRadio.Checked = true; objectRadio.Checked = false; waypointRadio.Checked = false; break; } groupId.Text = selected.id.ToString(); } else { selected = null; } }
private void groupList_SelectedValueChanged(object sender, EventArgs e) { itemList.Clear(); if (groupList.Text.Length > 0) { selected = groupData.ContainsKey((string)groupList.Text) ? groupData[(string)groupList.Text] : new Map.Group((string)groupList.Text, Map.Group.GroupTypes.objects, 0); switch (selected.type) { case Map.Group.GroupTypes.objects: foreach (Int32 i in selected) itemList.Text += String.Format("{0}\r\n", i); wallRadio.Checked = false; objectRadio.Checked = true; waypointRadio.Checked = false; break; case Map.Group.GroupTypes.waypoint: foreach (Int32 i in selected) itemList.Text += String.Format("{0}\r\n", i); wallRadio.Checked = false; objectRadio.Checked = false; waypointRadio.Checked = true; break; case Map.Group.GroupTypes.walls: foreach (Point pt in selected) itemList.Text += String.Format("{0},{1}\r\n", pt.X, pt.Y); wallRadio.Checked = true; objectRadio.Checked = false; waypointRadio.Checked = false; break; } groupId.Text = selected.id.ToString(); } else selected = null; }
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); }