private void areaModify_Click(object sender, EventArgs e)
        {
            if (facetView.SelectedNode != null)
            {
                RegionTag tag = (RegionTag)facetView.SelectedNode.Tag;
                Region    r   = tag.Parent;

                RegionArea ra = r.Area[tag.Index];

                SpecifyArea sa = new SpecifyArea();
                sa.Initialize(xSlider.Maximum, ySlider.Maximum, ra.Area, ra.ZMin);
                sa.ShowDialog(this);

                if (sa.Canceled)
                {
                    return;
                }

                Rectangle area = sa.Area;
                int       zmin = sa.zMin;

                ChangesMade = true;

                facetView.SelectedNode.Text = String.Format("x={0}, y={1}, width={2}, height={3}{4}", area.X, area.Y, area.Width, area.Height,
                                                            (zmin != 9999 ? String.Format(", zmin={0}", zmin) : ""));

                r.Area[tag.Index] = new RegionArea(area, zmin);
            }
        }
Esempio n. 2
0
        private void addArea_Click(object sender, EventArgs e)
        {
            Rectangle rect = mapDisplay.HighlightedArea;
            int zMin = 9999;

            if (rect.Width <= 0)
            {
                SpecifyArea sa = new SpecifyArea();
                sa.Initialize(xSlider.Maximum, ySlider.Maximum);
                sa.ShowDialog();

                if (sa.Canceled)
                    return;

                rect = sa.Area;
                zMin = sa.zMin;
            }

            Region r = null;
            TreeNode node = null;

            FindRegionNode(ref r, ref node, false);

            if (node == null || r == null)
                return;

            ChangesMade = true;

            foreach (RegionArea area in r.Area)
            {
                if (area.Area.X == rect.X &&
                    area.Area.Y == rect.Y &&
                    area.Area.Width == rect.Width &&
                    area.Area.Height == rect.Height)
                    return;
            }

            RegionArea newArea = new RegionArea(rect, zMin);
            r.Area.Add(newArea);

            bool areaNodeFound = false;

            foreach (TreeNode child in node.Nodes)
            {
                RegionTag tag = (RegionTag)child.Tag;

                if (tag.Reference == "area")
                {
                    areaNodeFound = true;

                    TreeNode areaNode = new TreeNode(String.Format("x={0}, y={1}, width={2}, height={3}{4}", newArea.Area.X, newArea.Area.Y,
                        newArea.Area.Width, newArea.Area.Height, (newArea.ZMin != 9999 ? String.Format(", zmin={0}", newArea.ZMin) : "")));
                    areaNode.Tag = new RegionTag(r, "regionarea", r.Area.Count - 1);
                    child.Nodes.Add(areaNode);
                }
            }

            if (!areaNodeFound)
            {
                TreeNode childNode = new TreeNode("Area");
                childNode.Tag = new RegionTag(r, "area");

                TreeNode areaNode = new TreeNode(String.Format("x={0}, y={1}, width={2}, height={3}{4}", newArea.Area.X, newArea.Area.Y,
                    newArea.Area.Width, newArea.Area.Height, (newArea.ZMin != 9999 ? String.Format(", zmin={0}", newArea.ZMin) : "")));
                areaNode.Tag = new RegionTag(r, "regionarea", r.Area.Count - 1);
                childNode.Nodes.Add(areaNode);

                node.Nodes.Add(childNode);
            }
        }
        private void addArea_Click(object sender, EventArgs e)
        {
            Rectangle rect = mapDisplay.HighlightedArea;
            int       zMin = 9999;

            if (rect.Width <= 0)
            {
                SpecifyArea sa = new SpecifyArea();
                sa.Initialize(xSlider.Maximum, ySlider.Maximum);
                sa.ShowDialog();

                if (sa.Canceled)
                {
                    return;
                }

                rect = sa.Area;
                zMin = sa.zMin;
            }

            Region   r    = null;
            TreeNode node = null;

            FindRegionNode(ref r, ref node, false);

            if (node == null || r == null)
            {
                return;
            }

            ChangesMade = true;

            foreach (RegionArea area in r.Area)
            {
                if (area.Area.X == rect.X &&
                    area.Area.Y == rect.Y &&
                    area.Area.Width == rect.Width &&
                    area.Area.Height == rect.Height)
                {
                    return;
                }
            }

            RegionArea newArea = new RegionArea(rect, zMin);

            r.Area.Add(newArea);

            bool areaNodeFound = false;

            foreach (TreeNode child in node.Nodes)
            {
                RegionTag tag = (RegionTag)child.Tag;

                if (tag.Reference == "area")
                {
                    areaNodeFound = true;

                    TreeNode areaNode = new TreeNode(String.Format("x={0}, y={1}, width={2}, height={3}{4}", newArea.Area.X, newArea.Area.Y,
                                                                   newArea.Area.Width, newArea.Area.Height, (newArea.ZMin != 9999 ? String.Format(", zmin={0}", newArea.ZMin) : "")));
                    areaNode.Tag = new RegionTag(r, "regionarea", r.Area.Count - 1);
                    child.Nodes.Add(areaNode);
                }
            }

            if (!areaNodeFound)
            {
                TreeNode childNode = new TreeNode("Area");
                childNode.Tag = new RegionTag(r, "area");

                TreeNode areaNode = new TreeNode(String.Format("x={0}, y={1}, width={2}, height={3}{4}", newArea.Area.X, newArea.Area.Y,
                                                               newArea.Area.Width, newArea.Area.Height, (newArea.ZMin != 9999 ? String.Format(", zmin={0}", newArea.ZMin) : "")));
                areaNode.Tag = new RegionTag(r, "regionarea", r.Area.Count - 1);
                childNode.Nodes.Add(areaNode);

                node.Nodes.Add(childNode);
            }
        }
Esempio n. 4
0
        private void areaModify_Click(object sender, EventArgs e)
        {
            if (facetView.SelectedNode != null)
            {
                RegionTag tag = (RegionTag)facetView.SelectedNode.Tag;
                Region r = tag.Parent;

                RegionArea ra = r.Area[tag.Index];

                SpecifyArea sa = new SpecifyArea();
                sa.Initialize(xSlider.Maximum, ySlider.Maximum, ra.Area, ra.ZMin);
                sa.ShowDialog(this);

                if (sa.Canceled)
                    return;

                Rectangle area = sa.Area;
                int zmin = sa.zMin;

                ChangesMade = true;

                facetView.SelectedNode.Text = String.Format("x={0}, y={1}, width={2}, height={3}{4}", area.X, area.Y, area.Width, area.Height,
                    (zmin != 9999 ? String.Format(", zmin={0}", zmin) : ""));

                r.Area[tag.Index] = new RegionArea(area, zmin);
            }
        }