예제 #1
0
 public CalculateDataThread(double sell, double buy, MainWindow main)
 {
     _sellPrice = sell;
     _buyPrice = buy;
     _main = main;
 }
예제 #2
0
        public static void FlashControl(Control control, Color flashColor, MainWindow main)
        {
            var thread = new Thread(new ThreadStart(delegate
                                                        {
                                                            Brush old = null;
                                                            Color oldColor;
                                                            main.Dispatcher.Invoke(
                                                                new Action(delegate { old = control.BorderBrush; }));
                                                            try
                                                            {
                                                                oldColor = ((SolidColorBrush) old).Color;
                                                            }
                                                            catch (Exception)
                                                            {
                                                                oldColor = Colors.WhiteSmoke;
                                                            }

                                                            for (int i = 0; i < 16; i++)
                                                            {
                                                                int ii = i%4;
                                                                switch (ii)
                                                                {
                                                                    case 0:
                                                                        main.Dispatcher.Invoke(
                                                                            new Action(
                                                                                delegate
                                                                                    {
                                                                                        control.BorderBrush =
                                                                                            new LinearGradientBrush(
                                                                                                flashColor, oldColor, 0);
                                                                                    }));
                                                                        break;

                                                                    case 1:
                                                                        main.Dispatcher.Invoke(
                                                                            new Action(
                                                                                delegate
                                                                                    {
                                                                                        control.BorderBrush =
                                                                                            new SolidColorBrush(
                                                                                                flashColor);
                                                                                    }));
                                                                        break;

                                                                    case 2:
                                                                        main.Dispatcher.Invoke(
                                                                            new Action(
                                                                                delegate
                                                                                    {
                                                                                        control.BorderBrush =
                                                                                            new LinearGradientBrush(
                                                                                                oldColor, flashColor, 0);
                                                                                    }));
                                                                        break;

                                                                    case 3:
                                                                        main.Dispatcher.Invoke(
                                                                            new Action(
                                                                                delegate { control.BorderBrush = old; }));
                                                                        break;
                                                                }
                                                                Thread.Sleep(175);
                                                            }
                                                            main.Dispatcher.Invoke(
                                                                new Action(delegate { control.BorderBrush = old; }));
                                                        }));
            thread.Start();
        }