Example #1
0
        public void OnPrinterPropertyChanged(SPrinterProperty property)
        {
            _property = property;
            int whiteNum   = (_property.nWhiteInkNum & 0x0F);
            int varnishNum = (_property.nWhiteInkNum >> 4);
            int len        = this.reservoirsButtons.Count;

            if (whiteNum + varnishNum > 0)
            {
                int wIndex = 0;
                int cIndex = 0;
                for (int i = 0; i < this.reservoirsButtons.Count; i++)
                {
                    ColorEnum color  = property.Get_ColorEnum(i);
                    bool      isWorV = color == ColorEnum.White || color == ColorEnum.Vanish;
                    if (isWorV)
                    {
                        if (wIndex <= whiteNum + varnishNum)
                        {
                            reservoirsButtons[len - whiteNum - varnishNum + wIndex].Text = string.Format("{0}({1})", property.Get_ColorIndex(i), i + 1);
                        }
                        else
                        {
                            reservoirsButtons[len - whiteNum - varnishNum + wIndex].Text = "";
                        }
                        wIndex++;
                    }
                    else
                    {
                        if (i < property.nColorNum)
                        {
                            reservoirsButtons[cIndex].Text = string.Format("{0}({1})", property.Get_ColorIndex(i), i + 1);
                        }
                        else
                        {
                            reservoirsButtons[cIndex].Text = "";
                        }
                        cIndex++;
                    }
                }
                for (int i = 0; i < this.reservoirsButtons.Count; i++)
                {
                    reservoirsButtons[i].Visible = !string.IsNullOrEmpty(reservoirsButtons[i].Text.Trim());
                }
            }
            else
            {
                for (int i = 0; i < this.reservoirsButtons.Count; i++)
                {
                    if (i < property.nColorNum)
                    {
                        reservoirsButtons[i].Text    = string.Format("{0}({1})", property.Get_ColorIndex(i), i + 1);
                        reservoirsButtons[i].Visible = true;
                    }
                    else
                    {
                        reservoirsButtons[i].Visible = false;
                    }
                }
            }
            panelPressureW.Visible = whiteNum + varnishNum > 0;
        }
Example #2
0
        private Color GetBackColorByIndex(int index)
        {
            ColorEnum colorEnum = _property.Get_ColorEnum(index);

            switch (colorEnum)
            {
            case ColorEnum.Cyan:
                return(Color.Cyan);

            case ColorEnum.Magenta:
                return(Color.Magenta);

            case ColorEnum.Yellow:
                return(Color.Yellow);

            case ColorEnum.Black:
                return(Color.Black);

            case ColorEnum.LightCyan:
                return(Color.LightCyan);

            case ColorEnum.LightMagenta:
                return(Color.LightPink);   //TODO

            case ColorEnum.LightYellow:
                return(Color.LightYellow);

            case ColorEnum.LightBlack:
                return(Color.LightGray);   //TODO

            case ColorEnum.Red:
                return(Color.Red);

            case ColorEnum.Blue:
                return(Color.Blue);

            case ColorEnum.Green:
                return(Color.Green);

            case ColorEnum.Orange:
                return(Color.Orange);

            case ColorEnum.White:
                return(Color.White);

            case ColorEnum.Vanish:
                return(Color.Violet);   //TODO

            case ColorEnum.SkyBlue:
                return(Color.SkyBlue);

            case ColorEnum.Gray:
                return(Color.Gray);

            case ColorEnum.Pink:
                return(Color.Pink);

            case ColorEnum.NULL:
                return(Color.Transparent);

            default:
                break;
            }
            return(Color.Transparent);
        }