Пример #1
0
        //
        // HÀM MÔ PHỎNG DI CHUYỂN
        //

        private void MoveButtonBubbleSort(int i, int j)
        {
            Status st = new Status();

            st.Pos1 = i;
            st.Pos2 = j;
            st.type = MoveType.MOVE_TOP_DOWN;
            for (int x = 0; x < SIZE; x++)
            {
                BackGroundBubbleSort.ReportProgress(0, st);
                System.Threading.Thread.Sleep(10);
            }
            st.type = MoveType.MOVE_LEFT_RiGHT;
            int Distance = Math.Abs(i - j) * (SIZE + GAP);

            for (int x = 0; x < Distance; x++)
            {
                BackGroundBubbleSort.ReportProgress(0, st);
                System.Threading.Thread.Sleep(10);
            }
            st.type = MoveType.MOVE_IN_LINE;
            for (int x = 0; x < SIZE; x++)
            {
                BackGroundBubbleSort.ReportProgress(0, st);
                System.Threading.Thread.Sleep(10);
            }

            st.type = MoveType.MOVED;
            BackGroundBubbleSort.ReportProgress(0, st);
            System.Threading.Thread.Sleep(10);
        }
Пример #2
0
        //
        // Cho bắt đầu BackgroundWorker của bulusort
        //

        private void btSort_Click(object sender, EventArgs e)
        {
            BackGroundBubbleSort.RunWorkerAsync();
        }