Browse Source

Merge f1e4729cdb into 3f3ae2a5d4

pull/517/merge
Ciprian Khlud 6 years ago committed by GitHub
parent
commit
19180aa6b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 100
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  2. 31
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileCategory.cs
  3. 30
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileTemplate.cs
  4. 269
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileViewModel.cs
  5. 113
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileWindow.xaml
  6. 84
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileWindow.xaml.cs
  7. 28
      src/Main/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj
  8. 13
      src/Main/SharpDevelop/Services/UIService.cs

100
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -275,7 +275,9 @@ @@ -275,7 +275,9 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\Components\LocalizedPropertyGrid\BooleanTypeConverter.cs" />
<Compile Include="Src\Gui\Components\SideBar\TextEditorSideBar.cs" />
<Compile Include="Src\Gui\Components\SideBar\TextEditorSideBar.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Components\StringListEditorDialog.xaml.cs">
<DependentUpon>StringListEditorDialog.xaml</DependentUpon>
</Compile>
@ -284,15 +286,26 @@ @@ -284,15 +286,26 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\CustomFocusManager.cs" />
<Compile Include="Src\Gui\Dialogs\AsynchronousWaitDialog.cs" />
<Compile Include="Src\Gui\Dialogs\AsynchronousWaitDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\AsynchronousWaitDialog.Designer.cs">
<DependentUpon>AsynchronousWaitDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\Dialogs\AbstractAttachToProcessForm.cs" />
<Compile Include="Src\Gui\Dialogs\AbstractAttachToProcessForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\AbstractAttachToProcessForm.Designer.cs">
<DependentUpon>AbstractAttachToProcessForm.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\Dialogs\NewFileCategory.cs" />
<Compile Include="Src\Gui\Dialogs\ExtractInterfaceDialog.cs" />
<Compile Include="Src\Gui\Dialogs\NewFileTemplate.cs" />
<Compile Include="Src\Gui\Dialogs\NewFileViewModel.cs" />
<Compile Include="Src\Gui\Dialogs\NewFileWindow.xaml.cs">
<DependentUpon>NewFileWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\OutputWindowOptionsPanel.xaml.cs">
<DependentUpon>OutputWindowOptionsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
@ -422,10 +435,10 @@ @@ -422,10 +435,10 @@
<Compile Include="Src\Gui\Dialogs\ExtractInterfaceDialog.Designer.cs">
<DependentUpon>ExtractInterfaceDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\Dialogs\GotoDialog.cs">
<Compile Include="Src\Gui\Dialogs\GotoDialog.cs" />
<Compile Include="Src\Gui\Dialogs\NewProjectDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\NewProjectDialog.cs" />
<Compile Include="Src\Gui\Dialogs\NewProjectDialog.Designer.cs">
<DependentUpon>NewProjectDialog.cs</DependentUpon>
</Compile>
@ -548,11 +561,15 @@ @@ -548,11 +561,15 @@
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\SvcUtilMessageView.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\SvcUtilPath.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\SvcUtilRunner.cs" />
<Compile Include="Src\Gui\Dialogs\ToolNotFoundDialog.cs" />
<Compile Include="Src\Gui\Dialogs\ToolNotFoundDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\ToolNotFoundDialog.Designer.cs">
<DependentUpon>ToolNotFoundDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\XmlFormsOptionPanel.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\XmlFormsOptionPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\TabbedOptionsDialog.xaml.cs">
<DependentUpon>TabbedOptionsDialog.xaml</DependentUpon>
<SubType>Code</SubType>
@ -669,11 +686,9 @@ @@ -669,11 +686,9 @@
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Components\SideBar\SharpDevelopSideTabItem.cs" />
<Compile Include="Src\Gui\Dialogs\AbstractOptionPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\AbstractOptionPanel.cs" />
<Compile Include="Src\Gui\Dialogs\CommonAboutDialog.cs">
<SubType>Form</SubType>
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\NewFileDialog.cs">
<SubType>Form</SubType>
@ -681,9 +696,7 @@ @@ -681,9 +696,7 @@
<Compile Include="Src\Gui\Dialogs\SharpDevelopAboutPanels.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\TabbedOptions.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\TabbedOptions.cs" />
<Compile Include="Src\Gui\Dialogs\WordCountDialog.cs">
<SubType>Form</SubType>
</Compile>
@ -694,7 +707,7 @@ @@ -694,7 +707,7 @@
<SubType>Component</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\GacReferencePanel.cs">
<SubType>Component</SubType>
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ProjectReferencePanel.cs">
<SubType>Component</SubType>
@ -819,7 +832,6 @@ @@ -819,7 +832,6 @@
<Compile Include="Src\Gui\Pads\PropertyPad\IDEContainer.cs" />
<Compile Include="Src\Gui\Pads\PropertyPad\PropertyContainer.cs" />
<Compile Include="Src\Gui\Dialogs\OptionPanels\ProjectOptions\BuildEvents.cs">
<SubType>UserControl</SubType>
<DependentUpon>BuildEvents.xaml</DependentUpon>
</Compile>
<Compile Include="Src\Gui\BrowserDisplayBinding\SchemeExtension.cs" />
@ -843,12 +855,18 @@ @@ -843,12 +855,18 @@
<Compile Include="Src\Services\RefactoringService\FindReferencesAndRenameHelper.cs" />
<Compile Include="Src\Internal\Doozers\DirectoryDoozer.cs" />
<Compile Include="Src\Project\ConfigurationGuiBinding.cs" />
<Compile Include="Src\Project\ChooseStorageLocationButton.cs" />
<Compile Include="Src\Project\ChooseStorageLocationButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Src\Gui\Pads\ProjectBrowser\NodeBuilder\NodeBuilders.cs" />
<Compile Include="Src\Gui\Pads\TaskList\TaskListPad.cs" />
<Compile Include="Src\Gui\FormLocationHelper.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\AddWebReferenceDialog.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\WebServicesView.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\AddWebReferenceDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\WebServicesView.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\Project\Items\WebReferencesProjectItem.cs" />
<Compile Include="Src\Gui\Pads\ProjectBrowser\NodeBuilder\WebReferenceNodeBuilder.cs" />
<Compile Include="Src\Gui\Pads\ProjectBrowser\TreeNodes\WebReferencesFolderNode.cs" />
@ -856,8 +874,12 @@ @@ -856,8 +874,12 @@
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\WebReferenceChanges.cs" />
<Compile Include="Src\Project\Converter\LanguageConverter.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\HttpAuthenticationHeader.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\UserCredentialsDialog.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\WebServiceDiscoveryClientProtocol.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\UserCredentialsDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\WebServiceDiscoveryClientProtocol.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\AsyncDiscoveryState.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\DiscoveryNetworkCredential.cs" />
<Compile Include="..\..\GlobalAssemblyInfo.cs">
@ -873,7 +895,9 @@ @@ -873,7 +895,9 @@
<Compile Include="Src\Services\HelpProvider.cs" />
<Compile Include="Src\Services\ParserService\CodeCompletionOptions.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\CompareProjectPropertyConditionEvaluator.cs" />
<Compile Include="Src\Gui\Dialogs\SharpDevelopColorDialog.cs" />
<Compile Include="Src\Gui\Dialogs\SharpDevelopColorDialog.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Src\Project\CustomTool.cs" />
<Compile Include="Src\Project\MSBuildBasedProject.cs" />
<Compile Include="Src\Project\MSBuildItemDefinitionGroup.cs" />
@ -890,22 +914,13 @@ @@ -890,22 +914,13 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Designer" />
<Folder Include="Dom\ClassBrowser" />
<Folder Include="Editor\CodeCompletion\Images" />
<Folder Include="Editor\ContextActions" />
<Folder Include="Debugging" />
<Folder Include="Project\TargetFrameworks" />
<Folder Include="Src\Editor\Dialogs" />
<Folder Include="Templates" />
<Folder Include="Project\Configuration" />
<Folder Include="Workbench\DisplayBinding" />
<Page Include="Editor\Bookmarks\BookmarkPadContent.xaml" />
<Page Include="Editor\CodeCompletion\CodeCompletionOptionPanel.xaml" />
<Page Include="Src\Editor\Dialogs\RenameSymbolDialog.xaml" />
<Page Include="Src\Gui\Components\FontSelector.xaml" />
<Page Include="Src\Gui\Components\StringListEditorDialog.xaml" />
<Page Include="Src\Gui\Components\StringListEditor.xaml" />
<Page Include="Src\Gui\Dialogs\NewFileWindow.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\ExternalToolPanel.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\CodeGenerationPanel.xaml" />
<Page Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\EditStandardHeaderPanel.xaml" />
@ -974,27 +989,6 @@ @@ -974,27 +989,6 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<Folder Include="Dom" />
<Folder Include="Editor" />
<Folder Include="Editor\Bookmarks" />
<Folder Include="Util" />
<Folder Include="Project" />
<Folder Include="Parser" />
<Folder Include="Project\Build" />
<Folder Include="Services" />
<Folder Include="WinForms" />
<Folder Include="Workbench" />
<Folder Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference" />
<Folder Include="Refactoring" />
<Folder Include="Src\Project\Behaviors" />
<Folder Include="Project\PortableLibrary" />
<Folder Include="themes" />
<Folder Include="Src\Editor\AvalonEdit" />
<Folder Include="Editor\CodeCompletion" />
<Folder Include="Src\Editor\Commands" />
<Folder Include="Editor\Search" />
<Folder Include="Src\Gui\Pads\TaskList" />
<Folder Include="Src\Services\NavigationService" />
<ProjectReference Include="..\..\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj">
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project>
<Name>ICSharpCode.Core.Presentation</Name>

