public void AddWorker(Worker worker)
        {
            if (!_workers.Contains(worker))
            {

            }
        }
Exemple #2
0
		/// <summary>
		/// This methods starts the Model. If we don't call this function, all we'll have
		/// is the user interface. There won't be anything valuable happening underneath.
		/// </summary>
		public static void Initialize()
		{
			// Event allows us to interrupt initialization
			if( m_DelayHandle.WaitOne( 1000 ) )
			{
				return;
			}

			for(int i = 0; i < 5; ++i)
			{
				Worker worker = new Worker();
				worker.Name = "Worker " + (i + 1).ToString();
				Workers.Add( worker );

				// Event allows us to interrupt initialization
				if( m_DelayHandle.WaitOne( 1000 ) )
				{
					return;
				}
			}
		}
 public void RemoveWorker(Worker worker)
 {
     _workers.Remove(worker);
 }
        /// <summary>
		/// This initialization function must be called on the UI thread. It registers 
		/// listeners on Model classes so we know where there is new information to display.
        /// </summary>
		public void InitializeBindings( Worker worker )
		{
			// This view model is responsible for pulling information from worker.
			m_MyWorker = worker;

			// This object must be created on the UI thread
			m_UIDispatcher = Dispatcher.CurrentDispatcher;

			// Listen to property changes in the worker
			m_MyWorker.PropertyChanged += new PropertyChangedEventHandler( OnSourcePropertyChangedSourceThread );

			OnSourcePropertyChangedSourceThread( m_MyWorker, new PropertyChangedEventArgs( "Name" ) );
		}
		/// <summary>
		/// Removes user interface elements for a worker
		/// </summary>
		private void RemoveWorkerTabItem( Worker worker )
		{
			TabItems.Remove( m_TabItemsDictionary[ worker ] );
			m_TabItemsDictionary.Remove( worker );
		}
		/// <summary>
		/// Creates the user interface elements for a Worker
		/// </summary>
		private void CreateWorkerTabItem( Worker worker )
		{
			// Create UI objects for this worker
			WorkerView view = new WorkerView();
			WorkerViewModel viewModel = new WorkerViewModel();
			TabItem tabItem = new TabItem();

			// Connect events, bindings and UI elements
			viewModel.InitializeBindings( worker ); ;
			view.DataContext = viewModel;
			tabItem.Header = viewModel.WorkerName;
			tabItem.Content = view;
			tabItem.DataContext = viewModel;
			tabItem.SetBinding( TabItem.HeaderProperty, "WorkerName" );

			// Add the Tab to the UI
			m_TabItemsDictionary[ worker ] = tabItem;
			TabItems.Add( tabItem );
		}