Skip to content

Commit 8164326

Browse files
lipchevangularsen
andauthored
Update the Samples (v6) (#1479)
- projects converted to Sdk style - added a new Directory.Packages for the Samples folder and updated the references to the latest (working) versions - minor fixes to the UnitConverter.Wpf --------- Co-authored-by: Andreas Gullberg Larsen <[email protected]>
1 parent 804cf7e commit 8164326

17 files changed

+89
-357
lines changed

Samples/Directory.Packages.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageVersion Include="UnitsNet" Version="5.65.0" />
7+
<PackageVersion Include="MahApps.Metro" Version="2.4.10" />
8+
<PackageVersion Include="Prism.Container.Abstractions" Version="9.0.106" />
9+
<PackageVersion Include="Prism.Unity" Version="9.0.537" />
10+
<PackageVersion Include="Prism.Wpf" Version="9.0.537" />
11+
<PackageVersion Include="Unity.Abstractions" Version="5.11.7" />
12+
</ItemGroup>
13+
</Project>

Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
1616

1717
protected override Window CreateShell()
1818
{
19-
return new MainWindow();
19+
return Container.Resolve<MainWindow>();
2020
}
2121
}
2222
}

Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/UnitToStringConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Windows.Controls;
77
using System.Windows.Data;
88
using System.Windows.Markup;
9-
using CommonServiceLocator;
9+
using Prism.Ioc;
1010
using UnitsNet;
1111
using WpfMVVMSample.Settings;
1212

@@ -22,7 +22,7 @@ public UnitToStringConverter()
2222
{
2323
if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
2424
{
25-
_settings = ServiceLocator.Current.GetInstance<SettingsManager>();
25+
_settings = Prism.Ioc.ContainerLocator.Container.Resolve<SettingsManager>();
2626
}
2727
}
2828

Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Windows;
7-
using System.Windows.Controls;
8-
using System.Windows.Data;
9-
using System.Windows.Documents;
10-
using System.Windows.Input;
11-
using System.Windows.Media;
12-
using System.Windows.Media.Imaging;
13-
using System.Windows.Navigation;
14-
using System.Windows.Shapes;
1+
using System.Windows;
152

