コード例 #1
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
        //Takes an image file and sets up a document to host it
        private void ImportImageFile(string filename)
        {
            form.StatusNormalMessage("Importing File...");
            Cursor.Current = Cursors.WaitCursor;

            //create the document and set up its view
            NuGenDocument doc = NewDocument();

            if (!doc.ImportFile(filename))
            {
                Cursor.Current = Cursors.Arrow;

                MessageBox.Show("Could not import image!");
                RemoveDocument(doc);

                return;
            }

            doc.InitDefaults();

            form.EnableControls();
            form.CheckedBackgroundOption(doc.BackgroundSelection);
            form.CheckedPointViewOption(docViewMap.GetView(doc).ViewPointSelection);
            form.StatusNormalMessage("Ready.");
            Cursor.Current = Cursors.Arrow;
        }
コード例 #2
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
        //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;
                }
            }
        }
コード例 #3
0
        public NuGenImageProcessor(NuGenDocument doc)
        {
            this.doc = doc;

            originalImage  = doc.OriginalImage;
            processedImage = (Image)doc.OriginalImage.Clone();
        }
コード例 #4
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
        //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;
                }
            }
        }
コード例 #5
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
        //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);
        }
コード例 #6
0
        private static void TestDocumentDeserialize()
        {
            Stream          stream     = File.Open("Test.osl", FileMode.Open);
            BinaryFormatter bformatter = new BinaryFormatter();

            NuGenDocument doc = (NuGenDocument)bformatter.Deserialize(stream);

            stream.Close();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
        //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);
        }
コード例 #9
0
        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;
        }
コード例 #10
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
        //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);
        }
コード例 #11
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
        //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;
                    }
                }
            }
        }
コード例 #12
0
        //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
        }
コード例 #13
0
        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;
        }
コード例 #14
0
 public NuGenScreenTranslate(NuGenDocument doc)
 {
     this.doc = doc;
 }
コード例 #15
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
 public void Add(NuGenDocument doc, NuGenView view)
 {
     docs.Add(doc);
     views.Add(view);
     doc.RegisterListener(view);
 }
コード例 #16
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
        //Open up a serialized document from file
        private void OpenDocumentFile(string filename)
        {
            form.StatusNormalMessage("Opening File...");
            Cursor.Current = Cursors.WaitCursor;

            // check, if document already open. If yes, set the focus to the first view
            foreach (NuGenDocument doc in docViewMap.Documents)
            {
                if (doc.SavePath == filename)
                {
                    docViewMap.GetView(doc).Activate();
                    Cursor.Current = Cursors.Arrow;
                    return;
                }
            }

            Stream s = null;

            NuGenDocument finalDoc = null;

            try
            {
                s = File.Open(filename, FileMode.Open);
                BinaryFormatter formatter = new BinaryFormatter();
                finalDoc          = NewDocument((NuGenDocument)formatter.Deserialize(s));
                finalDoc.SavePath = filename;
                finalDoc.UpdateListeners();
                finalDoc.ComputeTransformation();

                if (finalDoc.ValidAxes || finalDoc.ValidAxes)
                {
                    form.StatusNormalMessage("Axes Defined");
                }

                s.Close();

                if (docViewMap.Count == 1)
                {
                    form.EnableControls();
                }
            }
            catch (Exception e)
            {
                if (finalDoc != null)
                {
                    docViewMap.GetView(finalDoc).Close();
                }

                MessageBox.Show("Could not open document!");
                if (s != null)
                {
                    s.Close();
                }
            }

            form.CheckedBackgroundOption(finalDoc.BackgroundSelection);
            form.CheckedPointViewOption(docViewMap.GetView(finalDoc).ViewPointSelection);
            form.EnableControls();

            activeView.ShowCoordinates += new NuGenView.Show_Coordinates(this.Show_Coordinates);
            activeView.DrawAll();
            Cursor.Current = Cursors.Arrow;
        }
コード例 #17
0
ファイル: NuGenTransform.cs プロジェクト: carlhuth/GenXSource
 public void Remove(NuGenDocument d)
 {
     views.Remove(GetView(d));
     docs.Remove(d);
 }