31
src/Main/Base/Project/Src/Gui/Dialogs/NewFileCategory.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
using System.Collections.ObjectModel;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Widgets;
namespace ICSharpCode.SharpDevelop.Gui
{
public class NewFileCategory : ViewModelBase
{
string _displayName;
public NewFileCategory(string displayName)
{
Children = new ObservableCollection<NewFileCategory>();
Templates = new ObservableCollection<NewFileTemplate>();
DisplayName = StringParser.Parse(displayName);
}
public ObservableCollection<NewFileCategory> Children { get; set; }
public ObservableCollection<NewFileTemplate> Templates { get; set; }
public string DisplayName
{
get { return _displayName; }
set
{
_displayName = value;
OnPropertyChanged();
}
}
}
}

30
src/Main/Base/Project/Src/Gui/Dialogs/NewFileTemplate.cs

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Templates;
using ICSharpCode.SharpDevelop.Widgets;
namespace ICSharpCode.SharpDevelop.Gui
{
public class NewFileTemplate : ViewModelBase
{
public NewFileTemplate(FileTemplate template, string categoryDescription)
{
Template = template;
CategoryDescription = categoryDescription;
}
public FileTemplate Template { get; private set; }
public string CategoryDescription { get; set; }
public string DisplayName { get { return Template.DisplayName; } }
public string Description { get {
return StringParser.Parse(Template.Description);
} }
public ImageSource Picture { get{
return Template.Icon.ImageSource;
}
}
public string Name { get { return Template.Name; } }
}
}

