Ejemplo n.º 1
0
        /// <summary>
        /// загружает список узлов с которыми нет связи.
        /// </summary>
        /// <returns>возвращает список в глобальную переменную и bool в качестве успеха</returns>
        private bool getOtherNodes()
        {
            Node nodeclass = new Node();

            othernods = new List <Othernode>();
            List <Node_struct> list = tmplistnodes;

            Parallel.For(0, list.Count, (i, state) =>
            {
                if (list[i].ID != thisnod.ID)
                {
                    if (getProvConnectNodeToNode(list[i]))
                    {
                        Othernode ot = new Othernode();
                        ot.Node      = list[i];
                        othernods.Add(ot);
                    }
                }
            });
            return(true);
        }
Ejemplo n.º 2
0
        private Othernode nodКоторыйПеретаскивается(String name, int wh, Node nodeclass)
        {
            name = name.Remove(0, 1);
            int id = -1;

            for (int i = 0; i < name.Length; i++)
            {
                if (name[i] == ' ')
                {
                    id   = int.Parse(name.Substring(0, i));
                    name = name.Remove(0, i + 1);
                    break;
                }
            }
            if (id == -1)
            {
                return(null);
            }
            Node_struct nod = nodeclass.getNodeПоИд(tmplistnodes, id);
            Othernode   ot  = new Othernode();

            ot.Node = nod;
            return(ot);
        }
Ejemplo n.º 3
0
        private void listBoxПеретаскивание(DragEventArgs e, int idlistbox)
        {
            string name = e.Data.GetData(DataFormats.Text).ToString();
            int    what = int.Parse(name.Substring(0, 1));

            if (what == idlistbox)
            {
                return;
            }
            Node       nodeclass = new Node();
            UpdateNode upnode    = new UpdateNode();
            Othernode  othernod  = nodКоторыйПеретаскивается(name, idlistbox, nodeclass);

            if (othernod == null)
            {
                return;
            }
            if (nodeclass.getProvBoolЗацикленность(tmplistnodes, thisnod, othernod.Node, true, true))
            {
                return;
            }
            if (idlistbox == 1)
            {
                tmplistnodes = upnode.updateNodeConnectIn(tmplistnodes, thisnod, othernod.ID);
                if (what == 2)
                {
                    tmplistnodes = upnode.deleteNodeConnectOut(tmplistnodes, thisnod, othernod.ID);
                }
            }
            else if (idlistbox == 2)
            {
                tmplistnodes = upnode.updateNodeConnectOut(tmplistnodes, thisnod, othernod.ID);
                if (what == 1)
                {
                    tmplistnodes = upnode.deleteNodeConnectIn(tmplistnodes, thisnod, othernod.ID);
                }
            }
            else
            {
                othernods.Add(othernod);
                if (what == 1)
                {
                    tmplistnodes = upnode.deleteNodeConnectIn(tmplistnodes, thisnod, othernod.ID);
                }
                else
                {
                    tmplistnodes = upnode.deleteNodeConnectOut(tmplistnodes, thisnod, othernod.ID);
                }
            }
            if (what == 0)
            {
                bool удален = false;
                Parallel.For(0, othernods.Count, (i, state) =>
                {
                    try
                    {
                        if (удален == false && othernods[i].ID == othernod.ID)
                        {
                            удален = true;
                            othernods.RemoveAt(i);
                            state.Break();
                        }
                    }
                    catch (System.ArgumentOutOfRangeException ex)
                    {
                        Console.WriteLine("Обращение к элементу массива, который был уже удален. " + ex.ToString());
                    }
                });
            }
            //если нужно будет обновить thisnod;
            updateListBoxПослеПерестаскивания();
            UpdateDataGrivTable(true);
        }