Example #1
0
        private int LoadPresets()
        {
            int errStatus = 0;

            //string basePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Light-O-Rama 2015\\Sequences\\";
            string basePath = utils.DefaultChannelConfigsPath;
            string fileName = basePath + "ColorChanger Presets.xml";

            StreamReader reader = new StreamReader(fileName);
            string       lineIn;         // line read in (does not get modified)
            int          pos1      = -1; // positions of certain key text in the line
            int          lineCount = 0;

            // Zero these out from any previous run
            presetSetCount = 0;
            //colorChangeCount = 0;

            int curPreset = -1;
            int curChange = -1;

            ColorChange[] colorChanges = new ColorChange[1];

            // * PASS 1 - COUNT OBJECTS
            while ((lineIn = reader.ReadLine()) != null)
            {
                lineCount++;
                // does this line mark the start of a preset set?
                pos1 = lineIn.IndexOf("<presetSet name=");
                if (pos1 > 0)
                {
                    presetSetCount++;
                }
                pos1 = lineIn.IndexOf("<colorChange fromName=");
                if (pos1 > 0)
                {
                    //colorChangeCount++;
                }
            }
            reader.Close();

            // CREATE ARRAYS TO HOLD OBJECTS
            presetSets = new PresetSet[presetSetCount];

            // * PASS 2 - COLLECT OBJECTS
            reader = new StreamReader(fileName);
            while ((lineIn = reader.ReadLine()) != null)
            {
                lineCount++;
                // does this line mark the start of a preset set?
                pos1 = lineIn.IndexOf(TABLEpresetSet + " " + FIELDname);
                if (pos1 > 0)
                {
                    curPreset++;
                    PresetSet ps = new PresetSet();
                    ps.name = utils.getKeyWord(lineIn, FIELDname);
                    presetSets[curPreset] = ps;

                    lineIn    = reader.ReadLine();
                    lineIn    = reader.ReadLine();
                    curChange = -1;
                    pos1      = lineIn.IndexOf(TABLEcolorChange + " " + FIELDfromName);
                    while (pos1 > 0)
                    {
                        curChange++;
                        Array.Resize(ref colorChanges, curChange + 1);
                        ColorChange cc = new ColorChange();
                        cc.fromName             = utils.getKeyWord(lineIn, FIELDfromName);
                        cc.fromR                = utils.getKeyValue(lineIn, FIELDfromR);
                        cc.fromG                = utils.getKeyValue(lineIn, FIELDfromG);
                        cc.fromB                = utils.getKeyValue(lineIn, FIELDfromB);
                        cc.toName               = utils.getKeyWord(lineIn, FIELDtoName);
                        cc.toR                  = utils.getKeyValue(lineIn, FIELDtoR);
                        cc.toG                  = utils.getKeyValue(lineIn, FIELDtoG);
                        cc.toB                  = utils.getKeyValue(lineIn, FIELDtoB);
                        colorChanges[curChange] = cc;

                        lineIn = reader.ReadLine();
                        pos1   = lineIn.IndexOf(TABLEcolorChange + " " + FIELDfromName);
                    }
                    if (curChange > -1)
                    {
                        ps.colorChanges       = colorChanges;
                        ps.changeCount        = curChange + 1;
                        presetSets[curPreset] = ps;
                    }
                }
            }

            reader.Close();


            string sMsg;

            sMsg  = "File Parse Complete!\r\n\r\n";
            sMsg += lineCount.ToString() + " lines\r\n";
            sMsg += seq.Channels.Count.ToString() + " Channels\r\n";
            //sMsg += RGBchannels.Count.ToString() + " RGB Channels\r\n";
            //sMsg += seq.effectCount.ToString() + " Effects\r\n";
            //sMsg += groupCount.ToString() + " groups\r\n";
            //sMsg += groupItemCount.ToString() + " group items";

            DialogResult mReturn;

            mReturn = MessageBox.Show(sMsg, "File Parse Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);


            return(errStatus);
        }
Example #2
0
        private void cboPresets_SelectedIndexChanged(object sender, EventArgs e)
        {
            PresetSet ps = presetSets[cboPresets.SelectedIndex];

            ColorChange[] css = ps.colorChanges;
            string        txt;

            txtColorFrom1.Text = "";
            txtColorFrom2.Text = "";
            txtColorFrom3.Text = "";
            txtColorFrom4.Text = "";
            txtColorFrom5.Text = "";
            txtColorFrom6.Text = "";
            txtColorTo1.Text   = "";
            txtColorTo2.Text   = "";
            txtColorTo3.Text   = "";
            txtColorTo4.Text   = "";
            txtColorTo5.Text   = "";
            txtColorTo6.Text   = "";
            picFrom1.BackColor = grpColors.BackColor;
            picFrom2.BackColor = grpColors.BackColor;
            picFrom3.BackColor = grpColors.BackColor;
            picFrom4.BackColor = grpColors.BackColor;
            picFrom5.BackColor = grpColors.BackColor;
            picFrom6.BackColor = grpColors.BackColor;
            picTo1.BackColor   = grpColors.BackColor;
            picTo2.BackColor   = grpColors.BackColor;
            picTo3.BackColor   = grpColors.BackColor;
            picTo4.BackColor   = grpColors.BackColor;
            picTo5.BackColor   = grpColors.BackColor;
            picTo6.BackColor   = grpColors.BackColor;

            if (ps.changeCount > 0)
            {
                txt = css[0].fromR.ToString() + "," + css[0].fromG.ToString() + "," + css[0].fromB.ToString();
                txtColorFrom1.Text = txt;
                picFrom1.BackColor = makeColor(css[0].fromR, css[0].fromG, css[0].fromB);
                txt = css[0].toR.ToString() + "," + css[0].toG.ToString() + "," + css[0].toB.ToString();
                txtColorTo1.Text = txt;
                picTo1.BackColor = makeColor(css[0].toR, css[0].toG, css[0].toB);
            }
            if (ps.changeCount > 1)
            {
                txt = css[1].fromR.ToString() + "," + css[1].fromG.ToString() + "," + css[1].fromB.ToString();
                txtColorFrom2.Text = txt;
                picFrom2.BackColor = makeColor(css[1].fromR, css[1].fromG, css[1].fromB);
                txt = css[1].toR.ToString() + "," + css[1].toG.ToString() + "," + css[1].toB.ToString();
                txtColorTo2.Text = txt;
                picTo2.BackColor = makeColor(css[1].toR, css[1].toG, css[1].toB);
            }
            if (ps.changeCount > 2)
            {
                txt = css[2].fromR.ToString() + "," + css[2].fromG.ToString() + "," + css[2].fromB.ToString();
                txtColorFrom3.Text = txt;
                picFrom3.BackColor = makeColor(css[2].fromR, css[2].fromG, css[2].fromB);
                txt = css[2].toR.ToString() + "," + css[2].toG.ToString() + "," + css[2].toB.ToString();
                txtColorTo3.Text = txt;
                picTo3.BackColor = makeColor(css[2].toR, css[2].toG, css[2].toB);
            }
            if (ps.changeCount > 3)
            {
                txt = css[3].fromR.ToString() + "," + css[3].fromG.ToString() + "," + css[3].fromB.ToString();
                txtColorFrom4.Text = txt;
                picFrom4.BackColor = makeColor(css[3].fromR, css[3].fromG, css[3].fromB);
                txt = css[3].toR.ToString() + "," + css[3].toG.ToString() + "," + css[3].toB.ToString();
                txtColorTo4.Text = txt;
                picTo4.BackColor = makeColor(css[3].toR, css[3].toG, css[3].toB);
            }
            if (ps.changeCount > 4)
            {
                txt = css[4].fromR.ToString() + "," + css[4].fromG.ToString() + "," + css[4].fromB.ToString();
                txtColorFrom5.Text = txt;
                picFrom5.BackColor = makeColor(css[4].fromR, css[4].fromG, css[4].fromB);
                txt = css[4].toR.ToString() + "," + css[4].toG.ToString() + "," + css[4].toB.ToString();
                txtColorTo5.Text = txt;
                picTo5.BackColor = makeColor(css[4].toR, css[4].toG, css[4].toB);
            }
            if (ps.changeCount > 5)
            {
                txt = css[5].fromR.ToString() + "," + css[5].fromG.ToString() + "," + css[5].fromB.ToString();
                txtColorFrom6.Text = txt;
                picFrom6.BackColor = makeColor(css[5].fromR, css[5].fromG, css[5].fromB);
                txt = css[5].toR.ToString() + "," + css[5].toG.ToString() + "," + css[5].toB.ToString();
                txtColorTo6.Text = txt;
                picTo6.BackColor = makeColor(css[5].toR, css[5].toG, css[5].toB);
            }
        }