269
src/Main/Base/Project/Src/Gui/Dialogs/NewFileViewModel.cs

@ -0,0 +1,269 @@ @@ -0,0 +1,269 @@
/*
* Created by SharpDevelop.
* User: Ciprian Khlud
* Date: 7/19/2014
* Time: 10:52 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Templates;
using ICSharpCode.SharpDevelop.Widgets;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui
{
public class NewFileViewModel : ViewModelBase
{
#region Backing properties
private NewFileCategory _selectedCategory;
private string _searchFor;
private ObservableCollection<NewFileTemplate> _allTemplate;
private NewFileTemplate _selectedItem;
private string _fileName;
#endregion
public NewFileViewModel()
{
_allTemplate = new ObservableCollection<NewFileTemplate>();
Categories = new ObservableCollection<NewFileCategory>();
AllFileTemplates = new NewFileCategory("All");
Categories.Add(AllFileTemplates);
}
public NewFileCategory AllFileTemplates { get; set; }
public NewFileCategory SelectedCategory
{
get { return _selectedCategory; }
set
{
_selectedCategory = value;
OnPropertyChanged();
}
}
public ObservableCollection<NewFileTemplate> SelectedTemplates
{
get
{
UpdatedSelection();
return _allTemplate;
}
}
public void UpdatedSelection()
{
_allTemplate.Clear();
var selectedCategory = _selectedCategory;
if (selectedCategory == null) return;
var searchTokens = SearchFor.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
foreach (var item in selectedCategory.Templates)
{
if(PassFilter(item, searchTokens))
_allTemplate.Add(item);
}
}
static bool PassFilter(NewFileTemplate template, string[] searchTokens)
{
if (searchTokens.Length == 0)
return true;
var result = TextMatchesSearchTokens(searchTokens, template.DisplayName);
var resultDescription = TextMatchesSearchTokens(searchTokens, template.Description);
var resultCategory = TextMatchesSearchTokens(searchTokens, template.CategoryDescription);
return result ||resultDescription || resultCategory;
}
static bool TextMatchesSearchTokens(string[] searchTokens, string textToSearch)
{
foreach (var searchToken in searchTokens)
{
if (textToSearch.IndexOf(searchToken, StringComparison.OrdinalIgnoreCase) >= 0)
return true;
}
return false;
}
public NewFileTemplate SelectedItem
{
get { return _selectedItem; }
set
{
_selectedItem = value;
OnPropertyChanged();
OnPropertyChanged("Description");
FileName = GenerateCurrentFileName();
}
}
public IProject Project
{
get;
set;
}
public DirectoryName BasePath
{
get;
set;
}
public bool AllowUntitledFiles
{
get;
set;
}
string GenerateCurrentFileName()
{
if(SelectedItem==null)
return string.Empty;
return SelectedItem.Template.SuggestFileName(BasePath);
}
internal static string GenerateValidClassOrNamespaceName(string className, bool allowDot)
{
if (className == null)
throw new ArgumentNullException("className");
className = className.Trim();
if (className.Length == 0)
return string.Empty;
var nameBuilder = new StringBuilder();
if (className[0] != '_' && !char.IsLetter(className, 0))
nameBuilder.Append('_');
for (int idx = 0; idx < className.Length; ++idx)
{
if (Char.IsLetterOrDigit(className[idx]) || className[idx] == '_')
{
nameBuilder.Append(className[idx]);
}
else if (className[idx] == '.' && allowDot)
{
nameBuilder.Append('.');
}
else
{
nameBuilder.Append('_');
}
}
return nameBuilder.ToString();
}
internal void InitializeTemplates(IEnumerable<TemplateCategory> templateCategories)
{
var categories = Categories;
foreach (var templateCategory in Sorted(templateCategories)) {
var cat = CreateCategory(templateCategory);
categories.Add(cat);
}
SelectedCategory = AllFileTemplates;
}
IEnumerable<TemplateCategory> Sorted(IEnumerable<TemplateCategory> templateCategories)
{
return templateCategories
.OrderByDescending(c => c.SortOrder)
.ThenBy(c => StringParser.Parse(c.DisplayName));
}
NewFileCategory CreateCategory(TemplateCategory templateCategory)
{
var category = new NewFileCategory(templateCategory.DisplayName);
foreach (var subcategory in Sorted(templateCategory.Subcategories))
{
var subnode = CreateCategory(subcategory);
category.Children.Add(subnode);
}
foreach (var template in templateCategory.Templates.OfType<FileTemplate>())
{
if (!template.IsVisible(Project))
continue;
var titem = new NewFileTemplate(template, category.DisplayName);
AllFileTemplates.Templates.Add(titem);
category.Templates.Add(titem);
}
return category;
}
internal FileTemplateResult BuildSelectedResult()
{
var selectedTemplate = SelectedItem;
var fileName = FileName;
var standardNamespace = "DefaultNamespace";
var localizedTypeDescriptor = selectedTemplate.Template.CreateCustomizationObject();
var options = new FileTemplateOptions
{
ClassName =
GenerateValidClassOrNamespaceName(Path.GetFileNameWithoutExtension(FileName), false),
FileName = Core.FileName.Create(fileName),
IsUntitled = AllowUntitledFiles,
Namespace = standardNamespace,
CustomizationObject = localizedTypeDescriptor,
Project = Project
};
var result = selectedTemplate.Template.Create(options);
if (result != null)
selectedTemplate.Template.RunActions(result);
return result;
}
public FileTemplateResult Result { get;set; }
public string SearchFor
{
get
{
if (string.IsNullOrEmpty(_searchFor))
_searchFor = string.Empty;
return _searchFor;
}
set
{
_searchFor = value;
OnPropertyChanged();
}
}
public string FileName
{
get { return _fileName; }
set
{
_fileName = value;
OnPropertyChanged();
}
}
public string Description
{
get
{
return SelectedItem == null
? string.Empty
: SelectedItem.Description;
}
set { }
}
public ObservableCollection<NewFileCategory> Categories { get; set; }
}
}

113
src/Main/Base/Project/Src/Gui/Dialogs/NewFileWindow.xaml

@ -0,0 +1,113 @@ @@ -0,0 +1,113 @@
<Window x:Class="ICSharpCode.SharpDevelop.Gui.NewFileWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
Title="${res:Dialog.NewFile.DialogName}"
WindowStartupLocation="CenterScreen"
Height="400" Width="600">
<Window.DataContext>
<gui:NewFileViewModel />
</Window.DataContext>
<Grid Margin="4">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Categories" />
<TreeView Grid.Row="1"
ItemsSource="{Binding Categories}"
x:Name="categoryTreeView"
HorizontalAlignment="Stretch"
SelectedItemChanged="CategoryTreeView_SelectedItemChanged"
>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<TextBlock Text="{Binding DisplayName}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
<GridSplitter Grid.Column="1" ResizeDirection="Columns" Width="5" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
<Grid Grid.Column="2" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Text="Search:" VerticalAlignment="Center" />
<TextBox Text="{Binding SearchFor}" x:Name="SearchTextBox" Margin="2" Width="100" TextChanged="OnUpdateSearch" />
</StackPanel>
<ListBox Grid.Row="1" ItemsSource="{Binding SelectedTemplates}"
SelectedItem="{Binding SelectedItem}"
Grid.IsSharedSizeScope="True"
>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="Column1" />
<ColumnDefinition SharedSizeGroup="Column2" />
<ColumnDefinition Width="Auto" SharedSizeGroup="Column3" />
</Grid.ColumnDefinitions>
<Image Source="{Binding Picture}" Width="32" />
<StackPanel
Grid.Column="1"
HorizontalAlignment="Stretch"
>
<Label Content="{Binding DisplayName}" FontWeight="Bold" />
<Label Content="{Binding Description}" />
</StackPanel>
<Label Grid.Column="2"
Foreground="DarkGray"
HorizontalAlignment="Right"
Content="{Binding CategoryDescription}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
<StackPanel Grid.Row="2">
<Label Content="{Binding Description}" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="File name: " VerticalAlignment="Center" />
<TextBox Grid.Column="1" Text="{Binding FileName}" x:Name="fileNameTextBox" />
</Grid>
<widgets:UniformGridWithSpacing Columns="2" HorizontalAlignment="Right" Margin="0,4,12,12">
<Button
Content="{core:Localize Global.OKButtonText}"
IsDefault="True"
Name="okButton"
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Click="okButtonClick" />
<Button
Content="{core:Localize Global.CancelButtonText}"
IsCancel="True"
Name="cancelButton"
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Click="cancelButtonClick" />
</widgets:UniformGridWithSpacing>
</StackPanel>
</Grid>
</Window>

84
src/Main/Base/Project/Src/Gui/Dialogs/NewFileWindow.xaml.cs

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
/*
* Created by SharpDevelop.
* User: Ciprian Khlud
* Date: 7/19/2014
* Time: 10:52 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Templates;
namespace ICSharpCode.SharpDevelop.Gui
{
/// <summary>
/// Interaction logic for NewFileWindow.xaml
/// </summary>
public partial class NewFileWindow
{
public NewFileViewModel ViewModel
{
get
{
return (NewFileViewModel)DataContext;
}
}
public NewFileWindow()
{
InitializeComponent();
}
public NewFileWindow(IProject project, DirectoryName basePath, IEnumerable<TemplateCategory> templateCategories)
{
DataContext = new NewFileViewModel();
InitializeComponent();
ViewModel.Project = project;
ViewModel.BasePath = basePath;
ViewModel.AllowUntitledFiles = basePath == null;
if(ViewModel.AllowUntitledFiles)
{
categoryTreeView.Focus();
}
else
{
fileNameTextBox.Focus();
}
ViewModel.InitializeTemplates(templateCategories);
}
void okButtonClick(object sender, RoutedEventArgs e)
{
var result = ViewModel.BuildSelectedResult();
ViewModel.Result = result;
DialogResult = result!=null;
Close();
}
void cancelButtonClick(object sender, RoutedEventArgs e)
{
Close();
}
void CategoryTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
ViewModel.SelectedCategory = (NewFileCategory)categoryTreeView.SelectedItem;
ViewModel.UpdatedSelection();
}
private void OnUpdateSearch(object sender, TextChangedEventArgs e)
{
ViewModel.SearchFor = SearchTextBox.Text;
ViewModel.UpdatedSelection();
}
}
}

28
src/Main/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj

@ -63,19 +63,29 @@ @@ -63,19 +63,29 @@
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Menu\IStatusUpdate.cs" />
<Compile Include="Menu\Menu.cs" />
<Compile Include="Menu\Menu.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Menu\MenuCheckBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Menu\MenuCommand.cs" />
<Compile Include="Menu\MenuSeparator.cs" />
<Compile Include="Menu\MenuCommand.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Menu\MenuSeparator.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Menu\MenuService.cs" />
<Compile Include="MessageService\CustomDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MessageService\IDialogMessageService.cs" />
<Compile Include="MessageService\InputBox.cs" />
<Compile Include="MessageService\SaveErrorChooseDialog.cs" />
<Compile Include="MessageService\InputBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MessageService\SaveErrorChooseDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MessageService\SaveErrorInformDialog.cs">
<SubType>Form</SubType>
</Compile>
@ -84,11 +94,15 @@ @@ -84,11 +94,15 @@
<Compile Include="ToolBar\ToolBarCheckBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ToolBar\ToolBarCommand.cs" />
<Compile Include="ToolBar\ToolBarCommand.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ToolBar\ToolBarDropDownButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ToolBar\ToolBarLabel.cs" />
<Compile Include="ToolBar\ToolBarLabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ToolBar\ToolBarSeparator.cs">
<SubType>Component</SubType>
</Compile>

13
src/Main/SharpDevelop/Services/UIService.cs

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//#define EXPERIMENTAL_NEW_FILE
using System;
using System.Collections.Generic;
using System.Linq;
@ -49,6 +51,17 @@ namespace ICSharpCode.SharpDevelop @@ -49,6 +51,17 @@ namespace ICSharpCode.SharpDevelop
#if DEBUG
SD.Templates.UpdateTemplates();
#endif
#if EXPERIMENTAL_NEW_FILE
var nfdWpf = new NewFileWindow(project, directory, templates ?? SD.Templates.TemplateCategories);
if (nfdWpf.ShowDialog() ?? false)
{
return nfdWpf.ViewModel.Result;
}
else
{
return null;
}
#endif
using (NewFileDialog nfd = new NewFileDialog(project, directory, templates ?? SD.Templates.TemplateCategories)) {
if (nfd.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK)
return nfd.result;

Loading…
Cancel
Save