示例#1
0
 // This replaces the elements with those from another
 public void ReplaceElements(CommentInfo other)
 {
     this.elements = other.elements;
 }
示例#2
0
        // This selects the elements in a comment
        private static void SelectComment(CommentInfo c, bool clear)
        {
            //string editmode = "";

            // Leave any volatile mode
            General.Editing.CancelVolatileMode();

            if (clear)
            {
                General.Map.Map.ClearAllSelected();

                if (c.Elements[0] is Thing)
                {
                    General.Editing.ChangeMode("ThingsMode");
                }
                else if (c.Elements[0] is Vertex)
                {
                    General.Editing.ChangeMode("VerticesMode");
                }
                else if ((c.Elements[0] is Linedef) || (c.Elements[0] is Sidedef))
                {
                    General.Editing.ChangeMode("LinedefsMode");
                }
                else if (c.Elements[0] is Sector)
                {
                    General.Editing.ChangeMode("SectorsMode");
                }
            }
            else
            {
                if (!(c.Elements[0] is Thing))
                {
                    // Sectors mode is a bitch because it deals with selections somewhat aggressively
                    // so we have to switch to linedefs to make this work right
                    if ((General.Editing.Mode.GetType().Name == "VerticesMode") ||
                        (General.Editing.Mode.GetType().Name == "SectorsMode") ||
                        (General.Editing.Mode.GetType().Name == "MakeSectorMode"))
                    {
                        General.Editing.ChangeMode("LinedefsMode");
                    }
                }
            }

            // Select the map elements
            foreach (MapElement obj in c.Elements)
            {
                if (obj is SelectableElement)
                {
                    (obj as SelectableElement).Selected = true;

                    if (obj is Sector)
                    {
                        foreach (Sidedef sd in (obj as Sector).Sidedefs)
                        {
                            sd.Line.Selected = true;
                        }
                    }
                }
            }

            General.Editing.Mode.UpdateSelectionInfo();             //mxd
            General.Interface.RedrawDisplay();
        }
示例#3
0
        // Mouse released
        private void grid_MouseUp(object sender, MouseEventArgs e)
        {
            CommentInfo c = GetSelectedComment();

            // Show popup menu?
            if ((e.Button == MouseButtons.Right) && (c != null))
            {
                // Determine objects type
                string objname = "";
                if ((c.Elements[0] is Vertex) && (c.Elements.Count > 1))
                {
                    objname = "Vertices";
                }
                else if ((c.Elements[0] is Vertex) && (c.Elements.Count == 1))
                {
                    objname = "Vertex";
                }
                else if (((c.Elements[0] is Linedef) || (c.Elements[0] is Sidedef)) && (c.Elements.Count > 1))
                {
                    objname = "Linedefs";
                }
                else if (((c.Elements[0] is Linedef) || (c.Elements[0] is Sidedef)) && (c.Elements.Count == 1))
                {
                    objname = "Linedef";
                }
                else if ((c.Elements[0] is Sector) && (c.Elements.Count > 1))
                {
                    objname = "Sectors";
                }
                else if ((c.Elements[0] is Sector) && (c.Elements.Count == 1))
                {
                    objname = "Sector";
                }
                else if ((c.Elements[0] is Thing) && (c.Elements.Count > 1))
                {
                    objname = "Things";
                }
                else if ((c.Elements[0] is Thing) && (c.Elements.Count == 1))
                {
                    objname = "Thing";
                }
                editobjectitem.Text = "Edit " + objname + "...";

                // Show popup menu
                Point screenpos = grid.PointToScreen(new Point(e.X, e.Y));
                contextmenu.Tag = c;
                contextmenu.Show(screenpos);
            }
            else
            {
                // View selected comment
                if (c != null)
                {
                    ViewComment(c);

                    if (clickselects.Checked)
                    {
                        SelectComment(c, true);
                    }
                }

                LoseFocus();
            }
        }
示例#4
0
        // This changes the view to see the objects of a comment
        private static void ViewComment(CommentInfo c)
        {
            List <Vector2D> points = new List <Vector2D>();
            RectangleF      area   = MapSet.CreateEmptyArea();

            // Add all points to a list
            foreach (MapElement obj in c.Elements)
            {
                if (obj is Vertex)
                {
                    points.Add((obj as Vertex).Position);
                }
                else if (obj is Linedef)
                {
                    points.Add((obj as Linedef).Start.Position);
                    points.Add((obj as Linedef).End.Position);
                }
                else if (obj is Sidedef)
                {
                    points.Add((obj as Sidedef).Line.Start.Position);
                    points.Add((obj as Sidedef).Line.End.Position);
                }
                else if (obj is Sector)
                {
                    Sector s = (obj as Sector);
                    foreach (Sidedef sd in s.Sidedefs)
                    {
                        points.Add(sd.Line.Start.Position);
                        points.Add(sd.Line.End.Position);
                    }
                }
                else if (obj is Thing)
                {
                    Thing    t = (obj as Thing);
                    Vector2D p = t.Position;
                    points.Add(p);
                    points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f));
                    points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f));
                    points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f));
                    points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f));
                }
                else
                {
                    General.Fail("Unknown object given to zoom in on.");
                }
            }

            // Make a view area from the points
            foreach (Vector2D p in points)
            {
                area = MapSet.IncreaseArea(area, p);
            }

            // Make the area square, using the largest side
            if (area.Width > area.Height)
            {
                float delta = area.Width - area.Height;
                area.Y      -= delta * 0.5f;
                area.Height += delta;
            }
            else
            {
                float delta = area.Height - area.Width;
                area.X     -= delta * 0.5f;
                area.Width += delta;
            }

            // Add padding
            area.Inflate(100f, 100f);

            // Zoom to area
            ClassicMode editmode = (General.Editing.Mode as ClassicMode);

            editmode.CenterOnArea(area, 0.6f);
        }