All pastes #386347 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-03-08 15:18 UTC
rendered paste body
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
using System.Security;

namespace testnew2
{
	public partial class Form1 : Form
	{
		
		//initierar formen//////////////////////
		public Form1()
		{
			InitializeComponent();
			string tempFileName = @"C:\Documents and Settings\Markus\Mina dokument\EXJOBBET\RASCAL\Vc\bin\imgtest.txt";
			//Gör filnamnet kort
			
			Process proc = new Process();
			//c:\Documents and Settings\Markus\Mina dokument\EXJOBBET\RASCAL\Vc\bin\combine.exe
			proc.StartInfo.FileName = @"c:\windows\system32\cmd.exe";

			//proc.StartInfo.FileName = @"c:\Documents and Settings\Markus\Mina dokument\EXJOBBET\RASCAL\Vc\bin\rrcombine.exe";
			proc.StartInfo.Arguments = "/C dir";
			proc.StartInfo.CreateNoWindow = true;
			proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
			proc.StartInfo.RedirectStandardOutput = true;
			proc.StartInfo.UseShellExecute = false;


			proc.Start();
			Debug.WriteLine( "PROCESS OUTPUT:" );
			Debug.WriteLine( "---------------------" );
			Debug.WriteLine( proc.StandardOutput.ReadToEnd() );
			Debug.WriteLine( "---------------------" );
			proc.Close();

		}
		///
		//////////////////////////////vad händer då jag trycker på open/////////////////////////////
		
			private void openToolStripMenuItem_Click_1( object sender, EventArgs e )
			{

			OpenFileDialog dialog = new OpenFileDialog();
			ArrayList minLista = new ArrayList();
			StringBuilder shortPath = new StringBuilder(255);

		
			dialog.Filter =
			"Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|" +
			"All files (*.*)|*.*";

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

			DialogResult dr = dialog.ShowDialog();
			if ( dr == System.Windows.Forms.DialogResult.OK )
			{
				
				// Read the files
				for ( int i = 0; i < dialog.FileNames.Length; i++ )
				{
					minLista.Add(dialog.FileNames[i]);
					string file = dialog.FileNames[ i ];
					FileHandler.GetShortPathName(file, shortPath, shortPath.Capacity);
					file = shortPath.ToString();
					
					// Create a PictureBox.
					try
					{
						PictureBox pb = new PictureBox();
						Image loadedImage = Image.FromFile( file );
						pb.Height = 200;//pb.Height = loadedImage.Height;
						pb.Width = 200;	//pb.Width = loadedImage.Width;
						pb.Image = loadedImage;
						flowLayoutPanel1.Controls.Add( pb );
					}
					catch ( SecurityException ex )
					{
						// The user lacks appropriate permissions to read files, discover paths, etc.
						MessageBox.Show( "Security error. Please contact your administrator for details.\n\n" +
							"Error message: " + ex.Message + "\n\n" +
							"Details (send to Support):\n\n" + ex.StackTrace
						);
					}
					catch ( Exception ex )
					{
						// Could not load the image - probably related to Windows file system permissions.
						MessageBox.Show( "Cannot display the image: " + file.Substring( file.LastIndexOf( '\\' ) )
							+ ". You may not have permission to read the file, or " +
							"it may be corrupt.\n\nReported error: " + ex.Message );
					}
					
				}
				FileHandler.WriteToFile(ArrayList minLista);
			}
				
		}
	}
}