1
0
mirror of https://github.com/DarthAffe/Arge.git synced 2022-11-28 19:26:16 +00:00

Created a startable application

This commit is contained in:
Darth Affe 2017-05-13 15:52:02 +02:00
parent 974d33ae3f
commit a688a343e9
15 changed files with 427 additions and 4 deletions

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{30BAC2D7-4FB2-4464-A573-00DC9F211AFE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Arge.API.Skin</RootNamespace>
<AssemblyName>Arge.API.Skin</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Resources\CachedResourceDictionary.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=resources/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// 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("Arge.API.Skin")]
[assembly: AssemblyDescription("Skin-API of Arge")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Wyrez")]
[assembly: AssemblyProduct("Arge.API.Skin")]
[assembly: AssemblyCopyright("Copyright © Wyrez 2017")]
[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)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("30bac2d7-4fb2-4464-a573-00dc9f211afe")]
// 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")]

View File

@ -0,0 +1,56 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
namespace Arge.API.Skin
{
public class CachedResourceDictionary : ResourceDictionary
{
#region Properties & Fields
// ReSharper disable InconsistentNaming
private static readonly List<string> _cachedDictionaries = new List<string>();
private static readonly ResourceDictionary _innerDictionary = new ResourceDictionary();
// ReSharper restore
public new Uri Source
{
get => null;
set
{
lock (_innerDictionary)
{
UpdateCache(value);
MergedDictionaries.Clear();
MergedDictionaries.Add(_innerDictionary);
}
}
}
#endregion
#region Methods
private static void UpdateCache(Uri source)
{
string uriPath = source.OriginalString;
if (_cachedDictionaries.Contains(uriPath)) return;
_cachedDictionaries.Add(uriPath);
ResourceDictionary newDictionary = new ResourceDictionary { Source = new Uri(uriPath, source.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative) };
CopyDictionaryEntries(newDictionary, _innerDictionary);
}
private static void CopyDictionaryEntries(IDictionary source, IDictionary target)
{
foreach (object key in source.Keys)
if (!target.Contains(key))
target.Add(key, source[key]);
}
#endregion
}
}

View File

@ -5,6 +5,10 @@ VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Arge", "Arge\Arge.csproj", "{4509B24A-6B26-41B0-8B62-1C4201317692}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "API", "API", "{D786947A-A8D7-485E-9726-839655841958}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Arge.API.Skin", "Arge.API.Skin\Arge.API.Skin.csproj", "{30BAC2D7-4FB2-4464-A573-00DC9F211AFE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,8 +19,15 @@ Global
{4509B24A-6B26-41B0-8B62-1C4201317692}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4509B24A-6B26-41B0-8B62-1C4201317692}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4509B24A-6B26-41B0-8B62-1C4201317692}.Release|Any CPU.Build.0 = Release|Any CPU
{30BAC2D7-4FB2-4464-A573-00DC9F211AFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30BAC2D7-4FB2-4464-A573-00DC9F211AFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30BAC2D7-4FB2-4464-A573-00DC9F211AFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30BAC2D7-4FB2-4464-A573-00DC9F211AFE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{30BAC2D7-4FB2-4464-A573-00DC9F211AFE} = {D786947A-A8D7-485E-9726-839655841958}
EndGlobalSection
EndGlobal

View File

@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Caliburn.Micro" publicKeyToken="8e5891231f2ed21f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.1.0" newVersion="1.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,7 +1,15 @@
<Application x:Class="Arge.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Arge">
xmlns:arge="clr-namespace:Arge"
xmlns:bootstrapper="clr-namespace:Arge.Bootstrapper">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<bootstrapper:ArgeBootstrapper x:Key="Bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@ -18,7 +18,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -27,14 +27,42 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Caliburn.Micro, Version=3.0.3.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.3.0.3\lib\net45\Caliburn.Micro.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform, Version=3.0.3.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.3\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.0.3.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.3\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
<HintPath>..\packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.Unity.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
<HintPath>..\packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.Configuration.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.Unity.RegistrationByConvention, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
<HintPath>..\packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.RegistrationByConvention.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.3\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@ -57,8 +85,15 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Bootstrapper\UnityBootstrapper.cs" />
<Compile Include="ViewModels\AbstractViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="Views\ShellView.xaml.cs">
<DependentUpon>ShellView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Bootstrapper\ArgeBootstrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@ -76,6 +111,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -84,5 +120,12 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="Views\ShellView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Windows;
using Arge.ViewModels;
namespace Arge.Bootstrapper
{
public class ArgeBootstrapper : UnityBootstrapper
{
#region Methods
protected override void RegisterTypes()
{
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
Dictionary<string, object> settings = new Dictionary<string, object>
{
{ "Title", "Arge" },
{ "SizeToContent", SizeToContent.Manual },
{ "Width" , 1280 },
{ "Height" , 720 }
};
DisplayRootViewFor<ShellViewModel>(settings);
}
#endregion
}
}

View File

@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using Caliburn.Micro;
using Microsoft.Practices.Unity;
namespace Arge.Bootstrapper
{
public abstract class UnityBootstrapper : BootstrapperBase
{
#region Properties & Fields
protected IUnityContainer Container;
#endregion
#region Constructors
protected UnityBootstrapper()
{
Initialize();
}
#endregion
#region Methods
protected override void Configure()
{
Container = new UnityContainer();
RegisterSingleton(Container);
RegisterInterface<IWindowManager, WindowManager>();
RegisterInterface<IEventAggregator, EventAggregator>();
}
protected abstract void RegisterTypes();
protected override object GetInstance(Type service, string key)
{
return key != null ? Container.Resolve(service, key) : Container.Resolve(service);
}
protected override IEnumerable<object> GetAllInstances(Type service)
{
return Container.ResolveAll(service);
}
protected override void BuildUp(object instance)
{
instance = Container.BuildUp(instance);
base.BuildUp(instance);
}
#region Container-Registration
protected void RegisterInterface<TInterface, TImplementation>(bool registerTypeToo = true, bool registerAsSingleton = true, string uniqueName = null)
where TImplementation : TInterface
{
RegisterTypeIfMissing(typeof(TInterface), typeof(TImplementation), registerAsSingleton, uniqueName);
if (registerTypeToo)
RegisterTypeIfMissing(typeof(TImplementation), typeof(TImplementation), registerAsSingleton, uniqueName);
}
protected void RegisterSingleton<T>()
{
RegisterTypeIfMissing(typeof(T), typeof(T), true);
}
protected void RegisterSingleton<T>(T instance)
{
Container.RegisterInstance(typeof(T), instance, new ContainerControlledLifetimeManager());
}
protected void RegisterTypeIfMissing(Type fromType, Type toType, bool registerAsSingleton, string uniqueName = null)
{
if (fromType == null)
throw new ArgumentNullException(nameof(fromType));
if (toType == null)
throw new ArgumentNullException(nameof(toType));
if (!Container.IsRegistered(fromType))
{
if (registerAsSingleton)
Container.RegisterType(fromType, toType, uniqueName, new ContainerControlledLifetimeManager());
else
Container.RegisterType(fromType, toType, uniqueName);
}
}
#endregion
#endregion
}
}

View File

@ -0,0 +1,44 @@
using System.Runtime.CompilerServices;
using Caliburn.Micro;
namespace Arge.ViewModels
{
public abstract class AbstractViewModel : PropertyChangedBase
{
#region Method
/// <summary>
/// Checks if the property already matches the desirec value or needs to be updated.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to the backing-filed.</param>
/// <param name="value">Value to apply.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected virtual bool RequiresUpdate<T>(ref T storage, T value)
{
return !Equals(storage, value);
}
/// <summary>
/// Checks if the property already matches the desired value and updates it if not.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to the backing-filed.</param>
/// <param name="value">Value to apply.</param>
/// <param name="propertyName">Name of the property used to notify listeners. This value is optional
/// and can be provided automatically when invoked from compilers that support <see cref="CallerMemberNameAttribute"/>.</param>
/// <returns><c>true</c> if the value was changed, <c>false</c> if the existing value matched the desired value.</returns>
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (!RequiresUpdate(ref storage, value)) return false;
storage = value;
// ReSharper disable once ExplicitCallerInfoArgument
NotifyOfPropertyChange(propertyName);
return true;
}
#endregion
}
}

View File

@ -0,0 +1,6 @@
namespace Arge.ViewModels
{
public class ShellViewModel : AbstractViewModel
{
}
}

11
Arge/Views/ShellView.xaml Normal file
View File

@ -0,0 +1,11 @@
<UserControl x:Class="Arge.Views.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModels="clr-namespace:Arge.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ShellViewModel, IsDesignTimeCreatable=true}">
</UserControl>

View File

@ -0,0 +1,16 @@
using System.Windows.Controls;
namespace Arge.Views
{
public partial class ShellView : UserControl
{
#region Constructors
public ShellView()
{
InitializeComponent();
}
#endregion
}
}

7
Arge/packages.config Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caliburn.Micro" version="3.0.3" targetFramework="net45" />
<package id="Caliburn.Micro.Core" version="3.0.3" targetFramework="net45" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net45" />
<package id="Unity" version="4.0.1" targetFramework="net45" />
</packages>