public void SetProject(PPProject project) { //todo: refactor: SetProject and Load are almost the same function StatusChanged?.Invoke(this, new TextEventArgs("Prepping image...")); CancelLoad(); Project = project; bool runRegionsOnColorBitmap = (project.GreyscaleBitmap == null); editedSinceLastCleanCopy = true; regions.Clear(); regionWorker = new RequestRegionWorker(); regionWorker.Completed += new RunWorkerCompletedEventHandler(OnRequestRegionCompleted); regionWorker.ProgressChanged += new ProgressChangedEventHandler(Worker_OnProgressChanged); if (runRegionsOnColorBitmap) { regionWorker.Run(Project.ColorBitmap); Project.GreyscaleBitmap = Utilities.GetGreyscaleOfBitmap(Project.ColorBitmap, this.regions); //todo: try may be a timing issue here, where the image is still being worked on but the user is allowed to interact with it Project.Edited(); } else { regionWorker.Run(Project.GreyscaleBitmap); } }
public void Load(string filename) { StatusChanged?.Invoke(this, new TextEventArgs("Prepping image...")); CancelLoad(); if (Project == null) { Project = new PPProject(); } bool runRegionsOnColorBitmap = false; if (Path.GetExtension(filename) == PPProject.PROJECT_EXTENSION) { Project.LoadProject(filename); } else { bool isGreyscaleImage = Project.LoadImage(filename); runRegionsOnColorBitmap = !isGreyscaleImage; } editedSinceLastCleanCopy = true; regions.Clear(); regionWorker = new RequestRegionWorker(); regionWorker.Completed += new RunWorkerCompletedEventHandler(OnRequestRegionCompleted); regionWorker.ProgressChanged += new ProgressChangedEventHandler(Worker_OnProgressChanged); if (runRegionsOnColorBitmap) { regionWorker.Run(Project.ColorBitmap); Project.GreyscaleBitmap = Utilities.GetGreyscaleOfBitmap(Project.ColorBitmap, this.regions); //todo: try may be a timing issue here, where the image is still being worked on but the user is allowed to interact with it } else { regionWorker.Run(Project.GreyscaleBitmap); } }