Beispiel #1
0
        /// <summary>
        /// Add a new topic from a template file
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void cmdAddFromTemplate_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            string newFilePath = Path.GetDirectoryName(contentLayoutFile.FullPath);

            if (ucContentLayoutEditor.CurrentTopic != null && ucContentLayoutEditor.CurrentTopic.TopicFile != null)
            {
                newFilePath = Path.GetDirectoryName(ucContentLayoutEditor.CurrentTopic.TopicFile.FullPath);
            }

            using (SelectFileTemplateDlg dlg = new SelectFileTemplateDlg(true, newFilePath))
            {
                // If created, add it to the project, refresh the Project Explorer, and open the file for editing
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Topic t = this.AddTopicFile(dlg.NewFilename, e.Parameter != null);
                    MainForm.Host.ProjectExplorer.RefreshProject();

                    // Ensure that the topic we just added is opened by passing it as the sender
                    cmdEdit_Executed(t, e);
                }
            }
        }
        /// <summary>
        /// Add a new topic from a template file
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void cmdAddFromTemplate_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            string newFilePath = Path.GetDirectoryName(siteMapFile.FullPath);

            if(ucSiteMapEditor.CurrentTopic != null && ucSiteMapEditor.CurrentTopic.SourceFile.Path.Length != 0)
                newFilePath = Path.GetDirectoryName(ucSiteMapEditor.CurrentTopic.SourceFile);

            using(SelectFileTemplateDlg dlg = new SelectFileTemplateDlg(false, newFilePath))
            {
                // If created, add it to the project, refresh the Project Explorer, and open the file for editing
                if(dlg.ShowDialog() == DialogResult.OK)
                {
                    TocEntry t = this.AddTopicFile(dlg.NewFilename, e.Parameter != null);
                    MainForm.Host.ProjectExplorer.RefreshProject();

                    // Ensure that the topic we just added is opened by passing it as the sender
                    cmdEdit_Executed(t, e);
                }
            }
        }