internal static ICmykColor[] GetCmykColors()
        {
            try
            {
                string       selectedClass = CboClasses.GetSelectedClass();
                ICmykColor[] colors        = new ICmykColor[Convert.ToInt32(selectedClass)];
                int          currentIndex  = 0;

                string selectedColor = CboColors.GetSelectedColor();

                System.IO.StreamReader file =
                    new System.IO.StreamReader(filepath);
                string line;
                string currentColor = "";
                string currentClass = "";

                while ((line = file.ReadLine()) != null)
                {
                    if (currentIndex == colors.Length)
                    {
                        break;
                    }

                    string[] words = line.Split(',');
                    if (words[0] != "")
                    {
                        currentColor = words[0];
                    }
                    if (words[1] != "")
                    {
                        currentClass = words[1];
                    }
                    if (currentColor.Equals(selectedColor) && currentClass.Equals(selectedClass))
                    {
                        ICmykColor color = new CmykColorClass();
                        color.Cyan           = Convert.ToInt32(words[6]);
                        color.Magenta        = Convert.ToInt32(words[7]);
                        color.Yellow         = Convert.ToInt32(words[8]);
                        color.Black          = Convert.ToInt32(words[9]);
                        colors[currentIndex] = color;
                        currentIndex++;
                    }
                }
                return(colors);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
                LocateCBfile();
                return(GetCmykColors());
            }
        }
        internal static ICmykColor GetSingleCMYKColor()
        {
            try
            {
                ICmykColor color = new CmykColorClass();

                string selectedColor = CboColors.GetSelectedColor();
                string selectedClass = CboClasses.GetSelectedClass();
                /* FILEPATH needs to be modified whenever the cb.csv file is moved aka during installation */
                System.IO.StreamReader file =
                    new System.IO.StreamReader(filepath);
                string line;
                string currentColor = "";
                string currentClass = "";

                while ((line = file.ReadLine()) != null)
                {
                    string[] words = line.Split(',');
                    if (words[0] != "")
                    {
                        currentColor = words[0];
                    }
                    currentClass = words[5];
                    if (currentColor.Equals(selectedColor) && currentClass.Equals(selectedClass))
                    {
                        color.Cyan    = Convert.ToInt32(words[6]);
                        color.Magenta = Convert.ToInt32(words[7]);
                        color.Yellow  = Convert.ToInt32(words[8]);
                        color.Black   = Convert.ToInt32(words[9]);
                        return(color);
                    }
                }
                return(color);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
                LocateCBfile();
                return(GetSingleCMYKColor());
            }
        }
示例#3
0
 public ICmykColor GetCmykColor(int iCyan, int iMagenta, int iYellow, int iBlack, bool bUseWinDithering)
 {
     try
     {
         ICmykColor color = null;
         color                     = new CmykColorClass();
         iCyan                     = this.CheckNumValueRegion(iCyan, 0, 0xff);
         iMagenta                  = this.CheckNumValueRegion(iMagenta, 0, 0xff);
         iYellow                   = this.CheckNumValueRegion(iYellow, 0, 0xff);
         iBlack                    = this.CheckNumValueRegion(iBlack, 0, 0xff);
         color.Cyan                = iCyan;
         color.Magenta             = iMagenta;
         color.Yellow              = iYellow;
         color.Black               = iBlack;
         color.UseWindowsDithering = bUseWinDithering;
         return(color);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ColorFun", "GetCmykColor", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }