示例#1
0
 private void RaiseButtonNotifications()
 {
     AddTgFileCommand.RaiseCanExecuteChangedNotification();
     AddTgFolderCommand.RaiseCanExecuteChangedNotification();
     RemoveTgFileCommand.RaiseCanExecuteChangedNotification();
     ClearTgFilesCommand.RaiseCanExecuteChangedNotification();
     ProcessCommand.RaiseCanExecuteChangedNotification();
     SetOutputFolderCommand.RaiseCanExecuteChangedNotification();
     LoadOutputFolderCommand.RaiseCanExecuteChangedNotification();
     ExportAllCommand.RaiseCanExecuteChangedNotification();
     BatchSettingsCommand.RaiseCanExecuteChangedNotification();
 }
示例#2
0
        //private void Closing(object args)
        //{
        //    if (!Running)
        //    {
        //        return;
        //    }

        //    var result = MessageBox.Show("The program is currently running, are you sure you want to cancel it?", "Batch Running", MessageBoxButton.YesNo, MessageBoxImage.Question);

        //    if (result == MessageBoxResult.Yes)
        //    {
        //        IEnumerable<SingleMouseViewModel> allMice = TgItemsSource.Concat(NtgItemsSource);
        //        foreach (SingleMouseViewModel mouse in allMice)
        //        {
        //            mouse.Stop = true;
        //        }
        //        Running = false;
        //        return;
        //    }

        //    CancelEventArgs cancelEventArgs = args as CancelEventArgs;
        //    if (cancelEventArgs != null)
        //    {
        //        cancelEventArgs.Cancel = true;
        //    }
        //}

        private void LoadOutputFolder()
        {
            IRepository repo            = RepositoryResolver.Resolve <IRepository>();
            string      initialLocation = repo.GetValue <string>("OutputFolderLocation");

            string folderLocation = FileBrowser.BrowseForFolder(initialLocation);

            if (string.IsNullOrWhiteSpace(folderLocation))
            {
                return;
            }

            repo.SetValue("OutputFolderLocation", folderLocation);
            repo.Save();

            string[] artFiles = Directory.GetFiles(folderLocation, "*.art");

            foreach (string file in artFiles)
            //Parallel.ForEach(artFiles, file =>
            {
                string videoFileName = Path.GetFileNameWithoutExtension(file);

                //if (videoFileName.Contains("091119-0038"))
                //{
                //    Console.WriteLine("h");
                //}

                if (string.IsNullOrWhiteSpace(videoFileName))
                {
                    continue;
                    //return;
                }

                //if (videoFileName.Contains("091218-0179"))
                //{
                //    Console.WriteLine("test");
                //}

                //SingleMouseViewModel mouse = null;
                ////videoFileName = file.Replace(".art", "");
                //bool testBreak = false;
                //foreach (var listMouse in TgItemsSource)
                //{
                //    foreach (var temp in listMouse.VideoFiles)
                //    {
                //        if (temp.VideoFileName.Contains(videoFileName))
                //        {
                //            mouse = listMouse;
                //            testBreak = true;
                //            break;
                //        }
                //    }

                //    if (testBreak)
                //    {
                //        break;
                //    }
                //}

                SingleMouseViewModel mouse = TgItemsSource.FirstOrDefault(x => x.VideoFiles.FirstOrDefault(y => y.VideoFileName.Contains(videoFileName)) != null);

                if (mouse == null)
                {
                    //Can't find mouse
                    //return;
                    continue;
                }

                ISingleFile singleFile = mouse.VideoFiles.First(x => x.VideoFileName.Contains(videoFileName));

                XmlSerializer   serializer = new XmlSerializer(typeof(TrackedVideoXml));
                TrackedVideoXml trackedVideoXml;
                using (StreamReader reader = new StreamReader(file))
                {
                    trackedVideoXml = (TrackedVideoXml)serializer.Deserialize(reader);
                }

                ITrackedVideo trackedVideo = trackedVideoXml.GetData();

                IMouseDataResult mouseDataResult = ModelResolver.Resolve <IMouseDataResult>();

                if (trackedVideo.Result != SingleFileResult.Ok)
                {
                    mouseDataResult.Message      = trackedVideo.Message;
                    mouseDataResult.VideoOutcome = trackedVideo.Result;

                    if (mouse.Results == null)
                    {
                        mouse.Results = new Dictionary <ISingleFile, IMouseDataResult>();
                    }
                    mouse.Results.Add(singleFile, mouseDataResult);
                    mouse.ReviewCommand.RaiseCanExecuteChangedNotification();
                    mouse.UpdateProgress(singleFile, 1);

                    continue;
                }

                var tempResults = trackedVideo.Results;
                Dictionary <int, ISingleFrameResult> results = new Dictionary <int, ISingleFrameResult>();
                foreach (var kvp in tempResults)
                {
                    ISingleFrameResult singleFrame = ModelResolver.Resolve <ISingleFrameResult>();

                    if (kvp.Value != null)
                    {
                        ISingleFrameResult tempResult = kvp.Value;
                        singleFrame.HeadPoints        = tempResult.HeadPoints;
                        singleFrame.CentroidSize      = tempResult.CentroidSize;
                        singleFrame.PelvicArea        = tempResult.PelvicArea;
                        singleFrame.PelvicArea2       = tempResult.PelvicArea2;
                        singleFrame.PelvicArea3       = tempResult.PelvicArea3;
                        singleFrame.PelvicArea4       = tempResult.PelvicArea4;
                        singleFrame.SmoothedHeadPoint = tempResult.SmoothedHeadPoint;
                        singleFrame.Centroid          = tempResult.Centroid;
                    }

                    results.Add(kvp.Key, singleFrame);
                }


                mouseDataResult.Name              = mouse.Id;
                mouseDataResult.Results           = results;
                mouseDataResult.Age               = mouse.Age;
                mouseDataResult.Boundaries        = trackedVideo.Boundries;
                mouseDataResult.VideoOutcome      = SingleFileResult.Ok;
                mouseDataResult.GapDistance       = trackedVideo.GapDistance;
                mouseDataResult.ThresholdValue    = trackedVideo.ThresholdValue;
                mouseDataResult.ThresholdValue2   = trackedVideo.ThresholdValue2;
                mouseDataResult.StartFrame        = trackedVideo.StartFrame;
                mouseDataResult.EndFrame          = trackedVideo.EndFrame;
                mouseDataResult.SmoothMotion      = trackedVideo.SmoothMotion;
                mouseDataResult.FrameRate         = trackedVideo.FrameRate;
                mouseDataResult.UnitsToMilimeters = trackedVideo.UnitsToMilimeters;
                mouseDataResult.SmoothFactor      = 0.68;
                mouseDataResult.GenerateResults(file);
                mouseDataResult.PelvicArea  = trackedVideo.PelvicArea1;
                mouseDataResult.PelvicArea2 = trackedVideo.PelvicArea2;
                mouseDataResult.PelvicArea3 = trackedVideo.PelvicArea3;
                mouseDataResult.PelvicArea4 = trackedVideo.PelvicArea4;
                mouseDataResult.Type        = mouse.Type;
                mouseDataResult.DataLoadComplete();

                if (mouse.Results == null)
                {
                    mouse.Results = new Dictionary <ISingleFile, IMouseDataResult>();
                }

                mouse.UpdateProgress(singleFile, 1);
                mouse.Results.Add(singleFile, mouseDataResult);
                mouse.ReviewCommand.RaiseCanExecuteChangedNotification();
            }//);

            ExportAllCommand.RaiseCanExecuteChangedNotification();
        }