├── .gitignore ├── 00_Docu ├── 00_Docu │ ├── EditOverlay │ │ ├── Step1.png │ │ ├── Step2.png │ │ ├── Step3.png │ │ └── Step4_Result.png │ ├── ErrorHandling │ │ └── PopUpMessage.png │ └── SpaceLimits │ │ ├── Step1.png │ │ ├── Step2.png │ │ ├── Step3.png │ │ ├── Step4.png │ │ └── Step5_Result.png └── screenshot.png ├── LICENSE ├── README.md ├── SwitchToDesignMode_64x.png ├── appveyor.yml └── source ├── CleanAll.bat ├── InPlaceEditBoxDemo ├── App.xaml ├── App.xaml.cs ├── Behaviours │ ├── TreeViewItemBehaviour.cs │ ├── TreeViewSelectionChangedBehavior.cs │ └── TreeViewVirtualItemBehaviour.cs ├── Converters │ └── BoolToVisibilityConverter.cs ├── Demo │ ├── Create.cs │ └── CreateTestObject.cs ├── InPlaceEditBoxDemo.csproj ├── InPlaceEditBoxDemo.csproj.user ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── ViewModels │ ├── AppViewModel.cs │ ├── Base │ │ ├── BaseViewModel.cs │ │ └── RelayCommand.cs │ └── ViewModelModelConverter.cs └── converters │ ├── ISolutionItemItemTypeToTupleConverter.cs │ └── ItemTypeDisplayNameToTextConverter.cs ├── InPlaceEditTextBoxDemo.sln ├── InplaceEditBoxLib ├── AssemblyInfo.cs ├── Events │ └── EditEvent.cs ├── InplaceEditBoxLib.csproj ├── InplaceEditBoxLib.csproj.user ├── Interfaces │ └── IEditBox.cs ├── Local │ ├── Strings.Designer.cs │ ├── Strings.pt-PTresx │ └── Strings.resx ├── Themes │ ├── DarkBrushs.xaml │ ├── Generic.xaml │ ├── LightBrushs.xaml │ └── ResourceKeys.cs ├── ViewModels │ ├── Base │ │ └── ViewModelBase.cs │ └── EditInPlaceViewModel.cs └── Views │ ├── Attach.cs │ ├── BindingProxy.cs │ ├── EditBox.xaml │ ├── EditBox.xaml.cs │ └── EditBoxAdorner.cs ├── Services ├── ExplorerLib │ ├── Explorer.cs │ ├── ExplorerLib.csproj │ ├── ExplorerMultiFileResult.cs │ ├── ExplorerResult.cs │ ├── IExplorer.cs │ ├── IExplorerMultiFileResult.cs │ ├── IExplorerResult.cs │ └── Local │ │ ├── Strings.Designer.cs │ │ └── Strings.resx └── ServiceLocator │ ├── ServiceContainer.cs │ ├── ServiceInjector.cs │ └── ServiceLocator.csproj └── Solution ├── SolutionLib ├── Converters │ ├── ISolutionBaseItemToImageConverter.cs │ └── InvertedBooleanToVisibilityConverter.cs ├── Factory.cs ├── Interfaces │ ├── IFile.cs │ ├── IFolder.cs │ ├── IItem.cs │ ├── IItemChildren.cs │ ├── IParent.cs │ ├── IProject.cs │ ├── ISolution.cs │ ├── ISolutionRootItem.cs │ └── IViewModelBase.cs ├── Models │ └── SolutionItemType.cs ├── Resources │ ├── Files │ │ └── Light │ │ │ ├── Document_128x.png │ │ │ ├── Document_16x.png │ │ │ ├── Document_16x.xaml │ │ │ ├── Document_24x..png │ │ │ ├── Document_24x.xaml │ │ │ ├── Document_256x.png │ │ │ ├── Document_256x.xaml │ │ │ ├── Document_32x.png │ │ │ ├── Document_32x.xaml │ │ │ ├── Document_48x.png │ │ │ ├── Document_48x.xaml │ │ │ ├── Document_64x.png │ │ │ └── Document_64x.xaml │ ├── Folders │ │ └── Light │ │ │ ├── FolderOpen_128x.png │ │ │ ├── FolderOpen_256x.png │ │ │ ├── FolderOpen_256x.xaml │ │ │ ├── FolderOpen_32x.png │ │ │ ├── FolderOpen_32x.xaml │ │ │ ├── FolderOpen_32xLG.png │ │ │ ├── FolderOpen_32xLG.xaml │ │ │ ├── FolderOpen_32xMD.png │ │ │ ├── FolderOpen_32xMD.xaml │ │ │ ├── FolderOpen_32xSM.png │ │ │ ├── FolderOpen_32xSM.xaml │ │ │ ├── FolderOpen_48x.png │ │ │ ├── FolderOpen_48x.xaml │ │ │ ├── FolderOpen_64x.png │ │ │ ├── FolderOpen_64x.xaml │ │ │ ├── Folder_128x.png │ │ │ ├── Folder_256x.png │ │ │ ├── Folder_256x.xaml │ │ │ ├── Folder_25x.png │ │ │ ├── Folder_25x.xaml │ │ │ ├── Folder_32x.png │ │ │ ├── Folder_32x.xaml │ │ │ ├── Folder_32xLG.png │ │ │ ├── Folder_32xLG.xaml │ │ │ ├── Folder_32xMD.png │ │ │ ├── Folder_32xMD.xaml │ │ │ ├── Folder_32xSM.png │ │ │ ├── Folder_32xSM.xaml │ │ │ ├── Folder_48x.png │ │ │ ├── Folder_48x.xaml │ │ │ ├── Folder_64x.png │ │ │ └── Folder_64x.xaml │ ├── LightIcons.xaml │ ├── Projects │ │ └── Light │ │ │ ├── Application_128x.png │ │ │ ├── Application_12x.png │ │ │ ├── Application_12x.xaml │ │ │ ├── Application_16x.png │ │ │ ├── Application_16x.xaml │ │ │ ├── Application_256x.png │ │ │ ├── Application_256x.xaml │ │ │ ├── Application_32x.png │ │ │ ├── Application_32x.xaml │ │ │ ├── Application_64x.png │ │ │ └── Application_64x.xaml │ └── Solutions │ │ └── Light │ │ ├── AppFlyout_128x.png │ │ ├── AppFlyout_12x.png │ │ ├── AppFlyout_12x.xaml │ │ ├── AppFlyout_16x.png │ │ ├── AppFlyout_16x.xaml │ │ ├── AppFlyout_256x.png │ │ ├── AppFlyout_256x.xaml │ │ ├── AppFlyout_32x.png │ │ ├── AppFlyout_32x.xaml │ │ ├── AppFlyout_48x.png │ │ ├── AppFlyout_48x.xaml │ │ ├── AppFlyout_64x.png │ │ └── AppFlyout_64x.xaml ├── SolutionLib.csproj ├── Themes │ └── Generic.xaml ├── ViewModels │ ├── Base │ │ ├── BaseViewModel.cs │ │ └── RelayCommand.cs │ ├── Browser │ │ ├── Base │ │ │ ├── ItemChildrenViewModel.cs │ │ │ └── ItemViewModel.cs │ │ ├── FileViewModel.cs │ │ ├── FolderViewModel.cs │ │ ├── ProjectViewModel.cs │ │ ├── SolutionRootItemViewModel.cs │ │ └── SolutionViewModel.cs │ └── Collections │ │ ├── SortableObservableCollection.cs │ │ └── SortableObservableDictionaryCollection.cs └── Views │ └── TreeViewItemSelector.cs └── SolutionLibModels ├── Enums └── SolutionItemType.cs ├── Factory.cs ├── Interfaces ├── IFileItemModel.cs ├── IFolderItemModel .cs ├── IItemChildrenModel.cs ├── IItemModel.cs ├── IModelBase.cs ├── IProjectItemModel.cs ├── ISolutionModel.cs └── ISolutionRootItemModel.cs ├── Models ├── Base │ ├── ItemChildrenModel.cs │ └── ItemModel.cs ├── FileItemModel.cs ├── FolderItemModel.cs ├── ProjectItemModel.cs ├── SolutionModel.cs └── SolutionRootItemModel.cs ├── SQLite ├── JournalMode.cs ├── SQLiteDatabase.cs └── SolutionDB.cs ├── SolutionLibModels.csproj └── Xml └── Storage.cs /.gitignore: -------------------------------------------------------------------------------- 1 | source/packages/ 2 | packages/ 3 | 00_Release/ 4 | 01_Nuget/ 5 | 02_SamplesData/ 6 | debug/ 7 | release/ 8 | build/ 9 | bin/ 10 | obj/ 11 | cache/ 12 | log/ 13 | tmp/ 14 | /source/.vs/ 15 | .vs/ 16 | 17 | *~ 18 | *.lock 19 | *.DS_Store 20 | *.swp 21 | *.out 22 | *.sou 23 | *.suo 24 | *.sqlite 25 | -------------------------------------------------------------------------------- /00_Docu/00_Docu/EditOverlay/Step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/EditOverlay/Step1.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/EditOverlay/Step2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/EditOverlay/Step2.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/EditOverlay/Step3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/EditOverlay/Step3.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/EditOverlay/Step4_Result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/EditOverlay/Step4_Result.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/ErrorHandling/PopUpMessage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/ErrorHandling/PopUpMessage.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/SpaceLimits/Step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/SpaceLimits/Step1.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/SpaceLimits/Step2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/SpaceLimits/Step2.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/SpaceLimits/Step3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/SpaceLimits/Step3.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/SpaceLimits/Step4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/SpaceLimits/Step4.png -------------------------------------------------------------------------------- /00_Docu/00_Docu/SpaceLimits/Step5_Result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/00_Docu/SpaceLimits/Step5_Result.png -------------------------------------------------------------------------------- /00_Docu/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/00_Docu/screenshot.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Dirkster99 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SwitchToDesignMode_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/SwitchToDesignMode_64x.png -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.4.{build} 2 | 3 | configuration: Release 4 | 5 | platform: Any CPU 6 | 7 | image: Visual Studio 2019 Preview 8 | 9 | install: 10 | - cmd: choco install dotnetcore-sdk --pre 11 | 12 | before_build: 13 | - cmd: nuget restore source\InPlaceEditTextBoxDemo.sln 14 | 15 | build: 16 | verbosity: minimal 17 | 18 | artifacts: 19 | - path: source\InPlaceEditBoxDemo\bin\Release 20 | name: InPlaceEditBoxDemo 21 | 22 | - path: source\InplaceEditBoxLib\bin\Release 23 | name: InplaceEditBoxLib 24 | -------------------------------------------------------------------------------- /source/CleanAll.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | pushd "%~dp0" 3 | ECHO. 4 | ECHO. 5 | ECHO This script deletes all temporary build files in their 6 | ECHO corresponding BIN and OBJ Folder contained in the following projects 7 | ECHO. 8 | ECHO InPlaceEditBoxDemo 9 | ECHO InplaceEditBoxLib 10 | ECHO Solution\SolutionLib 11 | ECHO Solution\SolutionLibModels 12 | ECHO Services\ExplorerLib 13 | ECHO Services\ServiceLocator 14 | ECHO. 15 | REM Ask the user if hes really sure to continue beyond this point XXXXXXXX 16 | set /p choice=Are you sure to continue (Y/N)? 17 | if not '%choice%'=='Y' Goto EndOfBatch 18 | REM Script does not continue unless user types 'Y' in upper case letter 19 | ECHO. 20 | ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 21 | ECHO. 22 | ECHO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 23 | 24 | ECHO. 25 | ECHO Deleting .vs and BIN, OBJ Folders in project folder 26 | ECHO. 27 | RMDIR .vs /S /Q 28 | 29 | RMDIR /S /Q InPlaceEditBoxDemo\bin 30 | RMDIR /S /Q InPlaceEditBoxDemo\obj 31 | 32 | RMDIR /S /Q InplaceEditBoxLib\bin 33 | RMDIR /S /Q InplaceEditBoxLib\obj 34 | 35 | RMDIR /S /Q Solution\SolutionLib\bin 36 | RMDIR /S /Q Solution\SolutionLib\obj 37 | 38 | RMDIR /S /Q Solution\SolutionLibModels\bin 39 | RMDIR /S /Q Solution\SolutionLibModels\obj 40 | 41 | RMDIR /S /Q Services\ExplorerLib\bin 42 | RMDIR /S /Q Services\ExplorerLib\obj 43 | 44 | RMDIR /S /Q Services\ServiceLocator\bin 45 | RMDIR /S /Q Services\ServiceLocator\obj 46 | 47 | PAUSE 48 | 49 | :EndOfBatch 50 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo 2 | { 3 | using System.Windows; 4 | 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/Behaviours/TreeViewItemBehaviour.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo.Behaviours 2 | { 3 | using System.ComponentModel; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | 7 | /// 8 | /// Class implements an attached behaviour to bring a selected TreeViewItem 9 | /// into view when selection is driven by the viewmodel (not the user). 10 | /// 11 | /// Sample Usage: 12 | /// <TreeView.ItemContainerStyle> 13 | /// <Style TargetType="{x:Type TreeViewItem}"> 14 | /// <Setter Property="behav:TreeViewItemBehaviour.IsBroughtIntoViewWhenSelected" Value="True" /> 15 | /// <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /> 16 | /// <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> 17 | /// 18 | /// <!-- Setter Property="FontWeight" Value="Normal" /> 19 | /// <Style.Triggers> 20 | /// <Trigger Property="IsSelected" Value="True"> 21 | /// <Setter Property="FontWeight" Value="Bold" /> 22 | /// </Trigger> 23 | /// </Style.Triggers --> 24 | /// </Style> 25 | /// </TreeView.ItemContainerStyle> 26 | /// 27 | /// 28 | public static class TreeViewItemBehaviour 29 | { 30 | #region IsBroughtIntoViewWhenSelected 31 | #region IsBroughtIntoViewWhenSelectedDependencyProperty 32 | 33 | /// 34 | /// Backing storage of the IsBroughtIntoViewWhenSelected dependency property. 35 | /// 36 | public static readonly DependencyProperty IsBroughtIntoViewWhenSelectedProperty = 37 | DependencyProperty.RegisterAttached( 38 | "IsBroughtIntoViewWhenSelected", 39 | typeof(bool), 40 | typeof(TreeViewItemBehaviour), 41 | new UIPropertyMetadata(false, OnIsBroughtIntoViewWhenSelectedChanged)); 42 | 43 | /// 44 | /// Gets the value of the IsBroughtIntoViewWhenSelected dependency property. 45 | /// 46 | public static bool GetIsBroughtIntoViewWhenSelected(TreeViewItem treeViewItem) 47 | { 48 | return (bool)treeViewItem.GetValue(IsBroughtIntoViewWhenSelectedProperty); 49 | } 50 | 51 | /// 52 | /// Sets the value of the IsBroughtIntoViewWhenSelected dependency property. 53 | /// 54 | public static void SetIsBroughtIntoViewWhenSelected(TreeViewItem treeViewItem, bool value) 55 | { 56 | treeViewItem.SetValue(IsBroughtIntoViewWhenSelectedProperty, value); 57 | } 58 | #endregion IsBroughtIntoViewWhenSelectedDependencyProperty 59 | 60 | #region methods 61 | private static void OnIsBroughtIntoViewWhenSelectedChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) 62 | { 63 | // do not implement interaction logic for WPF Design-Time 64 | if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) 65 | return; 66 | 67 | TreeViewItem item = depObj as TreeViewItem; 68 | if (item == null) 69 | return; 70 | 71 | if (e.NewValue is bool == false) 72 | return; 73 | 74 | if ((bool)e.NewValue) 75 | { 76 | item.Selected += item_Selected; 77 | } 78 | else 79 | { 80 | item.Selected -= item_Selected; 81 | } 82 | } 83 | 84 | private static void item_Selected(object sender, RoutedEventArgs e) 85 | { 86 | TreeViewItem item = e.OriginalSource as TreeViewItem; 87 | 88 | if (item != null) 89 | { 90 | item.BringIntoView(); 91 | item.Focus(); 92 | } 93 | } 94 | #endregion methods 95 | #endregion // IsBroughtIntoViewWhenSelected 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/Behaviours/TreeViewSelectionChangedBehavior.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo.Behaviours 2 | { 3 | using System.ComponentModel; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Input; 7 | 8 | /// 9 | /// Source: 10 | /// http://stackoverflow.com/questions/1034374/drag-and-drop-in-mvvm-with-scatterview 11 | /// http://social.msdn.microsoft.com/Forums/de-DE/wpf/thread/21bed380-c485-44fb-8741-f9245524d0ae 12 | /// 13 | /// Attached behaviour to implement the SelectionChanged command/event via delegate command binding or routed commands. 14 | /// 15 | public static class TreeViewSelectionChangedBehavior 16 | { 17 | /// 18 | /// Field of attached ICommand property 19 | /// 20 | private static readonly DependencyProperty ChangedCommandProperty = DependencyProperty.RegisterAttached( 21 | "ChangedCommand", 22 | typeof(ICommand), 23 | typeof(TreeViewSelectionChangedBehavior), 24 | new PropertyMetadata(null, OnSelectionChangedCommandChange)); 25 | 26 | /// 27 | /// Setter method of the attached ChangedCommand property 28 | /// 29 | /// 30 | /// 31 | public static void SetChangedCommand(DependencyObject source, ICommand value) 32 | { 33 | source.SetValue(ChangedCommandProperty, value); 34 | } 35 | 36 | /// 37 | /// Getter method of the attached ChangedCommand property 38 | /// 39 | /// 40 | /// 41 | public static ICommand GetChangedCommand(DependencyObject source) 42 | { 43 | return (ICommand)source.GetValue(ChangedCommandProperty); 44 | } 45 | 46 | /// 47 | /// This method is hooked in the definition of the . 48 | /// It is called whenever the attached property changes - in our case the event of binding 49 | /// and unbinding the property to a sink is what we are looking for. 50 | /// 51 | /// 52 | /// 53 | private static void OnSelectionChangedCommandChange(DependencyObject d, DependencyPropertyChangedEventArgs e) 54 | { 55 | // do not implement interaction logic for WPF Design-Time 56 | if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) 57 | return; 58 | 59 | TreeView uiElement = d as TreeView; // Remove the handler if it exist to avoid memory leaks 60 | 61 | if (uiElement != null) 62 | { 63 | uiElement.SelectedItemChanged -= Selection_Changed; 64 | 65 | var command = e.NewValue as ICommand; 66 | if (command != null) 67 | { 68 | // the property is attached so we attach the Drop event handler 69 | uiElement.SelectedItemChanged += Selection_Changed; 70 | } 71 | } 72 | } 73 | 74 | /// 75 | /// This method is called when the selection changed event occurs. The sender should be the control 76 | /// on which this behaviour is attached - so we convert the sender into a 77 | /// and receive the Command through the getter listed above. 78 | /// 79 | /// The parameter contains the standard EventArgs data, 80 | /// which is unpacked and reales upon the bound command. 81 | /// 82 | /// This implementation supports binding of delegate commands and routed commands. 83 | /// 84 | /// 85 | /// 86 | private static void Selection_Changed(object sender, RoutedPropertyChangedEventArgs e) 87 | { 88 | var uiElement = sender as TreeView; 89 | 90 | // Sanity check just in case this was somehow send by something else 91 | if (uiElement == null) 92 | return; 93 | 94 | ICommand changedCommand = TreeViewSelectionChangedBehavior.GetChangedCommand(uiElement); 95 | 96 | // There may not be a command bound to this after all 97 | if (changedCommand == null) 98 | return; 99 | 100 | 101 | 102 | ////if ((e.NewValue == null && e.NewValue == null)) 103 | //// return; 104 | ////else 105 | ////{ 106 | //// // Actual value did not really change 107 | //// if ((e.NewValue != null && e.NewValue != null)) 108 | //// { 109 | //// if ((e.NewValue == e.NewValue)) 110 | //// return; 111 | //// } 112 | ////} 113 | 114 | // Check whether this attached behaviour is bound to a RoutedCommand 115 | if (changedCommand is RoutedCommand) 116 | { 117 | // Execute the routed command 118 | (changedCommand as RoutedCommand).Execute(e.NewValue, uiElement); 119 | } 120 | else 121 | { 122 | // Execute the Command as bound delegate 123 | changedCommand.Execute(e.NewValue); 124 | } 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/Converters/BoolToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo.Converters 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | 8 | /// 9 | /// Converts from boolean true or false to as defined in 10 | /// and properties of this object. 11 | /// 12 | [ValueConversion(typeof(bool), typeof(Visibility))] 13 | public class BoolToVisibilityConverter : IValueConverter 14 | { 15 | public BoolToVisibilityConverter() 16 | { 17 | this.True = Visibility.Visible; 18 | this.False = Visibility.Collapsed; 19 | } 20 | 21 | /// 22 | /// Converts from boolean true or false to as defined in 23 | /// and properties of this object. 24 | /// 25 | /// 26 | /// 27 | /// 28 | /// 29 | /// 30 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 31 | { 32 | if (value == null) 33 | return Binding.DoNothing; 34 | 35 | if (value is bool == false) 36 | return Binding.DoNothing; 37 | 38 | bool input = (bool)value; 39 | 40 | if (input == true) 41 | return True; 42 | 43 | return False; 44 | } 45 | 46 | /// 47 | /// Gets/sets the value that is associated with boolean true. 48 | /// 49 | public Visibility True { get; set; } 50 | 51 | /// 52 | /// Gets/sets the value that is associated with boolean false. 53 | /// 54 | public Visibility False { get; set; } 55 | 56 | /// 57 | /// Throws a . 58 | /// 59 | /// 60 | /// 61 | /// 62 | /// 63 | /// 64 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 65 | { 66 | throw new NotImplementedException(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/Demo/CreateTestObject.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo.Demo 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | /// 7 | /// implements a simple pojo type class to support the generation of test data. 8 | /// 9 | internal class CreateTestObject 10 | { 11 | public CreateTestObject( 12 | string project 13 | , string[] folders 14 | , string[] files) 15 | : this() 16 | { 17 | this.Project = project; 18 | 19 | if (folders != null) 20 | this.Folders = folders.ToList(); 21 | 22 | if (files != null) 23 | this.Files = files.ToList(); 24 | } 25 | 26 | protected CreateTestObject() 27 | { 28 | Project = string.Empty; 29 | Folders = null; 30 | Files = null; 31 | } 32 | 33 | public string Project { get; protected set; } 34 | 35 | public List Folders { get; protected set; } 36 | 37 | public List Files { get; protected set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/InPlaceEditBoxDemo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net461;netcoreapp3.0 6 | true 7 | 8 | 9 | 10 | 11 | 12 | ExplorerLib 13 | 14 | 15 | 16 | ServiceLocator 17 | 18 | 19 | 20 | SolutionModelsLib 21 | 22 | 23 | 24 | SolutionLib 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 54 | 55 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/InPlaceEditBoxDemo.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ProjectDebugger 5 | 6 | 7 | InPlaceEditBoxDemo 8 | net461 9 | 10 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo 2 | { 3 | using InPlaceEditBoxDemo.ViewModels; 4 | using ServiceLocator; 5 | using System.Windows; 6 | 7 | /// 8 | /// Interaction logic for MainWindow.xaml 9 | /// 10 | public partial class MainWindow : Window 11 | { 12 | public MainWindow() 13 | { 14 | InitializeComponent(); 15 | 16 | ServiceInjector.InjectServices(); // Start-up services 17 | 18 | Loaded += MainWindow_LoadedAsync; 19 | } 20 | 21 | private async void MainWindow_LoadedAsync(object sender, RoutedEventArgs e) 22 | { 23 | Loaded -= MainWindow_LoadedAsync; 24 | 25 | var appVM = new AppViewModel(); 26 | this.DataContext = appVM; 27 | 28 | appVM.ResetDefaults(); 29 | await appVM.LoadSampleDataAsync(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/ViewModels/Base/BaseViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo.ViewModels.Base 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Linq.Expressions; 6 | 7 | /// 8 | /// Every ViewModel class is required to implement the INotifyPropertyChanged 9 | /// interface in order to tell WPF when a property changed (for instance, when 10 | /// a method or setter is executed). 11 | /// 12 | /// Therefore, the PropertyChanged methode has to be called when data changes, 13 | /// because the relevant properties may or may not be bound to GUI elements, 14 | /// which in turn have to refresh their display. 15 | /// 16 | /// The PropertyChanged method is to be called by the members and properties of 17 | /// the class that derives from this class. Each call contains the name of the 18 | /// property that has to be refreshed. 19 | /// 20 | /// The BaseViewModel is derived from from System.Windows.DependencyObject to allow 21 | /// resulting ViewModels the implemantion of dependency properties. Dependency properties 22 | /// in turn are useful when working with IValueConverter and ConverterParameters. 23 | /// 24 | internal class BaseViewModel : INotifyPropertyChanged 25 | { 26 | /// 27 | /// Standard event handler of the interface 28 | /// 29 | public event PropertyChangedEventHandler PropertyChanged; 30 | 31 | /// 32 | /// Tell bound controls (via WPF binding) to refresh their display. 33 | /// 34 | /// Sample call: this.NotifyPropertyChanged(() => this.IsSelected); 35 | /// where 'this' is derived from 36 | /// and IsSelected is a property. 37 | /// 38 | /// 39 | /// 40 | public void NotifyPropertyChanged(Expression> property) 41 | { 42 | var lambda = (LambdaExpression)property; 43 | MemberExpression memberExpression; 44 | 45 | if (lambda.Body is UnaryExpression) 46 | { 47 | var unaryExpression = (UnaryExpression)lambda.Body; 48 | memberExpression = (MemberExpression)unaryExpression.Operand; 49 | } 50 | else 51 | memberExpression = (MemberExpression)lambda.Body; 52 | 53 | this.OnPropertyChanged(memberExpression.Member.Name); 54 | } 55 | 56 | /// 57 | /// Tell bound controls (via WPF binding) to refresh their display. 58 | /// 59 | /// Sample call: this.OnPropertyChanged("IsSelected"); 60 | /// where 'this' is derived from 61 | /// and IsSelected is a property. 62 | /// 63 | /// Name of property to refresh 64 | public void OnPropertyChanged(string propertyName) 65 | { 66 | try 67 | { 68 | if (this.PropertyChanged != null) 69 | this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 70 | } 71 | catch 72 | { 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/ViewModels/Base/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo.ViewModels.Base 2 | { 3 | using System; 4 | using System.Diagnostics; 5 | using System.Windows.Input; 6 | 7 | /// 8 | /// A command whose sole purpose is to 9 | /// relay its functionality to other 10 | /// objects by invoking delegates. The 11 | /// default return value for the CanExecute 12 | /// method is 'true'. 13 | /// 14 | /// Source: http://www.codeproject.com/Articles/31837/Creating-an-Internationalized-Wizard-in-WPF 15 | /// 16 | internal class RelayCommand : ICommand 17 | { 18 | #region Fields 19 | private readonly Action mExecute = null; 20 | private readonly Predicate mCanExecute = null; 21 | #endregion // Fields 22 | 23 | #region Constructors 24 | /// 25 | /// Class constructor 26 | /// 27 | /// 28 | public RelayCommand(Action execute) 29 | : this(execute, null) 30 | { 31 | } 32 | 33 | /// 34 | /// Creates a new command. 35 | /// 36 | /// The execution logic. 37 | /// The execution status logic. 38 | public RelayCommand(Action execute, Predicate canExecute) 39 | { 40 | if (execute == null) 41 | throw new ArgumentNullException("execute"); 42 | 43 | this.mExecute = execute; 44 | this.mCanExecute = canExecute; 45 | } 46 | 47 | #endregion // Constructors 48 | 49 | #region events 50 | /// 51 | /// Eventhandler to re-evaluate whether this command can execute or not 52 | /// 53 | public event EventHandler CanExecuteChanged 54 | { 55 | add 56 | { 57 | if (this.mCanExecute != null) 58 | CommandManager.RequerySuggested += value; 59 | } 60 | 61 | remove 62 | { 63 | if (this.mCanExecute != null) 64 | CommandManager.RequerySuggested -= value; 65 | } 66 | } 67 | #endregion 68 | 69 | #region methods 70 | /// 71 | /// Determine whether this pre-requisites to execute this command are given or not. 72 | /// 73 | /// 74 | /// 75 | [DebuggerStepThrough] 76 | public bool CanExecute(object parameter) 77 | { 78 | return this.mCanExecute == null ? true : this.mCanExecute((T)parameter); 79 | } 80 | 81 | /// 82 | /// Execute the command method managed in this class. 83 | /// 84 | /// 85 | public void Execute(object parameter) 86 | { 87 | this.mExecute((T)parameter); 88 | } 89 | #endregion methods 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/converters/ISolutionItemItemTypeToTupleConverter.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo.Converters 2 | { 3 | using SolutionLib.Interfaces; 4 | using SolutionLib.Models; 5 | using System; 6 | using System.Globalization; 7 | using System.Windows.Data; 8 | 9 | /// 10 | /// XAML converter to convert and 11 | /// enum members 12 | /// into a representaton for command binding. 13 | /// 14 | [ValueConversion(typeof(IItemChildren), typeof(Tuple))] 15 | [ValueConversion(typeof(SolutionItemType), typeof(Tuple))] 16 | public class ISolutionItemItemTypeToTupleConverter : IMultiValueConverter 17 | { 18 | /// 19 | /// Converts a value. 20 | /// 21 | /// 22 | /// 23 | /// 24 | /// 25 | /// 26 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | if (values == null) 29 | return Binding.DoNothing; 30 | 31 | if (values.Length != 2) 32 | return Binding.DoNothing; 33 | 34 | var item = values[0] as IItemChildren; 35 | 36 | if (item == null) 37 | return Binding.DoNothing; 38 | 39 | if (values[1] is SolutionItemType == false) 40 | return Binding.DoNothing; 41 | 42 | var itemType = (SolutionItemType)values[1]; 43 | 44 | return new Tuple(item, itemType); 45 | } 46 | 47 | /// 48 | /// Converts a value. 49 | /// 50 | /// 51 | /// 52 | /// 53 | /// 54 | /// 55 | object[] IMultiValueConverter.ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 56 | { 57 | throw new NotImplementedException(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /source/InPlaceEditBoxDemo/converters/ItemTypeDisplayNameToTextConverter.cs: -------------------------------------------------------------------------------- 1 | namespace InPlaceEditBoxDemo.Converters 2 | { 3 | using SolutionLib.Models; 4 | using System; 5 | using System.Globalization; 6 | using System.Windows.Data; 7 | 8 | /// 9 | /// XAML converter to convert enum members 10 | /// into from ResourceDictionary or fallback from 11 | /// static resource. 12 | /// 13 | [ValueConversion(typeof(string), typeof(string))] 14 | public class ItemTypeDisplayNameToTextConverter : IMultiValueConverter 15 | { 16 | /// 17 | /// Converts a value. 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | /// 24 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 25 | { 26 | if (values == null) 27 | return Binding.DoNothing; 28 | 29 | if (values.Length != 2) 30 | return Binding.DoNothing; 31 | 32 | var item = values[0] as string; 33 | 34 | if (item == null) 35 | return Binding.DoNothing; 36 | 37 | if (values[1] is SolutionItemType == false) 38 | return Binding.DoNothing; 39 | 40 | var itemType = (SolutionItemType)values[1]; 41 | 42 | string itemTypeText = string.Empty; 43 | 44 | switch (itemType) 45 | { 46 | case SolutionItemType.SolutionRootItem: 47 | itemTypeText = "Solution"; 48 | break; 49 | case SolutionItemType.File: 50 | itemTypeText = "File"; 51 | break; 52 | case SolutionItemType.Folder: 53 | itemTypeText = "Folder"; 54 | break; 55 | 56 | case SolutionItemType.Project: 57 | itemTypeText = "Project"; 58 | break; 59 | 60 | default: 61 | throw new ArgumentOutOfRangeException(itemType.ToString()); 62 | } 63 | 64 | return string.Format("{0} ({1})", item, itemTypeText); 65 | } 66 | 67 | /// 68 | /// Converts a value. 69 | /// 70 | /// 71 | /// 72 | /// 73 | /// 74 | /// 75 | object[] IMultiValueConverter.ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 76 | { 77 | throw new NotImplementedException(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Events/EditEvent.cs: -------------------------------------------------------------------------------- 1 | namespace InplaceEditBoxLib.Events 2 | { 3 | using System; 4 | 5 | /// 6 | /// Determine the type of edit event that can be reuqested from the view. 7 | /// 8 | public enum RequestEditEvent 9 | { 10 | /// 11 | /// Start the editing mode for renaming the item represented by the viewmodel 12 | /// that send this message to its view. 13 | /// 14 | StartEditMode, 15 | 16 | /// 17 | /// Unknown type of event should never occur if this enum is used correctly. 18 | /// 19 | Unknown 20 | } 21 | 22 | /// 23 | /// Event handler delegation method to be used when handling events. 24 | /// 25 | /// 26 | /// 27 | public delegate void RequestEditEventHandler(object sender, RequestEdit e); 28 | 29 | /// 30 | /// Implements an event that can be send from viewmodel to view 31 | /// to request certain edit modes. 32 | /// 33 | public class RequestEdit : EventArgs 34 | { 35 | #region constructors 36 | /// 37 | /// Parameterized class constructor 38 | /// 39 | /// 40 | public RequestEdit(RequestEditEvent eventRequest) : this() 41 | { 42 | this.Request = eventRequest; 43 | } 44 | 45 | /// 46 | /// Class Constructor 47 | /// 48 | protected RequestEdit() 49 | { 50 | this.Request = RequestEditEvent.Unknown; 51 | } 52 | #endregion constructors 53 | 54 | /// 55 | /// Gets the type of editing event that was requested by the viewmodel. 56 | /// 57 | public RequestEditEvent Request { get; private set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/InplaceEditBoxLib.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 1.4.2 6 | 1.4.2.0 7 | 1.4.2.0 8 | Open Source 9 | InplaceEditBoxLib 10 | 2014-2022 11 | InplaceEditBoxLib provides a WPF overlay textbox control 12 | https://github.com/Dirkster99/InplaceEditBoxLib 13 | https://github.com/Dirkster99/InplaceEditBoxLib 14 | Dirkster.InplaceEditBoxLib 15 | https://github.com/Dirkster99/InplaceEditBoxLib 16 | 17 | net452;netcoreapp3.0 18 | true 19 | 20 | https://github.com/Dirkster99/InplaceEditBoxLib 21 | https://github.com/Dirkster99/InplaceEditBoxLib 22 | https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/master/SwitchToDesignMode_64x.png 23 | wpf inplace-edit text overlay mvvm c# .net metro black light themed control library 24 | Add rename canceled command to notify when the user has canceled editing text 25 | en 26 | MIT 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/InplaceEditBoxLib.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Designer 7 | 8 | 9 | Designer 10 | 11 | 12 | Designer 13 | 14 | 15 | Designer 16 | 17 | 18 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Interfaces/IEditBox.cs: -------------------------------------------------------------------------------- 1 | namespace InplaceEditBoxLib.Interfaces 2 | { 3 | using InplaceEditBoxLib.Events; 4 | using UserNotification.Interfaces; 5 | 6 | /// 7 | /// Implement an interface that enables a viewmodel to interact 8 | /// with the control. 9 | /// 10 | public interface IEditBox : INotifyableViewModel 11 | { 12 | /// 13 | /// The viewmodel can fire this event to request editing of its item 14 | /// name in order to start the rename process via the control. 15 | /// 16 | /// The control will fire the command that is bound to the Command dependency 17 | /// property (if any) with the new name as parameter (if editing was not cancelled 18 | /// (through escape) in the meantime. 19 | /// 20 | event RequestEditEventHandler RequestEdit; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Local/Strings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace InplaceEditBoxLib.Local { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | public class Strings { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Strings() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | public static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("InplaceEditBoxLib.Local.Strings", typeof(Strings).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | public static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to \/:*?"<>|. 65 | /// 66 | public static string ForbiddenRenameKeys { 67 | get { 68 | return ResourceManager.GetString("ForbiddenRenameKeys", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to A name cannot contain any of the following characters: 74 | ///\/:*?"<>|. 75 | /// 76 | public static string ForbiddenRenameKeysMessage { 77 | get { 78 | return ResourceManager.GetString("ForbiddenRenameKeysMessage", resourceCulture); 79 | } 80 | } 81 | 82 | /// 83 | /// Looks up a localized string similar to Invalid Character Input. 84 | /// 85 | public static string ForbiddenRenameKeysTitle { 86 | get { 87 | return ResourceManager.GetString("ForbiddenRenameKeysTitle", resourceCulture); 88 | } 89 | } 90 | 91 | /// 92 | /// Looks up a localized string similar to Input Error. 93 | /// 94 | public static string STR_MSG_InvalidChar_TITLE { 95 | get { 96 | return ResourceManager.GetString("STR_MSG_InvalidChar_TITLE", resourceCulture); 97 | } 98 | } 99 | 100 | /// 101 | /// Looks up a localized string similar to An error occured.. 102 | /// 103 | public static string STR_MSG_UnknownError { 104 | get { 105 | return ResourceManager.GetString("STR_MSG_UnknownError", resourceCulture); 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Themes/DarkBrushs.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | #FFF4F4F5 13 | 14 | 17 | 18 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Themes/LightBrushs.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | #FF000000 13 | 14 | 17 | 18 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Themes/ResourceKeys.cs: -------------------------------------------------------------------------------- 1 | namespace InplaceEditBoxLib.Themes 2 | { 3 | using System.Windows; 4 | 5 | /// 6 | /// Class member act as a reference for resource dictionary based definitions. 7 | /// 8 | public static class ResourceKeys 9 | { 10 | #region Normal Control Foreground and Background Keys 11 | /// 12 | /// Color Key for Normal Foreground 13 | /// 14 | public static readonly ComponentResourceKey NormalForegroundKey = new ComponentResourceKey(typeof(ResourceKeys), "NormalForegroundKey"); 15 | 16 | /// 17 | /// Brush Key for Normal Foreground 18 | /// 19 | public static readonly ComponentResourceKey NormalForegroundBrushKey = new ComponentResourceKey(typeof(ResourceKeys), "NormalForegroundBrushKey"); 20 | #endregion Normal Control Foreground and Background Keys 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/ViewModels/Base/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | namespace InplaceEditBoxLib.ViewModels.Base 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Linq.Expressions; 6 | 7 | /// 8 | /// Base of Viewmodel classes implemented in this assembly. 9 | /// 10 | public class ViewModelBase : INotifyPropertyChanged 11 | { 12 | #region constructor 13 | /// 14 | /// Standard class constructor 15 | /// 16 | public ViewModelBase() 17 | { 18 | } 19 | #endregion constructor 20 | 21 | /// 22 | /// Standard event of the interface. 23 | /// 24 | public event PropertyChangedEventHandler PropertyChanged; 25 | 26 | #region methods 27 | /// 28 | /// Tell bound controls (via WPF binding) to refresh their display 29 | /// for the viewmodel property indicated as string. 30 | /// 31 | /// 32 | protected virtual void RaisePropertyChanged(string propName) 33 | { 34 | if (this.PropertyChanged != null) 35 | this.PropertyChanged(this, new PropertyChangedEventArgs(propName)); 36 | } 37 | 38 | /// 39 | /// Tell bound controls (via WPF binding) to refresh their display. 40 | /// 41 | /// Sample call: this.OnPropertyChanged(() => this.IsSelected); 42 | /// where 'this' is derived from 43 | /// and IsSelected is a property. 44 | /// 45 | /// 46 | /// 47 | protected void RaisePropertyChanged(Expression> propertyExpression) 48 | { 49 | if (propertyExpression.Body.NodeType == ExpressionType.MemberAccess) 50 | { 51 | var memberExpr = propertyExpression.Body as MemberExpression; 52 | string propertyName = memberExpr.Member.Name; 53 | this.RaisePropertyChanged(propertyName); 54 | } 55 | } 56 | #endregion methods 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/ViewModels/EditInPlaceViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace InplaceEditBoxLib.ViewModels 2 | { 3 | using System.Windows.Media.Imaging; 4 | using InplaceEditBoxLib.Events; 5 | using InplaceEditBoxLib.Interfaces; 6 | using UserNotification.Events; 7 | 8 | /// 9 | /// Implements a viewmodel class that can be used as base of a viewmodel 10 | /// that drives the view. 11 | /// 12 | public class EditInPlaceViewModel : Base.ViewModelBase, IEditBox 13 | { 14 | #region fields 15 | private bool _IsReadOnly; 16 | #endregion fields 17 | 18 | #region events 19 | /// 20 | /// Expose an event that is triggered when the viewmodel tells its view: 21 | /// Here is another notification message please show it to the user. 22 | /// 23 | public event UserNotification.Events.ShowNotificationEventHandler ShowNotificationMessage; 24 | 25 | /// 26 | /// Expose an event that is triggered when the viewmodel requests its view to 27 | /// start the editing mode for rename this item. 28 | /// 29 | public event InplaceEditBoxLib.Events.RequestEditEventHandler RequestEdit; 30 | #endregion events 31 | 32 | #region constructors 33 | /// 34 | /// Class constructor 35 | /// 36 | public EditInPlaceViewModel() 37 | { 38 | this.IsReadOnly = false; 39 | } 40 | #endregion constructors 41 | 42 | #region properties 43 | /// 44 | /// Gets/sets whether this folder is readonly (can be renamed) or not. 45 | /// A drive can, for example, not be renamed and is therefore, readonly 46 | /// on this context. 47 | /// 48 | public bool IsReadOnly 49 | { 50 | get 51 | { 52 | return this._IsReadOnly; 53 | } 54 | 55 | protected set 56 | { 57 | if (this._IsReadOnly != value) 58 | { 59 | this._IsReadOnly = value; 60 | 61 | this.RaisePropertyChanged(() => this.IsReadOnly); 62 | } 63 | } 64 | } 65 | #endregion properties 66 | 67 | #region methods 68 | /// 69 | /// Call this method to request of start editing mode for renaming this item. 70 | /// 71 | /// 72 | /// Returns true if event was successfully send (listener is attached), otherwise false 73 | public bool RequestEditMode(RequestEditEvent request) 74 | { 75 | if (this.RequestEdit != null) 76 | { 77 | this.RequestEdit(this, new RequestEdit(request)); 78 | return true; 79 | } 80 | 81 | return false; 82 | } 83 | 84 | /// 85 | /// Shows a pop-notification message with the given title and text. 86 | /// 87 | /// 88 | /// 89 | /// 90 | /// true if the event was succesfully fired. 91 | public bool ShowNotification(string title, string message, 92 | BitmapImage imageIcon = null) 93 | { 94 | if (this.ShowNotificationMessage != null) 95 | { 96 | this.ShowNotificationMessage(this, new ShowNotificationEvent 97 | ( 98 | title, 99 | message, 100 | imageIcon 101 | )); 102 | 103 | return true; 104 | } 105 | 106 | return false; 107 | } 108 | #endregion methods 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Views/Attach.cs: -------------------------------------------------------------------------------- 1 | namespace InplaceEditBoxLib.Views 2 | { 3 | using System.Windows; 4 | using System.Windows.Input; 5 | 6 | /// 7 | /// Implements a behaviour that can be used to attach input bindings a style (e.g. TreeViewItem) 8 | /// https://stackoverflow.com/questions/2660760/defining-inputbindings-within-a-style#7808997 9 | /// 10 | public class Attach 11 | { 12 | private static readonly DependencyProperty InputBindingsProperty = 13 | DependencyProperty.RegisterAttached("InputBindings", 14 | typeof(InputBindingCollection), 15 | typeof(Attach), 16 | new FrameworkPropertyMetadata(new InputBindingCollection(), 17 | (sender, e) => 18 | { 19 | var element = sender as UIElement; 20 | if (element == null) return; 21 | 22 | element.InputBindings.Clear(); 23 | element.InputBindings.AddRange((InputBindingCollection)e.NewValue); 24 | })); 25 | 26 | /// 27 | /// Gets the "InputBindings" dependency property. 28 | /// 29 | /// 30 | /// 31 | public static InputBindingCollection GetInputBindings(UIElement element) 32 | { 33 | return (InputBindingCollection)element.GetValue(InputBindingsProperty); 34 | } 35 | 36 | /// 37 | /// Sets the "InputBindings" dependency property. 38 | /// 39 | public static void SetInputBindings(UIElement element, InputBindingCollection inputBindings) 40 | { 41 | element.SetValue(InputBindingsProperty, inputBindings); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Views/BindingProxy.cs: -------------------------------------------------------------------------------- 1 | namespace InplaceEditBoxLib.Views 2 | { 3 | using System.Windows; 4 | 5 | /// 6 | /// Implements an XAML proxy which can be used to bind items (TreeViewItem, ListViewItem etc) 7 | /// with a viewmodel that manages the collecrions. 8 | /// 9 | /// Source: http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/ 10 | /// Issue: http://stackoverflow.com/questions/9994241/mvvm-binding-command-to-contextmenu-item 11 | /// 12 | public class BindingProxy : Freezable 13 | { 14 | /// 15 | /// Backing storage of the Data dependency property. 16 | /// 17 | /// Gets/sets the data object this class is forwarding to everyone 18 | /// who has a reference to this object. 19 | /// 20 | public static readonly DependencyProperty DataProperty = 21 | DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null)); 22 | 23 | /// 24 | /// Gets/sets the data object this class is forwarding to everyone 25 | /// who has a reference to this object. 26 | /// 27 | public object Data 28 | { 29 | get { return (object)GetValue(DataProperty); } 30 | set { SetValue(DataProperty, value); } 31 | } 32 | 33 | /// 34 | /// Overrides of Freezable 35 | /// 36 | /// 37 | protected override Freezable CreateInstanceCore() 38 | { 39 | return new BindingProxy(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /source/InplaceEditBoxLib/Views/EditBox.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /source/Services/ExplorerLib/ExplorerLib.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net40;netcoreapp3.0 5 | true 6 | 7 | 8 | -------------------------------------------------------------------------------- /source/Services/ExplorerLib/ExplorerMultiFileResult.cs: -------------------------------------------------------------------------------- 1 | namespace ExplorerLib 2 | { 3 | using System.Collections.Generic; 4 | 5 | internal class ExplorerMultiFileResult : IExplorerMultiFileResult 6 | { 7 | private List _FilePath = null; 8 | 9 | /// 10 | /// Class constructor 11 | /// 12 | /// 13 | /// 14 | public ExplorerMultiFileResult(IEnumerable filepaths 15 | , int selectedFilterIndex) 16 | : this() 17 | { 18 | if (filepaths != null) 19 | { 20 | foreach (var item in filepaths) 21 | _FilePath.Add(item); 22 | } 23 | 24 | SelectedFilterIndex = selectedFilterIndex; 25 | } 26 | 27 | /// 28 | /// Hidden parameterless ctor 29 | /// 30 | protected ExplorerMultiFileResult() 31 | { 32 | _FilePath = new List(); 33 | } 34 | 35 | /// 36 | /// Gets the full file path of the selected file. 37 | /// 38 | public IEnumerable Filepaths 39 | { 40 | get 41 | { 42 | return _FilePath; 43 | } 44 | } 45 | 46 | /// 47 | /// Gets the filterindex information of the selected file filter. 48 | /// 49 | public int SelectedFilterIndex { get; private set; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /source/Services/ExplorerLib/ExplorerResult.cs: -------------------------------------------------------------------------------- 1 | namespace ExplorerLib 2 | { 3 | internal class ExplorerResult : IExplorerResult 4 | { 5 | public ExplorerResult(string filepath 6 | , int selectedFilterIndex) 7 | : this() 8 | { 9 | Filepath = filepath; 10 | SelectedFilterIndex = selectedFilterIndex; 11 | } 12 | 13 | protected ExplorerResult() 14 | { 15 | } 16 | 17 | public string Filepath { get; private set; } 18 | 19 | public string FileExtension 20 | { 21 | get 22 | { 23 | try 24 | { 25 | return System.IO.Path.GetExtension(Filepath); 26 | } 27 | catch{} 28 | 29 | return string.Empty; 30 | } 31 | } 32 | 33 | public string FileDirectory 34 | { 35 | get 36 | { 37 | try 38 | { 39 | return System.IO.Path.GetDirectoryName(Filepath); 40 | } 41 | catch { } 42 | 43 | return string.Empty; 44 | } 45 | } 46 | 47 | public int SelectedFilterIndex { get; private set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /source/Services/ExplorerLib/IExplorer.cs: -------------------------------------------------------------------------------- 1 | namespace ExplorerLib 2 | { 3 | using System.Collections.Generic; 4 | 5 | /// 6 | /// Implements an interface to an object that 7 | /// implements a set of standard functions for accessing the 8 | /// file system via file open and file save dialogs. 9 | /// 10 | public interface IExplorer 11 | { 12 | /// 13 | /// Let the user select a file to open 14 | /// -> return its path if file open was OK'ed 15 | /// or return null on cancel. 16 | /// 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | IExplorerResult FileOpen(string fileFilter, 24 | string lastFilePath, 25 | string myDocumentsUserDir = null, 26 | string defaultExtension = null, 27 | int selectedExtensionIndex = 1); 28 | 29 | /// 30 | /// Method can be used to open mutlipe files via standard Windows Explorer 31 | /// File open dialog. 32 | /// 33 | /// 34 | /// 35 | /// 36 | /// 37 | /// 38 | /// 39 | IExplorerMultiFileResult FileOpenMultipleFiles(string fileFilter, 40 | string lastFilePath, 41 | string myDocumentsUserDir = null, 42 | string defaultExtension = null, 43 | int selectedExtensionIndex = 1); 44 | 45 | /// 46 | /// Save a file with a given path (that may be ommited -> results in SaveAs) 47 | /// using a given save function that takes a string parameter and returns bool on success. 48 | /// The can be set to true to indicate if whether SaveAs function is intended. 49 | /// The can be used to filter files when using a SaveAs dialog. 50 | /// 51 | /// 52 | /// 53 | /// 54 | /// 55 | /// 56 | /// 57 | /// 58 | string GetDirectoryFromFilePath(string lastFilePath); 59 | 60 | /// 61 | /// Save a file with a given path (that may be ommited -> results in SaveAs) 62 | /// 63 | /// The can be set to true to indicate whether SaveAs function is intended. 64 | /// The can be used to filter files when using a SaveAs dialog. 65 | /// 66 | /// The Save Dialog wrapper function returns a valid string if dialog was exit with OK and 67 | /// otherwise null (if user Cancelled function). 68 | /// 69 | /// 70 | /// 71 | /// 72 | /// 73 | /// 74 | IExplorerResult SaveDocumentFile(string path, 75 | string myDocumentsUserDir = null, 76 | bool saveAsFlag = false, 77 | string FileExtensionFilter = "", 78 | string defaultExtension = null, 79 | int selectedExtensionIndex = 1); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /source/Services/ExplorerLib/IExplorerMultiFileResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace ExplorerLib 4 | { 5 | /// 6 | /// Implements a simple result structure that is returned when the 7 | /// user selected multiple files in a dialog. 8 | /// 9 | public interface IExplorerMultiFileResult 10 | { 11 | /// 12 | /// Gets the full file path of the selected file. 13 | /// 14 | IEnumerable Filepaths { get; } 15 | 16 | /// 17 | /// Gets the filterindex information of the selected file filter. 18 | /// 19 | int SelectedFilterIndex { get; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /source/Services/ExplorerLib/IExplorerResult.cs: -------------------------------------------------------------------------------- 1 | namespace ExplorerLib 2 | { 3 | /// 4 | /// Implements a simple result structure that is returned when the 5 | /// user selected a file in a dialog. 6 | /// 7 | public interface IExplorerResult 8 | { 9 | /// 10 | /// Gets the full file path of the selected file. 11 | /// 12 | string Filepath { get; } 13 | 14 | /// 15 | /// Gets the extension of the selected file. 16 | /// 17 | string FileExtension { get; } 18 | 19 | /// 20 | /// Gets the directory path information of the selected file. 21 | /// 22 | string FileDirectory { get; } 23 | 24 | /// 25 | /// Gets the filterindex information of the selected file filter. 26 | /// 27 | int SelectedFilterIndex { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /source/Services/ServiceLocator/ServiceContainer.cs: -------------------------------------------------------------------------------- 1 | namespace ServiceLocator 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | /// 7 | /// Source: http://www.codeproject.com/Articles/70223/Using-a-Service-Locator-to-Work-with-MessageBoxes 8 | /// 9 | public class ServiceContainer 10 | { 11 | #region fields 12 | public static readonly ServiceContainer Instance = new ServiceContainer(); 13 | 14 | readonly Dictionary _serviceMap; 15 | readonly object _serviceMapLock; 16 | #endregion fields 17 | 18 | #region constructors 19 | /// 20 | /// Class Constructor 21 | /// 22 | private ServiceContainer() 23 | { 24 | _serviceMap = new Dictionary(); 25 | _serviceMapLock = new object(); 26 | } 27 | #endregion constructors 28 | 29 | #region methods 30 | public void AddService(TServiceContract implementation) 31 | where TServiceContract : class 32 | { 33 | lock (_serviceMapLock) 34 | { 35 | _serviceMap[typeof(TServiceContract)] = implementation; 36 | } 37 | } 38 | 39 | public TServiceContract GetService() 40 | where TServiceContract : class 41 | { 42 | object service; 43 | lock (_serviceMapLock) 44 | { 45 | _serviceMap.TryGetValue(typeof(TServiceContract), out service); 46 | } 47 | 48 | return service as TServiceContract; 49 | } 50 | #endregion methods 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /source/Services/ServiceLocator/ServiceInjector.cs: -------------------------------------------------------------------------------- 1 | namespace ServiceLocator 2 | { 3 | using ExplorerLib; 4 | using ServiceLocator; 5 | 6 | /// 7 | /// Creates and initializes all services. 8 | /// 9 | public static class ServiceInjector 10 | { 11 | /// 12 | /// Loads service objects into the ServiceContainer on startup. 13 | /// 14 | /// Returns the current instance 15 | /// to let caller work with service container items right after creation. 16 | public static ServiceContainer InjectServices() 17 | { 18 | ServiceContainer.Instance.AddService(new Explorer()); 19 | 20 | return ServiceContainer.Instance; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /source/Services/ServiceLocator/ServiceLocator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net40;netcoreapp3.0 5 | true 6 | 7 | 8 | 9 | 10 | {5a90b227-3c80-4b85-ae40-ee17fccd246d} 11 | ExplorerLib 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Converters/InvertedBooleanToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Converters 2 | { 3 | using System; 4 | using System.Windows; 5 | using System.Windows.Data; 6 | 7 | /// 8 | /// XAML converter to convert values 9 | /// into output values. 10 | /// 11 | [ValueConversion(typeof(bool), typeof(Visibility))] 12 | public class InvertedBooleanToVisibilityConverter : IValueConverter 13 | { 14 | #region IValueConverter Members 15 | /// 16 | /// Converts a value. 17 | /// 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 24 | { 25 | if (!(value is bool)) 26 | return null; 27 | 28 | bool boolValue = (bool)value; 29 | 30 | if (boolValue) 31 | return Visibility.Collapsed; 32 | else 33 | return Visibility.Visible; 34 | } 35 | 36 | /// 37 | /// Converts a value. 38 | /// 39 | /// 40 | /// 41 | /// 42 | /// 43 | /// 44 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 45 | { 46 | throw new NotImplementedException(); 47 | } 48 | 49 | #endregion 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Factory.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib 2 | { 3 | using SolutionLib.Interfaces; 4 | using SolutionLib.ViewModels.Browser; 5 | 6 | /// 7 | /// Contains methods for generating library objects that are exposed via interface only. 8 | /// 9 | public sealed class Factory 10 | { 11 | private Factory() 12 | { 13 | } 14 | 15 | /// 16 | /// Gets the root of a solution tree viewmodel object. Use the functions 17 | /// available below to manipulate amd mange the 18 | /// items in that tree. 19 | /// 20 | /// 21 | public static ISolution RootViewModel() 22 | { 23 | return new SolutionViewModel(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/IFile.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | /// 4 | /// Implements an interface to a viewmodel of a file item in 5 | /// a tree structured collection of items. 6 | /// 7 | /// Types of collection items can be distinguished via the: 8 | /// 1) an interface 9 | /// (eg. to select a template in an ItemTemplateSelector"/> or 10 | /// for usage in an HierarchicalDataTemplate./>, 11 | /// 12 | /// or 13 | /// 14 | /// 2) thrpigh enumeration in . 15 | /// 16 | public interface IFile : IItem 17 | { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/IFolder.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | /// 4 | /// Implements an interface to a viewmodel of a folder item in 5 | /// a tree structured collection of items. 6 | /// 7 | /// Types of collection items can be distinguished via the: 8 | /// 1) an interface 9 | /// (eg. to select a template in an ItemTemplateSelector or 10 | /// for usage in an HierarchicalDataTemplate, 11 | /// 12 | /// or 13 | /// 14 | /// 2) thrpigh enumeration in . 15 | /// 16 | public interface IFolder : IItemChildren 17 | { 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/IItem.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | using InplaceEditBoxLib.Events; 4 | using InplaceEditBoxLib.Interfaces; 5 | using SolutionLib.Models; 6 | using System.ComponentModel; 7 | using System.Windows.Media.Imaging; 8 | 9 | /// 10 | /// Defines properties and members of all objects displayed in a solution. 11 | /// 12 | public interface IItem : IEditBox, IViewModelBase, IParent 13 | { 14 | #region properties 15 | /// 16 | /// Gets a unique technical name to id the item 17 | /// and manage items in colleciton. 18 | /// 19 | SolutionItemType ItemType { get; } 20 | 21 | /// 22 | /// Gets a name for display in UI. 23 | /// 24 | string DisplayName { get; } 25 | 26 | /// 27 | /// Gets a description of the item - for usage in tool tip etc.. 28 | /// 29 | string Description { get; } 30 | 31 | /// 32 | /// Gets/sets whether this treeview item is expanded or not. 33 | /// 34 | bool IsItemExpanded { get; set; } 35 | 36 | /// 37 | /// Gets/sets whether this treeview item is selected or not. 38 | /// 39 | bool IsItemSelected { get; set; } 40 | 41 | /// 42 | /// Gets whether the of this treeview item 43 | /// can be edit by the user or not. 44 | /// 45 | bool IsReadOnly { get; } 46 | 47 | /// 48 | /// Gets/sets a string that determines the order in which items are displayed. 49 | /// 50 | string SortKey { get; set; } 51 | #endregion properties 52 | 53 | #region methods 54 | /// 55 | /// Sets the value of the property. 56 | /// 57 | /// 58 | void SetDisplayName(string displayName); 59 | 60 | /// 61 | /// Sets the value of the property. 62 | /// 63 | /// 64 | void SetDescription(string description); 65 | 66 | /// 67 | /// Sets the value of the property. 68 | /// 69 | /// 70 | void SetIsReadOnly(bool value); 71 | 72 | /// 73 | /// Sets the Parent property object 74 | /// where this object is the child in the treeview. 75 | /// 76 | void SetParent(IItem parent); 77 | 78 | /// 79 | /// Sets the ID of an item in the collection. 80 | /// 81 | /// 82 | void SetId(long itemId); 83 | 84 | /// 85 | /// Gets the ID of an item in the collection. 86 | /// 87 | long GetId(); 88 | 89 | #region IEditBox Members 90 | /// 91 | /// Call this method to request of start editing mode for renaming this item. 92 | /// 93 | /// 94 | /// Returns true if event was successfully send (listener is attached), otherwise false 95 | bool RequestEditMode(RequestEditEvent request); 96 | 97 | /// 98 | /// Shows a pop-notification message with the given title and text. 99 | /// 100 | /// 101 | /// 102 | /// 103 | /// true if the event was succesfully fired. 104 | bool ShowNotification(string title, string message, 105 | BitmapImage imageIcon = null); 106 | #endregion IEditBox Members 107 | #endregion methods 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/IItemChildren.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | using System.Collections.Generic; 4 | 5 | /// 6 | /// Implements a base class for a collection specific item type that can have children 7 | /// and does provide functions to manipulate the collection of children 8 | /// (remove, rename, add child etc.) 9 | /// 10 | public interface IItemChildren : IItem 11 | { 12 | /// 13 | /// Gets all children items of this (parent) item. 14 | /// 15 | IEnumerable Children { get; } 16 | 17 | #region methods 18 | /// 19 | /// Finds a child item by the given key or returns null. 20 | /// 21 | /// 22 | /// 23 | IItem FindChild(string displyName); 24 | 25 | /// 26 | /// Adding a new next child item via Inplace Edit Box requires that 27 | /// we know whether 'New Folder','New Folder 1', 'New Folder 2' ... 28 | /// is the next appropriate name - this method determines that name 29 | /// and returns it for a given type of a (to be created) child item. 30 | /// 31 | /// 32 | /// 33 | string SuggestNextChildName(Models.SolutionItemType nextTypeTpAdd); 34 | 35 | /// 36 | /// Adds a child item of type to this parent 37 | /// which can also be typed with . 38 | /// 39 | /// 40 | /// 41 | IItem AddChild(IItem item); 42 | 43 | /// 44 | /// Adds a child item with the given type 45 | /// ( cannot be added here). 46 | /// 47 | /// 48 | /// 49 | /// 50 | IItem AddChild(string displayName, Models.SolutionItemType type); 51 | 52 | /// 53 | /// Removes a child item from the collection of children in this item. 54 | /// 55 | /// 56 | /// 57 | bool RemoveChild(IItem item); 58 | 59 | /// 60 | /// Renames a child item int the collection of children in this item. 61 | /// A re-sort and IsItemSelected should be applied after the rename such that 62 | /// the renamed it should re-appear at the correct position in the sorted 63 | /// list of items. 64 | /// 65 | /// 66 | /// 67 | /// 68 | void RenameChild(IItem item, string newName); 69 | 70 | /// 71 | /// Removes all children (if any) below this item. 72 | /// 73 | void RemoveAllChild(); 74 | 75 | /// 76 | /// Sorts all items for display in a sorted fashion. 77 | /// 78 | void SortChildren(); 79 | 80 | /// 81 | /// Adds another folder (child) item in the given collection of items. 82 | /// 83 | /// 84 | /// 85 | IItem AddFolder(string displayName); 86 | 87 | /// 88 | /// Adds another project (child) item in the given collection of items. 89 | /// 90 | /// 91 | /// 92 | IItem AddProject(string displayName); 93 | 94 | /// 95 | /// Adds another file (child) item in the given collection of items. 96 | /// 97 | /// 98 | /// 99 | IItem AddFile(string displayName); 100 | #endregion methods 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/IParent.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | /// 4 | /// Models an interfaces to an item that can 5 | /// tell is parent (whether it has a paren or not). 6 | /// 7 | public interface IParent 8 | { 9 | /// 10 | /// Gets the parent object where this object is the child in the treeview. 11 | /// 12 | IItem Parent { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/IProject.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | /// 4 | /// Implements an interface to a viewmodel of a project item in 5 | /// a tree structured collection of items. 6 | /// 7 | /// Types of collection items can be distinguished via the: 8 | /// 1) an interface 9 | /// (eg. to select a template in an ItemTemplateSelector or 10 | /// for usage in an HierarchicalDataTemplate, 11 | /// 12 | /// or 13 | /// 14 | /// 2) thrpigh enumeration in . 15 | /// 16 | public interface IProject : IItemChildren 17 | { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/ISolution.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | using SolutionLib.Models; 4 | using System.Collections.Generic; 5 | using System.Windows.Input; 6 | 7 | /// 8 | /// A Solution root is the class that hosts all other solution related items. 9 | /// Even the SolutionRootItem that is part of the displayed collection is hosted in 10 | /// the collection below. 11 | /// 12 | public interface ISolution : IViewModelBase 13 | { 14 | #region properties 15 | /// 16 | /// Gets the root of the treeview. That is, there is only 17 | /// 1 item in the ObservableCollection and that item is the root. 18 | /// 19 | /// The Children property of that one 20 | /// represents the rest of the tree. 21 | /// 22 | IEnumerable Root { get; } 23 | 24 | /// 25 | /// Gets a command that Renames the item that is represented by this viewmodel. 26 | /// 27 | /// This command should be called directly by the implementing view 28 | /// since the new name of the item is delivered as string with the 29 | /// item itself as second parameter via bound via RenameCommandParameter 30 | /// dependency property. 31 | /// 32 | ICommand RenameCommand { get; } 33 | 34 | /// 35 | /// Gets the currently selected from the collection of tree items. 36 | /// 37 | IItem SelectedItem { get; } 38 | 39 | /// 40 | /// Gets a command that changes the currently 41 | /// to the item that is supplied as parameter 42 | /// of this command. 43 | /// 44 | ICommand SelectionChangedCommand { get; } 45 | 46 | /// 47 | /// Gets the file filter that is applied when the user opens a save/load 48 | /// dialog view to save/load the solution's treeview content. 49 | /// 50 | string SolutionFileFilter { get; } 51 | 52 | /// 53 | /// Gets the default file filter that is applied when the user opens a save/load 54 | /// dialog view to save/load the solution's treeview content for the first time. 55 | /// 56 | string SolutionFileFilterDefault { get; } 57 | #endregion properties 58 | 59 | #region methods 60 | /// 61 | /// Returns the first visible item in the treeview (if any) or null. 62 | /// 63 | /// This method is a convinience wrapper that unwinds the property 64 | /// since the viewmodel does support only ONE root at all times. 65 | /// 66 | /// 67 | IItemChildren GetRootItem(); 68 | 69 | /// 70 | /// Adds a solution root into the collection of solution items. 71 | /// 72 | /// Be careful here (!) since the current root item (if any) is discarded 73 | /// along with all its children since the viewmodel does support only ONE root 74 | /// at all times. 75 | /// 76 | /// 77 | /// 78 | IItemChildren AddSolutionRootItem(string displayName); 79 | 80 | /// 81 | /// Adds another child item below the root item in the collection. 82 | /// This will throw an Exception if parent is null. 83 | /// 84 | /// 85 | /// 86 | /// 87 | IItem AddRootChild(string itemName, 88 | SolutionItemType itemType); 89 | 90 | /// 91 | /// Adds another file (child) item below the parent item. 92 | /// This will throw an Exception if parent is null. 93 | /// 94 | /// 95 | /// 96 | /// 97 | /// 98 | IItem AddChild(string itemName, 99 | SolutionItemType itemType, 100 | IItemChildren parent); 101 | 102 | /// 103 | /// Resets all viewmodel items to initial states of construction time. 104 | /// 105 | void ResetToDefaults(); 106 | #endregion methods 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/ISolutionRootItem.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | /// 4 | /// Implements an interface for a viewmodel class of the first visible item in the treeview. 5 | /// Normally, there is only one root in any given tree - so this class implements 6 | /// that one item visually representing that root (eg.: Computer item in Windows Explorer). 7 | /// 8 | public interface ISolutionRootItem : IItemChildren 9 | { 10 | /// 11 | /// Rename the display item of the root item. 12 | /// 13 | /// 14 | void RenameRootItem(string newName); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Interfaces/IViewModelBase.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Interfaces 2 | { 3 | using System.ComponentModel; 4 | 5 | /// 6 | /// This interface provides a base interface for all items in the solution, 7 | /// including the root item, all items below it, and the solution root. 8 | /// 9 | public interface IViewModelBase : INotifyPropertyChanged 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Models/SolutionItemType.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Models 2 | { 3 | /// 4 | /// Determines the typed id for an item in a solution. 5 | /// 6 | public enum SolutionItemType 7 | { 8 | /// 9 | /// Represents the root of the items in the solution tree. 10 | /// 11 | SolutionRootItem = 0, 12 | 13 | /// 14 | /// A generic file. 15 | /// 16 | File = 100, 17 | 18 | /// 19 | /// A generic solution folder. 20 | /// 21 | Folder = 200, 22 | 23 | /// 24 | /// A generic project. 25 | /// 26 | Project = 300 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Files/Light/Document_128x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Files/Light/Document_16x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_16x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_24x..png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Files/Light/Document_24x..png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_24x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_256x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Files/Light/Document_256x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_256x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Files/Light/Document_32x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_32x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_48x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Files/Light/Document_48x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_48x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Files/Light/Document_64x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Files/Light/Document_64x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_128x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_256x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_256x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_256x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xLG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xLG.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xLG.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xMD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xMD.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xMD.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xSM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xSM.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_32xSM.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_48x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_48x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_48x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_64x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/FolderOpen_64x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_128x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_256x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_256x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_256x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_25x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_25x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_25x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_32x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_32x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xLG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xLG.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xLG.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xMD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xMD.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xMD.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xSM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xSM.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_32xSM.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_48x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_48x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_48x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Folders/Light/Folder_64x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Folders/Light/Folder_64x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/LightIcons.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Projects/Light/Application_128x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_12x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Projects/Light/Application_12x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_12x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Projects/Light/Application_16x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_16x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_256x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Projects/Light/Application_256x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_256x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Projects/Light/Application_32x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_32x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Projects/Light/Application_64x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Projects/Light/Application_64x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_128x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_128x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_12x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_12x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_12x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_16x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_16x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_256x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_256x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_256x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_32x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_32x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_48x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_48x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_48x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dirkster99/InplaceEditBoxLib/d987f597c4d713a6238a872393609aa9d00b4177/source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_64x.png -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Resources/Solutions/Light/AppFlyout_64x.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/SolutionLib.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net461;netcoreapp3.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  5 | 18 | 19 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/ViewModels/Base/BaseViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.ViewModels.Base 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Linq.Expressions; 6 | 7 | /// 8 | /// Every ViewModel class is required to implement the INotifyPropertyChanged 9 | /// interface in order to tell WPF when a property changed (for instance, when 10 | /// a method or setter is executed). 11 | /// 12 | /// Therefore, the PropertyChanged methode has to be called when data changes, 13 | /// because the relevant properties may or may not be bound to GUI elements, 14 | /// which in turn have to refresh their display. 15 | /// 16 | /// The PropertyChanged method is to be called by the members and properties of 17 | /// the class that derives from this class. Each call contains the name of the 18 | /// property that has to be refreshed. 19 | /// 20 | /// The BaseViewModel is derived from from System.Windows.DependencyObject to allow 21 | /// resulting ViewModels the implemantion of dependency properties. Dependency properties 22 | /// in turn are useful when working with IValueConverter and ConverterParameters. 23 | /// 24 | internal class BaseViewModel : INotifyPropertyChanged 25 | { 26 | /// 27 | /// Standard event handler of the interface 28 | /// 29 | public event PropertyChangedEventHandler PropertyChanged; 30 | 31 | /// 32 | /// Tell bound controls (via WPF binding) to refresh their display. 33 | /// 34 | /// Sample call: this.NotifyPropertyChanged(() => this.IsSelected); 35 | /// where 'this' is derived from 36 | /// and IsSelected is a property. 37 | /// 38 | /// 39 | /// 40 | public void NotifyPropertyChanged(Expression> property) 41 | { 42 | var lambda = (LambdaExpression)property; 43 | MemberExpression memberExpression; 44 | 45 | if (lambda.Body is UnaryExpression) 46 | { 47 | var unaryExpression = (UnaryExpression)lambda.Body; 48 | memberExpression = (MemberExpression)unaryExpression.Operand; 49 | } 50 | else 51 | memberExpression = (MemberExpression)lambda.Body; 52 | 53 | this.OnPropertyChanged(memberExpression.Member.Name); 54 | } 55 | 56 | /// 57 | /// Tell bound controls (via WPF binding) to refresh their display. 58 | /// 59 | /// Sample call: this.OnPropertyChanged("IsSelected"); 60 | /// where 'this' is derived from 61 | /// and IsSelected is a property. 62 | /// 63 | /// Name of property to refresh 64 | public void OnPropertyChanged(string propertyName) 65 | { 66 | try 67 | { 68 | if (this.PropertyChanged != null) 69 | this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 70 | } 71 | catch 72 | { 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/ViewModels/Base/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.ViewModels.Base 2 | { 3 | using System; 4 | using System.Diagnostics; 5 | using System.Windows.Input; 6 | 7 | /// 8 | /// A command whose sole purpose is to 9 | /// relay its functionality to other 10 | /// objects by invoking delegates. The 11 | /// default return value for the CanExecute 12 | /// method is 'true'. 13 | /// 14 | /// Source: http://www.codeproject.com/Articles/31837/Creating-an-Internationalized-Wizard-in-WPF 15 | /// 16 | internal class RelayCommand : ICommand 17 | { 18 | #region Fields 19 | private readonly Action mExecute = null; 20 | private readonly Predicate mCanExecute = null; 21 | #endregion // Fields 22 | 23 | #region Constructors 24 | /// 25 | /// Class constructor 26 | /// 27 | /// 28 | public RelayCommand(Action execute) 29 | : this(execute, null) 30 | { 31 | } 32 | 33 | /// 34 | /// Creates a new command. 35 | /// 36 | /// The execution logic. 37 | /// The execution status logic. 38 | public RelayCommand(Action execute, Predicate canExecute) 39 | { 40 | if (execute == null) 41 | throw new ArgumentNullException("execute"); 42 | 43 | this.mExecute = execute; 44 | this.mCanExecute = canExecute; 45 | } 46 | 47 | #endregion // Constructors 48 | 49 | #region events 50 | /// 51 | /// Eventhandler to re-evaluate whether this command can execute or not 52 | /// 53 | public event EventHandler CanExecuteChanged 54 | { 55 | add 56 | { 57 | if (this.mCanExecute != null) 58 | CommandManager.RequerySuggested += value; 59 | } 60 | 61 | remove 62 | { 63 | if (this.mCanExecute != null) 64 | CommandManager.RequerySuggested -= value; 65 | } 66 | } 67 | #endregion 68 | 69 | #region methods 70 | /// 71 | /// Determine whether this pre-requisites to execute this command are given or not. 72 | /// 73 | /// 74 | /// 75 | [DebuggerStepThrough] 76 | public bool CanExecute(object parameter) 77 | { 78 | return this.mCanExecute == null ? true : this.mCanExecute((T)parameter); 79 | } 80 | 81 | /// 82 | /// Execute the command method managed in this class. 83 | /// 84 | /// 85 | public void Execute(object parameter) 86 | { 87 | this.mExecute((T)parameter); 88 | } 89 | #endregion methods 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/ViewModels/Browser/FileViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.ViewModels.Browser 2 | { 3 | using SolutionLib.Interfaces; 4 | 5 | /// 6 | /// Implements a viewmodel for file items in a tree structured viewmodel collection. 7 | /// 8 | internal class FileViewModel : Base.ItemViewModel, IFile 9 | { 10 | #region constructors 11 | /// 12 | /// Class constructor 13 | /// 14 | public FileViewModel(IItem parent, string displayName) 15 | : base(parent, Models.SolutionItemType.File) 16 | { 17 | SetDisplayName(displayName); 18 | } 19 | 20 | /// 21 | /// Class constructor 22 | /// 23 | protected FileViewModel() 24 | : base(null, Models.SolutionItemType.File) 25 | { 26 | } 27 | #endregion constructors 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/ViewModels/Browser/FolderViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.ViewModels.Browser 2 | { 3 | using SolutionLib.Interfaces; 4 | 5 | internal class FolderViewModel : Base.ItemChildrenViewModel, IFolder 6 | { 7 | #region constructors 8 | /// 9 | /// Class constructor 10 | /// 11 | /// 12 | /// 13 | /// 14 | public FolderViewModel(IItem parent 15 | , string displayName 16 | , bool addDummyChild = true) 17 | : base(parent, Models.SolutionItemType.Folder, addDummyChild) 18 | { 19 | SetDisplayName(displayName); 20 | } 21 | 22 | /// 23 | /// Class constructor 24 | /// 25 | protected FolderViewModel() 26 | : base(null, Models.SolutionItemType.Folder) 27 | { 28 | } 29 | #endregion constructors 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/ViewModels/Browser/ProjectViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.ViewModels.Browser 2 | { 3 | using SolutionLib.Interfaces; 4 | 5 | internal class ProjectViewModel : Base.ItemChildrenViewModel, IProject 6 | { 7 | #region constructors 8 | /// 9 | /// Class constructor 10 | /// 11 | /// 12 | /// 13 | /// 14 | public ProjectViewModel(IItem parent 15 | , string displayName 16 | , bool addDummyChild = true) 17 | : base(parent, Models.SolutionItemType.Project, addDummyChild) 18 | { 19 | SetDisplayName(displayName); 20 | } 21 | 22 | /// 23 | /// Standard Class constructor 24 | /// 25 | protected ProjectViewModel() 26 | : base(null, Models.SolutionItemType.Project) 27 | { 28 | } 29 | #endregion constructors 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/ViewModels/Browser/SolutionRootItemViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.ViewModels.Browser 2 | { 3 | using SolutionLib.Interfaces; 4 | 5 | /// 6 | /// Implements a viewmodel class for the first visible item in the treeview. 7 | /// Normally, there is only one root in any given tree - so this class implements 8 | /// that one item visually representing that root (eg.: Computer item in Windows Explorer). 9 | /// 10 | internal class SolutionRootItemViewModel : Base.ItemChildrenViewModel, ISolutionRootItem 11 | { 12 | #region constructors 13 | /// 14 | /// Class constructor 15 | /// 16 | /// 17 | /// 18 | /// 19 | public SolutionRootItemViewModel(IItem parent 20 | , string displayName 21 | , bool addDummyChild = true) 22 | : base(parent, Models.SolutionItemType.SolutionRootItem, addDummyChild) 23 | { 24 | SetDisplayName(displayName); 25 | } 26 | 27 | /// 28 | /// Class constructor 29 | /// 30 | protected SolutionRootItemViewModel() 31 | : base(null, Models.SolutionItemType.SolutionRootItem) 32 | { 33 | } 34 | #endregion constructors 35 | 36 | #region methods 37 | /// 38 | /// Rename the display item of the root item. 39 | /// 40 | /// 41 | public void RenameRootItem(string newName) 42 | { 43 | SetDisplayName(newName); 44 | } 45 | #endregion methods 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/ViewModels/Collections/SortableObservableCollection.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.ViewModels.Collections 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Collections.ObjectModel; 6 | using System.Linq; 7 | using System.Windows; 8 | using System.Windows.Threading; 9 | 10 | /// 11 | /// Source: https://stackoverflow.com/questions/5487927/expand-wpf-treeview-to-support-sorting 12 | /// 13 | /// 14 | public class SortableObservableCollection : ObservableCollection 15 | { 16 | private static DispatcherPriority _ChildrenEditPrio = DispatcherPriority.DataBind; 17 | 18 | #region constructors 19 | /// 20 | /// Class constructor 21 | /// 22 | public SortableObservableCollection() : base() { } 23 | 24 | /// 25 | /// Class constructor 26 | /// 27 | public SortableObservableCollection(List l) : base(l) { } 28 | 29 | /// 30 | /// Class constructor 31 | /// 32 | public SortableObservableCollection(IEnumerable l) : base(l) { } 33 | #endregion 34 | 35 | #region Sorting 36 | /// 37 | /// Sorts the items of the collection in ascending order according to a key. 38 | /// 39 | /// The type of the key returned by . 40 | /// A function to extract a key from an item. 41 | public void Sort(Func keySelector) 42 | { 43 | InternalSort(Items.OrderBy(keySelector)); 44 | } 45 | 46 | /// 47 | /// Sorts the items of the collection in descending order according to a key. 48 | /// 49 | /// The type of the key returned by . 50 | /// A function to extract a key from an item. 51 | public void SortDescending(Func keySelector) 52 | { 53 | InternalSort(Items.OrderByDescending(keySelector)); 54 | } 55 | 56 | /// 57 | /// Sorts the items of the collection in ascending order according to a key. 58 | /// 59 | /// The type of the key returned by . 60 | /// A function to extract a key from an item. 61 | /// An to compare keys. 62 | public void Sort(Func keySelector, IComparer comparer) 63 | { 64 | InternalSort(Items.OrderBy(keySelector, comparer)); 65 | } 66 | 67 | /// 68 | /// Moves the items of the collection so that their orders are the same as those of the items provided. 69 | /// 70 | /// An to provide item orders. 71 | private void InternalSort(IEnumerable sortedItems) 72 | { 73 | var sortedItemsList = sortedItems.ToList(); 74 | 75 | foreach (var item in sortedItemsList) 76 | { 77 | Application.Current.Dispatcher.Invoke(() => 78 | { 79 | Move(IndexOf(item), sortedItemsList.IndexOf(item)); 80 | }, 81 | _ChildrenEditPrio); 82 | 83 | } 84 | } 85 | #endregion // Sorting 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /source/Solution/SolutionLib/Views/TreeViewItemSelector.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionLib.Views 2 | { 3 | using SolutionLib.Interfaces; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | 7 | /// 8 | /// Implements DataTemplate Selector for TreeViewItems. This is required 9 | /// since file entries CANNOT have children and all other types of items 10 | /// can have child entries below themselves. 11 | /// 12 | /// Usage: 13 | /// - Instantiate the Template selector in ResourceDictionary 14 | /// - Instantiate: 15 | /// - DataTemplate (for files) and 16 | /// - HierarchicalDataTemplate (items with children) 17 | /// in ResourceDictionary 18 | /// 19 | /// - Assign each template on the and 20 | /// properties below. 21 | /// 22 | /// - Assign the to the TreeView 23 | /// ItemTemplateSelector="{StaticResource TreeItemSelector}" 24 | /// 25 | public class TreeViewItemSelector : DataTemplateSelector 26 | { 27 | /// 28 | /// Gets/sets the property that holds the Template for items that cannot 29 | /// have children (files) in a TreeView. 30 | /// 31 | public DataTemplate FileTemplate { get; set; } 32 | 33 | /// 34 | /// Gets/sets the property that holds the Template for items that can 35 | /// have children (folder, project) in a TreeView. 36 | /// 37 | public DataTemplate ChildrenItemTemplate { get; set; } 38 | 39 | /// 40 | /// Overrides the statndard method that is invoked when the framework queries 41 | /// for the correct Template to be used for a given ViewModel object. 42 | /// 43 | /// 44 | /// 45 | /// 46 | public override DataTemplate SelectTemplate(object item, DependencyObject container) 47 | { 48 | if (item is IFile) 49 | return FileTemplate; 50 | 51 | return ChildrenItemTemplate; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Enums/SolutionItemType.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Enums 2 | { 3 | /// 4 | /// Determines the typed id for an item in a solution. 5 | /// 6 | public enum SolutionModelItemType 7 | { 8 | /// 9 | /// Represents the root of the items in the solution tree. 10 | /// 11 | SolutionRootItem = 0, 12 | 13 | /// 14 | /// A generic file. 15 | /// 16 | File = 100, 17 | 18 | /// 19 | /// A generic solution folder. 20 | /// 21 | Folder = 200, 22 | 23 | /// 24 | /// A generic project. 25 | /// 26 | Project = 300 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Factory.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib 2 | { 3 | using SolutionModelsLib.Interfaces; 4 | using SolutionModelsLib.Models; 5 | 6 | /// 7 | /// Class creates model objects for the outside world. 8 | /// 9 | public sealed class Factory 10 | { 11 | private Factory() 12 | { 13 | } 14 | 15 | /// 16 | /// Create a solution root data model object and return it. 17 | /// 18 | /// 19 | public static ISolutionModel CreateSolutionModel() 20 | { 21 | return new SolutionModel(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Interfaces/IFileItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Interfaces 2 | { 3 | public interface IFileItemModel : IItemModel 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Interfaces/IFolderItemModel .cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Interfaces 2 | { 3 | public interface IFolderItemModel : IItemChildrenModel 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Interfaces/IItemChildrenModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Interfaces 2 | { 3 | using System.Collections.Generic; 4 | 5 | /// 6 | /// Implements an interface for an abstract class that implements items 7 | /// that can have child items of their own. 8 | /// 9 | public interface IItemChildrenModel : IItemModel 10 | { 11 | #region properties 12 | /// 13 | /// Gets all children items of this (parent) item. 14 | /// 15 | IList Children { get; } 16 | #endregion properties 17 | 18 | #region methods 19 | /// 20 | /// Finds a child item based on the given key in . 21 | /// 22 | /// 23 | /// 24 | IItemModel FindChild(string displayName); 25 | 26 | /// 27 | /// Adds a child item with the given type 28 | /// ( cannot be added here). 29 | /// 30 | /// 31 | /// 32 | /// 33 | void AddChild(IItemModel item); 34 | #endregion methods 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Interfaces/IItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Interfaces 2 | { 3 | using SolutionModelsLib.Enums; 4 | using System.Xml.Serialization; 5 | 6 | /// 7 | /// Implements an interface for an abstract class that implements items 8 | /// that CANNOT have child items of their own. These items typically have 9 | /// just a name and an id (a file for example) but no item collections of 10 | /// their owm. 11 | /// 12 | public interface IItemModel : IModelBase, IXmlSerializable 13 | { 14 | #region properties 15 | /// 16 | /// Gets/Sets the Id for this item. 17 | /// 18 | long Id { get; set; } 19 | 20 | /// 21 | /// Gets/sets the parent item of this item. 22 | /// 23 | IItemModel Parent { get; set; } 24 | 25 | /// 26 | /// Gets/sets a technical type of this item to id the item 27 | /// in terms of its capabilities that are associated with this type of item. 28 | /// 29 | SolutionModelItemType ItemType { get; set; } 30 | 31 | /// 32 | /// Gets/sets a name for display in UI. 33 | /// 34 | string DisplayName { get; set; } 35 | 36 | //// /// 37 | //// /// Gets/sets whether the of this treeview item 38 | //// /// can be edit by the user or not. 39 | //// /// 40 | //// bool IsReadOnly { get; set; } 41 | #endregion properties 42 | 43 | #region methods 44 | /// 45 | /// Returns the string path either: 46 | /// 1) for the item or 47 | /// 2) for this item (if optional parameter is not set). 48 | /// 49 | /// 50 | /// 51 | string GetStackPath(IItemModel current = null); 52 | #endregion methods 53 | } 54 | } -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Interfaces/IModelBase.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Interfaces 2 | { 3 | /// 4 | /// This interface provides a base interface for all model items in the solution, 5 | /// including the root item, all items below it, and the solution root. 6 | /// 7 | public interface IModelBase 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Interfaces/IProjectItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Interfaces 2 | { 3 | public interface IProjectItemModel : IItemChildrenModel 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Interfaces/ISolutionModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Interfaces 2 | { 3 | using SolutionModelsLib.Enums; 4 | using System.Xml.Serialization; 5 | 6 | /// 7 | /// Implements an interface to the root model class that manages the complete 8 | /// tree model data structure that is mainly used for reading and writing data 9 | /// from and to file based persistence. 10 | /// 11 | public interface ISolutionModel : IModelBase, IXmlSerializable 12 | { 13 | /// 14 | /// Gets the root item of the tree structure managed in the implementing object 15 | /// (this tree has only one root item which is why we have no collection here). 16 | /// 17 | ISolutionRootItemModel Root { get; set; } 18 | 19 | /// 20 | /// Adds a new item of the requested type and name below the given 21 | /// item. 22 | /// 23 | /// 24 | /// 25 | /// 26 | /// 27 | IItemModel AddChild(string itemName, 28 | SolutionModelItemType itemType, 29 | IItemChildrenModel parent); 30 | 31 | /// 32 | /// Adds a child item with the given type 33 | /// ( cannot be added here). 34 | /// 35 | /// This wrapper uses a long input for conversion when reading from file. 36 | /// 37 | /// 38 | /// 39 | /// 40 | IItemModel AddChild(string displayName 41 | , long longType 42 | , IItemChildrenModel parent); 43 | 44 | /// 45 | /// Creates a new solution root item from the given parameters 46 | /// (replacing the current root item if there is any) 47 | /// and returns its interface. 48 | /// 49 | /// 50 | /// 51 | /// 52 | IItemChildrenModel AddSolutionRootItem(string displayName, long id = -1); 53 | } 54 | } -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Interfaces/ISolutionRootItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Interfaces 2 | { 3 | /// 4 | /// Implements an interface to the root item (first visible item at the root) 5 | /// of the tree view. 6 | /// 7 | public interface ISolutionRootItemModel : IItemChildrenModel 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Models/Base/ItemChildrenModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Models.Base 2 | { 3 | using SolutionModelsLib.Enums; 4 | using SolutionModelsLib.Interfaces; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | /// 9 | /// Defines a model with properties and members of all objects displayed in a solution - 10 | /// this type also provides basic functions to manage (add, remove, maintain) child items 11 | /// below this item. 12 | /// 13 | internal abstract class ItemChildrenModel : ItemModel, IItemChildrenModel 14 | { 15 | private readonly Dictionary _Children = new Dictionary(); 16 | 17 | #region constructors 18 | /// 19 | /// Class constructor 20 | /// 21 | protected ItemChildrenModel(IItemModel parent 22 | , string displayName 23 | , SolutionModelItemType itemType) 24 | : base(parent, displayName, itemType) 25 | { 26 | } 27 | 28 | /// 29 | /// Class constructor 30 | /// 31 | protected ItemChildrenModel(SolutionModelItemType itemType) 32 | : base(itemType) 33 | { 34 | } 35 | 36 | /// 37 | /// Class constructor 38 | /// 39 | protected ItemChildrenModel() 40 | : base() 41 | { 42 | } 43 | #endregion constructors 44 | 45 | #region properties 46 | /// 47 | /// Gets all children items of this (parent) item. 48 | /// 49 | public IList Children 50 | { 51 | get 52 | { 53 | return _Children.Values.ToList(); 54 | } 55 | } 56 | #endregion properties 57 | 58 | #region methods 59 | /// 60 | /// Finds a child item based on the given key in . 61 | /// 62 | /// 63 | /// 64 | public IItemModel FindChild(string displayName) 65 | { 66 | IItemModel rs = null; 67 | _Children.TryGetValue(displayName, out rs); 68 | 69 | return rs; 70 | } 71 | 72 | public void AddChild(IItemModel newItem) 73 | { 74 | _Children.Add(newItem.DisplayName, newItem); 75 | } 76 | 77 | internal bool RenameChild(string newDisplayName) 78 | { 79 | IItemModel rs = null; 80 | _Children.TryGetValue(newDisplayName, out rs); 81 | 82 | if (rs != null) 83 | { 84 | _Children.Remove(rs.DisplayName); 85 | rs.DisplayName = newDisplayName; 86 | AddChild(rs); 87 | return true; 88 | } 89 | 90 | return false; 91 | } 92 | #endregion methods 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Models/Base/ItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Models.Base 2 | { 3 | using SolutionModelsLib.Enums; 4 | using SolutionModelsLib.Interfaces; 5 | using System.Xml; 6 | using System.Xml.Schema; 7 | using System.Xml.Serialization; 8 | 9 | /// 10 | /// Defines a model with properties and members of all objects displayed in a solution. 11 | /// 12 | internal abstract class ItemModel : IItemModel 13 | { 14 | #region constructors 15 | /// 16 | /// Class constructor 17 | /// 18 | protected ItemModel(IItemModel parent 19 | , string displayName 20 | , SolutionModelItemType itemType) 21 | : this() 22 | { 23 | Parent = parent; 24 | DisplayName = displayName; 25 | ItemType = itemType; 26 | } 27 | 28 | /// 29 | /// Class constructor 30 | /// 31 | protected ItemModel(SolutionModelItemType itemType) 32 | : this() 33 | { 34 | ItemType = itemType; 35 | } 36 | 37 | /// 38 | /// Class constructor 39 | /// 40 | protected ItemModel() 41 | { 42 | // IsItemExpanded = false; 43 | // IsItemSelected = false; 44 | 45 | //// IsReadOnly = false; 46 | } 47 | #endregion constructors 48 | 49 | #region properties 50 | /// 51 | /// Gets/Sets the Id for this item. 52 | /// 53 | public long Id { get; set; } 54 | 55 | /// 56 | /// Gets/sets the parent item of this item. 57 | /// 58 | public IItemModel Parent { get; set; } 59 | 60 | /// 61 | /// Gets/sets a technical type of this item to id the item 62 | /// in terms of its capabilities that are associated with this type of item. 63 | /// 64 | public SolutionModelItemType ItemType { get; set; } 65 | 66 | /// 67 | /// Gets/sets a name for display in UI. 68 | /// 69 | public string DisplayName { get; set; } 70 | 71 | //// /// 72 | //// /// Gets/sets whether the of this treeview item 73 | //// /// can be edit by the user or not. 74 | //// /// 75 | //// public bool IsReadOnly { get; set; } 76 | 77 | /*/ 78 | /// Gets a description of the item - for usage in tool tip etc.. 79 | /// 80 | public string Description { get; set; } ***/ 81 | 82 | //// /// 83 | //// /// Gets the parent object where this object is the child in the treeview. 84 | //// /// 85 | //// public SolutionItem_Model Parent { get; set; } 86 | 87 | //// /// 88 | //// /// Gets/sets whether this treeview item is expanded or not. 89 | //// /// 90 | //// public bool IsItemExpanded { get; set; } 91 | //// 92 | //// /// 93 | //// /// Gets/sets whether this treeview item is selected or not. 94 | //// /// 95 | //// public bool IsItemSelected { get; set; } 96 | #endregion properties 97 | 98 | #region methods 99 | /// 100 | /// Returns the string path either: 101 | /// 1) for the item or 102 | /// 2) for this item (if optional parameter is not set). 103 | /// 104 | /// 105 | /// 106 | public string GetStackPath(IItemModel current = null) 107 | { 108 | if (current == null) 109 | current = this; 110 | 111 | string result = string.Empty; 112 | 113 | // Traverse the list of parents backwards and 114 | // add each child to the path 115 | while (current != null) 116 | { 117 | result = "/" + current.DisplayName + result; 118 | 119 | current = current.Parent; 120 | } 121 | 122 | return result; 123 | } 124 | 125 | #region IXmlSerializable methods 126 | /// 127 | /// Implements the GetSchema() method of the 128 | /// interface - deriving classes do not need to implement this method since it 129 | /// already returns null as required. 130 | /// 131 | /// 132 | XmlSchema IXmlSerializable.GetSchema() { return null; } 133 | 134 | /// 135 | /// Implements the ReadXml() method of the 136 | /// interface - deriving classes required to implement their own interface method 137 | /// since this implementation will throw a . 138 | /// 139 | /// 140 | void IXmlSerializable.ReadXml(XmlReader reader) 141 | { 142 | throw new System.NotImplementedException(); 143 | } 144 | 145 | /// 146 | /// Implements the WriteXml() method of the 147 | /// interface - deriving classes required to implement their own interface method 148 | /// since this implementation will throw a . 149 | /// 150 | /// 151 | void IXmlSerializable.WriteXml(XmlWriter writer) 152 | { 153 | throw new System.NotImplementedException(); 154 | } 155 | #endregion IXmlSerializable methods 156 | #endregion methods 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Models/FileItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Models 2 | { 3 | using SolutionModelsLib.Interfaces; 4 | using SolutionModelsLib.Models.Base; 5 | using System.Xml; 6 | using System.Xml.Serialization; 7 | 8 | /// 9 | /// Implements an interface to a viewmodel of a file item in 10 | /// a tree structured collection of items. 11 | /// 12 | /// Types of collection items can be distinguished via the: 13 | /// 1) an interface 14 | /// (eg. to select a template in an ItemTemplateSelector"/> or 15 | /// for usage in an HierarchicalDataTemplate./>, 16 | /// 17 | /// or 18 | /// 19 | /// 2) thrpigh enumeration in . 20 | /// 21 | [XmlRoot("File")] 22 | internal class FileItemModel : ItemModel, IFileItemModel 23 | { 24 | #region constructors 25 | /// 26 | /// Parameterized constructor for normal usage when new elements are created 27 | /// via other viewmodels through the UI. 28 | /// 29 | /// 30 | /// 31 | public FileItemModel(IItemModel parent, string displayName) 32 | : base(parent, displayName, Enums.SolutionModelItemType.File) 33 | { 34 | } 35 | 36 | /// 37 | /// Parameterless default constructor required for deserializing XML. 38 | /// 39 | internal FileItemModel() 40 | : base(null, string.Empty, Enums.SolutionModelItemType.File) 41 | { 42 | 43 | } 44 | #endregion constructors 45 | 46 | #region methods 47 | #region IXmlSerializable methods 48 | /// 49 | /// Implements the ReadXml() method of the interface. 50 | /// 51 | /// 52 | void IXmlSerializable.ReadXml(XmlReader reader) 53 | { 54 | while (reader.NodeType == System.Xml.XmlNodeType.Whitespace) 55 | reader.Read(); 56 | 57 | DisplayName = reader.GetAttribute("name"); 58 | 59 | long idValue = -1; 60 | long.TryParse(reader.GetAttribute("id"), out idValue); 61 | this.Id = idValue; 62 | 63 | reader.ReadStartElement(); // Consum File Tag 64 | } 65 | 66 | /// 67 | /// Implements the WriteXml() method of the interface. 68 | /// 69 | /// 70 | void IXmlSerializable.WriteXml(XmlWriter writer) 71 | { 72 | try 73 | { 74 | writer.WriteAttributeString("name", this.DisplayName); 75 | writer.WriteAttributeString("id", this.Id.ToString()); 76 | } 77 | catch (System.Exception) 78 | { 79 | throw; 80 | } 81 | } 82 | #endregion IXmlSerializable methods 83 | #endregion methods 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Models/FolderItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Models 2 | { 3 | using SolutionModelsLib.Interfaces; 4 | using SolutionModelsLib.Models.Base; 5 | using System.Xml; 6 | using System.Xml.Serialization; 7 | 8 | /// 9 | /// Implements an interface to a viewmodel of a folder item in 10 | /// a tree structured collection of items. 11 | /// 12 | /// Types of collection items can be distinguished via the: 13 | /// 1) an interface 14 | /// (eg. to select a template in an ItemTemplateSelector or 15 | /// for usage in an HierarchicalDataTemplate, 16 | /// 17 | /// or 18 | /// 19 | /// 2) through enumeration in . 20 | /// 21 | [XmlRoot("Folder")] 22 | internal class FolderItemModel : ItemChildrenModel, IFolderItemModel 23 | { 24 | #region constructors 25 | /// 26 | /// Parameterized constructor for normal usage when new elements are created 27 | /// via other viewmodels through the UI. 28 | /// 29 | /// 30 | /// 31 | public FolderItemModel(IItemModel parent, string displayName) 32 | : base(parent, displayName, Enums.SolutionModelItemType.Folder) 33 | { 34 | } 35 | 36 | /// 37 | /// Parameterless default constructor required for deserializing XML. 38 | /// 39 | internal FolderItemModel() 40 | : base(null, string.Empty, Enums.SolutionModelItemType.Folder) 41 | { 42 | 43 | } 44 | #endregion constructors 45 | 46 | #region methods 47 | #region IXmlSerializable methods 48 | /// 49 | /// Implements the ReadXml() method of the interface. 50 | /// 51 | /// 52 | void IXmlSerializable.ReadXml(XmlReader reader) 53 | { 54 | try 55 | { 56 | while (reader.NodeType == System.Xml.XmlNodeType.Whitespace) 57 | reader.Read(); 58 | 59 | DisplayName = reader.GetAttribute("name"); 60 | 61 | long idValue = -1; 62 | long.TryParse(reader.GetAttribute("id"), out idValue); 63 | this.Id = idValue; 64 | 65 | reader.ReadStartElement(); // Consum Folder Tag 66 | 67 | reader.MoveToContent(); 68 | while (reader.NodeType == System.Xml.XmlNodeType.Whitespace) 69 | reader.Read(); 70 | 71 | // Read Items collection and items below it 72 | if (reader.NodeType != System.Xml.XmlNodeType.EndElement) 73 | SolutionModel.ReadItemsCollection(reader, this); 74 | } 75 | catch (System.Exception) 76 | { 77 | throw; 78 | } 79 | } 80 | 81 | /// 82 | /// Implements the WriteXml() method of the interface. 83 | /// 84 | /// 85 | void IXmlSerializable.WriteXml(XmlWriter writer) 86 | { 87 | writer.WriteAttributeString("name", this.DisplayName); 88 | writer.WriteAttributeString("id", this.Id.ToString()); 89 | 90 | // Child Items are written here... 91 | writer.WriteStartElement("Items"); 92 | foreach (var item in Children) 93 | { 94 | SolutionModel.SerializeItem(writer, item); 95 | } 96 | writer.WriteEndElement(); 97 | } 98 | #endregion IXmlSerializable methods 99 | #endregion methods 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Models/ProjectItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Models 2 | { 3 | using SolutionModelsLib.Interfaces; 4 | using SolutionModelsLib.Models.Base; 5 | using System.Xml; 6 | using System.Xml.Serialization; 7 | 8 | /// 9 | /// Implements an interface to a viewmodel of a project item in 10 | /// a tree structured collection of items. 11 | /// 12 | /// Types of collection items can be distinguished via the: 13 | /// 1) an interface 14 | /// (eg. to select a template in an ItemTemplateSelector or 15 | /// for usage in an HierarchicalDataTemplate, 16 | /// 17 | /// or 18 | /// 19 | /// 2) thrpigh enumeration in . 20 | /// 21 | [XmlRoot("Project")] 22 | internal class ProjectItemModel : ItemChildrenModel, IProjectItemModel 23 | { 24 | #region constructors 25 | public ProjectItemModel(IItemChildrenModel parent, string displayName) 26 | : base(parent, displayName, Enums.SolutionModelItemType.Project) 27 | { 28 | } 29 | 30 | internal ProjectItemModel() 31 | : base(null, string.Empty, Enums.SolutionModelItemType.Project) 32 | { 33 | 34 | } 35 | #endregion constructors 36 | 37 | #region methods 38 | #region IXmlSerializable methods 39 | /// 40 | /// Implements the ReadXml() method of the interface. 41 | /// 42 | /// 43 | void IXmlSerializable.ReadXml(XmlReader reader) 44 | { 45 | while (reader.NodeType == System.Xml.XmlNodeType.Whitespace) 46 | reader.Read(); 47 | 48 | DisplayName = reader.GetAttribute("name"); 49 | 50 | long idValue = -1; 51 | long.TryParse(reader.GetAttribute("id"), out idValue); 52 | this.Id = idValue; 53 | 54 | reader.ReadStartElement(); // Consum Project Tag 55 | 56 | reader.MoveToContent(); 57 | while (reader.NodeType == System.Xml.XmlNodeType.Whitespace) 58 | reader.Read(); 59 | 60 | // Read Items collection and items below it 61 | if (reader.NodeType != System.Xml.XmlNodeType.EndElement) 62 | SolutionModel.ReadItemsCollection(reader, this); 63 | } 64 | 65 | /// 66 | /// Implements the WriteXml() method of the interface. 67 | /// 68 | /// 69 | void IXmlSerializable.WriteXml(XmlWriter writer) 70 | { 71 | writer.WriteAttributeString("name", this.DisplayName); 72 | writer.WriteAttributeString("id", this.Id.ToString()); 73 | 74 | // Child Items are written here... 75 | writer.WriteStartElement("Items"); 76 | foreach (var item in Children) 77 | { 78 | SolutionModel.SerializeItem(writer, item); 79 | } 80 | writer.WriteEndElement(); 81 | } 82 | #endregion IXmlSerializable methods 83 | #endregion methods 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Models/SolutionRootItemModel.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Models 2 | { 3 | using System.Xml; 4 | using System.Xml.Serialization; 5 | using SolutionModelsLib.Enums; 6 | using SolutionModelsLib.Interfaces; 7 | using SolutionModelsLib.Models.Base; 8 | 9 | /// 10 | /// Implements an interface for a model class of the first visible item in the treeview. 11 | /// 12 | /// Normally, there is only one root in any given tree - so this class implements 13 | /// that one item visually representing that root (eg.: Computer item in Windows Explorer). 14 | /// 15 | [XmlRoot("RootItem")] 16 | internal class SolutionRootItemModel : ItemChildrenModel, ISolutionRootItemModel 17 | { 18 | #region constructors 19 | /// 20 | /// Parameterized constructor for normal usage when new elements are created 21 | /// via other viewmodels through the UI. 22 | /// 23 | /// 24 | /// 25 | public SolutionRootItemModel(string displayName) 26 | : base(Enums.SolutionModelItemType.SolutionRootItem) 27 | { 28 | DisplayName = displayName; 29 | } 30 | 31 | /// 32 | /// Parameterless default constructor required for deserializing XML. 33 | /// 34 | protected SolutionRootItemModel() 35 | : base(Enums.SolutionModelItemType.SolutionRootItem) 36 | { 37 | } 38 | #endregion constructors 39 | 40 | #region methods 41 | #region IXmlSerializable methods 42 | /// 43 | /// Implements the ReadXml() method of the interface. 44 | /// 45 | /// 46 | void IXmlSerializable.ReadXml(XmlReader reader) 47 | { 48 | try 49 | { 50 | while (reader.NodeType == System.Xml.XmlNodeType.Whitespace) 51 | reader.Read(); 52 | 53 | this.DisplayName = reader.GetAttribute("name"); 54 | 55 | long idValue = -1; 56 | long.TryParse(reader.GetAttribute("id"), out idValue); 57 | this.Id = idValue; 58 | 59 | reader.ReadStartElement(); // Consum RootItem Tag 60 | 61 | reader.MoveToContent(); 62 | while (reader.NodeType == System.Xml.XmlNodeType.Whitespace) 63 | reader.Read(); 64 | 65 | // Read Items collection and items below it 66 | if (reader.NodeType != System.Xml.XmlNodeType.EndElement) 67 | SolutionModel.ReadItemsCollection(reader, this); 68 | } 69 | catch (System.Exception) 70 | { 71 | throw; 72 | } 73 | } 74 | 75 | /// 76 | /// Implements the WriteXml() method of the interface. 77 | /// 78 | /// 79 | void IXmlSerializable.WriteXml(XmlWriter writer) 80 | { 81 | writer.WriteAttributeString("name", this.DisplayName); 82 | writer.WriteAttributeString("id", this.Id.ToString()); 83 | 84 | // Child Items are written here... 85 | writer.WriteStartElement("Items"); 86 | foreach (var item in Children) 87 | { 88 | SolutionModel.SerializeItem(writer, item); 89 | } 90 | writer.WriteEndElement(); 91 | } 92 | #endregion IXmlSerializable methods 93 | #endregion methods 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/SQLite/JournalMode.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.SQLite 2 | { 3 | /// 4 | /// Models the Pragma Journal_Mode enumeration 5 | /// - ( and ). 6 | /// 7 | /// See details described below and: 8 | /// https://sqlite.org/pragma.html#pragma_journal_mode 9 | /// https://sqlite.org/wal.html 10 | /// 11 | public enum JournalMode 12 | { 13 | /// 14 | /// The DELETE journaling mode is the normal behavior. In the DELETE mode, the rollback journal is 15 | /// deleted at the conclusion of each transaction. Indeed, the delete operation is the action that 16 | /// causes the transaction to commit. (See the document titled Atomic Commit In SQLite for 17 | /// additional detail.) 18 | /// 19 | DELETE = 0, 20 | 21 | /// 22 | /// The TRUNCATE journaling mode commits transactions by truncating the rollback journal 23 | /// to zero-length instead of deleting it. On many systems, truncating a file is much faster 24 | /// than deleting the file since the containing directory does not need to be changed. 25 | /// 26 | TRUNCATE = 1, 27 | 28 | /// 29 | /// The PERSIST journaling mode prevents the rollback journal from being deleted at the end 30 | /// of each transaction. Instead, the header of the journal is overwritten with zeros. This 31 | /// will prevent other database connections from rolling the journal back. The PERSIST journaling 32 | /// mode is useful as an optimization on platforms where deleting or truncating a file is much 33 | /// more expensive than overwriting the first block of a file with zeros. See also: PRAGMA 34 | /// journal_size_limit and SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT. 35 | /// 36 | PERSIST = 2, 37 | 38 | /// 39 | /// The MEMORY journaling mode stores the rollback journal in volatile RAM. This saves disk I/O 40 | /// but at the expense of database safety and integrity. If the application using SQLite crashes 41 | /// in the middle of a transaction when the MEMORY journaling mode is set, then the database file 42 | /// will very likely go corrupt. 43 | /// 44 | MEMORY = 3, 45 | 46 | /// 47 | /// Indicates the WAL Journal Mode 48 | /// WAL mode is persisted as documented here: https://sqlite.org/wal.html 49 | /// 50 | WAL = 4, 51 | 52 | /// 53 | /// The OFF journaling mode disables the rollback journal completely. No rollback journal is ever 54 | /// created and hence there is never a rollback journal to delete. The OFF journaling mode disables 55 | /// the atomic commit and rollback capabilities of SQLite. The ROLLBACK command no longer works; it 56 | /// behaves in an undefined way. Applications must avoid using the ROLLBACK command when the journal 57 | /// mode is OFF. If the application crashes in the middle of a transaction when the OFF journaling 58 | /// mode is set, then the database file will very likely go corrupt. 59 | /// 60 | OFF = 5 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/SolutionLibModels.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net461;netcoreapp3.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /source/Solution/SolutionLibModels/Xml/Storage.cs: -------------------------------------------------------------------------------- 1 | namespace SolutionModelsLib.Xml 2 | { 3 | using SolutionModelsLib.Interfaces; 4 | using SolutionModelsLib.Models; 5 | using System.IO; 6 | using System.Runtime.Serialization; 7 | using System.Xml; 8 | 9 | /// 10 | /// Implements methods to serialize and deserialze XML from/to 11 | /// file via , wich requires 12 | /// a reference on the System.Runtime.Serialization assembly. 13 | /// 14 | public class Storage 15 | { 16 | /// 17 | /// Writes the associated XML of class Model T into string and returns it. 18 | /// 19 | /// 20 | public static string WriteXmlToString(ISolutionModel rootModel) 21 | { 22 | using (var stringWriter = new StringWriter()) // Write Xml to string 23 | { 24 | XmlWriter xmlWriter = null; 25 | try 26 | { 27 | xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings 28 | { 29 | Indent = true, 30 | IndentChars = " ", 31 | CloseOutput = true 32 | }); 33 | 34 | var dataContractSerializer = new DataContractSerializer(typeof(SolutionModel)); 35 | dataContractSerializer.WriteObject(xmlWriter, rootModel); 36 | } 37 | finally 38 | { 39 | if (xmlWriter != null) 40 | xmlWriter.Close(); 41 | } 42 | 43 | return stringWriter.ToString(); 44 | } 45 | } 46 | 47 | /// 48 | /// Writes the associated XML of class Model T into a file. 49 | /// 50 | /// 51 | /// 52 | public static void WriteXmlToFile(string filename, ISolutionModel rootModel) 53 | { 54 | XmlWriter xmlWriter = null; 55 | try 56 | { 57 | var fileStream = new FileStream(filename, FileMode.Create); 58 | xmlWriter = XmlWriter.Create(fileStream, new XmlWriterSettings 59 | { 60 | Indent = true, 61 | IndentChars = " ", 62 | CloseOutput = true 63 | }); 64 | 65 | var dataContractSerializer = new DataContractSerializer(typeof(SolutionModel)); 66 | dataContractSerializer.WriteObject(xmlWriter, rootModel); 67 | } 68 | finally 69 | { 70 | if (xmlWriter != null) 71 | xmlWriter.Close(); 72 | } 73 | } 74 | 75 | /// 76 | /// Writes the associated XML of class Model T into a file. 77 | /// 78 | /// 79 | public static ISolutionModel ReadXmlFromFile(string filename) 80 | { 81 | XmlReader xmlReader = null; 82 | try 83 | { 84 | xmlReader = XmlReader.Create(filename, new XmlReaderSettings 85 | { 86 | CloseInput = true 87 | }); 88 | 89 | var dataContractSerializer = new DataContractSerializer(typeof(SolutionModel)); 90 | return (ISolutionModel)dataContractSerializer.ReadObject(xmlReader); 91 | } 92 | finally 93 | { 94 | if (xmlReader != null) 95 | xmlReader.Close(); 96 | } 97 | } 98 | 99 | /// 100 | /// Reads the associated XML of class Model T from a string into an 101 | /// instance of class model T and returns it. 102 | /// 103 | /// An exception is thrown if the XML appears to be invalid for class model T. 104 | /// 105 | /// 106 | public static ISolutionModel ReadXmlFromString(string input) 107 | { 108 | using (var inputStream = new StringReader(input)) 109 | { 110 | XmlReader xmlReader = null; 111 | try 112 | { 113 | xmlReader = XmlReader.Create(inputStream, new XmlReaderSettings 114 | { 115 | CloseInput = true 116 | }); 117 | 118 | var dataContractSerializer = new DataContractSerializer(typeof(SolutionModel)); 119 | return (SolutionModel)dataContractSerializer.ReadObject(xmlReader); 120 | } 121 | finally 122 | { 123 | if (xmlReader != null) 124 | xmlReader.Close(); 125 | } 126 | } 127 | } 128 | } 129 | } 130 | --------------------------------------------------------------------------------