Ejemplo n.º 1
0
        private void Handle(StartSearch msg)
        {
            IncrementMessagesReceived();
            var validator = Context.ActorOf(FileValidatorActor.GetProps(), ActorPaths.FileValidator.Name);

            validator.Tell(new ValidateArgs(msg.Folders, msg.Extension));
        }
        public void UpdateProgress(double progress)
        {
            //MessageBox.Show("Progress update: " + progress.ToString());
            if (progress < 0)
            {
                SolidColorBrush myBrush = new SolidColorBrush();
                myBrush.Color          = Color.FromRgb(255, 150, 150);
                StartSearch.Background = myBrush;
                StartSearch.Content    = "Failure!";
                //ensure changes are visible:
                this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle,
                                       (NoArgDelegate) delegate { });
            }
            else if ((0 <= progress) && (1 >= progress))
            {
                LinearGradientBrush myBrush = new LinearGradientBrush();
                Point UpLeft      = StartSearch.PointToScreen(new Point(0, 0));
                Point CenterLeft  = new Point(UpLeft.X, UpLeft.Y + (StartSearch.ActualHeight / 2));
                Point CenterRight = new Point(CenterLeft.X + StartSearch.ActualWidth, CenterLeft.Y);
                myBrush.StartPoint = new Point(0, 0);
                myBrush.EndPoint   = new Point(1, 0);
                GradientStop GreenStart = new GradientStop();
                GreenStart.Color  = Color.FromRgb(100, 255, 100);
                GreenStart.Offset = 0.0;
                GradientStop GreenEnd = new GradientStop();
                GreenEnd.Color  = Color.FromRgb(100, 255, 100);
                GreenEnd.Offset = Math.Max(progress - 0.1, 0);
                GradientStop GreyStart = new GradientStop();
                GreyStart.Color  = Color.FromRgb(221, 221, 221);
                GreyStart.Offset = progress;
                GradientStop GreyEnd = new GradientStop();
                GreyEnd.Color  = Color.FromRgb(221, 221, 221);
                GreyEnd.Offset = 1.0;
                myBrush.GradientStops.Add(GreenStart);
                myBrush.GradientStops.Add(GreenEnd);
                myBrush.GradientStops.Add(GreyStart);
                myBrush.GradientStops.Add(GreyEnd);

                /*SolidColorBrush myBrush = new SolidColorBrush();
                 * double RedVal = Math.Round(((1 - progress) * 221) + (progress * 100));
                 * double GreenVal = Math.Round(((1 - progress) * 221) + (progress * 255));
                 * double BlueVal = Math.Round(((1 - progress) * 221) + (progress * 100));
                 * myBrush.Color = Color.FromRgb((byte)RedVal, (byte)GreenVal, (byte)BlueVal);
                 * //myBrush.Color = Color.FromRgb(100, 255, 100);*/
                StartSearch.Background = myBrush;
                //ensure changes are visible:
                this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle,
                                       (NoArgDelegate) delegate { });
            }
            else
            {
                SolidColorBrush myBrush = new SolidColorBrush();
                myBrush.Color          = Color.FromRgb(221, 221, 221);
                StartSearch.Background = myBrush;
            }
            //ensure changes are visible:
            this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle,
                                   (NoArgDelegate) delegate { });
        }