private void StoreNewAvarageDuration(JobEventArg obj, JobViewModel jobViewModel)
 {
     var newAvarageDuration = jobViewModel.AvarageDuration != 0
                                  ? (jobViewModel.AvarageDuration + jobViewModel.PreviousDuration)/2
                                  : jobViewModel.PreviousDuration;
     IsolatedStorageSettings.ApplicationSettings[obj.JobId] = newAvarageDuration;
 }
 private void Scanner_UpdateRecord(object sender, JobEventArg e)
 {
     this.Invoke(new MethodInvoker(() =>
     {
         lblTotalRecord.Text = $"Total Record: {e.Data.Count()}";
     }));
 }
 private void LoadAvarageDurationFromStore(JobEventArg obj, JobViewModel jobViewModel)
 {
     if (IsolatedStorageSettings.ApplicationSettings.Contains(obj.JobId))
     {
         jobViewModel.AvarageDuration = (long) IsolatedStorageSettings.ApplicationSettings[obj.JobId];
     }
 }
 private void Scanner_UpdateJobData(object sender, JobEventArg e)
 {
     this.Invoke(new MethodInvoker(() =>
     {
         gridControl1.DataSource = e.Data;
         gridControl1.RefreshDataSource();
     }));
 }
 public void EndJobHandler(JobEventArg obj)
 {
     --activeJobCount;
     if (activeJobCount <= 0)
     {
         iconSource = IconSourceInactive;
         PropertyChanged(this, new PropertyChangedEventArgs("IconSource"));
     }
 }
 public void BeginJobHandler(JobEventArg obj)
 {
     ++activeJobCount;
     if (activeJobCount > 0)
     {
         iconSource = IconSourceActive;
         PropertyChanged(this, new PropertyChangedEventArgs("IconSource"));
     }
 }
 public void EndJobHandler(JobEventArg obj)
 {
     var datacontext = DataContext as JobListViewModel;
     var result = from j in datacontext.Jobs where j.Id == obj.JobId select j;
     if (result.Count() == 1)
     {
         var jobViewModel = result.First();
         jobViewModel.Stop();
         StoreNewAvarageDuration(obj, jobViewModel);
         datacontext.Jobs.Remove(jobViewModel);
     }
 }
        public void BeginJobHandler(JobEventArg obj)
        {
            var datacontext = DataContext as JobListViewModel;
            var result = from j in datacontext.Jobs where j.Id == obj.JobId select j;
            if (result.Count() == 0)
            {
                var jobViewModel = new JobViewModel(obj.JobId, obj.JobName);

                LoadAvarageDurationFromStore(obj, jobViewModel);

                datacontext.Jobs.Add(jobViewModel);
                jobViewModel.Start();
            }
        }