Esempio n. 1
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. 2
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. 3
0
        private void GroupingTests(string theFile)
        {
            ////////////////////////////////////////////////////////////////////
            //
            // Tests for Grouping problems, trying to solve error
            // "This channel group is already in the channel group list"
            //
            ////////////////////////////////////////////////////////////////////

            StreamReader reader     = new StreamReader(theFile);
            int          sid        = utils.UNDEFINED;
            MemberType   typ        = MemberType.None;
            string       name       = "";
            string       info       = "";
            int          highID     = utils.UNDEFINED;
            string       lineIn     = reader.ReadLine();
            int          p          = lineIn.IndexOf(Sequence4.STARTchannel);
            int          lineNumber = 0;

            string[] data        = new string[7777];
            int[]    childIDs    = null;
            int      childCount  = 0;
            int      lastGroupID = utils.UNDEFINED;

            pnlInfo.Visible = true;
            bool gotOne          = false;
            bool ignoreDupes     = false;
            bool ignoreCircles   = false;
            bool ignoreConflicts = false;
            bool ignoreEmpty     = false;



            while (!reader.EndOfStream && !aborted)
            {
                lineIn = reader.ReadLine();
                lineNumber++;
                gotOne = false;

                // Test 1 - Collect SavedIndexes of ALL Channels, RGB Channels, and Channel Groups
                //    Look for duplicates
                p = lineIn.IndexOf(Sequence4.STARTchannel);
                if (p > 0)
                {
                    typ    = MemberType.Channel;
                    gotOne = true;
                }
                p = lineIn.IndexOf(Sequence4.STARTrgbChannel);
                if (p > 0)
                {
                    typ    = MemberType.RGBchannel;
                    gotOne = true;
                }
                p = lineIn.IndexOf(Sequence4.STARTchannelGroup);
                if (p > 0)
                {
                    typ    = MemberType.ChannelGroup;
                    gotOne = true;
                }
                if (gotOne)
                {
                    sid = utils.getKeyValue(lineIn, utils.FIELDsavedIndex);
                    if (sid > highID)
                    {
                        highID = sid;
                    }

                    // Test 2 - Check for duplicate children
                    // Test 3 - Check for circular reference (group includes itself)
                    if (typ == MemberType.ChannelGroup)
                    {
                        // First, check previous group
                        if (childCount > 0)
                        {
                            Array.Resize(ref childIDs, childCount);
                            Array.Sort(childIDs);
                            for (int c = 1; c < childCount; c++)
                            {
                                if (childIDs[c - 1] == childIDs[c])
                                {
                                    // Duplicate Members!!
                                    errCount++;
                                    if (!ignoreDupes && !aborted)
                                    {
                                        string[] zw  = data[lastGroupID].Split(utils.DELIM1);
                                        string   msg = "Duplicate Members in Group: " + zw[0] + "\r\n";
                                        msg += "SavedIndex=" + lastGroupID.ToString() + " starting at line " + zw[2] + "\r\n";
                                        string[] wz = data[childIDs[c]].Split(utils.DELIM1);
                                        msg += "Child: " + wz[0] + "\r\n";
                                        msg += "Saved Index=" + childIDs[c] + " Included more than once!";
                                        DialogResult dr = MessageBox.Show(this, msg, "Duplicate Child", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation);
                                        if (dr == DialogResult.Ignore)
                                        {
                                            ignoreDupes = true;
                                        }
                                        if (dr == DialogResult.Abort)
                                        {
                                            aborted     = true;
                                            ignoreDupes = true;
                                        }
                                    }
                                }
                                if (childIDs[c] == lastGroupID)
                                {
                                    // Circular Reference!!
                                    errCount++;
                                    if (!ignoreCircles && !aborted)
                                    {
                                        string[] zw  = data[lastGroupID].Split(utils.DELIM1);
                                        string   msg = "Circular Reference in Group: " + zw[0] + "\r\n";
                                        msg += "SavedIndex=" + lastGroupID.ToString() + " starting at line " + zw[2] + "\r\n";
                                        DialogResult dr = MessageBox.Show(this, msg, "Circular Reference", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation);
                                        if (dr == DialogResult.Ignore)
                                        {
                                            ignoreCircles = true;
                                        }
                                        if (dr == DialogResult.Abort)
                                        {
                                            aborted       = true;
                                            ignoreCircles = true;
                                        }
                                    }
                                }
                            }
                            if (childIDs[childCount - 1] == lastGroupID)
                            {
                                // Circular Reference!!
                                errCount++;
                                if (!ignoreCircles & !aborted)
                                {
                                    string[] zw  = data[lastGroupID].Split(utils.DELIM1);
                                    string   msg = "Circular Reference in Group: " + zw[0] + "\r\n";
                                    msg += "SavedIndex=" + lastGroupID.ToString() + " starting at line " + zw[2] + "\r\n";
                                    DialogResult dr = MessageBox.Show(this, msg, "Circular Reference", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    if (dr == DialogResult.Ignore)
                                    {
                                        ignoreCircles = true;
                                    }
                                    if (dr == DialogResult.Abort)
                                    {
                                        aborted       = true;
                                        ignoreCircles = true;
                                    }
                                }
                            }
                        }
                        // Finished checking previous group
                        // Setup for checking this group
                        childIDs    = new int[50];
                        childCount  = 0;
                        lastGroupID = sid;
                    }                     // end if group

                    name  = utils.getKeyWord(lineIn, utils.FIELDname);
                    info  = name;
                    info += utils.DELIM1 + SeqEnums.MemberName(typ);
                    info += utils.DELIM1 + lineNumber.ToString();
                    if (data[sid] == null)
                    {
                        data[sid]    = info;
                        lblNum.Text  = sid.ToString();
                        lblName.Text = name;
                        lblType.Text = SeqEnums.MemberName(typ);
                        pnlInfo.Refresh();
                    }
                    else
                    {
                        errCount++;
                        if (!ignoreConflicts && !aborted)
                        {
                            string   msg = "Conflict found on line " + lineNumber.ToString();
                            string[] zw  = data[sid].Split(utils.DELIM1);
                            msg += " with line " + zw[2] + "\r\n";
                            msg += zw[1] + " SavedIndex " + sid.ToString() + "\r\n";
                            msg += zw[0] + "\r\n";
                            msg += name;
                            DialogResult dr = MessageBox.Show(this, msg, "Conflict", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            if (dr == DialogResult.Ignore)
                            {
                                ignoreConflicts = true;
                            }
                            if (dr == DialogResult.Abort)
                            {
                                aborted         = true;
                                ignoreConflicts = true;
                            }
                        }
                    }             // end if saved item = null, or not
                }                 // End if Channel, RGB Channel, or Channel Group was found

                p = lineIn.IndexOf("<channelGroup savedInde");
                if (p > 0)
                {
                    // Group Child Item
                    sid = utils.getKeyValue(lineIn, utils.FIELDsavedIndex);
                    childIDs[childCount] = sid;
                    childCount++;
                }
            }             // End while lines remain
            reader.Close();

            if (!aborted)
            {
                // Test 4 - look for missing SavedIndexes
                for (int s = 0; s <= highID; s++)
                {
                    if (data[s] == null)
                    {
                        errCount++;
                        if (!ignoreEmpty && !aborted)
                        {
                            string       msg = "Missing Item: SavedIndex " + s.ToString() + " not found.";
                            DialogResult dr  = MessageBox.Show(this, msg, "Missing Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            if (dr == DialogResult.Ignore)
                            {
                                ignoreEmpty = true;
                            }
                            if (dr == DialogResult.Abort)
                            {
                                aborted     = true;
                                ignoreEmpty = true;
                            }
                        }
                    }
                }
            }

            pnlInfo.Visible = false;
        }