Beispiel #1
0
        /// <summary>
        /// RGB �� ������
        /// </summary>
        /// <param name="y"></param>
        /// <returns></returns>
        private Color GetRGB(double y)
        {
            RGB_Data_List clsRGB_Data_List = new RGB_Data_List();
            int dIndex = 0;

            try
            {
                dIndex = (int)(((y - yRangeStart) * (clsRGB_Data_List.clsRGB_Data.Length-1)) / (yRangeEnd - yRangeStart));

                if (dIndex<0)
                {
                    dIndex = 0;
                }
                if (dIndex>(clsRGB_Data_List.clsRGB_Data.Length-1))
                {
                    dIndex = clsRGB_Data_List.clsRGB_Data.Length-1;
                }

            }
            catch
            {
            }

            RGB_Data clsRGB_Data = clsRGB_Data_List.clsRGB_Data[dIndex];

            return Color.FromArgb((int)(clsRGB_Data.dimData[0] * 255),(int)(clsRGB_Data.dimData[1] * 255),(int)(clsRGB_Data.dimData[2] * 255));
        }
Beispiel #2
0
        /// <summary>
        /// Color Bar �׸���
        /// </summary>
        /// <param name="g"></param>
        private void ColorBar_Draw(Graphics g)
        {
            RGB_Data_List clsRGB_Data_List = new RGB_Data_List();

            float x0, y0, x1, y1, w0, h0;

            // calculate coordinates, width and hight inside
            x0 = ClientRectangle.Left + borderLeft;
            y0 = ClientRectangle.Top + borderTop;
            w0 = ClientRectangle.Width - borderLeft - borderRight;
            h0 = ClientRectangle.Height - borderTop - borderBottom;
            x1 = ClientRectangle.Right - borderRight;
            y1 = ClientRectangle.Bottom - borderBottom;

            // prepare the tools
            Pen penGrid = new Pen(colorGrid, 1);
            Pen penAxis = new Pen(colorAxis, 1);
            SolidBrush brushAxis = new SolidBrush(colorAxis);

            float d = h0 / Convert.ToInt32(clsRGB_Data_List.clsRGB_Data.Length);

            float X1, XW, Y1, YH;
            X1 = x1 + 10;
            XW = this.ColorBarGap;

            for (int i = 0; i < clsRGB_Data_List.clsRGB_Data.Length ; i++)
            {
                Y1 = y1 - (i + 1) * d;
                YH = d;

                Color color = Color.FromArgb((int)(clsRGB_Data_List.clsRGB_Data[i].dimData[0] * 255),(int)(clsRGB_Data_List.clsRGB_Data[i].dimData[1] * 255),(int)(clsRGB_Data_List.clsRGB_Data[i].dimData[2] * 255));

                SolidBrush brushColor = new SolidBrush(color);

                g.FillRectangle(brushColor,X1 - this.ColorBarGap,Y1, XW, YH);
                //g.DrawRectangle(penAxis,X1 - this.ColorBarGap,Y1, XW, YH);
            }

            // Bar MIN ���� ǥ��
            string s = this.yRangeStart.ToString();
            SizeF sf = g.MeasureString(s, fontAxis);
            g.DrawString(s, fontAxis, brushAxis, X1 + sf.Width / 2, y1 - sf.Height);

            // Bar MAX ���� ǥ��
            s = this.yRangeEnd.ToString();
            sf = g.MeasureString(s, fontAxis);
            g.DrawString(s, fontAxis, brushAxis, X1, y0);

            // Bar Middle ���� ǥ��
            double dMidTemp = (this.yRangeEnd + this.YRangeStart) / 2;
            s = dMidTemp.ToString();
            sf = g.MeasureString(s, fontAxis);
            float fMidTemp = ((y1 + sf.Height / 2) + (y0 - 10 - sf.Height / 2)) / 2;
            g.DrawString(s, fontAxis, brushAxis, X1, fMidTemp);
        }