public bool LoadFromFile(Document document, string filename, SizeInches size)
    {
      bool validFile;

      try
      {
        System.Drawing.Image image = Imaging.LoadImageFromFile(filename);
        validFile = true;
      }
      catch(Exception ex)
      {
        string msg = ex.Message;
        validFile = false;
      }

      if(validFile)
      {
        Page myPage = new PageFromFile(filename, size);
        document.AddPage(myPage);
      }

      return validFile;
    }
Пример #2
0
    private void imageLoad_Click(object sender, EventArgs e)
    {
      OpenFileDialog openFileDialog1 = new OpenFileDialog();

      // Set the file dialog to filter for graphics files. 
      openFileDialog1.Filter =
          "Images (*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF,*.PNG|" +
          "All files (*.*)|*.*";

      // Allow the user to select multiple images. 
      openFileDialog1.Multiselect = true;
      openFileDialog1.Title = "My Image Browser";

      if(openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
      {
        // load the files
        for(int i = 0; i < openFileDialog1.FileNames.Length; i++)
        {
          Page myPage = new PageFromFile(openFileDialog1.FileNames[i]);
          fDocument.AddPage(myPage);
        }
      }

      button3.Focus();
      RefreshControls();
    }