Exemplo n.º 1
0
        protected override void OnDeactivate(bool close)
        {
            WriteVarBOOL_ObservableCollection.Clear();
            WriteValBOOL_ObservableCollection.Clear();
            ReadVar_ObservableCollection.Clear();
            ReadVal_ObservableCollection.Clear();
            WriteVar_ObservableCollection.Clear();
            WriteVal_ObservableCollection.Clear();

            //BackgroundWorers Events detach
            _toggleButtonWorker.DoWork             -= DoWork_Toggle;
            _toggleButtonWorker.RunWorkerCompleted -= WorkCompleted_Toggle;
            _toggleButtonWorker.ProgressChanged    -= ProgressChanged_Toggle;

            _writeVarWorker.DoWork             -= DoWork_WriteVar;
            _writeVarWorker.RunWorkerCompleted -= WorkCompleted_WriteVar;
            _writeVarWorker.ProgressChanged    -= ProgressChanged_WriteVar;

            _readVarWorker.DoWork             -= DoWork_ReadVar;
            _readVarWorker.RunWorkerCompleted -= WorkCompleted_ReadVar;
            _readVarWorker.ProgressChanged    -= ProgressChanged_ReadVar;

            //Unsubscribe to the event messages
            _eventAggregator.Unsubscribe(this);
            base.OnDeactivate(close);
        }
Exemplo n.º 2
0
        //Overides
        #region Overides
        protected override void OnActivate()
        {
            //subscribe to the event messages
            _eventAggregator.Subscribe(this);

            // Read parent values on activation, after it will be handled by messaging
            MainViewModel ParentViewModel = (MainViewModel)this.Parent;

            IP_address_ReadWriteTab = ParentViewModel.IP_Address;
            Port_ReadWriteTab       = ParentViewModel.Port;

            //BackgroundWorers Events attach
            _toggleButtonWorker.DoWork             += DoWork_Toggle;
            _toggleButtonWorker.RunWorkerCompleted += WorkCompleted_Toggle;
            _toggleButtonWorker.ProgressChanged    += ProgressChanged_Toggle;

            _writeVarWorker.DoWork             += DoWork_WriteVar;
            _writeVarWorker.RunWorkerCompleted += WorkCompleted_WriteVar;
            _writeVarWorker.ProgressChanged    += ProgressChanged_WriteVar;

            _readVarWorker.DoWork             += DoWork_ReadVar;
            _readVarWorker.RunWorkerCompleted += WorkCompleted_ReadVar;
            _readVarWorker.ProgressChanged    += ProgressChanged_ReadVar;

            for (int i = 0; i < 5; i++)
            {
                WriteVarBOOL_ObservableCollection.Add(new Parameters()
                {
                    Name = i.ToString(), Value = ""
                });
                WriteValBOOL_ObservableCollection.Add(new Parameters()
                {
                    Name = i.ToString(), Value = ""
                });
                ReadVar_ObservableCollection.Add(new Parameters()
                {
                    Name = i.ToString(), Value = ""
                });
                ReadVal_ObservableCollection.Add(new Parameters()
                {
                    Name = i.ToString(), Value = ""
                });
                WriteVar_ObservableCollection.Add(new Parameters()
                {
                    Name = i.ToString(), Value = ""
                });
                WriteVal_ObservableCollection.Add(new Parameters()
                {
                    Name = i.ToString(), Value = ""
                });
            }

            base.OnActivate();
        }