Пример #1
0
        /// <summary>
        ///     The windows process event messages.
        /// </summary>
        /// <param name="args">
        ///     The event args.
        /// </param>
        private static void OnWndProc(WndEventComposition args)
        {
            if (!isVisible)
            {
                return;
            }

            LuminositySlider.OnWndProc(args);
            AlphaSlider.OnWndProc(args);

            var pos = Utils.GetCursorPos();

            if (args.Msg == WindowsMessages.WM_LBUTTONDOWN)
            {
                isMoving = Utils.IsUnderRectangle(pos, X, Y, BackgroundSprite.Width, 25);

                // Apply Button
                if (Utils.IsUnderRectangle(pos, X + 290, Y + 297, 74, 12))
                {
                    Close();
                    return;
                }

                // Cancel Button
                if (Utils.IsUnderRectangle(pos, X + 370, Y + 296, 73, 14))
                {
                    FireEvent(initialColor);
                    Close();
                    return;
                }

                if (Utils.IsUnderRectangle(pos, ColorPickerX, ColorPickerY, ColorPickerW, ColorPickerH))
                {
                    isSelecting = true;
                    UpdateColor();
                }
            }
            else if (args.Msg == WindowsMessages.WM_LBUTTONUP)
            {
                isMoving = isSelecting = false;
            }
            else if (args.Msg == WindowsMessages.WM_MOUSEMOVE)
            {
                if (isSelecting)
                {
                    if (Utils.IsUnderRectangle(pos, ColorPickerX, ColorPickerY, ColorPickerW, ColorPickerH))
                    {
                        UpdateColor();
                    }
                }

                if (isMoving)
                {
                    X += (int)(pos.X - previousPos.X);
                    Y += (int)(pos.Y - previousPos.Y);
                }

                previousPos = pos;
            }
        }