Ejemplo n.º 1
0
        private void OnLButtonUp()
        {
            if (movingFilter != null)
                foreach (Filter f in graph.SelectedFilters)
                    f.movingStartCoords = f.Coords;
            movingFilter = null;

            if (connectingPin != null)
            {
                if (mousepos == movingStart) //just click on pin
                {
                    if (connectingPin.Connection != null)
                    {
                        AMMediaType mt = new AMMediaType();
                        connectingPin.IPin.ConnectionMediaType(mt);
                        MediaTypeProps mtp = MediaTypeProps.CreateMTProps(mt); //new MediaTypeProps(mt);
                        Program.mainform.propform.SetObject(mtp);
                    }
                    else
                    {
                        IEnumMediaTypes mtenum;
                        if (connectingPin.IPin.EnumMediaTypes(out mtenum) >= 0)
                        {
                            AMMediaType[] mts = new AMMediaType[1];
                            List<MediaTypeProps> mtypes = new List<MediaTypeProps>();
                            IntPtr fetched = Marshal.AllocHGlobal(4);
                            while (mtenum.Next(1, mts, fetched) == 0)
                                mtypes.Add(MediaTypeProps.CreateMTProps(mts[0]));
                            Marshal.FreeHGlobal(fetched);
                            Program.mainform.propform.SetObject(mtypes.ToArray());
                        }
                    }
                }
                else
                {
                    if (otherPin != null)
                    {
                        Pin inpin, outpin;
                        if (connectingPin.Direction == PinDirection.Input)
                        {
                            inpin = connectingPin;
                            outpin = otherPin;
                        }
                        else
                        {
                            inpin = otherPin;
                            outpin = connectingPin;
                        }
                        graph.Connect(outpin, inpin, true);
                    }
                }
                Invalidate();
            }

            if (selecting)
            {
                Rectangle rc = new Rectangle(Math.Min(mousepos.X, movingStart.X), Math.Min(mousepos.Y, movingStart.Y),
                    Math.Abs(mousepos.X - movingStart.X), Math.Abs(mousepos.Y - movingStart.Y));
                if (ModifierKeys != Keys.Shift)
                    graph.ClearFiltersSelection();
                graph.SelectSeveralFilters(rc);
                selecting = false;
                Invalidate();
            }
            connectingPin = null;
            otherPin = null;
        }