예제 #1
0
 public void Draw(Graphics g, object itemToSkip = null)
 {
     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     for (int i = Items.Count - 1; i >= 0; i--) // Draw in Reverse Order so First ends up on top
     {
         ImageItem item = (ImageItem)Items[i];
         if (item != itemToSkip)
         {
             item.Draw(g);
         }
     }
 }
예제 #2
0
        private void MainForm_Paint(object sender, PaintEventArgs e)
        {
            if (VisionBoard.Current == null)
            {
                return;
            }

            // Set up Bitmap
            Bitmap   bitmap  = new Bitmap(Width, Height);
            Graphics bitmapG = Graphics.FromImage(bitmap);

            bitmapG.SetClip(new Rectangle(0, 0, Width, Height));
            bitmapG.TranslateTransform(Width / 2, Height / 2);

            // Reordering
            if (VisionBoard.Current.Reordering)
            {
                VisionBoard.Current.OrderIndex = VisionBoard.Current.Items.Count;
                VisionBoard.Current.Draw(bitmapG);
            }
            else
            {
                // Draw Non-Selected to Bitmap
                VisionBoard.Current.Draw(bitmapG, selectedItem);

                // Draw Selected to Bitmap
                if (selectedItem != null)
                {
                    selectedItem.Draw(bitmapG, true);
                }
            }

            // Paint Bitmap
            e.Graphics.DrawImage(bitmap, 0, 0);

            bitmapG.Dispose();
            bitmap.Dispose();
        }
예제 #3
0
        public void PlayAStep(Graphics g, int width, int height)
        {
            if (itemIndex >= Items.Count || itemIndex < 0)
            {
                return;
            }
            ImageItem activeItem = (ImageItem)Items[itemIndex];

            // bitmap to draw to and its bitmapG Graphics object
            Bitmap   bitmap  = new Bitmap(width, height);
            Graphics bitmapG = Graphics.FromImage(bitmap);

            //bitmapG.SetClip(new Rectangle(0, 0, width, height));

            // draw bitmapOfStaticItems of all items except activeItem to bitmapG
            getBitmapOfStaticItems(width, height, activeItem);
            bitmapG.DrawImage(bitmapOfStaticItems, 0, 0);

            bitmapG.TranslateTransform(width / 2, height / 2);                                // center (0,0)
            bitmapG.ScaleTransform(ScreensaverForm.ScaleFactor, ScreensaverForm.ScaleFactor); // Scale down to fit

            // actualStep between original position & zoomed-in position
            int actualStep;

            if (Step < MaxStep / 2 - PauseSteps / 2) // zooming in
            {
                actualStep = Step;
            }
            else if (Step > MaxStep / 2 + PauseSteps / 2) // zooming out
            {
                actualStep = MaxStep - Step;
            }
            else // pausing
            {
                actualStep = MaxStep / 2 - PauseSteps / 2;
            }

            // draw activeItem at its current zoom step to bitmapG

            // offset to accelerate
            //int offset = (int)Math.Round(Math.Sqrt(Math.Pow(HalfMaxStep / 2, 2) - Math.Pow(actualStep - HalfMaxStep / 2, 2))); // offset is in the range of [0..HalfMaxStep], slow moving on the ends and fast moving in the middle

            int x = /*-activeItem.X * offset / HalfMaxStep; //*/ (int)Math.Round(Math.Pow((Math.Pow(Math.Abs(activeItem.X), 0.666) / HalfwayStep * actualStep), 1.5));

            if (activeItem.X > 0)
            {
                x = -x;
            }
            int y = /*-activeItem.Y * offset / HalfMaxStep; //*/ (int)Math.Round(Math.Pow((Math.Pow(Math.Abs(activeItem.Y), 0.33) / HalfwayStep * actualStep), 3)); //-activeItem.Y * actualStep / HalfMaxStep;

            if (activeItem.Y > 0)
            {
                y = -y;
            }
            float rot      = -activeItem.RotationDegrees / HalfwayStep * actualStep;
            float maxScale = Math.Min(width * 0.95f / ScreensaverForm.ScaleFactor / activeItem.Size.Width, height * 0.95f / ScreensaverForm.ScaleFactor / activeItem.Size.Height);
            float scale    = 1 + (maxScale - 1) * actualStep / HalfwayStep;

            if (scale == 0)
            {
                scale = 1;
            }

            activeItem.Draw(bitmapG, x, y, rot, scale);

            // draw the bitmap to the screen
            g.DrawImage(bitmap, 0, 0);

            bitmapG.Dispose();
        }