Exemplo n.º 1
0
        void control_MouseUp(object sender, MouseEventArgs e)
        {
            this.container.CloseOnOuterMouseClick = false;

            PWColorCellsControl control = sender as PWColorCellsControl;
            int cellIndex = viewInfo.GetCellIndex(new Point(e.X, e.Y));

            if ((e.Button & MouseButtons.Left) != 0 && control.Capture)
            {
                if (cellIndex != -1)
                {
                    control.SelectedCellIndex = cellIndex;
                    control.Capture           = false;
                    OnEnterColor(control.SelectedCellIndex);
                }
            }
            if ((e.Button & MouseButtons.Right) != 0 && cellIndex >= ColorCellsControlViewInfo.CellColors.Length && rItem.ShowColorDialog)
            {
                ColorDialog cd = new ColorDialog();
                cd.FullOpen = true;
                cd.Color    = viewInfo.GetCellColor(cellIndex);

                try
                {
                    if (cd.ShowDialog() == DialogResult.OK)
                    {
                        viewInfo.CustomColors[cellIndex - ColorCellsControlViewInfo.CellColors.Length] = cd.Color;
                        OnEnterColor(cellIndex);
                    }
                }
                catch (Exception ex)
                { }
            }
            this.container.CloseOnOuterMouseClick = true;
        }
Exemplo n.º 2
0
        protected override void DrawContent(ControlGraphicsInfoArgs info)
        {
            //PWColorCellsControlViewInfo vi = info.ViewInfo as PWColorCellsControlViewInfo;
            //vi.PaintAppearance.DrawBackground(info.Cache, vi.ClientRect);
            //for (int i = 0; i < cellsCount; i++)
            //{
            //    Rectangle cellBounds = vi.GetCellRect(i);
            //    info.Graphics.FillRectangle(new SolidBrush(vi.GetCellColor(i)), cellBounds);
            //    vi.CellBorderPainter.DrawObject(new BorderObjectInfoArgs(info.Cache, cellBounds, null, ObjectState.Pressed));
            //    if (i == vi.SelectedCellIndex)
            //        ControlPaint.DrawFocusRectangle(info.Graphics, Rectangle.Inflate(cellBounds, 2, 2));
            //}
            PWColorCellsControlViewInfo vi = info.ViewInfo as PWColorCellsControlViewInfo;

            vi.PaintAppearance.DrawBackground(info.Cache, vi.ClientRect);
            for (int i = 0; i < cellsCount; i++)
            {
                Rectangle cellBounds = vi.GetCellRect(i);
                info.Graphics.FillRectangle(new SolidBrush(vi.GetCellColor(i)), cellBounds);
                vi.CellBorderPainter.DrawObject(new BorderObjectInfoArgs(info.Cache, cellBounds, null, ObjectState.Pressed));
                if (i == vi.SelectedCellIndex)
                {
                    ControlPaint.DrawFocusRectangle(info.Graphics, Rectangle.Inflate(cellBounds, 2, 2));
                }
            }
            Rectangle r = vi.ContentRect;
            float     x = ColorCellsControlViewInfo.CellsInternval;
            float     y = vi.GetCellRect(0).Height * 7 + ColorCellsControlViewInfo.CellsInternval;

            DevExpress.Skins.Skin        currentSkin;
            DevExpress.Skins.SkinElement element;
            string elementName;

            currentSkin = DevExpress.Skins.CommonSkins.GetSkin(vi.LookAndFeel);
            elementName = DevExpress.Skins.CommonSkins.SkinTextBorder;
            element     = currentSkin[elementName];
            Color skinBorderColor = element.Border.All;

            elementName = DevExpress.Skins.CommonSkins.SkinGroupPanel;
            element     = currentSkin[elementName];
            Color skinBackColor = element.Color.BackColor;

            info.Graphics.DrawLine(new Pen(skinBorderColor), x, y + 1, 8 * vi.GetCellRect(0).Width + (8) * ColorCellsControlViewInfo.CellsInternval, y + 1);
            Rectangle stringRect = new Rectangle(0, (int)y + 2, 8 * (vi.GetCellRect(0).Width + ColorCellsControlViewInfo.CellsInternval + ColorCellsControlViewInfo.CellsInternval), vi.GetCellRect(0).Height);

            info.Graphics.FillRectangle(new SolidBrush(skinBackColor), stringRect);
            info.Graphics.DrawString("Right Click to Define Custom Color", vi.PaintAppearance.Font, vi.PaintAppearance.GetForeBrush(info.Cache), x, y + 2, vi.PaintAppearance.GetStringFormat(vi.DefaultTextOptions));
        }
Exemplo n.º 3
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (PopupContainer != null)
            {
                PopupContainer.CloseOnOuterMouseClick = false;
            }
            base.OnMouseUp(e);
            int cellIndex = viewInfo.GetCellIndex(new Point(e.X, e.Y));

            if ((e.Button & MouseButtons.Left) != 0 && Capture)
            {
                if (cellIndex != -1)
                {
                    SelectedCellIndex = cellIndex;
                    Capture           = false;
                    OnEnterColor(SelectedCellIndex);
                }
            }
            //if ((e.Button & MouseButtons.Right) != 0 && cellIndex >= 64 && Properties.ShowColorDialog)
            if ((e.Button & MouseButtons.Right) != 0 && cellIndex >= ColorCellsControlViewInfo.CellColors.Length && Properties.ShowColorDialog)
            {
                ColorDialog     cd  = null;
                MonoColorDialog mcd = null;
                switch (viewInfo.SignType)
                {
                case SignType.Amber:
                    mcd = new MonoColorDialog(Color.FromArgb(255, 191, 63));
                    break;

                case SignType.Red:
                    mcd = new MonoColorDialog(Color.Red);
                    break;

                case SignType.Green:
                    mcd = new MonoColorDialog(Color.Green);
                    break;

                case SignType.Blue:
                    mcd = new MonoColorDialog(Color.Blue);
                    break;

                case SignType.White:
                    mcd = new MonoColorDialog();
                    break;

                default:
                    cd          = new ColorDialog();
                    cd.FullOpen = true;
                    cd.Color    = viewInfo.GetCellColor(cellIndex);
                    break;
                }
                lockFocus = true;
                if (shadowForm != null)
                {
                    this.shadowForm.HideShadows();
                }
                try
                {
                    if (cd != null && cd.ShowDialog() == DialogResult.OK)
                    {
                        viewInfo.CustomColors[cellIndex - ColorCellsControlViewInfo.CellColors.Length] = cd.Color;
                        OnEnterColor(cellIndex);
                    }
                    if (mcd != null && mcd.ShowDialog() == DialogResult.OK)
                    {
                        viewInfo.CustomColors[cellIndex - ColorCellsControlViewInfo.CellColors.Length] = mcd.Color;
                        OnEnterColor(cellIndex);
                    }
                }
                finally
                {
                    lockFocus = false;
                    if (shadowForm != null)
                    {
                        this.shadowForm.ShowHideShadows();
                    }
                }
            }
            if (PopupContainer != null)
            {
                PopupContainer.CloseOnOuterMouseClick = true;
            }
        }