Пример #1
0
 public void select(ProcessingNet n, int connection)
 {
     if (n == null) return;
     if (!nets.Contains(n))
         nets.Add(n);
     n.doSelect(connection);
 }
Пример #2
0
        private void netContextMenuChangeName(object sender, EventArgs e)
        {
            MenuItem m = sender as MenuItem;

            if (m == null)
            {
                return;
            }
            ContextMenu mr = m.Parent as ContextMenu;

            if (mr == null)
            {
                return;
            }
            ProcessingNet    n  = (ProcessingNet)mr.Tag;
            FlexibleInputWin fi = new FlexibleInputWin("Net Name", n.name);

            fi.StartPosition = FormStartPosition.Manual;
            fi.Location      = Cursor.Position;
            fi.ShowDialog();
            if (fi.stringValue != null)
            {
                if (fi.stringValue.Length > 0)
                {
                    n.name = fi.stringValue;
                }
            }
        }
Пример #3
0
        private void showNetContextMenu(Point p, ProcessingNet net)
        {
            MenuItem[] menuItems;
            if (net.isNamed)
            {
                menuItems = new MenuItem[]
                {
                    new MenuItem("Delete",
                                 new EventHandler(netContextMenuDelete)),
                    new MenuItem(string.Format("Change Name [{0}]", net.name),
                                 new EventHandler(netContextMenuChangeName)),
                    new MenuItem("Make UnNamed Net",
                                 new EventHandler(netContextMenuMakeUnNamed))
                };
            }
            else
            {
                menuItems = new MenuItem[]
                {
                    new MenuItem("Delete",
                                 new EventHandler(netContextMenuDelete)),
                    new MenuItem("Make Named Net",
                                 new EventHandler(netContextMenuMakeNamed))
                };
            };
            ContextMenu menu = new ContextMenu(menuItems);

            menu.Tag = net;
            menu.Show(this, p);
        }
Пример #4
0
 public void select(ProcessingNet n)
 {
     if (n == null) return;
     if (nets.Contains(n)) return;
     nets.Add(n);
     n.doSelect();
 }
Пример #5
0
 public void unselect(ProcessingNet n, int connection)
 {
     if (n == null) return;
     if (!nets.Contains(n)) return;
     n.unSelect(connection);
     if (!n.anySelected())
         nets.Remove(n);
 }
Пример #6
0
 public void unselect(ProcessingNet n)
 {
     if (n == null) return;
     if (!nets.Contains(n)) return;
     nets.Remove(n);
     n.unSelect();
     // n.selected = false;
 }
Пример #7
0
 public void selectMe(ProcessingNet n)
 {
     if (n == null)
     {
         return;
     }
     selection.select(n);
 }
Пример #8
0
        private void netContextMenuMakeUnNamed(object sender, EventArgs e)
        {
            MenuItem      m = (MenuItem)sender;
            ProcessingNet n = (ProcessingNet)m.Parent.Tag;

            n.isNamed = false;
            Invalidate();
        }
Пример #9
0
        private void netContextMenuDelete(object sender, EventArgs e)
        {
            MenuItem      m = (MenuItem)sender;
            ProcessingNet n = (ProcessingNet)m.Parent.Tag;

            LockWorker();
            // selection.unselect();
            n.Disconnect();
            nets.Remove(n);
            // selection.removeConnections();
            UnLockWorker();
            Invalidate();
        }
Пример #10
0
 public void selectMe(ProcessingNet n, int conn)
 {
     if (n == null)
     {
         return;
     }
     if (conn < 0)
     {
         selection.select(n);
     }
     else
     {
         selection.select(n, conn);
     }
 }
Пример #11
0
        public void MergeFrom(ProcessingNet src)
        {
            int ofs = connectedIOs.Count;

            foreach (RTIO sio in src.connectedIOs)
            {
                connectedIOs.Add(sio);
                sio.connectedTo = this;
            }
            foreach (ProcessingConnection sc in src.connections)
            {
                connections.Add(new ProcessingConnection(sc.i1 + ofs, sc.i2 + ofs));
            }
            CheckValidity();
        }
Пример #12
0
        public void createConnection(RTIO io, RTIO ioto)
        {
            if (io == ioto)
            {
                return;             // Loop back not allowed
            }
            // Check for attached nets
            if ((ioto.connectedTo != null) && (io.connectedTo != null))
            {
                // Both connected already
                if (ioto.connectedTo == io.connectedTo)
                {
                    return; // Already connected!
                }
                // Merge Nets
                ProcessingNet voidNet = ioto.connectedTo;
                LockWorker();
                io.connectedTo.MergeFrom(ioto.connectedTo);
                nets.Remove(voidNet);
                io.connectedTo.addConnection(io, ioto);
                UnLockWorker();
                return;
            }
            if (io.connectedTo != null)
            {
                LockWorker();
                io.connectedTo.addConnection(io, ioto);
                UnLockWorker();
                return;
            }
            if (ioto.connectedTo != null)
            {
                LockWorker();
                ioto.connectedTo.addConnection(io, ioto);
                UnLockWorker();
                return;
            }
            // Still here --> create new net
            ProcessingNet net = new ProcessingNet(this);

            LockWorker();
            net.addConnection(io, ioto);
            nets.Add(net);
            UnLockWorker();
        }
