Exemple #1
0
        //-------------------------------------------------------------
        //
        //	UniverseGet() - allow referenced retrieval of the data
        //
        //-------------------------------------------------------------

        public bool UniverseGet(int index, ref bool active, ref Int32 universe, ref Int32 start, ref Int32 size, ref string unicast,
                                ref string multicast, ref Int32 ttl)
        {
            var row = univDGVN.Rows[index];

            if (row.IsNewRow)
            {
                return(false);
            }

            if (row.Cells[ActiveColumn].Value == null)
            {
                active = false;
            }
            else
            {
                active = (bool)row.Cells[ActiveColumn].Value;
            }

            // all numeric columns are stored as strings
            universe = OutputPlugin.TryParseInt32((string)row.Cells[UniverseColumn].Value, 1);
            start    = OutputPlugin.TryParseInt32((string)row.Cells[StartColumn].Value, 1);
            size     = OutputPlugin.TryParseInt32((string)row.Cells[SizeColumn].Value, 1);
            ttl      = OutputPlugin.TryParseInt32((string)row.Cells[TtlColumn].Value, 1);

            // first set both unicast and multicast results to null

            unicast   = null;
            multicast = null;

            // then set the selected unicast/multicast destination

            if (row.Cells[DestinationColumn].Value != null)
            {
                var destination = (string)row.Cells[DestinationColumn].Value;

                if (destination.StartsWith("Unicast "))
                {
                    unicast = destination.Substring(8);
                }

                else if (destination.StartsWith("Multicast "))
                {
                    multicast = _nicNames[destination.Substring(10)];
                }
            }

            return(true);
        }
Exemple #2
0
        //-------------------------------------------------------------
        //
        //	okButton_Click() - validate the data consistency
        //
        //-------------------------------------------------------------

        private void okButton_Click(object sender, EventArgs e)
        {
            var valid                = true;
            var errorList            = new StringBuilder();
            var universeDestinations = new SortedList <string, int>();


            // first buid a table of active universe/destination combos

            foreach (var universeDestination in from DataGridViewRow row in univDGVN.Rows
                     where !row.IsNewRow
                     where row.Cells[ActiveColumn].Value != null
                     where (bool)row.Cells[ActiveColumn].Value
                     where row.Cells[DestinationColumn].Value != null
                     select(string) row.Cells[UniverseColumn].Value + ":" + (string)row.Cells[DestinationColumn].Value)
            {
                if (universeDestinations.ContainsKey(universeDestination))
                {
                    universeDestinations[universeDestination] = 1;
                }
                else
                {
                    universeDestinations.Add(universeDestination, 0);
                }
            }

            // now scan for empty destinations, duplicate universe/destination combos, channels errors, etc.

            foreach (var row in from DataGridViewRow row in univDGVN.Rows
                     where !row.IsNewRow
                     where row.Cells[ActiveColumn].Value != null
                     where (bool)row.Cells[ActiveColumn].Value
                     select row)
            {
                // test for null destinations
                if (row.Cells[DestinationColumn].Value == null)
                {
                    if (!valid)
                    {
                        errorList.Append("\r\n");
                    }
                    errorList.Append("Row ");
                    errorList.Append((row.Index + 1).ToString(CultureInfo.InvariantCulture));
                    errorList.Append(": No Destination Selected");
                    valid = false;
                }

                else
                {
                    // otherwise, test for duplicate universe/destination combos
                    var universeDestination = (string)row.Cells[UniverseColumn].Value + ":" + (string)row.Cells[DestinationColumn].Value;

                    if (universeDestinations[universeDestination] != 0)
                    {
                        if (!valid)
                        {
                            errorList.Append("\r\n");
                        }
                        errorList.Append("Row ");
                        errorList.Append((row.Index + 1).ToString(CultureInfo.InvariantCulture));
                        errorList.Append(": Duplicate Universe/Destination Combination");
                        valid = false;
                    }
                }

                // only test for range if more than 0 channels, otherwise wait for runtime
                if (_pluginChannelCount > 0)
                {
                    // now test for valid channel start
                    if (OutputPlugin.TryParseInt32((string)row.Cells[StartColumn].Value, 1) > _pluginChannelCount)
                    {
                        if (!valid)
                        {
                            errorList.Append("\r\n");
                        }
                        errorList.Append("Row ");
                        errorList.Append((row.Index + 1).ToString(CultureInfo.InvariantCulture));
                        errorList.Append(": Start Channel Out Of Range");
                        valid = false;
                    }

                    // now test for valid channel size
                    if (OutputPlugin.TryParseInt32((string)row.Cells[StartColumn].Value, 1) +
                        OutputPlugin.TryParseInt32((string)row.Cells[SizeColumn].Value, 1) - 1 > _pluginChannelCount)
                    {
                        if (!valid)
                        {
                            errorList.Append("\r\n");
                        }
                        errorList.Append("Row ");
                        errorList.Append((row.Index + 1).ToString(CultureInfo.InvariantCulture));
                        errorList.Append(": Start Channel + Size Out Of Range");
                        valid = false;
                    }
                }

                // now test for ttl value
                if (OutputPlugin.TryParseInt32((string)row.Cells[TtlColumn].Value, 1) != 0)
                {
                    continue;
                }
                if (!valid)
                {
                    errorList.Append("\r\n");
                }
                errorList.Append("Row ");
                errorList.Append((row.Index + 1).ToString(CultureInfo.InvariantCulture));
                errorList.Append(": Warning - Zero TTL");
                valid = false;
            }

            if (!valid)
            {
                J1MsgBox.ShowMsg("Your configurations contains active entries that may cause run time errors.", errorList.ToString(),
                                 "Configuration Validation", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                J1MsgBox.ShowMsg("Your configuration appears to be valid.",
                                 "Configuration Validation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }