Example #1
0
 //Add
 private void Button_Click_3(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(NewFileNameText.Text))
     {
         if (SelectedFileType == NewFileType.Window)
         {
             if (!NewFileNameText.Text.Contains(".xaml"))
             {
                 NewFileNameText.Text += ".xaml";
             }
             File.WriteAllText(Path.Combine(CurrentSolution.SourceDirectory, NewFileNameText.Text), Constants.CreateNewXamlWindowFile(CurrentSolution, NewFileNameText.Text));
             File.WriteAllText(Path.Combine(CurrentSolution.SourceDirectory, NewFileNameText.Text + ".cs"), Constants.CreateNewXamlCsFile(CurrentSolution, NewFileNameText.Text));
             CurrentSolution.AddProjectFile(NewFileNameText.Text, false);
             CurrentSolution.AddProjectFile(NewFileNameText.Text + ".cs");
             CurrentWorkspace.AddProjectFile(NewFileNameText.Text);
             CurrentWorkspace.AddProjectFile(NewFileNameText.Text + ".cs");
             CurrentSolution.Save();
             this.Close();
         }
         else if (SelectedFileType == NewFileType.UserControl)
         {
             if (!NewFileNameText.Text.Contains(".xaml"))
             {
                 NewFileNameText.Text += ".xaml";
             }
             File.WriteAllText(Path.Combine(CurrentSolution.SourceDirectory, NewFileNameText.Text), Constants.CreateNewXamlControlFile(CurrentSolution, NewFileNameText.Text));
             File.WriteAllText(Path.Combine(CurrentSolution.SourceDirectory, NewFileNameText.Text + ".cs"), Constants.CreateNewXamlCsFile(CurrentSolution, NewFileNameText.Text, true));
             CurrentSolution.AddProjectFile(NewFileNameText.Text, false);
             CurrentSolution.AddProjectFile(NewFileNameText.Text + ".cs");
             CurrentWorkspace.AddProjectFile(NewFileNameText.Text);
             CurrentWorkspace.AddProjectFile(NewFileNameText.Text + ".cs");
             CurrentSolution.Save();
             this.Close();
         }
         else if (SelectedFileType == NewFileType.Class)
         {
             if (!NewFileNameText.Text.Contains(".cs"))
             {
                 NewFileNameText.Text += ".cs";
             }
             File.WriteAllText(Path.Combine(CurrentSolution.SourceDirectory, NewFileNameText.Text), Constants.CreateNewClass(CurrentSolution, NewFileNameText.Text));
             CurrentSolution.AddProjectFile(NewFileNameText.Text);
             CurrentWorkspace.AddProjectFile(NewFileNameText.Text);
             CurrentSolution.Save();
             this.Close();
         }
         else
         {
             MessageBox.Show("You must select a new file type.", "Need User Input", MessageBoxButton.OK);
         }
     }
     else
     {
         MessageBox.Show("You must select a new file type.", "Need User Input", MessageBoxButton.OK);
     }
 }