/// <summary>
        /// Read the current settings an show the user the right UI with the Current Settings
        /// </summary>
        public void updateUiWithCurrentSettings()
        {
            if (currentConnectionSettings.currentConnectionSetting == 1)
            {
                connectionSelection.SelectedIndex = connectionSelection.Items.IndexOf("TCP");
                tcpIpPage          = new settingsPageTcpIp(currentConnectionSettings, expertModeIsEnabled);
                tcpIpPage.Changed += new TcpIpSettingsChangedEventHandler(connectionSettingsChanged);

                if (settingsContentFrame.IsLoaded)
                {
                    settingsContentFrame.Content = tcpIpPage;
                }
                else
                {
                    settingsContentFrame.Loaded += new RoutedEventHandler(tcpipContentFrameLoaded);
                }
            }
            else
            {
                connectionSelection.SelectedIndex = connectionSelection.Items.IndexOf("RS232");
                rs232Page          = new settingsPageRs232(currentConnectionSettings, expertModeIsEnabled);
                rs232Page.Changed += new Rs232SettingsChangedEventHandler(connectionSettingsChanged);

                if (settingsContentFrame.IsLoaded)
                {
                    settingsContentFrame.Content = rs232Page;
                }
                else
                {
                    settingsContentFrame.Loaded += new RoutedEventHandler(rs232ContentFrameLoaded);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read the current settings an show the user the right UI with the Current Settings
        /// </summary>
        private void setUiFromPreviousSettings()
        {
            connectionSelection.ItemsSource = new string[] { "RS232", "TCP" };

            if (currentConnectionSettings.currentConnectionSetting == 1)
            {
                connectionSelection.SelectedIndex = connectionSelection.Items.IndexOf("TCP");
                tcpIpPage          = new settingsPageTcpIp(currentConnectionSettings);
                tcpIpPage.Changed += new TcpIpSettingsChangedEventHandler(connectionSettingsChanged);
                if (settingsContentFrame.IsLoaded)
                {
                    settingsContentFrame.Content = tcpIpPage;
                }
                else
                {
                    settingsContentFrame.Loaded += new RoutedEventHandler(tcpipContentFrameLoaded);
                }
            }
            else
            {
                connectionSelection.SelectedIndex = connectionSelection.Items.IndexOf("RS232");
                rs232Page          = new settingsPageRs232(currentConnectionSettings);
                rs232Page.Changed += new Rs232SettingsChangedEventHandler(connectionSettingsChanged);
                if (settingsContentFrame.IsLoaded)
                {
                    settingsContentFrame.Content = rs232Page;
                }
                else
                {
                    settingsContentFrame.Loaded += new RoutedEventHandler(rs232ContentFrameLoaded);
                }
            }
        }
        /// <summary>
        /// Selection of the Connection has Changed. Lets show the Data Corresponding to the Requested Connection Ínterface
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void connectionSelection_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Get the Sender Object as an ComboBox Object
            ComboBox conSelect = sender as ComboBox;

            if (conSelect.SelectedItem.ToString() == "RS232")
            {
                currentConnectionSettings.currentConnectionSetting = 2;                                     //Save the current selected Connection Interface
                rs232Page          = new settingsPageRs232(currentConnectionSettings, expertModeIsEnabled); // Create a new Page with the current Interface Settings
                rs232Page.Changed += new Rs232SettingsChangedEventHandler(connectionSettingsChanged);

                if (settingsContentFrame.IsLoaded)
                {
                    settingsContentFrame.Content = rs232Page;
                }
                else
                {
                    settingsContentFrame.Loaded += new RoutedEventHandler(rs232ContentFrameLoaded);
                }
            }
            else
            {
                currentConnectionSettings.currentConnectionSetting = 1;                                     //Save the current selected Connection Interface
                tcpIpPage          = new settingsPageTcpIp(currentConnectionSettings, expertModeIsEnabled); // Create a new Page with the current Interface Settings
                tcpIpPage.Changed += new TcpIpSettingsChangedEventHandler(connectionSettingsChanged);


                if (settingsContentFrame.IsLoaded)
                {
                    settingsContentFrame.Content = tcpIpPage;
                }
                else
                {
                    settingsContentFrame.Loaded += new RoutedEventHandler(tcpipContentFrameLoaded);
                }
            }
        }