Example #1
0
        /// <summary>
        /// Prints a person
        /// </summary>
        /// <param name="p">Instance of person</param>
        /// <param name="p">Database instance</param>
        public void PrintPerson(Person p, TorpgenDB db)
        {
            mPerson = p;
            mDatabase = db;

            var ppd = new PrintPreviewDialog();
            var doc = new PrintDocument();

            var printSettings = new PrinterSettings();
            var pageSettings = new PageSettings();

            pageSettings.Margins.Left = 50;
            pageSettings.Margins.Right = 100;
            pageSettings.Margins.Top = 50;
            pageSettings.Margins.Bottom = 100;
            pageSettings.PaperSize = new PaperSize("A4", 850, 1100);

            //printSettings.PaperSizes = ;

            doc.PrintPage += new PrintPageEventHandler(HandlePrintPage);
            doc.DocumentName = p.listBoxString;
            doc.DefaultPageSettings = pageSettings;
            doc.PrinterSettings = printSettings;
            ppd.Document = doc;
            ((Form)ppd).WindowState = FormWindowState.Maximized;
            ppd.ShowDialog();
        }
Example #2
0
 public Person(TorpgenDB db)
 {
     birth = new LifeEvent(LifeEventTypes.Birth, "", "", "");
     death = new LifeEvent(LifeEventTypes.Death, "", "", "");
     _db = db;
 }
Example #3
0
        /// <summary>
        /// Used to print a person.
        /// </summary>
        /// <param name="mSettings"></param>
        /// <param name="ev"></param>
        /// <param name="db"></param>
        public void Print(PrintSettings mSettings, PrintPageEventArgs ev, TorpgenDB db)
        {
            String tmp = "";
            float currY = mSettings.Y;
            float x = mSettings.X;

            // Name
            tmp = firstName + " " + lastName;

            mSettings.graphics.DrawString(tmp, mSettings.font[(int)PrintSettings.Fonts.Header1], Brushes.Black, x, currY);
            currY += mSettings.yMargin;

            currY += mSettings.fontSize[(int)PrintSettings.Fonts.Header1].Height + mSettings.yMargin;

            // Separator
            PersonPrint.Instance.DrawSeparator(x, ev.PageBounds.Width - x, currY);
            currY += mSettings.yMargin;

            // Birth
            currY = birth.Print(mSettings, currY);
            // Death
            currY = death.Print(mSettings, currY);

            // Families (Marriages)

            currY += 40;
            mSettings.graphics.DrawString("Relationships", mSettings.font[(int)PrintSettings.Fonts.Header2], Brushes.Black, x, currY);
            currY += mSettings.fontSize[(int)PrintSettings.Fonts.Header2].Height + mSettings.yMargin;
            // Separator
            PersonPrint.Instance.DrawSeparator(x, ev.PageBounds.Width - x, currY);
            currY += mSettings.yMargin;

            for (int i = 0; i < marriages.Count; i++)
            {
                bool useWife = (gender == Gender.Male) ? true : false;
                Marriage m = db.GetMarriage(marriages[i]);
                currY = m.Print(mSettings, currY, useWife, ev, db);
            }

            // Notes
            currY += 40;
            mSettings.graphics.DrawString("Notes", mSettings.font[(int)PrintSettings.Fonts.Header2], Brushes.Black, x, currY);
            currY += mSettings.fontSize[(int)PrintSettings.Fonts.Header2].Height + (2 * mSettings.yMargin);
            // Separator
            PersonPrint.Instance.DrawSeparator(x, ev.PageBounds.Width - x, currY);
            currY += mSettings.yMargin;

            // See how wide the rectangle can be.
            SizeF size = mSettings.graphics.MeasureString(notes, mSettings.font[(int)PrintSettings.Fonts.Regular]);
            float width = mSettings.Width - mSettings.X - mSettings.X;
            RectangleF rect = new RectangleF(mSettings.X, currY, width, size.Height);
            mSettings.graphics.DrawString(notes, mSettings.font[(int)PrintSettings.Fonts.Regular], Brushes.Black, new PointF(mSettings.X, currY));
            mSettings.graphics.DrawRectangle(Pens.Transparent, Rectangle.Round(rect));

            currY += size.Height + mSettings.yMargin;
        }
