예제 #1
0
        /// <summary> Opens the template selection window. </summary>
        /// <returns></returns>
        protected override IQOpResult <string> OpenEditor(string defaultValue, IQVarElementTarget target)
        {
            // other_files_folder\eSCRIBE
            string otherFilesEscribe = EscribeOperations.EscribeRoot;

            // other_files_folder\eSCRIBE\<TemplatesRoot>
            // default TemplatesRoot to the eScribe templates, i.e. 'WKGroup'
            string templatesRoot = !String.IsNullOrEmpty(TemplatesRoot)
                                        ? TemplatesRoot
                                        : EscribeConstants.EscribeTemplatesRoot;

            string otherFilesEscribeTemplatesRoot = Path.Combine(otherFilesEscribe, templatesRoot);

            string selectedTemplate = SelectFileDialog.IsValidTemplate(defaultValue)
                                                ? Path.Combine(otherFilesEscribe, defaultValue)
                                                : defaultValue;

            var editor = new SelectFileDialog(otherFilesEscribeTemplatesRoot, String.Empty, selectedTemplate);

            if (editor.ShowDialog() != DialogResult.OK)
            {
                return new IQOpResult <string> {
                           Result = OpResultEnum.Cancelled
                }
            }
            ;

            // trim the 'other_files_folder\eSCRIBE\' part
            selectedTemplate = SelectFileDialog.TrimTemplateRoot(otherFilesEscribe, editor.SelectedFile);
            return(new IQOpResult <string> {
                Result = OpResultEnum.Completed, Value = selectedTemplate
            });
        }
    }