WebExpress.TabView.ContrastColor C# (CSharp) Method

ContrastColor() public method

public ContrastColor ( System color ) : Task
color System
return Task
        public async Task ContrastColor(System.Drawing.Color color)
        {
            int d = 0;


            double a = 1 - (0.299 * color.R + 0.587 * color.G + 0.114 * color.B) / 255;

            if (a < 0.4)
            {
                if (!mainWindow.TabBar.getTabFromForm(this).bgTab)
                    mainWindow.TabBar.getTabFromForm(this).label_TabTitle.Foreground =
                        System.Windows.Media.Brushes.Black;
                textBox.Foreground = System.Windows.Media.Brushes.Black;
                mainWindow.TabBar.getTabFromForm(this).actualForeground = System.Windows.Media.Brushes.Black;
                await BlackButtons();
                SolidColorBrush scb = new SolidColorBrush();
                scb.Color = System.Windows.Media.Color.FromArgb(255, 255, 255, 255);
                textBox.Background = scb;
                mainWindow.TabBar.getTabFromForm(this).CloseTab.ImageSource("close_Tab.png");
                mainWindow.TabBar.getTabFromForm(this).darkColor = false;
                MagicBox._isDark = false;
            }
            else
            {
                if (!mainWindow.TabBar.getTabFromForm(this).bgTab)
                    mainWindow.TabBar.getTabFromForm(this).label_TabTitle.Foreground =
                        System.Windows.Media.Brushes.White;
                textBox.Foreground = System.Windows.Media.Brushes.White;
                await WhiteButtons();
                SolidColorBrush scb = new SolidColorBrush();
                scb.Color = System.Windows.Media.Color.FromArgb(50, 255, 255, 255);
                textBox.Background = scb;
                mainWindow.TabBar.getTabFromForm(this).CloseTab.ImageSource("close_Tab_white.png");
                mainWindow.TabBar.getTabFromForm(this).actualForeground = System.Windows.Media.Brushes.White;
                mainWindow.TabBar.getTabFromForm(this).darkColor = true;
                MagicBox._isDark = true;
            }
        }