public MosaicWindow() { this.imageView = new TileView(); tileViewThreadController = new ThreadController(this); tileViewThreadController.SetThreadCompletedCallback(TileViewThreadCompleted); tileViewThreadController.SetThreadProgressCallback(TileViewProgressIndicator); this.TileView.SetThreadController(tileViewThreadController); InitializeComponent(); this.imageView.BackColor = Color.Black; this.imageView.HandleCreated += new EventHandler(OnTileViewerHandleCreated); this.imageView.MouseMove += new MouseEventHandler(OnTileViewerMouseMove); this.imageView.ZoomChanged += new EventHandler(OnTileViewerZoomChanged); this.imageView.Dock = DockStyle.Fill; this.viewPanel.Controls.Add(this.imageView); this.imageView.Toolbox = this.tileViewEditToolBox; this.tileOverView.SetMosaicWindow(this); this.tileOverView.TileOverViewCompletedLoadHandler += new TileOverViewHandler<TileOverView, TileOverViewEventArgs>(OnTileOverViewCompletedLoadHandler); this.toolStripZoomComboBox.SelectedIndex = 3; plugins = new List<MosaicPlugin>(); //plugins.Add(new ProfileTool("Profile", this)); plugins.Add(new RoiTool("Region", this)); plugins.Add(new LinearScaleTool("Linear Scale", this)); plugins.Add(new RGBBalanceTool("RGB Balance", this)); plugins.Add(new ScalebarTool("Scalebar", this)); MosaicPlugin.AllPlugins["Linear Scale"].Enabled = false; MosaicPlugin.AllPlugins["RGB Balance"].Enabled = false; MosaicPlugin.AllPlugins["Region"].Enabled = false; //MosaicPlugin.AllPlugins["Profile"].Enabled = false; }
internal TileSaver(ThreadController threadController, MosaicWindow window) { this.threadController = threadController; this.window = window; this.filePath = null; }
public void SetThreadController(ThreadController threadController) { this.threadController = threadController; }
private void Export() { ThreadController threadController = new ThreadController(this); threadController.SetThreadCompletedCallback(SaveFileThreadCompleted); threadController.SetThreadProgressCallback(SaveFileProgressIndicator); TileSaver saver = new TileSaver(threadController, this); saver.Export(); }
public void SaveCache() { saveCacheThreadController = new ThreadController(this); saveCacheThreadController.SetThreadCompletedCallback(SaveFileThreadCompleted); saveCacheThreadController.SetThreadProgressCallback(SaveFileProgressIndicator); TileSaver saver = new TileSaver(saveCacheThreadController, this); saver.SaveCacheFile(); }
public void Open(string[] originalFilePaths) { this.originalFilePaths = originalFilePaths; string[] cachefilePaths = new string[1]; MosaicPlugin.AllPlugins["Linear Scale"].Enabled = false; MosaicPlugin.AllPlugins["RGB Balance"].Enabled = false; TileReader[] tileReaders = new TileReader[6]; tileReaders[0] = new MosaicFileReader(originalFilePaths, this); tileReaders[1] = new Version2SequenceFileReader(originalFilePaths, this); tileReaders[2] = new SequenceFileReader(originalFilePaths, this); tileReaders[3] = new RosMosaicSequenceFileReader(originalFilePaths, this); tileReaders[4] = new ImageCollectionFileReader(originalFilePaths, this); tileReaders[5] = new MultiSequenceFileReader(originalFilePaths, this); foreach (TileReader t in tileReaders) { if (t.CanRead()) { originalTileReader = tileReader = t; break; } } if(tileReader == null) { MessageBox.Show("Unknown file type"); return; } // Check if there is cache availiable for this file if (tileReader.HasCache()) { cachefilePaths[0] = tileReader.GetCacheFilePath(); if (tileReader.GetType() != typeof(MosaicFileReader)) // create a new reader to read this cache, if we opened a mos file, we already have the reader tileReader = new MosaicFileReader(cachefilePaths, this); } this.menuStrip.Enabled = false; this.toolStrip.Enabled = false; ToolStripProgressBar progressbar = (ToolStripProgressBar)this.feedbackStatusStrip.Items[1]; openThreadController = new ThreadController(this); openThreadController.SetThreadCompletedCallback(OpenFileThreadCompleted); openThreadController.SetThreadProgressCallback(OpenFileProgressIndicator); tileReader.SetThreadController(openThreadController); progressbar.Value = 0; this.statusStrip.Refresh(); try { tileReader.ReadHeader(); } catch (MosaicException e) { // The cache file failed to be read. // Probably as the format has changed. Here we delete the cache file and recall the open function if (tileReader.GetType() == typeof(MosaicFileReader)) { if (originalTileReader.GetType() != typeof(MosaicFileReader)) { File.Delete(cachefilePaths[0]); this.Open(originalFilePaths); } else { // The user has tried to open the mos (cache) file directly // We don't know what other files to fall back too so we just error and return. // File.Delete(cachefilePaths[0]); // DO NOT DELETE THE FILE THEY JUST TRIED TO OPEN! MessageBox.Show("Unable to load file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception e) { MessageBox.Show("Failed to read header information correctly. " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { this.menuStrip.Enabled = true; this.toolStrip.Enabled = true; } MosaicWindow.MosaicInfo = new MosaicInfo(tileReader); this.tileOverView.CreateOverview(); this.tileOverView.Location = new Point(25, this.TileView.Bottom - this.tileOverView.Height - 25); this.tileOverView.Show(); // TileLoadInfo should now be ready as we have read the header. this.BlendingEnabled = true; this.CorrelationEnabled = true; // Threaded Operation tileReader.CreateThumbnails(); }