public NuGenImageProcessor(NuGenDocument doc) { this.doc = doc; originalImage = doc.OriginalImage; processedImage = (Image)doc.OriginalImage.Clone(); }
public GridRemovalSettingsDialog(NuGenDocument doc) { this.settings = doc.GridRemovalSettings; this.originalImage = doc.OriginalImage; this.discretizeSettings = doc.DiscretizeSettings; this.transform = doc.Transform; this.bgColor = doc.BackgroundColor; this.coordSettings = doc.CoordSettings; if (doc.ValidAxes) this.gridRemovalMesh = doc.GridDisplaySettings; else this.gridRemovalMesh.initialized = false; discretizeSettings.discretizeMethod = DiscretizeMethod.DiscretizeForeground; InitializeComponent(); InitializeDefaults(); if (!(doc.ValidAxes || doc.ValidScale)) { textBox1.Enabled = false; textBox2.Enabled = false; checkBox2.Enabled = false; checkBox2.Checked = false; checkBox3.Enabled = false; checkBox3.Checked = false; } histogram.ValueChanged = this.ValueChanged; ValueChanged(true); this.MaximumSize = Size; }
private static void TestDocumentSerialize() { NuGenDocument doc = new NuGenDocument(DigitizeState.SegmentState); Stream stream = File.Open("Test.osl", FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(stream, doc); stream.Close(); }
//Enumerates through views and returns the document at the same position public NuGenView GetView(NuGenDocument doc) { IEnumerator<NuGenDocument> iDocs = docs.GetEnumerator(); IEnumerator<NuGenView> iViews = views.GetEnumerator(); while (iViews.MoveNext() & iDocs.MoveNext()) { if (iDocs.Current == doc) { return iViews.Current; } } return null; }
public ExportSettingsDialog(ExportSettings settings, NuGenDocument doc, List<string> includedCurves, List<string> excludedCurves) { this.settings = settings; this.includedCurves = includedCurves; this.excludedCurves = excludedCurves; this.pointsets = doc.PointSets; this.coordSettings = doc.CoordSettings; this.gridSettings = doc.GridDisplaySettings; InitializeComponent(); InitializeDefaults(); this.MaximumSize = Size; }
//Full featured test of serialization private static void TestDocumentSerialization() { NuGenDocument doc = new NuGenDocument(DigitizeState.SegmentState); Stream stream = File.Open("Test.osl", FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(stream, doc); stream.Close(); //Now read back from the stream we just wrote stream = File.Open("Test.osl", FileMode.Open); NuGenDocument docDeserialized = (NuGenDocument)bformatter.Deserialize(stream); stream.Close(); //examine the two docs for identicality }
public void Remove(NuGenDocument d) { views.Remove(GetView(d)); docs.Remove(d); }
//Shows the user a file dialog which they use to select a save path private void SaveDocumentAs(NuGenDocument doc) { if (doc != null) { SaveFileDialog dlg = new SaveFileDialog(); dlg.InitialDirectory = Directory.GetCurrentDirectory(); dlg.Filter = dlg.Filter = "NuGenTransform Files (*.ngt)|*.ngt"; dlg.DefaultExt = doc.SavePath; dlg.ShowDialog(); string filename = dlg.FileName; if (filename.Length > 0) { Cursor.Current = Cursors.WaitCursor; try { Stream s = File.Open(filename, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(s, doc); s.Close(); } catch (Exception e) { MessageBox.Show("Error loading file"); } Cursor.Current = Cursors.Arrow; } } }
//Saves a doucment by serializing it private void SaveDocument(NuGenDocument doc) { if (doc != null) { if (!doc.SaveFileExists) SaveDocumentAs(doc); else { Cursor.Current = Cursors.WaitCursor; try { Stream s = File.Open(doc.SavePath, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(s, doc); s.Close(); } catch (Exception e) { MessageBox.Show("Error saving file"); } Cursor.Current = Cursors.Arrow; } } }
//Removes a document and its corresponding view private void RemoveDocument(NuGenDocument doc) { if (doc != null) { if (docViewMap.GetView(doc) != null) { if (docViewMap.GetView(doc).Visible) docViewMap.GetView(doc).Close(); docViewMap.Remove(doc); if (docViewMap.Count < 1) { activeView = null; } } } }
public void Add(NuGenDocument doc, NuGenView view) { docs.Add(doc); views.Add(view); doc.RegisterListener(view); }
//Creates a new document by copying an old document public NuGenDocument NewDocument(NuGenDocument doc) { if (docViewMap.Count == 0) { form.EnableControls(); } NuGenView view = new NuGenView(form, doc, this.SendStatusMessage); activeView = view; activeView.Focus(); view.Activate(); view.FormClosing += new FormClosingEventHandler(View_Closing); docViewMap.Add(doc, view); form.StatusPermanentMessage("Three axis points or the scale bar must be defined."); return doc; }
//Initializes a new document and its corresponding view when importing or opening a document public NuGenDocument NewDocument() { NuGenDocument doc = null; if (docViewMap.Count == 0) { form.EnableControls(); } if (ActiveDocument != null) { // this document is not the first so start up in same state as previous document for continuity doc = new NuGenDocument(ActiveDocument.DigitizeState); } else { doc = new NuGenDocument(NuGenDefaultSettings.GetInstance().SessionsSettings.initialDigitizeState); } NuGenView view = new NuGenView(form, doc, this.SendStatusMessage); activeView = view; activeView.Focus(); view.Activate(); view.FormClosing += new FormClosingEventHandler(View_Closing); docViewMap.Add(doc, view); doc.UpdateListeners(); form.StatusPermanentMessage("Three axis points or the scale bar must be defined."); activeView.ShowCoordinates += new NuGenView.Show_Coordinates(this.Show_Coordinates); return doc; }
public NuGenView(Form parent, NuGenDocument doc, Delegate_SendStatusMessage sendStatusMessage) { MdiParent = parent; Visible = true; WindowState = FormWindowState.Maximized; int x = Genetibase.NuGenTransform.Properties.Settings.Default.WINDOW_MEASURE_WIDTH; int y = Genetibase.NuGenTransform.Properties.Settings.Default.WINDOW_MEASURE_HEIGHT; this.sendStatusMessage = sendStatusMessage; imagePanel = new InnerPanel(); Size = new Size(x, y); viewPointSelection = NuGenDefaultSettings.GetInstance().ViewPointSelection; this.doc = doc; imagePanel.Paint += new PaintEventHandler(NuGenView_Paint); imagePanel.MouseClick += new MouseEventHandler(NuGenView_MouseClick); imagePanel.MouseDown += new MouseEventHandler(NuGenView_MousePress); imagePanel.MouseUp += new MouseEventHandler(NuGenView_MouseRelease); imagePanel.MouseMove += new MouseEventHandler(NuGenView_MouseMove); imagePanel.MouseDoubleClick += new MouseEventHandler(NuGenView_MouseDoubleClick); Controls.Add(imagePanel); curveSelected = NuGenPointSetCollection.DefaultCurveName; measureSelected = NuGenPointSetCollection.DefaultMeasureName; doc.ActiveCurveName = curveSelected; doc.ActiveMeasureName = measureSelected; selectedPointList = new List<NuGenPoint>(); selectedPointGestatingList = new List<NuGenPoint>(); editPointsList = new List<NuGenPoint>(); this.DoubleBuffered = true; this.AutoScroll = true; }
public NuGenScreenTranslate(NuGenDocument doc) { this.doc = doc; }