using System; using System.Drawing; using System.Windows.Forms; using System.IO; public class UI : Form { private Label inputFileLabel; private Label outputFileLabel; private Button inputFileButton; private Button outputFileButton; public UI() { Text = "File Converter"; inputFileLabel = new Label(); inputFileLabel.Text = "input file name"; inputFileLabel.Location = new Point(24,16); outputFileLabel = new Label(); outputFileLabel.Text = "output file name"; outputFileLabel.Location = new Point(24,56); inputFileButton = new Button(); inputFileButton.Text = "Select input file"; inputFileButton.Location = new Point(130,16); inputFileButton.Size = new Size(100,20); inputFileButton.Click += new EventHandler(inputFileButtonClicked); outputFileButton = new Button(); outputFileButton.Text = "Select ouput file"; outputFileButton.Location = new Point(130,56); outputFileButton.Size = new Size(100,20); outputFileButton.Click += new EventHandler(outputFileButtonClicked); this.Controls.Add(inputFileLabel); this.Controls.Add(inputFileButton); this.Controls.Add(outputFileLabel); this.Controls.Add(outputFileButton); } private void inputFileButtonClicked(object o, EventArgs e) { OpenFileDialog fd = new OpenFileDialog(); fd.Filter = "out files (*.in)|*.in|all files (*.*)|*.*"; if (fd.ShowDialog() == DialogResult.OK) { inputFileLabel.Text = fd.FileName; } } private void outputFileButtonClicked(object o, EventArgs e) { SaveFileDialog fd = new SaveFileDialog(); fd.Filter = "out files (*.out)|*.out|all files (*.*)|*.*"; if (fd.ShowDialog() == DialogResult.OK) { outputFileLabel.Text = fd.FileName; } /* The above yields an exception: Unhandled Exception: System.ArgumentOutOfRangeException: Argument is out of range. Parameter name: Index out of range. in [0x00035] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs:2626) System.Windows.Forms.ListView+SelectedListViewItemCollection:get_Item (Int32 index) in [0x0000c] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/FileDialog.cs:737) System.Windows.Forms.FileDialog:OnClickOpenSaveButton (System.Object sender, System.EventArgs e) in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs) in [0x00013] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:4060) System.Windows.Forms.Control:OnClick (System.EventArgs e) in [0x0002c] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:96) System.Windows.Forms.Button:OnClick (System.EventArgs e) in [0x00006] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:79) System.Windows.Forms.Button:PerformClick () in [0x00026] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs:1488) System.Windows.Forms.Form:ProcessDialogKey (Keys keyData) in [0x00013] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:3241) System.Windows.Forms.Control:ProcessDialogKey (Keys keyData) in [0x00013] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:3241) System.Windows.Forms.Control:ProcessDialogKey (Keys keyData) in [0x00002] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs:768) System.Windows.Forms.TextBoxBase:ProcessDialogKey (Keys keyData) in [0x00055] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:2911) System.Windows.Forms.Control:PreProcessMessage (System.Windows.Forms.Message msg) in [0x00221] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:388) System.Windows.Forms.Application:RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) in [0x000ab] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs:1160) System.Windows.Forms.Form:ShowDialog (IWin32Window ownerWin32) in (wrapper remoting-invoke-with-check) System.Windows.Forms.Form:ShowDialog (System.Windows.Forms.IWin32Window) in [0x00019] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs:116) System.Windows.Forms.CommonDialog:ShowDialog (IWin32Window ownerWin32) in [0x00002] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CommonDialog.cs:105) System.Windows.Forms.CommonDialog:ShowDialog () in (wrapper remoting-invoke-with-check) System.Windows.Forms.CommonDialog:ShowDialog () in [0x00012] (at /home/troels/temp2/UI.cs:60) UI:outputFileButtonClicked (System.Object o, System.EventArgs e) in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void_object_EventArgs (object,System.EventArgs) in [0x00013] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:4060) System.Windows.Forms.Control:OnClick (System.EventArgs e) in [0x0002c] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:96) System.Windows.Forms.Button:OnClick (System.EventArgs e) in [0x000a6] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs:478) System.Windows.Forms.ButtonBase:OnMouseUp (System.Windows.Forms.MouseEventArgs mevent) in [0x00002] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:100) System.Windows.Forms.Button:OnMouseUp (System.Windows.Forms.MouseEventArgs e) in [0x002a6] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:3772) System.Windows.Forms.Control:WndProc (System.Windows.Forms.Message m) in [0x00057] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ButtonBase.cs:527) System.Windows.Forms.ButtonBase:WndProc (System.Windows.Forms.Message m) in [0x00002] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Button.cs:113) System.Windows.Forms.Button:WndProc (System.Windows.Forms.Message m) in [0x00007] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:159) System.Windows.Forms.Control+ControlNativeWindow:WndProc (System.Windows.Forms.Message m) in [0x00056] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NativeWindow.cs:146) System.Windows.Forms.NativeWindow:WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) in [0x0001c] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:2467) System.Windows.Forms.XplatUIX11:DispatchMessage (System.Windows.Forms.MSG msg) in [0x00006] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs:396) System.Windows.Forms.XplatUI:DispatchMessage (System.Windows.Forms.MSG msg) in [0x0023f] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:395) System.Windows.Forms.Application:RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) in [0x00007] (at /home/troels/rpm/BUILD/mono-1.1.13.8/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs:292) System.Windows.Forms.Application:Run (System.Windows.Forms.Form mainForm) in [0x00005] (at /home/troels/temp2/UI.cs:105) UI:Main () */ } public static void Main() { Application.Run(new UI()); } }