From bd3c023dd90ee8d82de41c71cff790e28fd1d2c3 Mon Sep 17 00:00:00 2001 From: Ciprian Khlud Date: Sun, 20 Jul 2014 13:23:16 +0300 Subject: [PATCH] Make selection and most grid items to work. Grid splitter works also. Known errors: - OK button does nothing - images and resources code is not working --- .../Src/Gui/Dialogs/NewFileTemplateItem.cs | 3 + .../Src/Gui/Dialogs/NewFileViewModel.cs | 98 ++++++++++++++++--- .../Src/Gui/Dialogs/NewFileWindow.xaml | 33 +++++-- .../Src/Gui/Dialogs/NewFileWindow.xaml.cs | 17 +++- 4 files changed, 128 insertions(+), 23 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileTemplateItem.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileTemplateItem.cs index 52358718c4..cc80da3c07 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileTemplateItem.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileTemplateItem.cs @@ -11,5 +11,8 @@ namespace ICSharpCode.SharpDevelop.Gui } public FileTemplate Template { get; private set; } + public string DisplayName { get { return Template.DisplayName; } } + public string Description { get { return Template.Description; } } + public string Name { get { return Template.Name; } } } } \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileViewModel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileViewModel.cs index 6ccec7493d..1710042dd0 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileViewModel.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileViewModel.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Runtime.CompilerServices; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Templates; using ICSharpCode.SharpDevelop.Widgets; @@ -18,16 +19,71 @@ namespace ICSharpCode.SharpDevelop.Gui { public class NewFileViewModel : ViewModelBase { + #region Backing properties + private NewFileCategory _selectedCategory; + private string _searchFor; + private ObservableCollection _allTemplate; + private NewFileTemplateItem _selectedItem; + + #endregion + public NewFileViewModel() { - AllTemplate = new ObservableCollection(); - Templates = new ObservableCollection() - { - new NewFileCategory("Empty file") - }; - Icons= new Dictionary(); + _allTemplate = new ObservableCollection(); + + Icons = new Dictionary(); Categories = new ObservableCollection(); + + AllFileTemplates = new NewFileCategory("All"); + Categories.Add(AllFileTemplates); + } + + public NewFileCategory AllFileTemplates { get; set; } + + public NewFileCategory SelectedCategory + { + get { return _selectedCategory; } + set + { + _selectedCategory = value; + OnPropertyChanged(); + } + } + + + public ObservableCollection SelectedTemplates + { + get + { + UpdatedSelection(); + return _allTemplate; + } + } + + public void UpdatedSelection() + { + _allTemplate.Clear(); + var selectedCategory = _selectedCategory; + if (selectedCategory != null) + { + foreach (var item in selectedCategory.Templates) + { + _allTemplate.Add(item); + } + } } + + public NewFileTemplateItem SelectedItem + { + get { return _selectedItem; } + set + { + _selectedItem = value; + OnPropertyChanged(); + OnPropertyChanged("Description"); + } + } + public IProject Project { get; @@ -48,14 +104,30 @@ namespace ICSharpCode.SharpDevelop.Gui public FileTemplateResult Result { get; set; } - public string SearchFor { get; set; } - public string Description { get; set; } - public ObservableCollection AllTemplate { get; set; } + public string SearchFor + { + get { return _searchFor; } + set { _searchFor = value; } + } - public Dictionary Icons { - get; - set; - } + public string Description + { + get + { + return SelectedItem == null + ? string.Empty + : SelectedItem.Template.Description; + + } + set { } + } + + + public Dictionary Icons + { + get; + set; + } public ObservableCollection Categories { get; set; } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileWindow.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileWindow.xaml index 293af78a91..c18001799d 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileWindow.xaml +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileWindow.xaml @@ -22,7 +22,7 @@ - + @@ -30,7 +30,9 @@ + x:Name="categoryTreeView" + SelectedItemChanged="CategoryTreeView_SelectedItemChanged" + > @@ -39,9 +41,9 @@ - - - + + + @@ -50,10 +52,15 @@ - + - + + @@ -61,8 +68,16 @@ - - +