AnimateColor() public static method

public static AnimateColor ( SolidColorBrush from, SolidColorBrush to, UIElement control, double duration ) : void
from System.Windows.Media.SolidColorBrush
to System.Windows.Media.SolidColorBrush
control System.Windows.UIElement
duration double
return void
Ejemplo n.º 1
0
 private void bg2_MouseLeave(object sender, MouseEventArgs e)
 {
     if (bgTab)
     {
         StaticFunctions.AnimateColor(Colors.Gainsboro, Colors.Transparent, bg, 0.2);
     }
 }
Ejemplo n.º 2
0
        private void UserControl_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            BrushConverter converter = new BrushConverter();

            bg.Background = (SolidColorBrush)converter.ConvertFromString("#FFF");
            SolidColorBrush scb   = (SolidColorBrush)converter.ConvertFromString("#FFE2E2E2");
            Color           color = scb.Color;

            StaticFunctions.AnimateColor(color, Colors.White, bg, 0.2);
        }
Ejemplo n.º 3
0
        public async Task ChangeColor()
        {
            try
            {
                await Dispatcher.BeginInvoke((Action)(() =>
                {
                    Thread thread = new Thread(new ThreadStart(delegate()
                    {
                        System.Threading.Thread.Sleep(200);
                        this.Dispatcher.BeginInvoke(DispatcherPriority.Send,
                                                    new ThreadStart(async delegate()
                        {
                            var topLeftCorner = WebView.PointToScreen(new System.Windows.Point(0, 0));
                            var topLeftGdiPoint = new System.Drawing.Point((int)topLeftCorner.X, (int)topLeftCorner.Y);
                            var size = new System.Drawing.Size((int)WebView.ActualWidth, (int)WebView.ActualHeight);
                            Bitmap screenShot = new Bitmap((int)WebView.ActualWidth, (int)WebView.ActualHeight);
                            using (var graphics = Graphics.FromImage(screenShot))
                            {
                                graphics.CopyFromScreen(topLeftGdiPoint, new System.Drawing.Point(), size,
                                                        CopyPixelOperation.SourceCopy);
                            }
                            SolidColorBrush oldBrush = (SolidColorBrush)Panel.Background;
                            SolidColorBrush brush = new SolidColorBrush(StaticFunctions.ToMediaColor(screenShot.GetPixel(1, 1)));
                            StaticFunctions.AnimateColor(oldBrush, StaticFunctions.ToMediaColor(screenShot.GetPixel(1, 1)), Panel, 0.1);
                            mainWindow.TabBar.getTabFromForm(this).Color = brush;
                            mainWindow.TabBar.getTabFromForm(this).refreshColor();

                            StaticFunctions.AnimateColor(oldBrush, StaticFunctions.ToMediaColor(screenShot.GetPixel(1, 1)), textBox, 0.1);
                            StaticFunctions.AnimateColor(oldBrush, StaticFunctions.ToMediaColor(screenShot.GetPixel(1, 1)), ListContainer, 0.1);
                            StaticFunctions.AnimateColor(oldBrush, StaticFunctions.ToMediaColor(screenShot.GetPixel(1, 1)), MagicBox, 0.1);


                            await ContrastColor(screenShot.GetPixel(1, 1));
                            this.Refresh();
                        }));
                    }));
                    thread.Name = "thread-UpdateText";
                    thread.Start();
                }));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Change color error: " + ex.Message + " " + ex.Data);
            }
        }