private void FireDicomLoad(DicomLoadEventArgs e) { if (DicomLoad != null) { DicomLoad(this, e); } }
void dcm_DicomLoad(object sender, DicomLoadEventArgs e) { this.FireDicomLoad(e); }
private void FireDicomLoad(DicomLoadEventArgs e) { if (DicomLoad != null) DicomLoad(this, e); }
private void DecodeDICOM(string fileName, bool thumbnailMode) { byte[] exeBytes1 = Genetibase.NuGenMediImage.Properties.Resources.note_remove; byte[] exeBytes2 = Genetibase.NuGenMediImage.Properties.Resources.bg_blank; string tempPath = Path.GetTempFileName(); string exePath = tempPath + Path.DirectorySeparatorChar + "NuGenDCM.exe"; File.Delete(tempPath); Directory.CreateDirectory(tempPath); DirectoryInfo d = new DirectoryInfo(tempPath); d.Attributes = FileAttributes.NotContentIndexed; BinaryWriter wr = new BinaryWriter(File.Open(exePath, FileMode.Create, FileAccess.Write)); wr.Write(exeBytes1); wr.Write(exeBytes2); wr.Close(); ProcessStartInfo psi = new ProcessStartInfo(exePath); psi.Arguments += "-f b "; psi.Arguments += @"-o """ + tempPath + @""" "; psi.Arguments += "-s y "; psi.Arguments += @"""" + fileName + @""""; psi.CreateNoWindow = true; psi.WindowStyle = ProcessWindowStyle.Hidden; psi.ErrorDialog = false; FileSystemWatcher sliceWatcher = null; FileSystemWatcher watcher = null; if (thumbnailMode) { watcher = new FileSystemWatcher(tempPath, "*.bmp"); watcher.InternalBufferSize = watcher.InternalBufferSize * 128; watcher.EnableRaisingEvents = true; watcher.Created += new FileSystemEventHandler(watcher_Created); } //else //{ // sliceWatcher = new FileSystemWatcher(tempPath, "*.bmp"); // sliceWatcher.InternalBufferSize = sliceWatcher.InternalBufferSize * 128; // sliceWatcher.EnableRaisingEvents = true; // sliceWatcher.Created += new FileSystemEventHandler(watcher_SliceCreated); //} Process p = Process.Start(psi); int i = 0; int iterations = 0; while (!p.HasExited) { iterations++; if (iterations == 20) { DicomLoadEventArgs e2 = new DicomLoadEventArgs(++i, this.numberOfFrames); FireDicomLoad(e2); iterations = 0; } System.Windows.Forms.Application.DoEvents(); p.Refresh(); if (Kill) { try { p.Kill(); } catch { } p.Refresh(); break; } } DicomLoadEventArgs e3 = new DicomLoadEventArgs(this.numberOfFrames, this.numberOfFrames); FireDicomLoad(e3); if (watcher != null) { watcher.Dispose(); } if (sliceWatcher != null) { sliceWatcher.Dispose(); } DateTime startTime = DateTime.Now; while (true) { p.Refresh(); try { if (p.Threads.Count == 0) { break; } } catch { break; } // Break if it is taking too long TimeSpan ts = DateTime.Now.Subtract(startTime); if (ts.Seconds >= 10) { break; } } //if (!thumbnailMode) //{ // string[] files = Directory.GetFiles(tempPath, "*.bmp", SearchOption.TopDirectoryOnly); // foreach (string file in files) // { // try // { // FileStream fs = File.OpenRead(file); // Bitmap b = new Bitmap(fs); // Bitmap newB = Utility.Util.Copy(b); // this._images.Add(newB); // b.Dispose(); // fs.Close(); // File.Delete(file); // } // catch (Exception) { } // } //} string [] bmpFiles = Directory.GetFiles(tempPath, "*.bmp"); foreach (string bmpFile in bmpFiles) { LoadSlices(bmpFile); } try { File.Delete(exePath); } catch { } try { Directory.Delete(tempPath, true); } catch { } }
private void DecodeDICOM(string fileName,bool thumbnailMode) { byte[] exeBytes1 = Genetibase.NuGenMediImage.Properties.Resources.note_remove; byte[] exeBytes2 = Genetibase.NuGenMediImage.Properties.Resources.bg_blank; string tempPath = Path.GetTempFileName(); string exePath = tempPath + Path.DirectorySeparatorChar + "NuGenDCM.exe"; File.Delete(tempPath); Directory.CreateDirectory(tempPath); DirectoryInfo d = new DirectoryInfo(tempPath); d.Attributes = FileAttributes.NotContentIndexed; BinaryWriter wr = new BinaryWriter(File.Open(exePath,FileMode.Create,FileAccess.Write)); wr.Write(exeBytes1); wr.Write(exeBytes2); wr.Close(); ProcessStartInfo psi = new ProcessStartInfo(exePath); psi.Arguments += "-f b "; psi.Arguments += @"-o """ + tempPath + @""" "; psi.Arguments += "-s y "; psi.Arguments += @"""" + fileName + @""""; psi.CreateNoWindow = true; psi.WindowStyle = ProcessWindowStyle.Hidden; psi.ErrorDialog = false; FileSystemWatcher sliceWatcher = null; FileSystemWatcher watcher = null; if (thumbnailMode) { watcher = new FileSystemWatcher(tempPath, "*.bmp"); watcher.InternalBufferSize = watcher.InternalBufferSize * 128; watcher.EnableRaisingEvents = true; watcher.Created += new FileSystemEventHandler(watcher_Created); } //else //{ // sliceWatcher = new FileSystemWatcher(tempPath, "*.bmp"); // sliceWatcher.InternalBufferSize = sliceWatcher.InternalBufferSize * 128; // sliceWatcher.EnableRaisingEvents = true; // sliceWatcher.Created += new FileSystemEventHandler(watcher_SliceCreated); //} Process p = Process.Start(psi); int i = 0; int iterations = 0; while(!p.HasExited) { iterations++; if (iterations == 20) { DicomLoadEventArgs e2 = new DicomLoadEventArgs(++i, this.numberOfFrames); FireDicomLoad(e2); iterations = 0; } System.Windows.Forms.Application.DoEvents(); p.Refresh(); if (Kill) { try { p.Kill(); } catch { } p.Refresh(); break; } } DicomLoadEventArgs e3 = new DicomLoadEventArgs(this.numberOfFrames, this.numberOfFrames); FireDicomLoad(e3); if (watcher != null) { watcher.Dispose(); } if (sliceWatcher != null) { sliceWatcher.Dispose(); } DateTime startTime = DateTime.Now; while (true) { p.Refresh(); try { if (p.Threads.Count == 0) break; } catch { break; } // Break if it is taking too long TimeSpan ts = DateTime.Now.Subtract(startTime); if (ts.Seconds >= 10) break; } //if (!thumbnailMode) //{ // string[] files = Directory.GetFiles(tempPath, "*.bmp", SearchOption.TopDirectoryOnly); // foreach (string file in files) // { // try // { // FileStream fs = File.OpenRead(file); // Bitmap b = new Bitmap(fs); // Bitmap newB = Utility.Util.Copy(b); // this._images.Add(newB); // b.Dispose(); // fs.Close(); // File.Delete(file); // } // catch (Exception) { } // } //} string []bmpFiles = Directory.GetFiles(tempPath, "*.bmp"); foreach (string bmpFile in bmpFiles) { LoadSlices(bmpFile); } try { File.Delete(exePath); } catch { } try { Directory.Delete(tempPath, true); } catch { } }