示例#1
0
 public void updateview2()
 {
     if (Delaunay.Checked && dlay.Count > 0)
     {
         Delaunay.PerformClick();
     }
     if (Tyson.Checked && dlay.Count > 0)
     {
         Tyson.PerformClick();
     }
 }
示例#2
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            if (MouseOnMap)
            {
                MouseOnMap = false;
                switch (MouseCommand)
                {
                case MOUSECOMMAND.Select:
                    for (int i = 0; i < document.layers.Count; i++)
                    {
                        document.layers[i].ClearSelection();
                    }
                    if (e.X == MouseStartX && e.Y == MouseStartY)
                    {
                        for (int i = 0; i < document.layers.Count; i++)
                        {
                            GISFeature feature = document.layers[i].SelectByClick(new Point(e.X, e.Y), view);
                            if (feature != null)
                            {
                                feature.Selected = true;
                            }
                        }
                    }
                    else
                    {
                        GISExtent extent = view.RectToExtent(new Rectangle(
                                                                 Math.Min(e.X, MouseStartX),
                                                                 Math.Min(e.Y, MouseStartY),
                                                                 Math.Abs(e.X - MouseStartX),
                                                                 Math.Abs(e.Y - MouseStartY)));
                        for (int i = 0; i < document.layers.Count; i++)
                        {
                            List <GISFeature> features = document.layers[i].SelectByExtent(extent);
                            for (int j = 0; j < features.Count; j++)
                            {
                                features[j].Selected = true;
                            }
                        }
                    }
                    updateview();

                    if (layerDialog != null)
                    {
                        layerDialog.UpdateSelection();
                    }
                    break;

                case MOUSECOMMAND.ZoomIn:
                    if (e.X == MouseStartX && e.Y == MouseStartY)
                    {
                        GISVertex MouseLocation = view.ToMapVertex(new Point(e.X, e.Y));
                        double    ZoomInfactor  = 0.8;
                        double    newwidth      = view.CurrentMapExtent.Width * ZoomInfactor;
                        double    newheight     = view.CurrentMapExtent.Height * ZoomInfactor;
                        double    newminx       = MouseLocation.x - (MouseLocation.x - view.CurrentMapExtent.MinX) * ZoomInfactor;
                        double    newminy       = MouseLocation.y - (MouseLocation.y - view.CurrentMapExtent.MinY) * ZoomInfactor;
                        view.CurrentMapExtent.SetValue(new GISVertex(newminx, newminy), new GISVertex(newminx + newwidth, newminy + newheight));
                    }
                    else
                    {
                        view.CurrentMapExtent = view.RectToExtent(new Rectangle(
                                                                      Math.Min(e.X, MouseStartX),
                                                                      Math.Min(e.Y, MouseStartY),
                                                                      Math.Abs(e.X - MouseStartX),
                                                                      Math.Abs(e.Y - MouseStartY)));
                    }
                    if (Delaunay.Checked || Tyson.Checked)
                    {
                        updateview2();
                    }
                    else
                    {
                        updateview();
                    }
                    break;

                case MOUSECOMMAND.ZoomOut:
                    if (e.X == MouseStartX && e.Y == MouseStartY)
                    {
                        GISVertex MouseLocation = view.ToMapVertex(new Point(e.X, e.Y));
                        double    ZoomOutfactor = 0.8;
                        double    newwidth      = view.CurrentMapExtent.Width / ZoomOutfactor;
                        double    newheight     = view.CurrentMapExtent.Height / ZoomOutfactor;
                        double    newminx       = MouseLocation.x - (MouseLocation.x - view.CurrentMapExtent.MinX) / ZoomOutfactor;
                        double    newminy       = MouseLocation.y - (MouseLocation.y - view.CurrentMapExtent.MinY) / ZoomOutfactor;
                        view.CurrentMapExtent.SetValue(new GISVertex(newminx, newminy), new GISVertex(newminx + newwidth, newminy + newheight));
                    }
                    else
                    {
                        GISExtent extent = view.RectToExtent(new Rectangle(
                                                                 Math.Min(e.X, MouseStartX),
                                                                 Math.Min(e.Y, MouseStartY),
                                                                 Math.Abs(e.X - MouseStartX),
                                                                 Math.Abs(e.Y - MouseStartY)));
                        double newwidth  = view.CurrentMapExtent.Width * view.CurrentMapExtent.Width / extent.Width;
                        double newheight = view.CurrentMapExtent.Height * view.CurrentMapExtent.Height / extent.Height;
                        double newminx   = extent.MinX - (extent.MinX - view.CurrentMapExtent.MinX) * newwidth / view.CurrentMapExtent.Width;
                        double newminy   = extent.MinY - (extent.MinY - view.CurrentMapExtent.MinY) * newheight / view.CurrentMapExtent.Height;
                        view.CurrentMapExtent.SetValue(new GISVertex(newminx, newminy), new GISVertex(newminx + newwidth, newminy + newheight));
                    }
                    if (Delaunay.Checked || Tyson.Checked)
                    {
                        updateview2();
                    }
                    else
                    {
                        updateview();
                    }
                    break;

                case MOUSECOMMAND.Pan:
                    GISVertex C1 = view.CurrentMapExtent.MapCenter;
                    GISVertex M1 = view.ToMapVertex(new Point(MouseStartX, MouseStartY));
                    GISVertex M2 = view.ToMapVertex(new Point(e.X, e.Y));
                    GISVertex C2 = new GISVertex(C1.x - (M2.x - M1.x), C1.y - (M2.y - M1.y));
                    view.CurrentMapExtent.SetMapCenter(C2);
                    updateview();
                    if (Delaunay.Checked && dlay.Count > 0)
                    {
                        Delaunay.PerformClick();
                    }
                    if (Tyson.Checked && dlay.Count > 0)
                    {
                        Tyson.PerformClick();
                    }
                    break;

                case MOUSECOMMAND.Dis:
                    GISVertex v1  = view.ToMapVertex(new Point(MouseStartX, MouseStartY));
                    GISVertex v2  = view.ToMapVertex(new Point(e.X, e.Y));
                    double    dis = Math.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y));
                    MessageBox.Show(dis.ToString());
                    break;
                }
            }
        }