Skip to content

Commit

Permalink
Review the TreeViewExample fixes #18
Browse files Browse the repository at this point in the history
  • Loading branch information
mpostol committed Jul 19, 2018
1 parent 86a03e1 commit 2cb2ba8
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
<ProjectGuid>{32EE831B-AD46-48AC-B303-23A6D818B8D5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TP.MVVMExample.UnitTest</RootNamespace>
<AssemblyName>TP.MVVMExample.UnitTest</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<RootNamespace>TP.GraphicalData</RootNamespace>
<AssemblyName>TP.GraphicalData.UnitTest</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Windows;
using TP.MVVMExample.Model;
using TP.MVVMExample.ViewModel;
using TP.GraphicalData.Model;
using TP.GraphicalData.ViewModel;

namespace TP.MVVMExample.UnitTest
namespace TP.GraphicalData
{
[TestClass]
public class MainViewModelUnitTest
Expand Down
2 changes: 1 addition & 1 deletion Lecture/P06.GraphicalData/GraphicalData/App.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Application x:Class="TP.MVVMExample.App"
<Application x:Class="TP.GraphicalData.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
Expand Down
26 changes: 13 additions & 13 deletions Lecture/P06.GraphicalData/GraphicalData/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
//____________________________________________________________________________
//
// Copyright (C) 2018, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/TP
//____________________________________________________________________________

using System.Windows;

namespace TP.MVVMExample
namespace TP.GraphicalData
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application { }

}
11 changes: 5 additions & 6 deletions Lecture/P06.GraphicalData/GraphicalData/GraphicalData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="DelegateExample.cs" />
<Compile Include="Model\DataLayerSimulator.cs" />
<Compile Include="Model\DataLayerr.cs" />
<Compile Include="MVVMLight\RelayCommand.cs" />
<Compile Include="MVVMLight\ViewModelBase.cs" />
<Compile Include="Model\User.cs" />
<Compile Include="TreeViewExample\DelegateCommand.cs" />
<Compile Include="TreeViewExample\ITreeViewItem.cs" />
<Compile Include="TreeViewExample\MainWindow.xaml.cs">
<Compile Include="TreeView\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="TreeViewExample\MyViewModel.cs" />
<Compile Include="TreeView\MyViewModel.cs" />
<Compile Include="TreeView\TreeViewItem.cs" />
<Compile Include="ViewModel\MainViewModel.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
Expand All @@ -81,7 +80,7 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="TreeViewExample\MainWindow.xaml">
<Page Include="TreeView\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@

//____________________________________________________________________________
//
// Copyright (C) 2018, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/TP
//____________________________________________________________________________

using System;
using System.Windows.Input;

namespace TP.MVVMExample.MVVMLight
namespace TP.GraphicalData.MVVMLight
{

/// <summary>
Expand All @@ -12,7 +18,7 @@ namespace TP.MVVMExample.MVVMLight
/// Execute and CanExecute callback methods.
/// </summary>
/// <remarks>The <see cref="CommandManager"/>handles automatic enabling/disabling of controls based on the CanExecute delegate.</remarks>
internal class RelayCommand : ICommand
public class RelayCommand : ICommand
{

#region constructors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@

///____________________________________________________________________________
//
// Copyright (C) 2018, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/TP
//____________________________________________________________________________

using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace TP.MVVMExample.MVVMLight
{
internal class ViewModelBase : INotifyPropertyChanged
public class ViewModelBase : INotifyPropertyChanged
{

#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
#endregion
Expand Down
5 changes: 2 additions & 3 deletions Lecture/P06.GraphicalData/GraphicalData/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Window x:Class="TP.MVVMExample.MainWindow"
<Window x:Class="TP.GraphicalData.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TP.MVVMExample"
xmlns:vm="clr-namespace:TP.MVVMExample.ViewModel"
xmlns:vm="clr-namespace:TP.GraphicalData.ViewModel"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="Auto">
<Window.Resources>
Expand Down
25 changes: 6 additions & 19 deletions Lecture/P06.GraphicalData/GraphicalData/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows;

namespace TP.MVVMExample
namespace TP.GraphicalData
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

using System.Collections.Generic;

namespace TP.MVVMExample.Model
namespace TP.GraphicalData.Model
{
internal class DataLayer
public class DataLayer
{
internal IEnumerable<User> User
public IEnumerable<User> User
{
get
{
Expand Down
2 changes: 1 addition & 1 deletion Lecture/P06.GraphicalData/GraphicalData/Model/User.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

using System;

namespace TP.MVVMExample.Model
namespace TP.GraphicalData.Model
{
/// <summary>
/// Class User - a class representing user
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WpfApplication2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -14,22 +10,7 @@
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]


[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
Expand All @@ -38,19 +19,7 @@
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: InternalsVisibleToAttribute("TP.MVVMExample.UnitTest")]
//[assembly: InternalsVisibleToAttribute("TP.MVVMExample.UnitTest")]

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using System.Windows.Input;

namespace TP.Lecture.TreeViewExample
namespace TP.GraphicalData
{
/// <summary>
/// Class DelegateCommand implements
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Window x:Class="TP.Lecture.TreeViewExample.MainWindow"
<Window x:Class="TP.GraphicalData.TreeView.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TP.Lecture.TreeViewExample"
mc:Ignorable="d"
Title="Aplikacja" Height="350" Width="525">
Title="Application title" Height="350" Width="525">
<Grid>
<TreeView Name="TreeView" Margin="312,19,8,23" RenderTransformOrigin="0.5,0.5" ItemsSource="{Binding HierarchicalAreas}">
<TreeView.ItemTemplate>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Windows;

namespace TP.Lecture.TreeViewExample
namespace TP.GraphicalData.TreeView
{
/// <summary>
/// Interaction logic for MainWindow.xaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
using Microsoft.Win32;
//____________________________________________________________________________
//
// Copyright (C) 2018, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/TP
//____________________________________________________________________________

using Microsoft.Win32;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using TP.GraphicalData.MVVMLight;

namespace TP.Lecture.TreeViewExample
namespace TP.GraphicalData.TreeView
{
/// <summary>
/// Class MyViewModel - ViewModel implementation
/// </summary>
/// <seealso cref="System.ComponentModel.INotifyPropertyChanged" />
public class MyViewModel : INotifyPropertyChanged
{

#region constructors
public MyViewModel()
{
HierarchicalAreas = new ObservableCollection<ITreeViewItem>();
Click_Button = new DelegateCommand(LoadDLL);
Click_Browse = new DelegateCommand(Browse);
HierarchicalAreas = new ObservableCollection<TreeViewItem>();
Click_Button = new RelayCommand(LoadDLL);
Click_Browse = new RelayCommand(Browse);
}
#endregion

#region DataContext
public ObservableCollection<ITreeViewItem> HierarchicalAreas { get; set; }
public string PathVariable
{
get { return pathVariable; }
set { pathVariable = value; }
}
public Visibility ChangeControlVisibility
{
get { return _visibility; }
set
{
_visibility = value;
}
}
public ObservableCollection<TreeViewItem> HierarchicalAreas { get; set; }
public string PathVariable { get; set; }
public Visibility ChangeControlVisibility { get; set; } = Visibility.Hidden;
public ICommand Click_Browse { get; }
public ICommand Click_Button { get; }
#endregion
Expand All @@ -49,16 +47,14 @@ private void RaisePropertyChanged(string propertyName_)
#endregion

#region private
private string pathVariable;
private Visibility _visibility = Visibility.Hidden;
private void LoadDLL()
{
if (pathVariable.Substring(pathVariable.Length - 4) == ".dll")
if (PathVariable.Substring(PathVariable.Length - 4) == ".dll")
TreeViewLoaded();
}
private void TreeViewLoaded()
{
ITreeViewItem rootItem = new ITreeViewItem { Name = pathVariable.Substring(pathVariable.LastIndexOf('\\') + 1) };
TreeViewItem rootItem = new TreeViewItem { Name = PathVariable.Substring(PathVariable.LastIndexOf('\\') + 1) };
HierarchicalAreas.Add(rootItem);
}
private void Browse()
Expand All @@ -67,13 +63,11 @@ private void Browse()
test.Filter = "Dynamic Library File(*.dll)| *.dll";
test.ShowDialog();
if (test.FileName.Length == 0)
{
MessageBox.Show("No files selected");
}
else
{
pathVariable = test.FileName;
_visibility = Visibility.Visible;
PathVariable = test.FileName;
ChangeControlVisibility = Visibility.Visible;
RaisePropertyChanged("ChangeControlVisibility");
RaisePropertyChanged("PathVariable");
}
Expand Down
Loading

0 comments on commit 2cb2ba8

Please sign in to comment.