//--------------------------------------------
        // list of connection
        //--------------------------------------------

        private void prepareListViewListOfConnections()
        {
            // retreive train connections off cache
            List <TrainConnection> connections = ShortestPathAlgoritm.getInstance().getTrainConnections();

            // prevent off method draw called on this listView
            listViewListOfConnections.BeginUpdate();
            // clearStableLines previous content
            listViewListOfConnections.Items.Clear();
            // loop over trainConnections
            foreach (TrainConnection connection in connections)
            {
                ListViewItem lvi = new ListViewItem();
                // fill the information about train connection;
                lvi.Text = connection.FromStation.Name;
                lvi.Tag  = connection.FromStation.Name + " -> " + connection.ToStation.Name;

                // fill other information about connection
                lvi.SubItems.Add(connection.ToStation.Name);
                lvi.SubItems.Add(connection.Time.ToString());
                lvi.SubItems.Add(connection.Distance.ToString());
                lvi.SubItems.Add(connection.Passengers.ToString());
                lvi.SubItems.Add(connection.LinesOfConnection);
                lvi.SubItems.Add(connection.ChangingStation);

                listViewListOfConnections.Items.Add(lvi);
            }
            // release list of items
            listViewListOfConnections.EndUpdate();
        }
        private void detailsOfConnectionOpen()
        {
            // if nothing selected
            if (listViewListOfConnections.SelectedItems.Count.Equals(0))
            {
                MessageBox.Show("Please, select the connection.", "No connection selected");
            }
            // if selected
            else
            {
                TrainConnection connection = ShortestPathAlgoritm.getInstance().getTrainConnectionOnFromTo(
                    listViewListOfConnections.SelectedItems[0].Text,
                    listViewListOfConnections.SelectedItems[0].SubItems[1].Text);

                FormDetailsOfConnection formDetailsOfConnection = new FormDetailsOfConnection(connection);

                // before calling subform - remember listView focus
                int selectedIndex = listViewListOfConnections.SelectedIndices[0];


                DialogResult dr = formDetailsOfConnection.ShowDialog();
                if (dr.Equals(DialogResult.OK))
                {
                    // update list view
                    prepareListViewListOfConnections();
                    // refresh selection and focus on selected item
                    FormUtil.listView_SelecdAndFocus(listViewListOfConnections, selectedIndex);
                }
            }
        }
        /// <summary>
        /// Creates the groups of connection. Forgets previous groups of connections.
        /// </summary>
        public void createGroupsOfConnection()
        {
            // createConstraintSet new groups
            List <GroupOfConnections> groupsList = new List <GroupOfConnections>();
            // parse groups
            List <List <TrainConnection> > groups = groupByListOfLines(ShortestPathAlgoritm
                                                                       .getInstance().getTrainConnections());

            // loop over all groups
            foreach (List <TrainConnection> group in groups)
            {
                // createConstraintSet instance of class group
                GroupOfConnections groupOfConnections = new GroupOfConnections(group);
                // addConstraint
                groupsList.Add(groupOfConnections);
            }

            // initialize variable of cache
            groupsOfConnections = groupsList;
        }
        private void editPathConnectionOpen()
        {
            // if nothing selected
            if (listViewListOfConnections.SelectedItems.Count.Equals(0))
            {
                MessageBox.Show("Please, select the connection", "No connection selected");
            }
            // if selected
            else
            {
                TrainConnection connection = ShortestPathAlgoritm.getInstance().getTrainConnectionOnFromTo(
                    listViewListOfConnections.SelectedItems[0].Text,
                    listViewListOfConnections.SelectedItems[0].SubItems[1].Text);

                FormEditPathOfConnection editPathConnection = new FormEditPathOfConnection(connection);

                // before calling subform - remember listView focus
                int selectedIndex = listViewListOfConnections.SelectedIndices[0];

                // open subform as a dialog
                DialogResult dr = editPathConnection.ShowDialog();

                // if the dialog was closed by button OK
                if (dr.Equals(DialogResult.OK))
                {
                    // and if there are new valid stages
                    List <Stage> newStages = editPathConnection.NewStages;
                    if (newStages != null)
                    {
                        // set new stages
                        connection.setStages(newStages);
                        connection.updateGeneratedValues();
                        // refresh ListView
                        prepareListViewListOfConnections();
                        // refresh selection and focus on selected item
                        FormUtil.listView_SelecdAndFocus(listViewListOfConnections, selectedIndex);
                    }
                }
            }
        }
        //--------------------------------------------
        // button NEXT list of station
        //--------------------------------------------

        private void buttonListOfStationNext_Click(object sender, EventArgs e)
        {
            buttonNextStarted();
            ShortestPathAlgoritm shortestPathAlgorithm;

            try
            {
                // activate algorithm
                shortestPathAlgorithm = ShortestPathAlgoritm.getInstance();
                shortestPathAlgorithm.calculateShortestPath();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Error in the shortest path algorithm processing.");
                buttonNextEnded();
                return;
            }

            try
            {
                shortestPathAlgorithm.generateAllTrainConnections();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Could not generate the list of connections.");
                buttonNextEnded();
                return;
            }

            try
            {
                // prepare list view
                prepareListViewListOfConnections();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Could not prepare the list of connections.");
                buttonNextEnded();
                return;
            }

            // TODO: added coz one place of processing data
            try
            {
                prepareListViewListOfGroupsOfConnections();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Error in groupping connections process.");
                buttonNextEnded();
                return;
            }

            // TODO: added coz one place of processing data
            try
            {
                FinalInput.getInstance().createTransfers();
                prepareListViewListOfTransfers();
            }
            catch
            {
                ErrorMessageBoxUtil.ShowError("Could not extract transfers from the given list of connections.");
                buttonNextEnded();
                return;
            }


            // open particular tab
            selectTab(tabPageListOfConncetions);
            buttonNextEnded();
        }