diff --git a/ImageHandlingLibrary/Filing.cs b/ImageHandlingLibrary/Filing.cs new file mode 100644 index 0000000..1dbe12b --- /dev/null +++ b/ImageHandlingLibrary/Filing.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ImageHandlingLibrary +{ + public class Filing + { + + } +} diff --git a/ImageHandlingLibrary/ImageHandlingLibrary.csproj b/ImageHandlingLibrary/ImageHandlingLibrary.csproj new file mode 100644 index 0000000..7a03a1c --- /dev/null +++ b/ImageHandlingLibrary/ImageHandlingLibrary.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {CF1C98B6-5093-4B93-8B14-A0278B1AF724} + Library + Properties + ImageHandlingLibrary + ImageHandlingLibrary + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ImageHandlingLibrary/InterFaces/IRegistring.cs b/ImageHandlingLibrary/InterFaces/IRegistring.cs new file mode 100644 index 0000000..3e69784 --- /dev/null +++ b/ImageHandlingLibrary/InterFaces/IRegistring.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ImageHandlingLibrary.InterFaces +{ + public interface IRegistring + { + string GetRegistryRootDir(); + void SetRegistryValues(string rootDir); + } +} diff --git a/ImageHandlingLibrary/Properties/AssemblyInfo.cs b/ImageHandlingLibrary/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e61c373 --- /dev/null +++ b/ImageHandlingLibrary/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("ImageHandlingLibrary")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ImageHandlingLibrary")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[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("cf1c98b6-5093-4b93-8b14-a0278b1af724")] + +// 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")] diff --git a/ImageHandlingLibrary/Registring.cs b/ImageHandlingLibrary/Registring.cs new file mode 100644 index 0000000..c125b21 --- /dev/null +++ b/ImageHandlingLibrary/Registring.cs @@ -0,0 +1,59 @@ +using ImageHandlingLibrary.InterFaces; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ImageHandlingLibrary +{ + public class Registring :IRegistring + { + public Registring() + { + CU = Registry.CurrentUser; + } + public RegistryKey CU { get; set; } + + public string GetRegistryRootDir() + { + string output; + RegistryKey PictureHandling = CU.OpenSubKey(@"SOFTWARE\IdoIt4u\PictureHandling"); + if (PictureHandling == null) + { + output = @"D:\OurPictures"; + SetRegistryValues(output); + } + else + { + output = (string)PictureHandling.GetValue(@"RootMap"); + } + return output; + } + + public void SetRegistryValues(string rootDir) + { + RegistryKey IdoIt4u = CU.OpenSubKey(@"SOFTWARE\IdoIt4u", true); + RegistryKey PictureHandling = null; + if (IdoIt4u != null) + { + PictureHandling = IdoIt4u.OpenSubKey(@"PictureHandling", true); + } + + if (PictureHandling == null) + { + if (IdoIt4u == null) + { + IdoIt4u = Registry.CurrentUser.CreateSubKey(@"Software\IdoIt4u", true); + } + else + PictureHandling = IdoIt4u.CreateSubKey(@"PictureHandling", true); + } + else + { + PictureHandling.SetValue(@"RootMap", rootDir); + } + } + } +} diff --git a/ImageHandlingUI/Bootstrapper.cs b/ImageHandlingUI/Bootstrapper.cs index 2e82096..c2072e1 100644 --- a/ImageHandlingUI/Bootstrapper.cs +++ b/ImageHandlingUI/Bootstrapper.cs @@ -11,14 +11,57 @@ namespace ImageHandlingUI { public class Bootstrapper : BootstrapperBase { + // implementing SimpleContainer (dependency injection system in Caliburn micro) + private SimpleContainer _container = new SimpleContainer(); + public Bootstrapper() { Initialize(); } + // implementing SimpleContainer (dependency injection system in Caliburn micro) + // + protected override void Configure() + { + _container.Instance(_container); + + _container + .Singleton() + .Singleton(); + + GetType().Assembly.GetTypes() + .Where(type => type.IsClass) + .Where(type => type.Name.EndsWith("ViewModel")) + .ToList() + .ForEach(viewModelType => _container.RegisterPerRequest( + viewModelType, viewModelType.ToString(), viewModelType)); + } + // + // implementing SimpleContainer (dependency injection system in Caliburn micro) + protected override void OnStartup(object sender, StartupEventArgs e) { DisplayRootViewFor(); } + + // implementing SimpleContainer (dependency injection system in Caliburn micro) + // + protected override object GetInstance(Type service, string key) + { + return _container.GetInstance(service, key); + } + + protected override IEnumerable GetAllInstances(Type service) + { + return _container.GetAllInstances(service); + } + + protected override void BuildUp(object instance) + { + _container.BuildUp(instance); + } + // + // implementing SimpleContainer (dependency injection system in Caliburn micro) + } } diff --git a/PictureHandling/App.config b/PictureHandling/App.config index 56efbc7..b1f4bcd 100644 --- a/PictureHandling/App.config +++ b/PictureHandling/App.config @@ -1,6 +1,18 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/PictureHandling/PictureHandling.csproj b/PictureHandling/PictureHandling.csproj index b652691..9ee420e 100644 --- a/PictureHandling/PictureHandling.csproj +++ b/PictureHandling/PictureHandling.csproj @@ -34,13 +34,26 @@ 4 + + ..\packages\Autofac.5.2.0\lib\net461\Autofac.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.1\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + ..\packages\System.Collections.Specialized.4.3.0\lib\net46\System.Collections.Specialized.dll True True + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + @@ -60,6 +73,7 @@ + Form1.cs @@ -87,5 +101,11 @@ + + + {cf1c98b6-5093-4b93-8b14-a0278b1af724} + ImageHandlingLibrary + + \ No newline at end of file diff --git a/PictureHandling/Program.cs b/PictureHandling/Program.cs index 63347bb..1d42a03 100644 --- a/PictureHandling/Program.cs +++ b/PictureHandling/Program.cs @@ -1,4 +1,5 @@ -using System; +using Autofac; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -14,6 +15,10 @@ namespace PictureHandling [STAThread] static void Main() { + var containerBuilder = new ContainerBuilder(); + containerBuilder.RegisterModule(); + var container = containerBuilder.Build(); + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); diff --git a/PictureHandling/ProgramModule.cs b/PictureHandling/ProgramModule.cs new file mode 100644 index 0000000..d303662 --- /dev/null +++ b/PictureHandling/ProgramModule.cs @@ -0,0 +1,20 @@ +using Autofac; +using ImageHandlingLibrary; +using ImageHandlingLibrary.InterFaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PictureHandling +{ + class ProgramModule : Module + { + protected override void Load(ContainerBuilder builder) + { + builder.RegisterType().As(); + } + + } +} diff --git a/PictureHandling/packages.config b/PictureHandling/packages.config index edfe0fb..a867bb4 100644 --- a/PictureHandling/packages.config +++ b/PictureHandling/packages.config @@ -1,4 +1,8 @@  + + + + \ No newline at end of file diff --git a/PictureHandlingProject.sln b/PictureHandlingProject.sln index 2e6139a..de0d078 100644 --- a/PictureHandlingProject.sln +++ b/PictureHandlingProject.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PictureHandling", "PictureH EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageHandlingWPFUI", "ImageHandlingUI\ImageHandlingWPFUI.csproj", "{9F7FC0FF-02D4-4B31-8B8A-81B015483445}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageHandlingLibrary", "ImageHandlingLibrary\ImageHandlingLibrary.csproj", "{CF1C98B6-5093-4B93-8B14-A0278B1AF724}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {9F7FC0FF-02D4-4B31-8B8A-81B015483445}.Debug|Any CPU.Build.0 = Debug|Any CPU {9F7FC0FF-02D4-4B31-8B8A-81B015483445}.Release|Any CPU.ActiveCfg = Release|Any CPU {9F7FC0FF-02D4-4B31-8B8A-81B015483445}.Release|Any CPU.Build.0 = Release|Any CPU + {CF1C98B6-5093-4B93-8B14-A0278B1AF724}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF1C98B6-5093-4B93-8B14-A0278B1AF724}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF1C98B6-5093-4B93-8B14-A0278B1AF724}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF1C98B6-5093-4B93-8B14-A0278B1AF724}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE