none
Problemas al ensamblar proyecto RRS feed

  • Pregunta

  • Hola estoy intentando emsamblar y probar el siguiente código y me dan errores:

    ¿ Alguna idea?
    ¿ Sería en un único fichero?

    ==============================================

    using System;using System.Drawing;

    using System.Drawing.Imaging;

    using System.Collections;

    using System.ComponentModel;

    using System.Windows.Forms;

    using System.Data;

    using System.IO;

     

    namespace multipagetiff

    {

      /// <summary>

      /// Summary description for Form1.

      /// </summary>

      public class Form1 : System.Windows.Forms.Form

      {

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.Container components = null;

     

        public Form1()

        {

          //

          // Required for Windows Form Designer support

          //

          InitializeComponent();

     

          //

          // TODO: Add any constructor code after InitializeComponent call

          //

     

          this.SetStyle(ControlStyles.ResizeRedraw,true);

        }

     

        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        protected override void Dispose( bool disposing )

        {

          if( disposing )

          {

            if (components != null)

            {

              components.Dispose();

            }

          }

          base.Dispose( disposing );

        }

     

        #region Windows Form Designer generated code

        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

          //

          // Form1

          //

          this.AllowDrop = true;

          this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

          this.ClientSize = new System.Drawing.Size(288, 173);

          this.Name = "Form1";

          this.Text = "Multi Page Tiff Generator";

          this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

     

        }

        #endregion

     

        /// <summary>

        /// The main entry point for the application.

        /// </summary>

        [STAThread]

        static void Main()

        {

          Application.Run(new Form1());

        }

     

        protected override void OnDragEnter(DragEventArgs e)

        {

          if(e.Data.GetDataPresent(DataFormats.FileDrop))

          {

            bool allow=true;

            foreach(string s in (string[])e.Data.GetData(DataFormats.FileDrop))

            {

              string ext= Path.GetExtension(s).ToLower();

              if(

                !(ext==".jpg" ||

                ext==".jpeg" ||

                ext==".tif" ||

                ext==".gif" ||

                ext==".bmp"))

                allow=false;

            }

            if(allow)

              e.Effect=DragDropEffects.Copy;

            else

              e.Effect=DragDropEffects.None;

          }

        }

     

     

        protected override void OnDragDrop(DragEventArgs e)

        {

          string[] sa=(string[])e.Data.GetData(DataFormats.FileDrop);

     

          SaveFileDialog dlg=new SaveFileDialog();

          dlg.DefaultExt=".tif";

          if(dlg.ShowDialog()!=DialogResult.OK)

            return;

     

     

          //get the codec for tiff files

          ImageCodecInfo info=null;

          foreach(ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())

            if(ice.MimeType=="image/tiff")

              info=ice;

          

          //use the save encoder

          Encoder enc=Encoder.SaveFlag;

     

          EncoderParameters ep=new EncoderParameters(1);

          ep.Param[0]=new EncoderParameter(enc,(long)EncoderValue.MultiFrame);

     

          Bitmap pages=null;

        

          int frame=0;

     

          foreach(string s in sa)

          {

            if(frame==0)

            {

              pages=(Bitmap)Image.FromFile(s);

              //save the first frame

              pages.Save(dlg.FileName,info,ep);

            }

            else

            {

              //save the intermediate frames

              ep.Param[0]=new EncoderParameter(enc,(long)EncoderValue.FrameDimensionPage);

              Bitmap bm=(Bitmap)Image.FromFile(s);

              pages.SaveAdd(bm,ep);

            }

            

            if(frame==sa.Length-1)

            {

              //flush and close.

              ep.Param[0]=new EncoderParameter(enc,(long)EncoderValue.Flush);

              pages.SaveAdd(ep);

            }

     

            frame++;

          }

     

        }

     

     

        private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)

        {

          StringFormat sf=(StringFormat)StringFormat.GenericTypographic.Clone();

          sf.Alignment=StringAlignment.Center;

          sf.LineAlignment=StringAlignment.Center;

          e.Graphics.DrawString("Drop images here to make a multi-page tiff",Font,Brushes.Black,newRectangleF(0,0,this.ClientSize.Width,this.ClientSize.Height),sf);

        }

      }

    }

    ==============================================



    viernes, 22 de junio de 2012 9:20

Todas las respuestas