Ejemplo n.º 1
0
        private void GraphForm_MouseMove(object sender, MouseEventArgs e)
        {
            mousepos = e.Location;
            mousepos.X += hScrollBar.Value;
            mousepos.Y += vScrollBar.Value - toolStripHeight;

            if (movingFilter != null)
            {
                int dx = (mousepos.X - movingStart.X) / graph.cellsize;
                int dy = (mousepos.Y - movingStart.Y) / graph.cellsize;
                if (dx != 0 || dy != 0)
                {
                    Point c = movingFilter.movingStartCoords;
                    c.X += dx;
                    c.Y += dy;
                    c.X = Math.Max(c.X, 1);
                    c.Y = Math.Max(c.Y, 0);
                    if (c != movingFilter.Coords)
                    {
                        foreach(Filter f in graph.SelectedFilters)
                            graph.PlaceFilter(f, false);
                        bool canplace = true;
                        foreach (Filter f in graph.SelectedFilters)
                        {
                            c = f.movingStartCoords;
                            c.X += dx;
                            c.Y += dy;
                            c.X = Math.Max(c.X, 1);
                            c.Y = Math.Max(c.Y, 0);
                            if (!graph.CanPlaceFilter(c, f))
                            {
                                canplace = false;
                                break;
                            }
                        }

                        if (canplace)
                        {
                            foreach (Filter f in graph.SelectedFilters)
                            {
                                c = f.movingStartCoords;
                                c.X += dx;
                                c.Y += dy;
                                c.X = Math.Max(c.X, 1);
                                c.Y = Math.Max(c.Y, 0);
                                f.Coords = c;
                                graph.PlaceFilter(f, true);
                            }
                            graph.RecalcPaths();
                            RecalcScrolls();
                            Invalidate();
                        }
                        else
                            foreach (Filter f in graph.SelectedFilters)
                                graph.PlaceFilter(f, true);
                    }
                }
            }
            if (connectingPin != null && connectingPin.Connection==null)
            {
                otherPin = null;
                Filter f = graph.FilterInPoint(mousepos);
                if (f != null)
                {
                    Pin p = f.PinInPoint(mousepos);
                    if (p != null && p.Direction != connectingPin.Direction && p.Connection==null)
                        otherPin = p;                        
                }
                Invalidate();
            }
            if (selecting)
            {
                Invalidate();
            }
            DescribeActions();
        }