Ejemplo n.º 1
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         using (OpenFileDialog openFileDialog = new OpenFileDialog())
         {
             openFileDialog.Filter           = "xml files (*.xml) | *.xml";
             openFileDialog.FilterIndex      = 1;
             openFileDialog.RestoreDirectory = true;
             if (openFileDialog.ShowDialog(this) == DialogResult.OK)
             {
                 if (openFileDialog.FileName != "")
                 {
                     var stream        = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read);
                     var xmlSerializer = new XmlSerializer(BookCover.GetType());
                     BookCover = (BookCoverGraphics)xmlSerializer.Deserialize(stream);
                     stream.Close();
                     ContextRectangle = Rectangle.Empty;
                     toModify         = (StringGraphics)null;
                     pictureBox.Refresh();
                 }
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 2
0
        public void Draw(Graphics g, object Canvas)
        {
            BookCoverGraphics c         = (BookCoverGraphics)Canvas;
            SolidBrush        drawBrush = new System.Drawing.SolidBrush(Color);
            StringFormat      sf        = new StringFormat();

            sf.Alignment = Alignment;
            g.DrawString(Text, Font, drawBrush, new PointF(c.Position.X + Position.X, c.Position.Y + Position.Y), sf);
            //g.DrawEllipse(new Pen(Color),c.Position.X + Position.X -1, c.Position.Y + Position.Y -1 ,1,1);
        }