コード例 #1
0
        public void Start()
        {
            for (int i = 0; i < COLOR_COUNT; i++)
            {
                int rNum = rand.Next(100, 255);

                Selection.Add(new Model
                {
                    Value           = -rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb((byte)rNum, 0, 0))
                });

                Insertion.Add(new Model
                {
                    Value           = rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb((byte)rNum, (byte)(rNum / 2), 0))
                });

                Heap.Add(new Model
                {
                    Value           = -rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb((byte)rNum, (byte)rNum, 0))
                });

                Bubble.Add(new Model
                {
                    Value           = rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb(0, (byte)rNum, 0))
                });

                Cocktail.Add(new Model
                {
                    Value           = rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb(0, (byte)rNum, (byte)rNum))
                });

                Circle.Add(new Model
                {
                    Value           = -rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb(0, (byte)(rNum / 1.5), (byte)rNum))
                });

                Merge.Add(new Model
                {
                    Value           = -rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb((byte)(rNum / 2), 0, (byte)rNum))
                });

                Quick.Add(new Model
                {
                    Value           = -rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb((byte)rNum, 0, (byte)rNum))
                });

                Shell.Add(new Model
                {
                    Value           = -rNum,
                    Height          = HEIGHT,
                    BorderThickness = new Thickness(0),
                    Background      = new SolidColorBrush(Color.FromRgb((byte)rNum, 0, (byte)(rNum / 2)))
                });
            }

            selectionSort = new SelectionSort(Selection);
            insertionSort = new InsertionSort(Insertion);
            heapSort      = new HeapSort(Heap);
            bubbleSort    = new BubbleSort(Bubble);
            cocktailSort  = new CocktailSort(Cocktail);
            circleSort    = new CircleSort(Circle);
            mergeSort     = new MergeSort(Merge);
            quickSort     = new QuickSort(Quick);
            shellSort     = new ShellSort(Shell);

            timer.Elapsed += new ElapsedEventHandler(Update);
            timer.Interval = UPDATE_SPEED;
            timer.Enabled  = true;
        }