private void LocateToolStripMenuItemClick(object sender, EventArgs e) { var tDirDialog = new FolderBrowserDialog(); tDirDialog.Description = @"Current folder location of the CslaGen templates is:" + Environment.NewLine + _controller.TemplatesDirectory + Environment.NewLine + @"Select a new folder location and press OK."; tDirDialog.ShowNewFolderButton = false; if (!string.IsNullOrEmpty(_controller.TemplatesDirectory)) { tDirDialog.SelectedPath = _controller.TemplatesDirectory; } else { tDirDialog.RootFolder = Environment.SpecialFolder.Desktop; } var dialogResult = tDirDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { var tdir = tDirDialog.SelectedPath; if (tDirDialog.SelectedPath.LastIndexOf('\\') != tDirDialog.SelectedPath.Length - 1) { tdir += @"\"; } _controller.TemplatesDirectory = tdir; ConfigTools.Change("TemplatesDirectory", _controller.TemplatesDirectory); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { _fileDialog.AutoUpgradeEnabled = true; _fileDialog.DefaultExt = "dll"; _fileDialog.InitialDirectory = GeneratorController.Current.ObjectsDirectory; _fileDialog.Filter = @"Assembly files (*.DLL) | *.DLL|Executable files (*.EXE) | *.EXE"; _fileDialog.RestoreDirectory = false; _fileDialog.Title = @"Select the Objects file"; DialogResult result = _fileDialog.ShowDialog(); if (result == DialogResult.Cancel) { return(value); } GeneratorController.Current.ObjectsDirectory = _fileDialog.FileName.Substring(0, _fileDialog.FileName.LastIndexOf('\\')); ConfigTools.Change("ObjectsDirectory", GeneratorController.Current.ObjectsDirectory); return(_fileDialog.FileName); }