예제 #1
0
        private void DrawButtons()
        {
            int size               = FormDpiHandler.ScaleWithCurrentDpi(15);
            var buttons            = CreateColorPalette(size, size);
            var recentColorButtons = CreateLastUsedColorButtonRow(size, size);

            SuspendLayout();
            panelColors.Controls.Clear();
            panelColors.Controls.AddRange(buttons.ToArray());
            panelRecentColors.Controls.Clear();
            panelRecentColors.Controls.AddRange(recentColorButtons.ToArray());
            UpdateRecentColorsButtonRow();
            ResumeLayout();
        }
예제 #2
0
        /// <summary>
        ///     Constructor
        /// </summary>
        public AboutForm(
            ICoreConfiguration coreConfiguration,
            IGreenshotLanguage greenshotlanguage,
            IVersionProvider versionProvider
            ) : base(coreConfiguration, greenshotlanguage)
        {
            _greenshotlanguage = greenshotlanguage;
            // Make sure our resources are removed again.
            Disposed    += Cleanup;
            FormClosing += Cleanup;

            // Enable animation for this form, when we don't set this the timer doesn't start as soon as the form is loaded.
            EnableAnimation = true;
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            // Use the self drawn image, first we create the background to be the backcolor (as we animate from this)
            _bitmap           = BitmapFactory.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor);
            pictureBox1.Image = _bitmap;

            _dpiSubscription = FormDpiHandler.OnDpiChanged.Subscribe(info =>
            {
                pictureBox1.Size = FormDpiHandler.ScaleWithCurrentDpi(new NativeSize(90, 90));
            });

            var versionInfo = $@"Greenshot {versionProvider.CurrentVersion} {(coreConfiguration.IsPortable ? " Portable" : "")} ({OsInfo.Bits} bit)";

            if (versionProvider.IsUpdateAvailable)
            {
                versionInfo += $" latest is: {versionProvider.LatestVersion}";
            }
            lblTitle.Text = versionInfo;
            // Number of frames the pixel animation takes
            var frames = FramesForMillis(2000);

            // The number of frames the color-cycle waits before it starts
            _waitFrames = FramesForMillis(6000);

            // Every pixel is created after pixelWaitFrames frames, which is increased in the loop.
            var pixelWaitFrames = FramesForMillis(2000);

            // Create pixels
            for (var index = 0; index < _gSpots.Count; index++)
            {
                // Read the pixels in the order of the flow
                var gSpot = _gSpots[_flowOrder[index]];
                // Create the animation, first we do nothing (on the final destination)
                RectangleAnimator pixelAnimation;

                // Make the pixel grom from the middle, if this offset isn't used it looks like it's shifted
                var offset = (w - 2) / 2;

                // If the optimize for Terminal Server is set we make the animation without much ado
                if (IsTerminalServerSession)
                {
                    // No animation
                    pixelAnimation = new RectangleAnimator(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), 1, EasingTypes.Cubic);
                }
                else
                {
                    // Create the animation, first we do nothing (on the final destination)
                    var standingStill = new Rectangle(gSpot.X + offset, gSpot.Y + offset, 0, 0);
                    pixelAnimation = new RectangleAnimator(standingStill, standingStill, pixelWaitFrames, EasingTypes.Quintic);
                    // And than we size to the wanted size.
                    pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), frames);
                }
                // Increase the wait frames
                pixelWaitFrames += FramesForMillis(100);
                // Add to the list of to be animated pixels
                _pixels.Add(pixelAnimation);
                // Add a color to the list for this pixel.
                _pixelColors.Add(_pixelColor);
            }
            // Make sure the frame "loop" knows we have to animate
            _hasAnimationsLeft = true;

            // Pixel Color cycle colors, here we use a pre-animated loop which stores the values.
            var pixelColorAnimator = new ColorAnimator(_pixelColor, Color.FromArgb(255, 255, 255), 6, EasingTypes.Quadratic);

            pixelColorAnimator.QueueDestinationLeg(_pixelColor, 6, EasingTypes.Quadratic, EasingModes.EaseOut);
            do
            {
                _colorFlow.Add(pixelColorAnimator.Current);
                pixelColorAnimator.Next();
            } while (pixelColorAnimator.HasNext);

            // color animation for the background
            _backgroundAnimation = new ColorAnimator(BackColor, _backColor, FramesForMillis(5000));
        }