public void AddElement(StateCharPair k, StateFiniteAutomata v)
        {
            List<StateFiniteAutomata> s = null;
            if (functionData.Count > 0)
            {

                if(functionData.ContainsKey(k) )
                {
                    s = functionData[k];
                    s.Add(v);
                }
                else
                {
                    s = new List<StateFiniteAutomata>();
                    s.Add(v);
                    functionData.Add(k, s);
                }
            }
            else
            {
                 s = new List<StateFiniteAutomata>();
                 s.Add(v);
                 functionData.Add(k, s);

            }
        }
 public bool DeleteRow(StateCharPair sp, StateFiniteAutomata s)
 {
     if (functionData.Count > 0)
     {
         List<StateFiniteAutomata> nStates = functionData[sp];
         if (nStates != null) { return nStates.Remove(s); }
     }
     return false;
 }
        public bool SetDirectState(StateCharPair sp, StateFiniteAutomata s)
        {
            if (functionData.Count > 0)
            {
                List<StateFiniteAutomata> nStates = null;
                if(functionData.ContainsKey(sp))
                {
                    nStates=functionData[sp];

                    if (!nStates.Contains(s)) { nStates.Add(s); return true; }
                }
                else
                {
                    nStates = new List<StateFiniteAutomata>();
                    nStates.Add(s);
                    functionData.Add(sp, nStates);
                    return true;
                }

            }
            return false;
        }
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            int createOption = tbox.PressedButton;
            if (selectState == 4)
            {
                removeTextTempBox();
                selectState = 0;
            }
            switch (createOption)
            {
                case 0:   break; //here edditing current item
                case 1:
                    {
                        if (graph.HasStartNode == false)
                        {
                            string newName = default_state_name + currentStateNumber;
                            currentStateNumber++;
                            Node tempNode=graph.AddStartNode(e.X, e.Y,newName);
                            StateFiniteAutomata state1 = new StateFiniteAutomata(tempNode);
                            tempNode.NodeState = state1;
                            mainAutomate.AddStartState(state1);
                            listView2.Items.Insert(0, "->" + state1.Name);
                            tbox.FreezeStartNode();
                            graph.HasStartNode = true;
                        }
                    }
                    break;
                case 2:
                    {
                        string newName = default_state_name + currentStateNumber;
                        currentStateNumber++;
                        Node tempNode = graph.AddCommonNode(e.X, e.Y, newName);
                        StateFiniteAutomata state1 = new StateFiniteAutomata(tempNode);
                        tempNode.NodeState = state1;
                        mainAutomate.AddState(state1);
                        listView2.Items.Add(state1.Name);

                    }
                    break;
                case 3:
                    {
                        string newName = default_state_name + currentStateNumber;
                        currentStateNumber++;
                        Node tempNode = graph.AddAcceptNode(e.X, e.Y, newName);
                        StateFiniteAutomata state1 = new StateFiniteAutomata(tempNode);
                        tempNode.NodeState=state1;
                        mainAutomate.AddAcceptState(state1);
                        listView2.Items.Add("("+state1.Name+")");
                    }
                    break;
                case 4:
                    {
                        if (selectState == 0)
                        {
                            if(graph.SelectBeginNode(e.X, e.Y))
                                selectState = 1;
                        }
                        else if(selectState==1)
                        {
                            Node [] twoNodes=graph.AddEdgeToPosition(e.X, e.Y,DEFAULT_CHAR);
                            if (twoNodes!=null)
                            {
                                if (mainAutomate.InnerAlphabet.AddToAlphabet(DEFAULT_CHAR))
                                    listView1.Items.Add(DEFAULT_CHAR.ToString());
                                StateCharPair spair = new StateCharPair(twoNodes[0].NodeState, DEFAULT_CHAR);
                                mainAutomate.OpFunction.AddElement(spair, twoNodes[1].NodeState);
                                addToFunctionView(twoNodes[0].Name, DEFAULT_CHAR, twoNodes[1].Name);
                                graph.ClearSelection();
                                selectState = 0;
                            }
                        }

                    }
                    break;

            }
            this.listView2.Refresh();
            this.pictureBox1.Refresh();
        }