Example #1
0
        private void DisplayImageTimerTick(object sender, EventArgs e)
        {
            try
            {
                string path = this.photoRepository.NextPhotoFilePath;

                ICollageView view = this.GetNextView();

                var control = new ImageDisplayUserControl(path, this);
                view.ImageCanvas.Children.Add(control);
                this.imageQueue.Enqueue(control);

                if (this.imageQueue.Count > this.MaxInQueue)
                {
                    this.RemoveImageFromQueue(view);
                }

                this.SetUserControlPosition(control, view);
            }
            catch (Exception ex)
            {
                this.controller.HandleError(ex);
                this.controller.Shutdown();
            }
        }
Example #2
0
        private void RemoveImageFromQueue(ICollageView view)
        {
            ImageDisplayUserControl control;

            if (this.imageQueue.TryDequeue(out control))
            {
                Action <ImageDisplayUserControl, ICollageView> action = this.RemoveImageFromPanel;
                control.FadeOutImage(action, view);
            }
        }
Example #3
0
 private void RemoveImageFromPanel(ImageDisplayUserControl control, ICollageView view)
 {
     try
     {
         if (view.ImageCanvas.Children.Contains(control))
         {
             view.ImageCanvas.Children.Remove(control);
         }
     }
     catch (Exception ex)
     {
         this.controller.HandleError(ex);
     }
 }
Example #4
0
        private void SetUserControlPosition(UIElement control, ICollageView view)
        {
            var positioner = new ImagePositioner(this, control, view);

            positioner.Position();
        }
        public void FadeOutImage(Action <ImageDisplayUserControl, ICollageView> onCompletedAction, ICollageView view)
        {
            try
            {
                var storyboard = new Storyboard();
                var duration   = new TimeSpan(0, 0, 1);

                var animation
                    = new DoubleAnimation
                    {
                    From     = 1.0,
                    To       = 0.0,
                    Duration = new Duration(duration)
                    };

                storyboard.Completed += delegate { onCompletedAction(this, view); };

                Storyboard.SetTargetName(animation, this.MainBorder.Name);
                Storyboard.SetTargetProperty(animation, new PropertyPath(OpacityProperty));
                storyboard.Children.Add(animation);
                storyboard.Begin(this);
            }
            catch (Exception ex)
            {
                this.presenter.HandleError(ex);
            }
        }
        public ImagePositioner(CollagePresenter presenterToUse, UIElement controlToPosition, ICollageView view)
        {
            this.presenter = presenterToUse;
            this.control   = controlToPosition;
            this.control.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            this.controlWidth  = Convert.ToInt32(this.control.DesiredSize.Width);
            this.controlHeight = Convert.ToInt32(this.control.DesiredSize.Height);

            this.viewportHeight = Convert.ToInt32(view.WindowActualHeight);
            this.viewportWidth  = Convert.ToInt32(view.WindowActualWidth);
        }