Exemplo n.º 1
0
        /// <summary>
        /// Timer Tick to update the current Connection State
        /// </summary>
        /// <param name="sender"></param>
        private void updateStatusBar_Tick(object sender)
        {
            // Create a new Event Argument
            ConnectionStateUpdateEventArgs eventAargument = new ConnectionStateUpdateEventArgs();

            /// read the Current State of the Connection

            if (connectionSettings.functionSelect == 0)
            {
                eventAargument.connection1State = singleConnection.getConnectionState();
                eventAargument.connection2State = -1;// Hide the Second Communication
            }
            else if (connectionSettings.functionSelect == 1)
            {
                eventAargument.connection1State = multiConnection.getConnection1State();
                eventAargument.connection2State = multiConnection.getConnection2State();
            }

            // Call the Notifiy Function to Raise the Event
            statusbarUpdate(eventAargument);


            connectionStateCommuniation1 = eventAargument.connection1State;
            connectionStateCommuniation2 = eventAargument.connection2State;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Connect Method
        /// </summary>
        public void Connect(ConnectionSettings settingsForTheCommunicaton)
        {
            // Only get the Date if the local Values are null
            if (connectionSettings == null)
            {
                // OK First of all copy the Settings Object.
                // Clone the Settings Object. becouse We are gone to change the Settings withe the interfacing of the users..
                connectionSettings = (ConnectionSettings)ObjectCopier.Clone(settingsForTheCommunicaton);
            }

            if (connectionSettings.functionSelect == 0 && 0 != singleConnection.getConnectionState())
            {
                return;
            }
            else if (connectionSettings.functionSelect == 1 && (0 != multiConnection.getConnection1State() || 0 != multiConnection.getConnection2State()))
            {
                return;
            }



            // OK First of all copy the Settings Object.
            // Clone the Settings Object. becouse We are gone to change the Settings withe the interfacing of the users..
            connectionSettings = (ConnectionSettings)ObjectCopier.Clone(settingsForTheCommunicaton);

            // bevore we try to connect lets Disconnect every maybe runnung Communications
            //Disconnect();


            if (connectionSettings.functionSelect == 0)
            {
                singleConnection.connectionSettings = connectionSettings;
                singleConnection.Connect();
            }
            else if (connectionSettings.functionSelect == 1)
            {
                multiConnection.connectionSettings = connectionSettings;
                multiConnection.Connect();
            }

            // Start the StatusBar Update Ticker
            stateTimer = new Timer(new TimerCallback(updateStatusBar_Tick));
            stateTimer.Change(0, 200);
        }