Example #1
0
        /// <summary>
        /// The constructor access the data available from the channels manager
        /// and populates the GUI
        /// </summary>
        public simple_Switcher()
        {
            //show a splash screen on  window load
            Thread splash = new Thread(new ThreadStart(showSplash));

            splash.Start();
            Thread.Sleep(1250);
            splash.Abort();
            Thread.Sleep(100);

            InitializeComponent();

            //initialize channel data
            ch_mngr = new Channels_Manager();

            //
            cn_mngr = new Connections_Manager();

            //add channel names to listbox
            for (int i = 0; i < ch_mngr.number_of_Src_Channels; i++)
            {
                src_listBox.Items.Add((string)ch_mngr.get_Channel_Information("Sources", i, 0));
            }

            for (int i = 0; i < ch_mngr.number_of_Dest_Channels; i++)
            {
                dest_listBox.Items.Add((string)ch_mngr.get_Channel_Information("Destinations", i, 0));
            }

            //set the first channels as visible
            if (src_listBox.Items.Count > 0 && dest_listBox.Items.Count > 0)
            {
                src_listBox.SelectedIndex  = 0;
                dest_listBox.SelectedIndex = 0;
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        public void refresh_ListBoxes()
        {
            //get the currently selected ant store it
            int src_sel  = src_listBox.SelectedIndex;
            int dest_sel = dest_listBox.SelectedIndex;

            //remove all items
            src_listBox.Items.Clear();
            dest_listBox.Items.Clear();

            //re-add all items
            //add channel names to listbox
            for (int i = 0; i < ch_mngr.number_of_Src_Channels; i++)
            {
                src_listBox.Items.Add((string)ch_mngr.get_Channel_Information("Sources", i, 0));
            }

            for (int i = 0; i < ch_mngr.number_of_Dest_Channels; i++)
            {
                dest_listBox.Items.Add((string)ch_mngr.get_Channel_Information("Destinations", i, 0));
            }

            //set the selected to previously selected
            if (src_sel > -1 || dest_sel > -1)
            {
                src_listBox.SelectedIndex  = src_sel;
                dest_listBox.SelectedIndex = dest_sel;
            }
            else
            {
                dest_listBox.SelectedIndex = 0;
                src_listBox.SelectedIndex  = 0;
            }
        }
Example #3
0
        /// <summary>
        /// The constructor access the data available from the channels manager
        /// and populates the GUI
        /// </summary>
        public simple_Switcher()
        {
            InitializeComponent();

            //get current date time
            DOY = DateTime.Now.DayOfYear;

            //initialize channel data
            ch_mngr = new Channels_Manager();

            //initialize connections
            cn_mngr = new Connections_Manager();

            //initialize combo box arrays
            in_combobox_array = new ComboBox[]
            {
                in_comboBox1, in_comboBox2, in_comboBox3, in_comboBox4,
                in_comboBox5, in_comboBox6, in_comboBox7, in_comboBox8,
                in_comboBox9, in_comboBox10, in_comboBox11, in_comboBox12,
                in_comboBox13, in_comboBox14, in_comboBox15, in_comboBox16,
                in_comboBox17, in_comboBox18, in_comboBox19, in_comboBox20,
                in_comboBox21, in_comboBox22, in_comboBox23, in_comboBox24
            };

            out_combobox_array = new ComboBox[]
            {
                out_comboBox1, out_comboBox2, out_comboBox3, out_comboBox4,
                out_comboBox5, out_comboBox6, out_comboBox7, out_comboBox8,
                out_comboBox9, out_comboBox10, out_comboBox11, out_comboBox12
            };

            //initialize array to rember last selector positon when moving
            selector_lastpos = new string[12, 6];

            //add channel names to listbox
            for (int i = 0; i < ch_mngr.Number_of_Channels("Sources"); i++)
            {
                src_listBox.Items.Add((string)ch_mngr.get_Channel_Information("Sources", i, 0));

                //add names to in combo boxes
                for (int j = 0; j < in_combobox_array.Length; j++)
                {
                    in_combobox_array[j].Items.Add((string)ch_mngr.get_Channel_Information("Sources", i, 0));
                }
            }

            for (int i = 0; i < ch_mngr.Number_of_Channels("Destinations"); i++)
            {
                dest_listBox.Items.Add((string)ch_mngr.get_Channel_Information("Destinations", i, 0));

                //add names to out combo boxes
                for (int j = 0; j < out_combobox_array.Length; j++)
                {
                    out_combobox_array[j].Items.Add((string)ch_mngr.get_Channel_Information("Destinations", i, 0));
                }
            }

            //initialize crosspoints points
            x_crosspoints = new int[24];
            y_crosspoints = new int[12];

            //set comboboxes to first selection
            int p = 0;

            for (int j = 0; j < in_combobox_array.Length / 2; j++)
            {
                //incremental setting on intialize
                if (p < in_combobox_array[0].Items.Count)
                {
                    in_combobox_array[j].SelectedIndex = p++;
                    in_combobox_array[j + (in_combobox_array.Length / 2)].SelectedIndex = p++;
                }
                else
                {
                    p = 0;
                    in_combobox_array[j].SelectedIndex = p++;
                    in_combobox_array[j + (in_combobox_array.Length / 2)].SelectedIndex = p++;
                }
            }

            p = 0;
            for (int j = 0; j < out_combobox_array.Length; j++)
            {
                //incremental setting on intialize
                if (p < out_combobox_array[0].Items.Count)
                {
                    out_combobox_array[j].SelectedIndex = p++;
                }
                else
                {
                    p = 0;
                    out_combobox_array[j].SelectedIndex = p++;
                }
            }
        }
Example #4
0
        private void src_Add_Click(object sender, EventArgs e)
        {
            //no colons allowed
            if (src_nameBox.Text.Contains(":") || src_portBox.Text.Contains(":") || src_ipBox.Text.Contains(":"))
            {
                //
                return;
            }

            //check if ip is in correct format
            try
            {
                IPAddress.Parse(src_ipBox.Text);
            }
            catch (ArgumentNullException s)
            {
                MessageBox.Show(s.Message);
            }
            catch (FormatException f)
            {
                MessageBox.Show(f.Message);
            }

            //check if port is only numbers
            for (int j = 0; j < src_portBox.Text.Length; j++)
            {
                if (!Char.IsNumber(src_portBox.Text, j))
                {
                    return;
                }
            }

            //add to hd stored file
            if (ch_mngr.add_Channel("Sources", src_nameBox.Text, src_ipBox.Text, Convert.ToInt32(src_portBox.Text)))
            {
                //add to list and combo boxes
                src_listBox.Items.Add(src_nameBox.Text);

                for (int j = 0; j < in_combobox_array.Length; j++)
                {
                    //
                    in_combobox_array[j].Items.Add(src_nameBox.Text);
                }
            }
            else
            {
                //clear all lists and reinitialize them
                src_listBox.Items.Clear();

                for (int m = 0; m < ch_mngr.Number_of_Channels("Sources"); m++)
                {
                    src_listBox.Items.Add(ch_mngr.get_Channel_Information("Sources", m, 0));
                }

                for (int j = 0; j < in_combobox_array.Length; j++)
                {
                    //
                    in_combobox_array[j].Items.Clear();

                    for (int k = 0; k < ch_mngr.Number_of_Channels("Sources"); k++)
                    {
                        in_combobox_array[j].Items.Add(ch_mngr.get_Channel_Information("Sources", k, 0));
                    }
                }
            }
        }