163
namespace WpfMVVMSample
174
{

Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindowViewModel.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
using Prism.Commands;
2-
using Prism.Mvvm;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
1+
using Prism.Mvvm;
82
using UnitsNet;
9-
using UnitsNet.Units;
10-
using WpfMVVMSample.Converters;
11-
using WpfMVVMSample.Properties;
123
using WpfMVVMSample.Settings;
134

145
namespace WpfMVVMSample
Lines changed: 11 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,25 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
42
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{B72F9215-70FF-4155-89BC-9A02CC550447}</ProjectGuid>
3+
<TargetFramework>net48</TargetFramework>
84
<OutputType>WinExe</OutputType>
95
<RootNamespace>WpfMVVMSample</RootNamespace>
10-
<AssemblyName>MvvmSample.Wpf</AssemblyName>
11-
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12-
<FileAlignment>512</FileAlignment>
13-
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14-
<WarningLevel>4</WarningLevel>
15-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16-
<TargetFrameworkProfile />
17-
</PropertyGroup>
18-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19-
<PlatformTarget>AnyCPU</PlatformTarget>
20-
<DebugSymbols>true</DebugSymbols>
21-
<DebugType>full</DebugType>
22-
<Optimize>false</Optimize>
23-
<OutputPath>bin\Debug\</OutputPath>
24-
<DefineConstants>DEBUG;TRACE</DefineConstants>
25-
<ErrorReport>prompt</ErrorReport>
26-
<WarningLevel>4</WarningLevel>
27-
</PropertyGroup>
28-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29-
<PlatformTarget>AnyCPU</PlatformTarget>
30-
<DebugType>pdbonly</DebugType>
31-
<Optimize>true</Optimize>
32-
<OutputPath>bin\Release\</OutputPath>
33-
<DefineConstants>TRACE</DefineConstants>
34-
<ErrorReport>prompt</ErrorReport>
35-
<WarningLevel>4</WarningLevel>
6+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
7+
<UseWPF>true</UseWPF>
8+
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
369
</PropertyGroup>
3710
<ItemGroup>
38-
<Reference Include="CommonServiceLocator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
39-
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\CommonServiceLocator.dll</HintPath>
40-
</Reference>
41-
<Reference Include="Prism, Version=7.1.0.431, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
42-
<HintPath>..\..\packages\Prism.Core.7.1.0.431\lib\net45\Prism.dll</HintPath>
43-
</Reference>
44-
<Reference Include="Prism.Unity.Wpf, Version=7.1.0.431, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
45-
<HintPath>..\..\packages\Prism.Unity.7.1.0.431\lib\net45\Prism.Unity.Wpf.dll</HintPath>
46-
</Reference>
47-
<Reference Include="Prism.Wpf, Version=7.1.0.431, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
48-
<HintPath>..\..\packages\Prism.Wpf.7.1.0.431\lib\net45\Prism.Wpf.dll</HintPath>
49-
</Reference>
50-
<Reference Include="System" />
11+
<PackageReference Include="Prism.Unity" />
12+
<PackageReference Include="Prism.Wpf" />
13+
</ItemGroup>
14+
<ItemGroup>
5115
<Reference Include="System.Configuration" />
52-
<Reference Include="System.Configuration.ConfigurationManager, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
53-
<HintPath>..\..\packages\System.Configuration.ConfigurationManager.4.5.0\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
54-
</Reference>
55-
<Reference Include="System.Data" />
5616
<Reference Include="System.Data.OracleClient" />
57-
<Reference Include="System.Drawing" />
5817
<Reference Include="System.Net" />
59-
<Reference Include="System.Security.AccessControl, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
60-
<HintPath>..\..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll</HintPath>
61-
</Reference>
62-
<Reference Include="System.Security.Permissions, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
63-
<HintPath>..\..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll</HintPath>
64-
</Reference>
65-
<Reference Include="System.Security.Principal.Windows, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
66-
<HintPath>..\..\packages\System.Security.Principal.Windows.4.5.1\lib\net461\System.Security.Principal.Windows.dll</HintPath>
67-
</Reference>
6818
<Reference Include="System.ServiceProcess" />
6919
<Reference Include="System.Transactions" />
70-
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
71-
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
72-
</Reference>
73-
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
74-
<HintPath>..\..\packages\Prism.Wpf.7.1.0.431\lib\net45\System.Windows.Interactivity.dll</HintPath>
75-
</Reference>
76-
<Reference Include="System.Xml" />
77-
<Reference Include="Microsoft.CSharp" />
78-
<Reference Include="System.Core" />
79-
<Reference Include="System.Xml.Linq" />
80-
<Reference Include="System.Data.DataSetExtensions" />
81-
<Reference Include="System.Net.Http" />
82-
<Reference Include="System.Xaml">
83-
<RequiredTargetFramework>4.0</RequiredTargetFramework>
84-
</Reference>
85-
<Reference Include="UnitsNet, Version=5.0.0.0, Culture=neutral, PublicKeyToken=f8601875a1f041da, processorArchitecture=MSIL">
86-
<HintPath>..\..\packages\UnitsNet.5.9.0\lib\netstandard2.0\UnitsNet.dll</HintPath>
87-
</Reference>
88-
<Reference Include="Unity.Abstractions, Version=3.3.1.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
89-
<HintPath>..\..\packages\Unity.Abstractions.3.3.1\lib\net47\Unity.Abstractions.dll</HintPath>
90-
</Reference>
91-
<Reference Include="Unity.Configuration, Version=5.2.5.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
92-
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.Configuration.dll</HintPath>
93-
</Reference>
94-
<Reference Include="Unity.Container, Version=5.8.11.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
95-
<HintPath>..\..\packages\Unity.Container.5.8.11\lib\net47\Unity.Container.dll</HintPath>
96-
</Reference>
97-
<Reference Include="Unity.Interception, Version=5.5.5.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
98-
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.Interception.dll</HintPath>
99-
</Reference>
100-
<Reference Include="Unity.Interception.Configuration, Version=5.1.7.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
101-
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.Interception.Configuration.dll</HintPath>
102-
</Reference>
103-
<Reference Include="Unity.RegistrationByConvention, Version=2.1.9.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
104-
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.RegistrationByConvention.dll</HintPath>
105-
</Reference>
106-
<Reference Include="Unity.ServiceLocation, Version=2.1.2.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
107-
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.ServiceLocation.dll</HintPath>
108-
</Reference>
109-
<Reference Include="WindowsBase" />
110-
<Reference Include="PresentationCore" />
111-
<Reference Include="PresentationFramework" />
112-
</ItemGroup>
113-
<ItemGroup>
114-
<ApplicationDefinition Include="App.xaml">
115-
<Generator>MSBuild:Compile</Generator>
116-
<SubType>Designer</SubType>
117-
</ApplicationDefinition>
118-
<Compile Include="Converters\EnumBindingSource.cs" />
119-
<Compile Include="Settings\SettingsManager.cs" />
120-
<Page Include="MainWindow.xaml">
121-
<Generator>MSBuild:Compile</Generator>
122-
<SubType>Designer</SubType>
123-
</Page>
124-
<Compile Include="App.xaml.cs">
125-
<DependentUpon>App.xaml</DependentUpon>
126-
<SubType>Code</SubType>
127-
</Compile>
128-
<Compile Include="Converters\UnitToStringConverter.cs" />
129-
<Compile Include="MainWindow.xaml.cs">
130-
<DependentUpon>MainWindow.xaml</DependentUpon>
131-
<SubType>Code</SubType>
132-
</Compile>
133-
</ItemGroup>
134-
<ItemGroup>
135-
<Compile Include="MainWindowViewModel.cs" />
136-
<Compile Include="Properties\AssemblyInfo.cs">
137-
<SubType>Code</SubType>
138-
</Compile>
139-
<Compile Include="Properties\Resources.Designer.cs">
140-
<AutoGen>True</AutoGen>
141-
<DesignTime>True</DesignTime>
142-
<DependentUpon>Resources.resx</DependentUpon>
143-
</Compile>
144-
<Compile Include="Properties\Settings.Designer.cs">
145-
<AutoGen>True</AutoGen>
146-
<DependentUpon>Settings.settings</DependentUpon>
147-
<DesignTimeSharedInput>True</DesignTimeSharedInput>
148-
</Compile>
149-
<EmbeddedResource Include="Properties\Resources.resx">
150-
<Generator>ResXFileCodeGenerator</Generator>
151-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
152-
</EmbeddedResource>
153-
<None Include="packages.config" />
154-
<None Include="Properties\Settings.settings">
155-
<Generator>SettingsSingleFileGenerator</Generator>
156-
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
157-
</None>
15820
</ItemGroup>
21+
15922
<ItemGroup>
160-
<None Include="App.config" />
23+
<PackageReference Include="UnitsNet" />
16124
</ItemGroup>
162-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
16325
</Project>

Samples/MvvmSample.Wpf/MvvmSample.Wpf/packages.config

Lines changed: 0 additions & 17 deletions
This file was deleted.

Samples/Samples.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmSample.Wpf", "MvvmSampl
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitConverter.Console", "UnitConverter.Console\UnitConverter.Console.csproj", "{B3141011-CEF2-46DE-B3DD-7FECD0D6108C}"
1111
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Files", "_Files", "{D3B39B9C-CE85-4929-A268-1AEBD945127C}"
13+
ProjectSection(SolutionItems) = preProject
14+
build.bat = build.bat
15+
Directory.Packages.props = Directory.Packages.props
16+
msbuild.cmd = msbuild.cmd
17+
EndProjectSection
18+
EndProject
1219
Global
1320
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1421
Debug|Any CPU = Debug|Any CPU
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
8-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
99

10-
<ItemGroup>
11-
<PackageReference Include="UnitsNet" Version="5.31.0" />
12-
</ItemGroup>
10+
<ItemGroup>
11+
<PackageReference Include="UnitsNet" />
12+
</ItemGroup>
1313

14-
</Project>
14+
</Project>

Samples/UnitConverter.Wpf/UnitConverter.Wpf/App.xaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
99
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
1010
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
11-
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
12-
<!-- Accent and AppTheme setting -->
13-
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
14-
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
11+
<!-- Theme setting -->
12+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
1513
</ResourceDictionary.MergedDictionaries>
1614
</ResourceDictionary>
1715
</Application.Resources>

Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.ObjectModel;
1+
using System.Collections.ObjectModel;
22
using System.ComponentModel;
33
using System.Windows.Input;
44
using UnitsNet.Samples.UnitConverter.Wpf.Properties;
@@ -23,8 +23,8 @@ public interface IMainWindowVm : INotifyPropertyChanged
2323

2424
string FromHeader { get; }
2525
string ToHeader { get; }
26-
decimal FromValue { get; set; }
27-
decimal ToValue { get; }
26+
double FromValue { get; set; }
27+
double ToValue { get; }
2828
ICommand SwapCommand { get; }
2929
}
3030
}

0 commit comments

Comments
 (0)