//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);
        }
Exemple #2
0
        void preview_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            Pen linePen = new Pen(origStyle.lineColor, (int)origStyle.lineSize);

            g.DrawLine(linePen, new Point(50, 50), new Point(175, 50));

            NuGenView.DrawPoint(g, new Point(50, 50), origStyle);
            NuGenView.DrawPoint(g, new Point(175, 50), origStyle);
        }
        public void View_Activated(object sender, System.EventArgs args)
        {
            activeView = (NuGenView)sender;

            foreach (Form f in form.MdiChildren)
            {
                f.Text = "Inactive";
            }

            if (activeView != null)
            {
                activeView.Text = "Active";
            }
        }
        //Enumerates through documents and returns the view at the same position
        public NuGenDocument GetDocument(NuGenView view)
        {
            IEnumerator <NuGenDocument> iDocs  = docs.GetEnumerator();
            IEnumerator <NuGenView>     iViews = views.GetEnumerator();

            while (iViews.MoveNext() & iDocs.MoveNext())
            {
                if (iViews.Current == view)
                {
                    return(iDocs.Current);
                }
            }

            return(null);
        }
        //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);
        }
        //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 Remove(NuGenView v)
 {
     docs.Remove(GetDocument(v));
     views.Remove(v);
 }
 public void Add(NuGenDocument doc, NuGenView view)
 {
     docs.Add(doc);
     views.Add(view);
     doc.RegisterListener(view);
 }