Esempio n. 1
0
        private void frmColors_Load(object sender, EventArgs e)
        {
            string s = NearestColor.NetListToLorListPct();

            System.Diagnostics.Debugger.Break();
            initForm();
        }
Esempio n. 2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Channel,");
            sb.Append(theChannel.SavedIndex.ToString() + COMMA);
            sb.Append(utils.XMLifyName(theChannel.Name) + COMMA);
            sb.Append(COMMA);             // Centiseconds
            sb.Append(SeqEnums.DeviceName(theChannel.output.deviceType) + COMMA);
            if (theChannel.output.deviceType == DeviceType.LOR)
            {
                sb.Append(theChannel.output.unit.ToString() + COMMA);
                sb.Append(theChannel.output.networkName + COMMA);
                sb.Append(theChannel.output.circuit.ToString() + COMMA);
                sb.Append(COMMA + COMMA);
            }
            if (theChannel.output.deviceType == DeviceType.DMX)
            {
                sb.Append(COMMA + COMMA + COMMA);
                sb.Append(theChannel.output.universe.ToString() + COMMA);
                sb.Append(theChannel.output.channel.ToString() + COMMA);
            }
            sb.Append(theChannel.color.ToString() + COMMA);
            sb.Append("#" + utils.Color_LORtoHTML(theChannel.color) + COMMA);
            sb.Append(NearestColor.FindNearestColorName(theChannel.color));

            string ret = sb.ToString();

            return(ret);
        }
Esempio n. 3
0
        public override string ToString()
        {
            string ret = utils.XMLifyName(theChannel.Name);
            int    p   = theChannel.Name.IndexOf(',');

            if (p >= 0)
            {
                ret = "\"" + ret + "\"";
            }

            ret += ",";
            if (isKeywd)
            {
                ret += "Yes,";
            }
            else
            {
                ret += "No,";
            }
            ret += foundOrder.ToString();
            ret += theChannel.SavedIndex.ToString() + ",";
            DeviceType devType = theChannel.output.deviceType;

            ret += SeqEnums.DeviceName(devType) + ",";
            if (devType == DeviceType.LOR)
            {
                ret += theChannel.output.unit.ToString() + "," + theChannel.output.channel.ToString() + ",";
            }
            if (devType == DeviceType.DMX)
            {
                ret += theChannel.output.network.ToString() + "," + theChannel.output.channel.ToString() + ",";
            }
            if (devType == DeviceType.Digital)
            {
                ret += theChannel.output.network.ToString() + "," + theChannel.output.channel.ToString() + ",";
            }
            if (devType == DeviceType.None)
            {
                ret += ",,";
            }
            ret += utils.Color_LORtoHTML(theChannel.color) + ",";
            ret += NearestColor.FindNearestColorName(theChannel.Color);             // + ",";
            return(ret);
        }
Esempio n. 4
0
        private int LoadPreset(string theName)
        {
            int count = 0;

            string theFile = utils.DefaultChannelConfigsPath + theName + PRESETEXT;

            try
            {
                if (!System.IO.File.Exists(theFile))
                {
                    theFile += STAR;
                }
                if (!System.IO.File.Exists(theFile))
                {
                    System.IO.StreamReader reader = new System.IO.StreamReader(theFile);
                    while (!reader.EndOfStream)
                    {
                        // While lines remain, get the next line
                        string lineIn = reader.ReadLine();
                        // Check for comments, and split the comment from the data
                        string dat     = lineIn;
                        string comment = "";
                        int    sep     = lineIn.IndexOf('#');
                        if (sep < 0)
                        {
                            sep = lineIn.IndexOf(';');
                        }
                        if (sep < 0)
                        {
                            sep = lineIn.IndexOf("\\\\");
                        }
                        if (sep > 0)
                        {
                            dat     = lineIn.Substring(0, sep);
                            comment = lineIn.Substring(sep);
                            string[] values = dat.Split(',');
                            // Does the data consist of 6 numbers?
                            if (values.Length == 6)
                            {
                                Preset set = new Preset();
                                short  pct = 0;
                                Int16.TryParse(values[0], out pct);
                                set.FindRedPct = (byte)pct;
                                Int16.TryParse(values[1], out pct);
                                set.FindGrnPct = (byte)pct;
                                Int16.TryParse(values[2], out pct);
                                set.FindBluPct = (byte)pct;
                                Int16.TryParse(values[3], out pct);
                                set.ReplRedPct = (byte)pct;
                                Int16.TryParse(values[4], out pct);
                                set.ReplGrnPct = (byte)pct;
                                Int16.TryParse(values[5], out pct);
                                set.ReplBluPct = (byte)pct;

                                sep = comment.IndexOf(" to ");
                                if (sep > 0)
                                {
                                    string find = comment.Substring(0, sep);
                                    string repl = comment.Substring(sep + 4);
                                    set.FindColorName = find;
                                    set.ReplColorName = repl;
                                }
                                else
                                {
                                    int lc = set.FindGrnPct << 16;
                                    lc += set.FindBluPct << 8;
                                    lc += set.FindRedPct;
                                    string find = NearestColor.FindNearestColorName(lc);
                                    set.FindColorName = find;

                                    lc  = set.ReplGrnPct << 16;
                                    lc += set.ReplBluPct << 8;
                                    lc += set.ReplRedPct;
                                    string repl = NearestColor.FindNearestColorName(lc);
                                    set.ReplColorName = repl;
                                }



                                count++;
                                Array.Resize(ref curPresets, count);
                                curPresets[count - 1] = set;
                            }
                        }
                    }
                    reader.Close();
                }
            }
            catch
            {
                System.Diagnostics.Debugger.Break();
            }

            return(count);
        }