Esempio n. 1
0
    public bool RemoveEdge(FVertex from, FVertex to)
    {
        if (from == null)
        {
            throw new ArgumentNullException("from");
        }

        if (to == null)
        {
            throw new ArgumentNullException("to");
        }


        for (int i = 0; i < graphEdges.Count; i++)
        {
            if (((graphEdges [i].FromVertex == from) && (graphEdges [i].ToVertex == to)) ||
                ((graphEdges [i].FromVertex == to) && (graphEdges [i].ToVertex == from)))
            {
                RemoveEdge(graphEdges [i]);
                return(true);
            }
        }


        return(false);
    }
Esempio n. 2
0
    public FEdge AddEdge(FVertex from, FVertex to, String type)
    {
        FEdge edge = new FEdge(from, to, type);

        AddEdge(edge);
        return(edge);
    }
Esempio n. 3
0
 public void Clear()
 {
     /*foreach (FEdge e in graphEdges) {
      *      Destroy(e.FromVertex.Data);
      *      Destroy(e.FromVertex);
      *      Destroy(e.ToVertex.Data);
      *      Destroy(e.ToVertex);
      *      Destroy(e);
      * }
      * foreach (FVertex f in graphVertices) {
      *      Destroy(f.Data);
      *      Destroy(f);
      * }*/
     graphVertices.Clear();
     graphVertices = new List <FVertex>();
     graphEdges.Clear();
     graphEdges = new List <FEdge>();
     characters.Clear();
     characters = new List <FVertex>();
     humans.Clear();
     humans = new List <FVertex>();
     //Destroy(center.Data);
     //Destroy(center);
     center = null;
 }
Esempio n. 4
0
 void panel1_MouseWheel(object sender, MouseEventArgs e)
 {
     try
     {
         if (layer != null && panel1.Bounds.Contains(e.Location))
         {
             if (e.Delta > 0)
             {
                 FVertex mouselocation = view.ToMapVertex(new Point(e.X, e.Y));
                 double  ZoomInfactor  = 0.85;
                 double  newwidth      = view.MyMapExtent.width * ZoomInfactor;
                 double  newheight     = view.MyMapExtent.height * ZoomInfactor;
                 double  newminx       = mouselocation.getX() - (mouselocation.getX() - view.MyMapExtent.minX) * ZoomInfactor;
                 double  newminy       = mouselocation.getY() - (mouselocation.getY() - view.MyMapExtent.minY) * ZoomInfactor;
                 view.MyMapExtent.setValue(new FVertex(newminx + newwidth, newminy + newheight), new FVertex(newminx, newminy));
                 DrawMap();
             }
             else if (e.Delta < 0)
             {
                 FVertex mouselocation = view.ToMapVertex(new Point(e.X, e.Y));
                 double  ZoomInfactor  = 0.85;
                 double  newwidth      = view.MyMapExtent.width / ZoomInfactor;
                 double  newheight     = view.MyMapExtent.height / ZoomInfactor;
                 double  newminx       = mouselocation.getX() - (mouselocation.getX() - view.MyMapExtent.minX) / ZoomInfactor;
                 double  newminy       = mouselocation.getY() - (mouselocation.getY() - view.MyMapExtent.minY) / ZoomInfactor;
                 view.MyMapExtent.setValue(new FVertex(newminx + newwidth, newminy + newheight), new FVertex(newminx, newminy));
                 DrawMap();
             }
         }
     }
     catch
     {
         MessageBox.Show("Error");
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Graph&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="isDirected">if set to <c>true</c> [is directed].</param>
 public FGraph()
 {
     graphVertices = new List<FVertex> ();
     graphEdges = new List<FEdge> ();
     characters = new List<FVertex>();
     humans = new List<FVertex>();
     center = null;
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Graph&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="isDirected">if set to <c>true</c> [is directed].</param>
 public FGraph()
 {
     graphVertices = new List <FVertex> ();
     graphEdges    = new List <FEdge> ();
     characters    = new List <FVertex>();
     humans        = new List <FVertex>();
     center        = null;
 }
Esempio n. 7
0
 public FVertex GetPartnerVertex(FVertex vertex)
 {
     if (from == vertex) {
         return to;
     } else if (to == vertex) {
         return from;
     } else {
         throw new ArgumentException ("Vertex not part of edge");
     }
 }
Esempio n. 8
0
 public static void LinkToAllChars(FVertex f)
 {
     // go through list of chars, check if same as n, if not, add edge
     foreach (FVertex curChar in g.characters)
     {
         if (curChar.Data.name != f.Data.name)
         {
             Forces.g.AddEdge(f, curChar, "character");
         }
     }
 }
Esempio n. 9
0
    public FEdge GetEdgeTo(FVertex toVertex)
    {
        for (int i = 0; i < edges.Count; i++)
        {
            if ((edges[i].FromVertex == toVertex) || (edges[i].ToVertex == toVertex))
            {
                return(edges[i]);
            }
        }

        return(null);
    }
Esempio n. 10
0
    public bool HasEdgeTo(FVertex toVertex)
    {
        for (int i = 0; i < edges.Count; i++)
        {
            if ((edges[i].ToVertex == toVertex) || ((edges[i].FromVertex == toVertex)))
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 11
0
    public bool HasEdgeTo(FVertex toVertex)
    {
        for (int i = 0; i < edges.Count; i++)
        {

                if ((edges[i].ToVertex == toVertex) || ((edges[i].FromVertex == toVertex)))
                {
                    return true;
                }

        }

        return false;
    }
Esempio n. 12
0
    public FEdge GetEdgeTo(FVertex toVertex)
    {
        for (int i = 0; i < edges.Count; i++)
        {

                if ((edges[i].FromVertex == toVertex) || (edges[i].ToVertex == toVertex))
                {
                    return edges[i];
                }

        }

        return null;
    }
Esempio n. 13
0
    public FVertex AddVertex(Node item)
    {
        FVertex vertex = new FVertex(item);

        if (vertex.Data.type == "char")
        {
            characters.Add(vertex);
        }
        if (vertex.Data.type == "human")
        {
            humans.Add(vertex);
        }
        graphVertices.Add(vertex);
        return(vertex);
    }
Esempio n. 14
0
    public FEdge(FVertex fromVertex, FVertex toVertex, double weight, String t)
    {
        if (fromVertex == null) {
            throw new ArgumentNullException ("fromVertex");
        }

        if (toVertex == null) {
            throw new ArgumentNullException ("toVertex");
        }

        from = fromVertex;
        to = toVertex;
        edgeWeight = weight;
        type = t;
    }
Esempio n. 15
0
 public FVertex GetPartnerVertex(FVertex vertex)
 {
     if (from == vertex)
     {
         return(to);
     }
     else if (to == vertex)
     {
         return(from);
     }
     else
     {
         throw new ArgumentException("Vertex not part of edge");
     }
 }
Esempio n. 16
0
    public FEdge(FVertex fromVertex, FVertex toVertex, double weight, String t)
    {
        if (fromVertex == null)
        {
            throw new ArgumentNullException("fromVertex");
        }

        if (toVertex == null)
        {
            throw new ArgumentNullException("toVertex");
        }

        from       = fromVertex;
        to         = toVertex;
        edgeWeight = weight;
        type       = t;
    }
Esempio n. 17
0
    public void AddVertex(FVertex vertex)
    {
        if (graphVertices.Contains(vertex))
        {
            throw new ArgumentException("Vertex already exists");
        }
        if (vertex.Data.type == "char")
        {
            characters.Add(vertex);
        }
        if (vertex.Data.type == "human")
        {
            humans.Add(vertex);
        }

        graphVertices.Add(vertex);
    }
 public static void LinkToAllChars(FVertex f)
 {
     // go through list of chars, check if same as n, if not, add edge
     foreach (FVertex curChar in g.characters)
     {
         if (curChar.Data.name != f.Data.name)
         {
             Forces.g.AddEdge(f, curChar, "character");
         }
     }
     if (g.humans.Count > 0)           // link everyone to the human!!!
     {
         if (f.Data.name != g.humans[0].Data.name)
         {
             Forces.g.AddEdge(f, g.humans[0], "human");
             Debug.Log("Added link to human");
         }
     }
 }
Esempio n. 19
0
    public bool RemoveVertex(FVertex vertex)
    {
        if (vertex == null)
        {
            throw new ArgumentNullException("vertex");
        }

        if (!graphVertices.Remove(vertex))
        {
            return(false);
        }
        else
        {
            // Delete all the edges in which this vertex forms part of
            List <FEdge> list = vertex.EdgeList;

            while (list.Count > 0)
            {
                RemoveEdge(list [0]);
            }

            return(true);
        }
    }
Esempio n. 20
0
        public void DrawMap()
        {
            view.SetValue(view.MyMapExtent, panel1.ClientRectangle);
            if (backwindow != null)
            {
                backwindow.Dispose();
            }
            backwindow = new Bitmap(panel1.ClientRectangle.Width, panel1.ClientRectangle.Height);
            Graphics g = Graphics.FromImage(backwindow);

            g.FillRectangle(new SolidBrush(Color.AliceBlue), panel1.ClientRectangle);

            FVertex v1            = view.ToMapVertex(new Point(0, view.myWindowSize.Height - 1));
            FVertex v2            = view.ToMapVertex(new Point(view.myWindowSize.Width - 1, 0));
            FExtent displayextent = new FExtent(v2, v1);

            if (layer != null)
            {
                layer.draw(g, view, displayextent);
            }
            Graphics graphics = panel1.CreateGraphics();

            graphics.DrawImage(backwindow, 0, 0);
        }
Esempio n. 21
0
 public FVertex AddVertex(Node item)
 {
     FVertex vertex = new FVertex (item);
     if (vertex.Data.type == "char") {
         characters.Add (vertex);
     }
     if (vertex.Data.type == "human") {
         humans.Add (vertex);
     }
     graphVertices.Add (vertex);
     return vertex;
 }
Esempio n. 22
0
    public void AddVertex(FVertex vertex)
    {
        if (graphVertices.Contains (vertex)) {
            throw new ArgumentException ("Vertex already exists");
        }
        if (vertex.Data.type == "char") {
            characters.Add (vertex);
        }
        if (vertex.Data.type == "human") {
            humans.Add (vertex);
        }

        graphVertices.Add (vertex);
    }
Esempio n. 23
0
 public void AddEdge(FVertex from, FVertex to, double weight, String type)
 {
     FEdge edge = new FEdge (from, to, weight, type);
     AddEdge (edge);
 }
Esempio n. 24
0
 public FEdge AddEdge(FVertex from, FVertex to, String type)
 {
     FEdge edge = new FEdge (from, to, type);
     AddEdge (edge);
     return edge;
 }
Esempio n. 25
0
 public FEdge(FVertex fromVertex, FVertex toVertex, String t)
     : this(fromVertex, toVertex, 0, t)
 {
 }
Esempio n. 26
0
    public void AddEdge(FVertex from, FVertex to, double weight, String type)
    {
        FEdge edge = new FEdge(from, to, weight, type);

        AddEdge(edge);
    }
Esempio n. 27
0
 public FEdge GetEdge(FVertex from, FVertex to)
 {
     return(from.GetEdgeTo(to));
 }
Esempio n. 28
0
 public Node(String n, String m, String t, float a, float b, FVertex f)
     : this(n,m,t,a,b,f,null)
 {
 }
Esempio n. 29
0
    public Node(String n, String m, String t, float a, float b, FVertex f, CharFuncs g)
    {
        name     = n;
        calledby = m;
        type     = t;
        x        = a;
        y        = b;
        if (f == null)
        {
            fvert = new FVertex(this);
        }
        else
        {
            fvert = f;
        }
        origObj = g;
        switch (type)
        {
        case "char":
            disp       = new Vector2(0f, 0f);
            pos        = new Vector2(x, y);
            ismoveable = true;
            // add to char list & all
            //Forces.g.characters.Add (fvert); // how do I get this vertex to add here?
            Forces.g.AddVertex(fvert);             // really should have this as the vertex - maybe put the logic to add to char list when do vertex?
            // add audience
            FVertex aud2 = Forces.g.AddVertex(new Node(this.name + "A", this.name + "A", "audience", this.x, Forces.L + 5, null));
            aud = aud2.Data;
            // add audience link
            Forces.g.AddEdge(fvert, aud2, "audience");

            // add links to all other chars
            Forces.LinkToAllChars(fvert);
            // create center or link to center
            if (Forces.g.center == null && (Forces.g.characters.Count + Forces.g.humans.Count >= 2))
            {
                Debug.Log("CREATED CENTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                new Node("CENTER", "CENTER", "center", this.x, this.y, null);
                Forces.LinkToAllChars(Forces.g.center);
            }
            else if (Forces.g.center != null)
            {
                Forces.g.AddEdge(Forces.g.center, fvert, "center");
            }

            // recalculate center
            Forces.recalcCenter();
            break;

        case "target":
            disp       = new Vector2(0f, 0f);
            pos        = new Vector2(x, y);
            ismoveable = false;
            // add to all
            Forces.g.AddVertex(fvert);
            break;

        case "human":
            calledby   = "HUMAN";
            disp       = new Vector2(0f, 0f);
            pos        = new Vector2(x, y);
            ismoveable = false;
            // capture original as x&y?
            orig.x = x;
            orig.y = y;
            // add to all
            Forces.g.AddVertex(fvert);
            // add to humans - done above
            //add audience
            FVertex haud = Forces.g.AddVertex(new Node(this.name + "A", this.name + "A", "audience", this.x, Forces.L + 5, null));
            aud = haud.Data;
            // add audience link
            Forces.g.AddEdge(fvert, haud, "audience");


            // add links to all other chars
            Forces.LinkToAllChars(fvert);
            // create center or link to center
            if (Forces.g.center == null && Forces.g.characters.Count + Forces.g.humans.Count >= 2)
            {
                new Node("CENTER", "CENTER", "center", this.x, this.y, null);
                Forces.LinkToAllChars(Forces.g.center);
            }
            else if (Forces.g.center != null)
            {
                Forces.g.AddEdge(Forces.g.center, fvert, "center");
            }

            // recalculate center
            Forces.recalcCenter();
            break;

        case "center":
            // calculate x & y using chars and humans (sum them then divide by count of two groups)
            calledby   = "CENTER";
            disp       = new Vector2(0f, 0f);
            pos        = new Vector2(x, y);
            ismoveable = true;
            // add to all
            Forces.g.AddVertex(fvert);              // duplicates the center vertex - don't do!!
            Forces.g.center = fvert;
            // add to chars???
            // create link to self for all chars & humans
            // create audience
            FVertex caud = Forces.g.AddVertex(new Node(this.name + "A", this.name + "A", "audience", this.x, Forces.L + 5, null));
            aud = caud.Data;
            // create link audience
            Forces.g.AddEdge(fvert, caud, "audience");


            break;

        case "audience":
            disp       = new Vector2(0f, 0f);
            pos        = new Vector2(x, y);
            ismoveable = false;
            // add to all
            //Forces.g.AddVertex (fvert);
            break;

        default:
            disp       = new Vector2(0f, 0f);
            pos        = new Vector2(x, y);
            ismoveable = false;
            break;
        }
    }
Esempio n. 30
0
    public Node(String n, String m, String t, float a, float b, FVertex f, CharFuncs g)
    {
        name = n;
        calledby = m;
        type = t;
        x = a;
        y = b;
        if (f == null) {
            fvert = new FVertex(this);
        } else {
            fvert = f;
        }
        origObj = g;
        switch (type)
        {
        case "char":
            disp = new Vector2(0f,0f);
            pos = new Vector2(x,y);
            ismoveable = true;
            // add to char list & all
            //Forces.g.characters.Add (fvert); // how do I get this vertex to add here?
            Forces.g.AddVertex(fvert); // really should have this as the vertex - maybe put the logic to add to char list when do vertex?
            // add audience
            FVertex aud2 = Forces.g.AddVertex (new Node(this.name+"A", this.name+"A", "audience", this.x, Forces.L+5, null));
            aud = aud2.Data;
            // add audience link
            Forces.g.AddEdge (fvert, aud2,"audience");

            // add links to all other chars
            Forces.LinkToAllChars(fvert);
            // create center or link to center
            if (Forces.g.center == null && (Forces.g.characters.Count + Forces.g.humans.Count >=2)) {
                Debug.Log("CREATED CENTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                new Node("CENTER", "CENTER", "center", this.x, this.y, null);
                Forces.LinkToAllChars(Forces.g.center);
            } else if (Forces.g.center != null) {
                Forces.g.AddEdge (Forces.g.center, fvert, "center");
            }

            // recalculate center
            Forces.recalcCenter();
            break;
        case "target":
            disp = new Vector2(0f,0f);
            pos = new Vector2(x,y);
            ismoveable = false;
            // add to all
            Forces.g.AddVertex (fvert);
            break;
        case "human":
            calledby = "HUMAN";
            disp = new Vector2(0f,0f);
            pos = new Vector2(x,y);
            ismoveable = false;
            // capture original as x&y?
            orig.x = x;
            orig.y = y;
            // add to all
            Forces.g.AddVertex (fvert);
            // add to humans - done above
            //add audience
            FVertex haud = Forces.g.AddVertex (new Node(this.name+"A", this.name+"A", "audience", this.x, Forces.L+5, null));
            aud = haud.Data;
            // add audience link
            Forces.g.AddEdge (fvert, haud,"audience");

            // add links to all other chars
            Forces.LinkToAllChars(fvert);
            // create center or link to center
            if (Forces.g.center == null && Forces.g.characters.Count + Forces.g.humans.Count >=2) {
                new Node("CENTER", "CENTER", "center", this.x, this.y, null);
                Forces.LinkToAllChars(Forces.g.center);
            } else if (Forces.g.center != null) {
                Forces.g.AddEdge (Forces.g.center, fvert, "center");
            }

            // recalculate center
            Forces.recalcCenter();
            break;
        case "center":
            // calculate x & y using chars and humans (sum them then divide by count of two groups)
            calledby = "CENTER";
            disp = new Vector2(0f,0f);
            pos = new Vector2(x,y);
            ismoveable = true;
            // add to all
            Forces.g.AddVertex (fvert); // duplicates the center vertex - don't do!!
            Forces.g.center = fvert;
            // add to chars???
            // create link to self for all chars & humans
            // create audience
            FVertex caud = Forces.g.AddVertex (new Node(this.name+"A", this.name+"A", "audience", this.x, Forces.L+5, null));
            aud = caud.Data;
            // create link audience
            Forces.g.AddEdge (fvert, caud, "audience");

            break;
        case "audience":
            disp = new Vector2(0f,0f);
            pos = new Vector2(x,y);
            ismoveable = false;
            // add to all
            Forces.g.AddVertex (fvert);
            break;
        default:
            disp = new Vector2(0f,0f);
            pos = new Vector2(x,y);
            ismoveable = false;
            break;
        }
    }
Esempio n. 31
0
 public FEdge(FVertex fromVertex, FVertex toVertex, String t) : this(fromVertex, toVertex, 0, t)
 {
 }
Esempio n. 32
0
 public static void LinkToAllChars(FVertex f)
 {
     // go through list of chars, check if same as n, if not, add edge
     foreach (FVertex curChar in g.characters) {
         if (curChar.Data.name != f.Data.name) {
             Forces.g.AddEdge (f, curChar, "character");
         }
     }
 }
Esempio n. 33
0
 public void Clear()
 {
     /*foreach (FEdge e in graphEdges) {
         Destroy(e.FromVertex.Data);
         Destroy(e.FromVertex);
         Destroy(e.ToVertex.Data);
         Destroy(e.ToVertex);
         Destroy(e);
     }
     foreach (FVertex f in graphVertices) {
         Destroy(f.Data);
         Destroy(f);
     }*/
     graphVertices.Clear ();
     graphVertices = new List<FVertex>();
     graphEdges.Clear ();
     graphEdges = new List<FEdge>();
     characters.Clear ();
     characters = new List<FVertex>();
     humans.Clear ();
     humans = new List<FVertex>();
     //Destroy(center.Data);
     //Destroy(center);
     center = null;
 }
Esempio n. 34
0
 public Node(String n, String m, String t, float a, float b, FVertex f) : this(n, m, t, a, b, f, null)
 {
 }
Esempio n. 35
0
 public FEdge GetEdge(FVertex from, FVertex to)
 {
     return from.GetEdgeTo (to);
 }
Esempio n. 36
0
    public bool RemoveEdge(FVertex from, FVertex to)
    {
        if (from == null) {
            throw new ArgumentNullException ("from");
        }

        if (to == null) {
            throw new ArgumentNullException ("to");
        }

        for (int i = 0; i < graphEdges.Count; i++) {
            if (((graphEdges [i].FromVertex == from) && (graphEdges [i].ToVertex == to)) ||
                        ((graphEdges [i].FromVertex == to) && (graphEdges [i].ToVertex == from))) {
                RemoveEdge (graphEdges [i]);
                return true;
            }
        }

        return false;
    }
Esempio n. 37
0
    public bool RemoveVertex(FVertex vertex)
    {
        if (vertex == null) {
            throw new ArgumentNullException ("vertex");
        }

        if (!graphVertices.Remove (vertex)) {
            return false;
        } else {
            // Delete all the edges in which this vertex forms part of
            List<FEdge> list = vertex.EdgeList;

            while (list.Count > 0) {
                RemoveEdge (list [0]);
            }

            return true;
        }
    }
Esempio n. 38
0
        private void ShowFormula(string cellRef, string formula)
        {
            var formulaObject = new ExcelFormulaParser.ExcelFormula(formula);
            System.Action action = () =>
            {
                this.Graph = new FGraph();
                var rootItem = new FVertex() { Name = cellRef };
                Graph.AddVertex(rootItem);
                ShowFormula(new Queue<ExcelFormulaToken>(formulaObject), rootItem);
                graphLayout.Graph = this.Graph;
            };

            Dispatcher.BeginInvoke(action);
        }
Esempio n. 39
0
        private void ShowFormula(Queue<ExcelFormulaToken> tokens, FVertex parent)
        {
            while (tokens.Any())
            {
                var token = tokens.Dequeue();
                if (token.Type == ExcelFormulaTokenType.Argument && token.Value == ",")
                {
                    continue;
                }

                if (token.Type == ExcelFormulaTokenType.Function && token.Subtype == ExcelFormulaTokenSubtype.Stop)
                {
                    return;
                }

                var child = new FVertex {Name = token.Value};
                this.Graph.AddVertex(child);
                this.Graph.AddEdge(new FEdge(parent, child));
                if (token.Type == ExcelFormulaTokenType.Function && token.Subtype == ExcelFormulaTokenSubtype.Start)
                {
                    ShowFormula(tokens, child);
                }
            }
        }
Esempio n. 40
0
        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                switch (MouseCommand)
                {
                case MOUSECOMMAND.Select:
                {
                    if (layer == null)
                    {
                        break;
                    }
                    layer.ClearSelection();
                    if (e.X == MouseStartX && e.Y == MouseStartY)        //点选
                    {
                        FFeature feature = layer.SelectByClick(new Point(e.X, e.Y), view);
                        if (feature != null)
                        {
                            feature.selected = true;
                        }
                    }
                    else        //框选
                    {
                        FExtent 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)));
                        List <FFeature> features = layer.SelectByExtent(extent);
                        for (int j = 0; j < features.Count; j++)
                        {
                            features[j].selected = true;
                        }
                    }
                    DrawMap();
                    if (attributeDialog != null)
                    {
                        attributeDialog.UpdataSelection();
                    }
                    break;
                }

                case MOUSECOMMAND.ZoomIn:
                {
                    if (e.X == MouseStartX && e.Y == MouseStartY)
                    {
                        FVertex mouselocation = view.ToMapVertex(new Point(e.X, e.Y));
                        double  ZoomInfactor  = 0.9;
                        double  newwidth      = view.MyMapExtent.width * ZoomInfactor;
                        double  newheight     = view.MyMapExtent.height * ZoomInfactor;
                        double  newminx       = mouselocation.getX() - (mouselocation.getX() - view.MyMapExtent.minX) * ZoomInfactor;
                        double  newminy       = mouselocation.getY() - (mouselocation.getY() - view.MyMapExtent.minY) * ZoomInfactor;
                        view.MyMapExtent.setValue(new FVertex(newminx + newwidth, newminy + newheight), new FVertex(newminx, newminy));
                    }
                    else
                    {
                        view.MyMapExtent = view.RectToExtent(new Rectangle(
                                                                 Math.Min(e.X, MouseStartX), Math.Min(e.Y, MouseStartY),
                                                                 Math.Abs(e.X - MouseStartX), Math.Abs(e.Y - MouseStartY)));
                    }
                    DrawMap();
                    break;
                }

                case MOUSECOMMAND.ZoomOut:
                {
                    if (e.X == MouseStartX && e.Y == MouseStartY)
                    {
                        FVertex mouselocation = view.ToMapVertex(new Point(e.X, e.Y));
                        double  ZoomInfactor  = 0.9;
                        double  newwidth      = view.MyMapExtent.width / ZoomInfactor;
                        double  newheight     = view.MyMapExtent.height / ZoomInfactor;
                        double  newminx       = mouselocation.getX() - (mouselocation.getX() - view.MyMapExtent.minX) / ZoomInfactor;
                        double  newminy       = mouselocation.getY() - (mouselocation.getY() - view.MyMapExtent.minY) / ZoomInfactor;
                        view.MyMapExtent.setValue(new FVertex(newminx + newwidth, newminy + newheight), new FVertex(newminx, newminy));
                    }
                    else
                    {
                        FExtent 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.MyMapExtent.width * view.MyMapExtent.width / extent.width;
                        double newheight = view.MyMapExtent.height * view.MyMapExtent.height / extent.height;
                        double newminx   = extent.minX - (extent.minX - view.MyMapExtent.minX) * newwidth / view.MyMapExtent.width;
                        double newminy   = extent.minY - (extent.minY - view.MyMapExtent.minY) * newheight / view.MyMapExtent.height;
                        view.MyMapExtent.setValue(new FVertex(newminx + newwidth, newminy + newheight), new FVertex(newminx, newminy));
                    }
                    DrawMap();
                    break;
                }

                case MOUSECOMMAND.Pan:
                {
                    FVertex C1 = view.MyMapExtent.mapcenter;
                    FVertex M1 = view.ToMapVertex(new Point(MouseStartX, MouseStartY));
                    FVertex M2 = view.ToMapVertex(new Point(e.X, e.Y));
                    FVertex C2 = new FVertex(C1.getX() - (M2.getX() - M1.getX()), C1.getY() - (M2.getY() - M1.getY()));
                    view.MyMapExtent.SetMapCenter(C2);
                    DrawMap();
                    break;
                }
                }
            }
        }