BlottoBeats.Client.MainForm.initButtons C# (CSharp) Метод

initButtons() публичный Метод

public initButtons ( ) : void
Результат void
        public void initButtons()
        {
            buttons.Clear();
            if (redditDropped) this.Size = new Size(33 * size / 8, 23 * size / 8);
            else if (settingsDropped) this.Size = new Size(33 * size / 8, 19 * size / 8);
            else this.Size = new Size(33 * size / 8, size);
            font = new Font("Arial", (float)(3.0 * size / 20));
            smallFont = new Font("Arial", (float)(3.0 * size / 35));
            lightInline.Width = size / 40;
            lightOutline.Width = size / 40;

            List<Point> playBar = new List<Point>();
            playBar.Add(new Point(0, 0));
            playBar.Add(new Point(13 * size / 4, 0));
            playBar.Add(new Point(13 * size / 4, 3 * size / 8));
            playBar.Add(new Point(0, 3 * size / 8));
            playBarButton = new Button(playBar, new Point(3 * size / 4, size / 8), darkColor, null, null, null);
            playBarButton.Clicked += playBarClicked;
            buttons.Add(playBarButton);

            List<Point> bottomButton = new List<Point>();
            bottomButton.Add(new Point(0, 3 * size / 8));
            bottomButton.Add(new Point(size / 4, 0));
            bottomButton.Add(new Point(3 * size / 4, 0));
            bottomButton.Add(new Point(size / 2, 3 * size / 8));

            Bitmap backImg = new Bitmap(origBackImg, new Size(size / 5, size / 5));
            Button backButton = new Button(bottomButton, new Point(3 * size / 4, size / 2), darkColor, lightOutline, colorOverlay(backImg, lightColor.Color), new Point(9 * size / 32, 3 * size / 32));
            backButton.Clicked += backClicked;
            buttons.Add(backButton);

            Bitmap nextImg = new Bitmap(origNextImg, new Size(size / 5, size / 5));
            Button nextButton = new Button(bottomButton, new Point(size / 2 + 3 * size / 4, size / 2), darkColor, lightOutline, colorOverlay(nextImg, lightColor.Color), new Point(9 * size / 32, 3 * size / 32));
            nextButton.Clicked += nextClicked;
            buttons.Add(nextButton);

            Bitmap upvoteImg = new Bitmap(origUpvoteImg, new Size(size / 4, size / 4));
            Button upvoteButton = new Button(bottomButton, new Point(size + 3 * size / 4, size / 2), upvoteColor, lightOutline, colorOverlay(upvoteImg, lightColor.Color), new Point(7 * size / 32, size / 16));
            upvoteButton.Clicked += upvoteClicked;
            buttons.Add(upvoteButton);

            Bitmap downvoteImg = new Bitmap(origDownvoteImg, new Size(size / 4, size / 4));
            Button downvoteButton = new Button(bottomButton, new Point(3 * size / 2 + 3 * size / 4, size / 2), downvoteColor, lightOutline, colorOverlay(downvoteImg, lightColor.Color), new Point(9 * size / 32, size / 16));
            downvoteButton.Clicked += downvoteClicked;
            buttons.Add(downvoteButton);

            Bitmap redditImg = new Bitmap(origRedditImg, new Size(size / 4, size / 4));
            Button redditButton = new Button(bottomButton, new Point(4 * size / 2 + 3 * size / 4, size / 2), darkColor, lightOutline, colorOverlay(redditImg, lightColor.Color), new Point(size / 4, size / 16));
            redditButton.Clicked += redditClicked;
            buttons.Add(redditButton);

            Bitmap settingsImg = new Bitmap(origSettingsImg, new Size(size / 4, size / 4));
            Button settingsButton = new Button(bottomButton, new Point(5 * size / 2 + 3 * size / 4, size / 2), darkColor, lightOutline, colorOverlay(settingsImg, lightColor.Color), new Point(size / 4, 3 * size / 32));
            settingsButton.Clicked += settingsClicked;
            buttons.Add(settingsButton);

            List<Point> slider = new List<Point>();
            slider.Add(new Point(0, 0));
            slider.Add(new Point(size / 8, 3 * size / 16));
            slider.Add(new Point(0, 3 * size / 8));
            slider.Add(new Point(-size / 8, 3 * size / 16));
            sliderButton = new Button(slider, new Point((int)(progress * (193 * size / 64) + size), size / 8), sliderColor, lightInline, null, null);
            sliderButton.Clicked += sliderClicked;
            buttons.Add(sliderButton);

            List<Point> play = new List<Point>();
            for (int i = 0; i < 128; i++)
                play.Add(new Point((int)(size / 2 + Math.Cos((1.0 * i / 128) * (2 * Math.PI)) * (size / 2)), (int)(size / 2 + Math.Sin((1.0 * i / 128) * (2 * Math.PI)) * (size / 2))));
            playImg = colorOverlay(new Bitmap(origPlayImg, new Size(size / 2, size / 2)), lightColor.Color);
            pauseImg = colorOverlay(new Bitmap(origPauseImg, new Size(size / 2, size / 2)), lightColor.Color);
            Bitmap playButtonImg = playImg;
            Point imgLoc = new Point(size / 3, size / 4);
            if (playing)
            {
                playButtonImg = pauseImg;
                imgLoc = new Point(size / 4, size / 4);
            }
            playButton = new Button(play, new Point(0, 0), medColor, lightInline, playButtonImg, imgLoc);
            playButton.Clicked += this.playClicked;
            buttons.Add(playButton);

            List<Point> menuButton = new List<Point>();
            menuButton.Add(new Point(0, 0));
            menuButton.Add(new Point(size / 4, 0));
            menuButton.Add(new Point(size / 4, size / 8));
            menuButton.Add(new Point(0, size / 8));

            Button minimizeButton = new Button(menuButton, new Point(7 * size / 2, 0), medColor, null, null, null);
            minimizeButton.Clicked += minimizeClicked;
            buttons.Add(minimizeButton);

            Button exitButton = new Button(menuButton, new Point(15 * size / 4, 0), downvoteColor, null, null, null);
            exitButton.Clicked += exitClicked;
            buttons.Add(exitButton);

            List<Point> buttonShape = new List<Point>();
            buttonShape.Add(new Point(0, 0));
            buttonShape.Add(new Point(size / 4, 0));
            buttonShape.Add(new Point(size / 4, size / 4));
            buttonShape.Add(new Point(0, size / 4));

            Bitmap advSettingsImg = new Bitmap(origAdvSettingsImg, new Size(size / 4, size / 4));
            advSettingButton = new Button(buttonShape, new Point(13 * size / 16, 30 * size / 32), darkColor, null, colorOverlay(advSettingsImg, lightColor.Color), new Point(0, 0));
            advSettingButton.Clicked += advSettingClicked;

            Bitmap exportImg = new Bitmap(origExportImg, new Size(size / 4, size / 4));
            exportButton = new Button(buttonShape, new Point(18 * size / 16, 30 * size / 32), darkColor, null, colorOverlay(exportImg, lightColor.Color), new Point(0, 0));
            exportButton.Clicked += exportClicked;

            List<Point> smallButtonShape = new List<Point>();
            smallButtonShape.Add(new Point(0, 0));
            smallButtonShape.Add(new Point(size / 8, 0));
            smallButtonShape.Add(new Point(size / 8, size / 8));
            smallButtonShape.Add(new Point(0, size / 8));

            prevGenreButton = new Button(smallButtonShape, new Point(13 * size / 16, 15 * size / 16), darkColor, null, null, null);
            prevGenreButton.Clicked += prevGenreClicked;

            nextGenreButton = new Button(smallButtonShape, new Point(57 * size / 16, 15 * size / 16), darkColor, null, null, null);
            nextGenreButton.Clicked += nextGenreClicked;

            foreach (Setting setting in settings)
                setting.init(size);
        }

Usage Example

Пример #1
0
 private void updateAllButtons()
 {
     initButtons();
     Invalidate();
     form.initButtons();
     form.Invalidate();
     form.accountForm.initButtons();
     form.accountForm.Invalidate();
 }