Browse Source

Ajout de 2 sous-projets : AryxDevLibrary4 qui contiendra des méthodes, basées sur le .net framework 4.0. AryxDevViewLibrary elle est une librairie qui contiendra des méthodes pour tout ce qui concerne les vues et les méthodes associées.

FileUtils : Correction sur IsSubElementOf().
Logger : déport de l'écriture de le fichier log dans une méthode surchargeable.
Aryx 1 year ago
parent
commit
3670df9dbd

+ 6 - 0
AryxDevLibrary.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+    <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
+  </PropertyGroup>
+</Project>

+ 12 - 0
AryxDevLibrary.sln

@@ -7,6 +7,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AryxDevLibrary", "AryxDevLi
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AryxUtilsTest", "..\AryxDevLibraryTest\AryxUtilsTest\AryxUtilsTest.csproj", "{5887C441-06CE-422D-A32C-21A772FEBC7A}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AryxDevViewLibrary", "AryxDevViewLibrary\AryxDevViewLibrary.csproj", "{F5A272A6-54F0-44A3-B44D-725130007110}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AryxDevLibrary4", "AryxDevLibrary4.0\AryxDevLibrary4.csproj", "{E852C0DA-78EE-4A7B-BC6E-6BC2E43E9537}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -21,6 +25,14 @@ Global
 		{5887C441-06CE-422D-A32C-21A772FEBC7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{5887C441-06CE-422D-A32C-21A772FEBC7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{5887C441-06CE-422D-A32C-21A772FEBC7A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F5A272A6-54F0-44A3-B44D-725130007110}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F5A272A6-54F0-44A3-B44D-725130007110}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F5A272A6-54F0-44A3-B44D-725130007110}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F5A272A6-54F0-44A3-B44D-725130007110}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E852C0DA-78EE-4A7B-BC6E-6BC2E43E9537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E852C0DA-78EE-4A7B-BC6E-6BC2E43E9537}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E852C0DA-78EE-4A7B-BC6E-6BC2E43E9537}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E852C0DA-78EE-4A7B-BC6E-6BC2E43E9537}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 6 - 0
AryxDevLibrary.sln.DotSettings.user

@@ -0,0 +1,6 @@
+<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/CodeStyle/LiveTemplatesUseVar/PreferVar/@EntryValue">False</s:Boolean>
+	<s:Boolean x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=DFDF32E702B84FA78B33EA1E039F9410/@KeyIndexDefined">True</s:Boolean>
+	<s:Int64 x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=DFDF32E702B84FA78B33EA1E039F9410/GroupingIndex/@EntryValue">4</s:Int64>
+	<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=DFDF32E702B84FA78B33EA1E039F9410/Name/@EntryValue">TextOrDefault</s:String>
+	<s:String x:Key="/Default/Housekeeping/UnitTestingMru/UnitTestSessionPersistentData/=DFDF32E702B84FA78B33EA1E039F9410/XmlSerializedElements/@EntryValue">&lt;Session&gt;&lt;e Id="AryxUtilsTest.DateUtilsTest" Project="5887C441-06CE-422D-A32C-21A772FEBC7A" Provider="MSTest" /&gt;&lt;e Id="AryxUtilsTest.DateUtilsTest.GetRelativePath" Project="5887C441-06CE-422D-A32C-21A772FEBC7A" Provider="MSTest" /&gt;&lt;/Session&gt;</s:String></wpf:ResourceDictionary>

BIN
AryxDevLibrary.v12.suo


+ 53 - 0
AryxDevLibrary4.0/AryxDevLibrary4.csproj

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{E852C0DA-78EE-4A7B-BC6E-6BC2E43E9537}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>AryxDevLibrary4</RootNamespace>
+    <AssemblyName>AryxDevLibrary4</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</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\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Class1.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 6 - 0
AryxDevLibrary4.0/Class1.cs

@@ -0,0 +1,6 @@
+namespace AryxDevLibrary4
+{
+    public class Class1
+    {
+    }
+}

+ 36 - 0
AryxDevLibrary4.0/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Les informations générales relatives à un assembly dépendent de 
+// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
+// associées à un assembly.
+[assembly: AssemblyTitle("AryxDevLibrary for .net4.0")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AryxDevLibrary4.0")]
+[assembly: AssemblyCopyright("Copyright ©  2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 
+// aux composants COM.  Si vous devez accéder à un type dans cet assembly à partir de 
+// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
+[assembly: ComVisible(false)]
+
+// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
+[assembly: Guid("a54d92a1-3ee5-4aff-9ec4-352973fa6361")]
+
+// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
+//
+//      Version principale
+//      Version secondaire 
+//      Numéro de build
+//      Révision
+//
+// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 
+// en utilisant '*', comme indiqué ci-dessous :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 57 - 0
AryxDevViewLibrary/AryxDevViewLibrary.csproj

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{F5A272A6-54F0-44A3-B44D-725130007110}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>AryxDevViewLibrary</RootNamespace>
+    <AssemblyName>AryxDevViewLibrary</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</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\Release\</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.Windows.Forms" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="WindowsBase" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="utils\ClipboardNotification.cs" />
+    <Compile Include="utils\DgColumnExtended.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 36 - 0
AryxDevViewLibrary/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Les informations générales relatives à un assembly dépendent de 
+// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
+// associées à un assembly.
+[assembly: AssemblyTitle("AryxDevViewLibrary")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AryxDevViewLibrary")]
+[assembly: AssemblyCopyright("Copyright ©  2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 
+// aux composants COM.  Si vous devez accéder à un type dans cet assembly à partir de 
+// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
+[assembly: ComVisible(false)]
+
+// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
+[assembly: Guid("c08ecd44-51b2-4623-9910-24f0a54428c2")]
+
+// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
+//
+//      Version principale
+//      Version secondaire 
+//      Numéro de build
+//      Révision
+//
+// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 
+// en utilisant '*', comme indiqué ci-dessous :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 70 - 0
AryxDevViewLibrary/utils/ClipboardNotification.cs

@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+
+namespace AryxDevViewLibrary.utils
+{
+    public class ClipboardNotification
+    {
+        /// <summary>
+        /// Occurs when the contents of the clipboard is updated.
+        /// </summary>
+        public static event EventHandler ClipboardUpdate;
+
+        private static NotificationForm _form = new NotificationForm();
+
+        /// <summary>
+        /// Raises the <see cref="ClipboardUpdate"/> event.
+        /// </summary>
+        /// <param name="e">Event arguments for the event.</param>
+        private static void OnClipboardUpdate(EventArgs e)
+        {
+            var handler = ClipboardUpdate;
+            if (handler != null)
+            {
+                handler(null, e);
+            }
+        }
+
+        /// <summary>
+        /// Hidden form to recieve the WM_CLIPBOARDUPDATE message.
+        /// </summary>
+        private class NotificationForm : Form
+        {
+            public NotificationForm()
+            {
+                NativeMethods.SetParent(Handle, NativeMethods.HWND_MESSAGE);
+                NativeMethods.AddClipboardFormatListener(Handle);
+            }
+
+            protected override void WndProc(ref Message m)
+            {
+                if (m.Msg == NativeMethods.WM_CLIPBOARDUPDATE)
+                {
+                    OnClipboardUpdate(null);
+                }
+                base.WndProc(ref m);
+            }
+        }
+    }
+
+    internal static class NativeMethods
+    {
+        // See http://msdn.microsoft.com/en-us/library/ms649021%28v=vs.85%29.aspx
+        public const int WM_CLIPBOARDUPDATE = 0x031D;
+        public static IntPtr HWND_MESSAGE = new IntPtr(-3);
+
+        // See http://msdn.microsoft.com/en-us/library/ms632599%28VS.85%29.aspx#message_only
+        [DllImport("user32.dll", SetLastError = true)]
+        [return: MarshalAs(UnmanagedType.Bool)]
+        public static extern bool AddClipboardFormatListener(IntPtr hwnd);
+
+        // See http://msdn.microsoft.com/en-us/library/ms633541%28v=vs.85%29.aspx
+        // See http://msdn.microsoft.com/en-us/library/ms649033%28VS.85%29.aspx
+        [DllImport("user32.dll", SetLastError = true)]
+        public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
+    }
+}

+ 17 - 0
AryxDevViewLibrary/utils/DgColumnExtended.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace AryxDevViewLibrary.utils
+{
+    public class DgColumnExtended : DataGridTextColumn
+    {
+
+        public String BasePropName { get; set; }
+
+    }
+
+}

+ 6 - 1
utils/FileUtils.cs

@@ -125,7 +125,12 @@ namespace AryxDevLibrary.utils
             }
 
             String[] pathSplitted = path.SplitByStr(@"\");
-            String[] parentSplitted = path.SplitByStr(@"\");
+            String[] parentSplitted = parentToCheck.SplitByStr(@"\");
+
+            if (pathSplitted.Length <= parentSplitted.Length)
+            {
+                return false;
+            }
 
             for (int i = 0; i < parentSplitted.Length; i++)
             {

+ 3 - 1
utils/logger/Logger.cs

@@ -186,13 +186,15 @@ namespace AryxDevLibrary.utils.logger
             }
         }
 
-        protected void WriteLineToLogFile(string lines, string levelLbl, string lineFormatted)
+        protected virtual void WriteLineToLogFile(string lines, string levelLbl, string lineFormatted)
         {
             lock (lockObj)
             {
                 if (FileLog.Exists && MaxLogFileSizeBeforeRotate != null && FileLog.Length > FileUtils.HumanReadableSizeToLong(MaxLogFileSizeBeforeRotate))
                 {
+                    string fileLogB = FileLog.FullName;
                     FileLog.MoveTo(FileLog.FullName + "." + DateTime.Now.ToString("yyyyMMdd'T'HHmmss"));
+                    FileLog = new FileInfo(fileLogB);
                 }
 
                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(FileLog.FullName, true))