Пример #13
0
        public RTIO() : base()
        {
            _title                 = "IO";
            _titleFont             = new Font(FontFamily.GenericSansSerif, 8);
            _titleColor            = Color.DimGray;
            _showTitle             = true;
            _IOtype                = ProcessingIOType.SignalInput;
            _contactColor          = Color.DimGray;
            _contactBackColor      = Color.Black;
            _contactHighlightColor = Color.Red;
            _orientation           = RTOrientation.East;
            _highlighted           = false;
            _hideOnShrink          = false; // IOs stay on shrink by default
            // this.DoubleBuffered = true;

            titleBrush          = new SolidBrush(_titleColor);
            contactBackBrush    = new SolidBrush(_contactBackColor);
            contactPen          = new Pen(_contactColor);
            contactHighlightPen = new Pen(_contactHighlightColor);

            connectedTo = null;
        }
Пример #14
0
 public void CopyFrom(ProcessingNet src)
 {
     connectedIOs = src.connectedIOs;
     connections  = src.connections;
 }
Пример #15
0
 public bool selected(ProcessingNet n)
 {
     if (n == null) return false;
     return nets.Contains(n);
 }
Пример #16
0
        public void FixGraph()
        {
            // Step 1: Remove unreferenced IOs and unconnected IOs in the connection List
            List <Boolean> referenced = new List <bool>();

            foreach (RTIO io in connectedIOs)
            {
                referenced.Add(false);
            }
            foreach (ProcessingConnection cnct in connections)
            {
                referenced[cnct.i1] = true;
                referenced[cnct.i2] = true;
            }
            int i = 0;

            while (i < referenced.Count)
            {
                if (!referenced[i])
                {
                    connectedIOs[i].connectedTo = null;
                    connectedIOs.RemoveAt(i);
                    referenced.RemoveAt(i);
                    foreach (ProcessingConnection cnct in connections)
                    {
                        cnct.IntelliRemove(i);
                    }
                }
                else
                {
                    i++;
                }
            }

            // Step 2: Remove already unconnected IOs
            i = 0;
            while (i < connectedIOs.Count)
            {
                if (connectedIOs[i].connectedTo == null)
                { // Found one
                    foreach (ProcessingConnection cnct in connections)
                    {
                        cnct.IntelliRemove(i);
                    }
                    connectedIOs.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }

            // Step 3: Check for Valid Net at all
            if (connectedIOs.Count < 2)
            { // less than two nodes --> invalid
                foreach (RTIO pio in connectedIOs)
                {
                    pio.connectedTo = null;
                }
                owner.nets.Remove(this);
                return;
            }

            // Step 4: Check for disconnected Nets
            List <ProcessingConnectionRef> cr = new List <ProcessingConnectionRef>();

            foreach (ProcessingConnection cnct in connections)
            {
                cr.Add(new ProcessingConnectionRef(connectedIOs[cnct.i1], connectedIOs[cnct.i2]));
            }
            for (i = 0; i < cr.Count; i++)
            {
                cr[i].group = i;
            }
            for (i = 0; i < cr.Count; i++)
            {
                for (int j = 0; j < cr.Count; j++)
                {
                    if (j != i)
                    {
                        if (cr[j].ConnectedTo(cr[i]))
                        {
                            int grp = (cr[i].group < cr[j].group) ? cr[i].group : cr[j].group;
                            cr[i].group = cr[j].group = grp;
                        }
                    }
                }
            }
            List <int> groups = new List <int>();

            foreach (ProcessingConnectionRef c in cr)
            {
                if (groups.IndexOf(c.group) < 0)
                {
                    groups.Add(c.group);
                }
            }
            // Now groups contains the independant list of nets
            if (groups.Count > 1)
            {
                // Must Split
                // Remove all Links first
                foreach (RTIO io in connectedIOs)
                {
                    io.connectedTo = null;
                }

                List <ProcessingNet> newNets = new List <ProcessingNet>();
                foreach (int grp in groups)
                {
                    ProcessingNet pn = new ProcessingNet(owner);
                    foreach (ProcessingConnectionRef c in cr)
                    {
                        if (c.group == grp)
                        {
                            pn.addConnection(c.i1, c.i2);
                        }
                    }
                    newNets.Add(pn);
                }
                CopyFrom(newNets[0]);
                CheckValidity();
                newNets.RemoveAt(0);
                foreach (ProcessingNet n in newNets)
                {
                    owner.nets.Add(n);
                    n.CheckValidity();
                }
            }
            else
            {
                // Still one Set --> everything is ok
                CheckValidity();
            }
        }
Пример #17
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            switch (dragMode)
            {
            case DragMode.None:
                break;

            case DragMode.MouseDown:
                // Just Mouse up again --> a click
                Vector mp = fromScreen(new Vector(e.Location.X, e.Location.Y));
                foreach (ProcessingNet n in nets)
                {
                    n.selectOnHit(mp, selection);
                }
                if (selection.items > 0)
                {
                    Invalidate();
                }
                dragMode = DragMode.None;
                break;

            case DragMode.MouseDownRight:
                // Click
                Vector mpr = fromScreen(new Vector(e.Location.X, e.Location.Y));
                foreach (ProcessingNet n in nets)
                {
                    n.selectOnHit(mpr, selection);
                }
                if (selection.items > 0)
                {
                    Invalidate();
                }
                dragMode = DragMode.None;
                if (selection.items == 1)
                {
                    ProcessingNet n = selection.getNet(0);
                    if (n != null)
                    {
                        showNetContextMenu(e.Location, n);
                    }
                }
                selection.unselect();
                break;

            case DragMode.SelectWin:
                // unSelectAll();
                dragStop = fromScreen(new Vector(e.Location.X, e.Location.Y));
                VectorRect selwin = VectorRect.FromTwoPoints(dragStart, dragStop);
                foreach (RTForm f in elements)
                {
                    f.selectOnContained(selwin, selection);
                }
                foreach (ProcessingNet n in nets)
                {
                    n.selectOnContained(selwin, selection);
                }
                showCaret = false;
                dragMode  = DragMode.None;
                Invalidate();
                break;
            }
        }