Example #4
0
        /// <summary>
        /// Prints marriage information.
        /// </summary>
        /// <param name="mSettings">Printing settings</param>
        /// <param name="currY">Current Y coordinate value</param>
        /// <param name="useWife">Flag if it is the wife part that should be printed</param>
        public float Print(PrintSettings mSettings, float currY, bool useWife, PrintPageEventArgs ev, TorpgenDB db)
        {
            var spouse = db.GetPerson(useWife ? wife : husband);
            float x = mSettings.X;

            if (spouse == null)
            {
                return currY;
            }

            string tmp = spouse.firstName + " " + spouse.lastName + " (" + spouse.birth.ToString() + "). ";

            mSettings.graphics.DrawString(tmp, mSettings.font[(int)PrintSettings.Fonts.Regular], Brushes.Black, PersonPrint.CurrentPrintSettings.tab0, currY);
            currY += mSettings.yMargin;
            currY += mSettings.fontSize[(int)PrintSettings.Fonts.Regular].Height + mSettings.yMargin;

            tmp = "Married: " + info.date + ", " + info.place;
            mSettings.graphics.DrawString(tmp, mSettings.font[(int)PrintSettings.Fonts.Regular], Brushes.Black, PersonPrint.CurrentPrintSettings.tab1, currY);
            currY += mSettings.yMargin;
            currY += mSettings.fontSize[(int)PrintSettings.Fonts.Regular].Height + mSettings.yMargin;

            tmp = "Children";
            mSettings.graphics.DrawString(tmp, mSettings.font[(int)PrintSettings.Fonts.Bold], Brushes.Black, PersonPrint.CurrentPrintSettings.tab1, currY);
            currY += mSettings.yMargin;
            currY += mSettings.fontSize[(int)PrintSettings.Fonts.Regular].Height + mSettings.yMargin;

            // Print all children these two persons have together.
            List<Person> kids = db.GetChildren(husband, wife);

            foreach (var k in kids)
            {
                tmp = k.firstName + " " + k.lastName + " (" + k.birth + ")";

                mSettings.graphics.DrawString(tmp, mSettings.font[(int)PrintSettings.Fonts.Regular], Brushes.Black, PersonPrint.CurrentPrintSettings.tab2, currY);
                currY += mSettings.yMargin;
                currY += mSettings.fontSize[(int)PrintSettings.Fonts.Regular].Height + mSettings.yMargin;
            }

            return currY;
        }
Example #5
0
        /// <summary>
        /// Loads the database
        /// </summary>
        private void LoadPersonsFromFile()
        {
            try
            {
                XmlSerializer ser = new XmlSerializer(mDB.GetType());
                StreamReader reader = new StreamReader(@"C:\temp\torpgen.xml");
                mDB = (TorpgenDB)ser.Deserialize(reader);
                reader.Close();

                mDB.updateDict();

                PopulatePersonListBox();
            }
            catch (Exception e)
            {
                MessageBox.Show("Error in XML file: " + e.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                // See if we can create a file if it did not exist.
                //savePersonsToFile();
            }
        }
Example #6
0
        private void HandleNewDatabase()
        {
            // Open a file chooser to let the user select a new file to work with

            SaveFileDialog d = new SaveFileDialog();
            d.Filter = "TorpGen files (*.xml)|*.xml| All files (*.*)|*.*";
            d.InitialDirectory = "C:";
            d.Title = "Create new TorpGen configuration file";

            if (d.ShowDialog() == DialogResult.OK)
            {
                mFileName = d.FileName;
            }
            else
            {
                return;
            }

            mDB = new TorpgenDB();
        }