public static FileForm ShowDialogue(Window window, FileFormTypes fileFormType, OperationTypes operationType, CloseEvent closeFunction = null, string title = null, bool resizable = true, bool isDialog = true, string category = null, ISkinFile file = null) { var openFileForm = new FileForm(); openFileForm.Initialize(fileFormType, operationType, closeFunction, title, resizable, isDialog, category, file); openFileForm.Show(window); openFileForm.UpdateSize(); openFileForm.X = (openFileForm.Parent.Width / 2) - (openFileForm.Width / 2); openFileForm.Y = (openFileForm.Parent.Height / 2) - (openFileForm.Height / 2); return(openFileForm); }
public DrawBoxPair <TextField, ResizableButton> AddBrowseField(FileForm.FileFormTypes fileFormType, FileForm.OperationTypes operationType, string labelText, string buttonTitle = "Browse") { var pair = AddTextFieldWithButton(labelText, buttonTitle, null); var currentForm = container; //So that if container == null, the delegate can still refer to it. pair.DrawBox2.Click += delegate(object sender) { FileForm.ShowDialogue(currentForm.Parent, fileFormType, operationType, delegate(object _sender) { var fileForm = (FileForm)_sender; if (fileForm.Result == DialogResult.OK) { if (operationType == FileForm.OperationTypes.Open || operationType == FileForm.OperationTypes.Select) { switch (fileFormType) { case FileForm.FileFormTypes.File: pair.DrawBox1.Text = fileForm.SelectedFile.FullName; break; case FileForm.FileFormTypes.Folder: pair.DrawBox1.Text = fileForm.SelectedFolder.FullName; break; } } else if (operationType == FileForm.OperationTypes.Save) { pair.DrawBox1.Text = fileForm.SaveDirectory; } } }); }; return(pair); }