Beispiel #1
0
 private void DrawItems(List <SortedItem> items)
 {
     VisualizationPanel.Controls.Clear();
     foreach (var item in items)
     {
         VisualizationPanel.Controls.Add(item.VerticalProgressBar);
         VisualizationPanel.Controls.Add(item.Label);
     }
     VisualizationPanel.Refresh();
 }
Beispiel #2
0
        private void ClearButton_Click(object sender, EventArgs e)
        {
            items.Clear();
            VisualizationPanel.Controls.Clear();
            VisualizationPanel.Refresh();

            TimeLabel.Text        = "Time: ";
            ComparsionsLabel.Text = "Compare: ";
            SwopsLabel.Text       = "Swops: ";
        }
Beispiel #3
0
        private void AlgorithmSetEvent(object sender, Tuple <int, SortedItem> e)
        {
            e.Item2.SetColor(Color.Red);
            VisualizationPanel.Refresh();
            Thread.Sleep(20);

            e.Item2.SetPosition(e.Item1);
            VisualizationPanel.Refresh();
            Thread.Sleep(20);

            e.Item2.SetColor(Color.Blue);
            VisualizationPanel.Refresh();
            Thread.Sleep(20);
        }
Beispiel #4
0
        private void AlgorithmCompareEvent(object sender, Tuple <SortedItem, SortedItem> e)
        {
            e.Item1.SetColor(Color.Red);
            e.Item2.SetColor(Color.Green);
            VisualizationPanel.Refresh();

            Thread.Sleep(20);

            e.Item1.SetColor(Color.Blue);
            e.Item2.SetColor(Color.Blue);
            VisualizationPanel.Refresh();

            Thread.Sleep(20);
        }
Beispiel #5
0
        private void BttnSort_Click(AlgorithmBase <SortedItem> algorithm)
        {
            RefreshItems();

            for (int i = 0; i < algorithm.Items.Count; i++)
            {
                algorithm.Items[i].SetPosition(i);
            }

            VisualizationPanel.Refresh();

            algorithm.CompareEvent += AlgorithmCompareEvent;
            algorithm.SwopEvent    += AlgorithmSwopEvent;
            algorithm.SetEvent     += AlgorithmSetEvent;
            var time = algorithm.Sort();

            TimeLabel.Text        = "Time: " + time.Seconds;
            ComparsionsLabel.Text = "Compare: " + algorithm.ComparsionCount;
            SwopsLabel.Text       = "Swops: " + algorithm.ComparsionCount;
        }
Beispiel #6
0
        private void AlgorithmSwopEvent(object sender, Tuple <SortedItem, SortedItem> e)
        {
            e.Item1.SetColor(Color.Aqua);
            e.Item2.SetColor(Color.Brown);
            VisualizationPanel.Refresh();

            Thread.Sleep(20);

            var temp = e.Item1.Number;

            e.Item1.SetPosition(e.Item2.Number);
            e.Item2.SetPosition(temp);
            VisualizationPanel.Refresh();

            Thread.Sleep(20);

            e.Item1.SetColor(Color.Blue);
            e.Item2.SetColor(Color.Blue);
            VisualizationPanel.Refresh();

            Thread.Sleep(20);
        }