Implemented VirtualPrinterDriver project

This commit is contained in:
Marco Batzinger 2020-10-19 17:44:50 +02:00
parent f29c84821b
commit 5c87967c3f
125 changed files with 8191 additions and 0 deletions

View file

@ -0,0 +1,23 @@
using Autofac;
using VirtualPrinter.ProgressInfo.Core;
using VirtualPrinter.ProgressInfo.Core.Message;
using VirtualPrinter.ProgressInfo.Lib;
using VirtualPrinter.ProgressInfo.Lib.Interfaces;
using VirtualPrinter.ProgressInfo.Lib.Message;
namespace VirtualPrinter.ProgressInfo.Autofac
{
public class ProgressInfoModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<ProgressInfoBroker>().As<IProgressInfo>().SingleInstance();
builder.RegisterType<MessageFactory>().As<IMessageFactory>();
builder.RegisterType<Message>();
builder.RegisterType<ProgressInfoServerFactory>().As<IProgressInfoServerFactory>();
builder.RegisterType<ProgressInfoProcessManager>().As<IProgressInfoProcessManager>();
builder.RegisterType<ProgressInfoServer>().As<IProgressInfoServer>();
}
}
}

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("VirtualPrinter.ProgressInfo.Autofac")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("17e2cf8a-462c-4130-9faf-f1ca5fc4e06d")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,65 @@
<?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>{17E2CF8A-462C-4130-9FAF-F1CA5FC4E06D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VirtualPrinter.ProgressInfo.Autofac</RootNamespace>
<AssemblyName>VirtualPrinter.ProgressInfo.Autofac</AssemblyName>
<TargetFrameworkVersion>v4.6.1</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>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Files\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProgressInfoModule.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtualPrinter.ProgressInfo.Core\VirtualPrinter.ProgressInfo.Core.csproj">
<Project>{24D28558-C825-43E6-85D2-7C59F4A97698}</Project>
<Name>VirtualPrinter.ProgressInfo.Core</Name>
</ProjectReference>
<ProjectReference Include="..\VirtualPrinter.ProgressInfo.Lib\VirtualPrinter.ProgressInfo.Lib.csproj">
<Project>{d66f55e5-b3f7-4c61-a4f2-b55c4d412e01}</Project>
<Name>VirtualPrinter.ProgressInfo.Lib</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.0.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0-rc.2.20475.5" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.7.1" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0-rc.2.20475.5" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,11 @@
using VirtualPrinter.Agent.Core;
namespace VirtualPrinter.ProgressInfo.Core
{
public interface IProgressInfo
{
void Progress(IJob job, uint val);
void Initialize(IJob job);
void Finish(IJob job);
}
}

View file

@ -0,0 +1,6 @@
namespace VirtualPrinter.ProgressInfo.Core.Message
{
public interface IFinal : IMessage
{
}
}

View file

@ -0,0 +1,6 @@
namespace VirtualPrinter.ProgressInfo.Core.Message
{
public interface IMessage
{
}
}

View file

@ -0,0 +1,16 @@
using JetBrains.Annotations;
namespace VirtualPrinter.ProgressInfo.Core.Message
{
public interface IMessageFactory
{
[NotNull]
Message CreateStart();
[NotNull]
Message CreateStep(uint val);
[NotNull]
Message CreateFinal();
}
}

View file

@ -0,0 +1,6 @@
namespace VirtualPrinter.ProgressInfo.Core.Message
{
public interface IStart : IMessage
{
}
}

View file

@ -0,0 +1,7 @@
namespace VirtualPrinter.ProgressInfo.Core.Message
{
public interface IStep : IMessage
{
uint Value { get; set; }
}
}

View file

@ -0,0 +1,17 @@
using System;
namespace VirtualPrinter.ProgressInfo.Core.Message
{
[Serializable]
public class Message
{
public Message(MessageType type, uint val)
{
Type = type;
Value = val;
}
public MessageType Type { get; }
public uint Value { get; }
}
}

View file

@ -0,0 +1,11 @@
namespace VirtualPrinter.ProgressInfo.Core.Message
{
public enum MessageType : uint
{
None,
Initialize,
Finalize,
Step,
Close
}
}

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("VirtualPrinter.ProgressInfo.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("24d28558-c825-43e6-85d2-7c59f4a97698")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,57 @@
<?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>{24D28558-C825-43E6-85D2-7C59F4A97698}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VirtualPrinter.ProgressInfo.Core</RootNamespace>
<AssemblyName>VirtualPrinter.ProgressInfo.Core</AssemblyName>
<TargetFrameworkVersion>v4.6.1</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>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Files\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Message\IMessage.cs" />
<Compile Include="IProgressInfo.cs" />
<Compile Include="Message\IFinal.cs" />
<Compile Include="Message\IMessageFactory.cs" />
<Compile Include="Message\IStart.cs" />
<Compile Include="Message\IStep.cs" />
<Compile Include="Message\Message.cs" />
<Compile Include="Message\MessageType.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\VirtualPrinter.Agent.Core\VirtualPrinter.Agent.Core.csproj">
<Project>{135c85eb-2116-4cc4-8ccb-b6804b9d6467}</Project>
<Name>VirtualPrinter.Agent.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,13 @@
using VirtualPrinter.Agent.Core;
namespace VirtualPrinter.ProgressInfo.Lib.Interfaces
{
public interface IProgressInfoProcessManager
{
bool IsRunning();
void Run(IJob job);
void Stop();
}
}

View file

@ -0,0 +1,18 @@
using JetBrains.Annotations;
using NamedPipeWrapper;
namespace VirtualPrinter.ProgressInfo.Lib.Interfaces
{
public interface IProgressInfoServer
{
[CanBeNull]
event ConnectionEventHandler<Core.Message.Message, Core.Message.Message> ClientConnected;
void PushMessage([NotNull] Core.Message.Message message);
void Start();
void Stop();
}
}

View file

@ -0,0 +1,7 @@
namespace VirtualPrinter.ProgressInfo.Lib.Interfaces
{
public interface IProgressInfoServerFactory
{
IProgressInfoServer Create();
}
}

View file

@ -0,0 +1,37 @@
using System;
using JetBrains.Annotations;
using VirtualPrinter.ProgressInfo.Core.Message;
namespace VirtualPrinter.ProgressInfo.Lib.Message
{
public class MessageFactory : IMessageFactory
{
[NotNull]
private readonly Func<MessageType, uint, Core.Message.Message> _factory;
public MessageFactory([NotNull]Func<MessageType, uint, Core.Message.Message> factory)
{
_factory = factory;
}
public Core.Message.Message CreateStart()
{
return _factory(MessageType.Initialize, 0);
}
public Core.Message.Message CreateStep(uint val)
{
return _factory(MessageType.Step, val);
}
public Core.Message.Message CreateFinal()
{
return _factory(MessageType.Finalize, 0);
}
public Core.Message.Message CreateClose()
{
return _factory(MessageType.Close, 0);
}
}
}

View file

@ -0,0 +1,88 @@
using System;
using JetBrains.Annotations;
using NamedPipeWrapper;
using VirtualPrinter.Agent.Core;
using VirtualPrinter.Logging;
using VirtualPrinter.ProgressInfo.Core;
using VirtualPrinter.ProgressInfo.Core.Message;
using VirtualPrinter.ProgressInfo.Lib.Interfaces;
namespace VirtualPrinter.ProgressInfo.Lib
{
public class ProgressInfoBroker : IProgressInfo, IDisposable
{
[NotNull]
private readonly IVirtualPrinterLogger<ProgressInfoBroker> _logger;
[NotNull]
private readonly IMessageFactory _messageFactory;
[NotNull]
private readonly IProgressInfoServer _progressInfoServer;
[NotNull]
private readonly IProgressInfoProcessManager _progressInfoProcessManager;
public ProgressInfoBroker
(
[NotNull]IVirtualPrinterLogger<ProgressInfoBroker> logger,
[NotNull]IMessageFactory messageFactory,
[NotNull]IProgressInfoServerFactory progressInfoServerFactory,
[NotNull]IProgressInfoProcessManager progressProcessManager
)
{
_logger = logger;
_messageFactory = messageFactory;
_progressInfoProcessManager = progressProcessManager;
_progressInfoServer = progressInfoServerFactory.Create();
_progressInfoServer.ClientConnected += ServerOnClientConnected;
_progressInfoServer.Start();
}
public void Dispose()
{
_progressInfoProcessManager.Stop();
_progressInfoServer.Stop();
}
public void Progress(IJob job, uint val)
{
StartProgressAgentIfNotRunning(job);
_progressInfoServer.PushMessage(_messageFactory.CreateStep(val));
}
public void Initialize(IJob job)
{
StartProgressAgentIfNotRunning(job);
_progressInfoServer.PushMessage(_messageFactory.CreateStart());
}
public void Finish(IJob job)
{
_progressInfoServer.PushMessage(_messageFactory.CreateFinal());
Dispose();
}
private void ServerOnClientConnected(NamedPipeConnection<Core.Message.Message, Core.Message.Message> connection)
{
LogDebug("New Progress Client connected");
}
private void StartProgressAgentIfNotRunning(IJob job)
{
if(!_progressInfoProcessManager.IsRunning())
{
_progressInfoProcessManager.Run(job);
}
}
private void LogDebug(string message, params object[] args)
{
_logger.Debug(message, args);
}
}
}

View file

@ -0,0 +1,47 @@
using JetBrains.Annotations;
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using VirtualPrinter.Agent.Core;
using VirtualPrinter.ProgressInfo.Lib.Interfaces;
using VirtualPrinter.Utils;
namespace VirtualPrinter.ProgressInfo.Lib
{
[ExcludeFromCodeCoverage]
public class ProgressInfoProcessManager : IProgressInfoProcessManager
{
private const string ProcessName = "VPDAgentProgress";
public bool IsRunning()
{
return Process.GetProcesses().Any(pList => pList.ProcessName.Contains(ProcessName));
}
public void Run([NotNull]IJob job)
{
if (job == null)
{
throw new ArgumentNullException(nameof(job));
}
var path = Path.GetDirectoryName(typeof(ProgressInfoProcessManager).Assembly.Location);
var file = Path.Combine(path, ProcessName + ".exe");
new Shell().Execute(job.JobInfo, job.SessionInfo, file, null);
}
public void Stop()
{
var processes = Process.GetProcesses().Where(pList => pList.ProcessName.Contains(ProcessName));
foreach(var process in processes)
{
process.Kill();
}
}
}
}

View file

@ -0,0 +1,42 @@
using System.Diagnostics.CodeAnalysis;
using JetBrains.Annotations;
using NamedPipeWrapper;
using VirtualPrinter.ProgressInfo.Lib.Interfaces;
namespace VirtualPrinter.ProgressInfo.Lib
{
[ExcludeFromCodeCoverage]
public class ProgressInfoServer : IProgressInfoServer
{
[NotNull]
private readonly NamedPipeServer<Core.Message.Message> _server;
public ProgressInfoServer([NotNull] NamedPipeServer<Core.Message.Message> server)
{
_server = server;
_server.ClientConnected += ServerOnClientConnected;
}
public event ConnectionEventHandler<Core.Message.Message, Core.Message.Message> ClientConnected;
private void ServerOnClientConnected([CanBeNull] NamedPipeConnection<Core.Message.Message, Core.Message.Message> connection) => ClientConnected?.Invoke(connection);
public void PushMessage([CanBeNull] Core.Message.Message message)
{
_server.PushMessage(message);
}
public void Start()
{
_server.Start();
}
public void Stop()
{
_server.Stop();
}
}
}

View file

@ -0,0 +1,46 @@
using System;
using System.IO.Pipes;
using System.Security.AccessControl;
using System.Security.Principal;
using JetBrains.Annotations;
using NamedPipeWrapper;
using VirtualPrinter.ProgressInfo.Lib.Interfaces;
namespace VirtualPrinter.ProgressInfo.Lib
{
public class ProgressInfoServerFactory : IProgressInfoServerFactory
{
private const string PipeName = "vdpagent";
[NotNull]
private readonly Func<NamedPipeServer<Core.Message.Message>, IProgressInfoServer> _factorInfoServer;
public ProgressInfoServerFactory
(
[NotNull]Func<NamedPipeServer<Core.Message.Message>, IProgressInfoServer> factorInfoServer
)
{
_factorInfoServer = factorInfoServer;
}
public IProgressInfoServer Create()
{
var namedPipeServer = new NamedPipeServer<Core.Message.Message>(PipeName, GetPipeSecurity());
return _factorInfoServer(namedPipeServer);
}
[NotNull]
private static PipeSecurity GetPipeSecurity()
{
var security = new PipeSecurity();
security.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));
security.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null), PipeAccessRights.FullControl, AccessControlType.Allow));
return security;
}
}
}

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("VirtualPrinter.ProgressInfo.Lib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("d66f55e5-b3f7-4c61-a4f2-b55c4d412e01")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,74 @@
<?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>{D66F55E5-B3F7-4C61-A4F2-B55C4D412E01}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VirtualPrinter.ProgressInfo.Lib</RootNamespace>
<AssemblyName>VirtualPrinter.ProgressInfo.Lib</AssemblyName>
<TargetFrameworkVersion>v4.6.1</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>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Files\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Interfaces\IProgressInfoProcessManager.cs" />
<Compile Include="Interfaces\IProgressInfoServer.cs" />
<Compile Include="Interfaces\IProgressInfoServerFactory.cs" />
<Compile Include="Message\MessageFactory.cs" />
<Compile Include="ProgressInfoBroker.cs" />
<Compile Include="ProgressInfoProcessManager.cs" />
<Compile Include="ProgressInfoServer.cs" />
<Compile Include="ProgressInfoServerFactory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\VirtualPrinter.Agent.Core\VirtualPrinter.Agent.Core.csproj">
<Project>{135c85eb-2116-4cc4-8ccb-b6804b9d6467}</Project>
<Name>VirtualPrinter.Agent.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\VirtualPrinter.Agent.Lib\VirtualPrinter.Agent.Lib.csproj">
<Project>{94e8105f-5001-403b-b9f1-b0b0b236ad65}</Project>
<Name>VirtualPrinter.Agent.Lib</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\VirtualPrinter.Logging\VirtualPrinter.Logging.csproj">
<Project>{aa25364d-22d5-44b0-86a5-6fb14c686308}</Project>
<Name>VirtualPrinter.Logging</Name>
</ProjectReference>
<ProjectReference Include="..\..\Common\VirtualPrinter.Utils\VirtualPrinter.Utils.csproj">
<Project>{cd1c8e9d-5335-41ac-b0c0-88fd7c7c55f3}</Project>
<Name>VirtualPrinter.Utils</Name>
</ProjectReference>
<ProjectReference Include="..\VirtualPrinter.ProgressInfo.Core\VirtualPrinter.ProgressInfo.Core.csproj">
<Project>{24d28558-c825-43e6-85d2-7c59f4a97698}</Project>
<Name>VirtualPrinter.ProgressInfo.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="NamedPipeWrapper" Version="1.5.3-Beta" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,19 @@
using System;
using System.Windows.Forms;
namespace VirtualPrinter.ProgressInfo
{
internal static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ProgressForm());
}
}
}

View file

@ -0,0 +1,84 @@
namespace VirtualPrinter.ProgressInfo
{
partial class ProgressForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProgressForm));
this.lbProgress = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// lbProgress
//
this.lbProgress.AutoSize = true;
this.lbProgress.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbProgress.Location = new System.Drawing.Point(12, 60);
this.lbProgress.Name = "lbProgress";
this.lbProgress.Size = new System.Drawing.Size(113, 16);
this.lbProgress.TabIndex = 1;
this.lbProgress.Text = "0 pages converted";
//
// pictureBox1
//
this.pictureBox1.Image = global::VirtualPrinter.ProgressInfo.Properties.Resources.waiting;
this.pictureBox1.Location = new System.Drawing.Point(50, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(32, 35);
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
//
// ProgressForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(135, 83);
this.ControlBox = false;
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.lbProgress);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ProgressForm";
this.Opacity = 0.82D;
this.ShowInTaskbar = false;
this.Text = "AMAGNO Virtual Printer Progress";
this.TopMost = true;
this.Load += new System.EventHandler(this.ProgressForm_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lbProgress;
private System.Windows.Forms.PictureBox pictureBox1;
}
}

View file

@ -0,0 +1,84 @@
using NamedPipeWrapper;
using System;
using System.Windows.Forms;
using JetBrains.Annotations;
using VirtualPrinter.ProgressInfo.Core.Message;
namespace VirtualPrinter.ProgressInfo
{
public partial class ProgressForm : Form
{
private const string PipeName = "vdpagent";
public ProgressForm()
{
InitializeComponent();
var client = new NamedPipeClient<Core.Message.Message>(PipeName)
{
AutoReconnect = true
};
client.ServerMessage += ServerMessage;
client.Start(new TimeSpan(TimeSpan.TicksPerMinute));
}
private void ServerMessage(NamedPipeConnection<Core.Message.Message, Core.Message.Message> connection, [NotNull]Core.Message.Message message)
{
if (message == null)
{
throw new ArgumentNullException(nameof(message));
}
switch (message.Type) {
case MessageType.Finalize:
Invoke((Action) Finish);
break;
case MessageType.Initialize:
Invoke((Action) Initialize);
break;
case MessageType.Step:
Invoke((Action) (() => Progress(message.Value)));
break;
case MessageType.Close:
Invoke((Action) Dispose);
break;
case MessageType.None:
throw new ArgumentException("'None' is not a valid MessageType");
default:
throw new ArgumentOutOfRangeException();
}
}
private void Progress(uint val)
{
lbProgress.Text = $@"{val} pages converted";
}
private void Initialize()
{
PlaceToBottomRight();
Show();
BringToFront();
}
private void Finish()
{
Hide();
}
private void PlaceToBottomRight()
{
var desktopWorkingArea = Screen.PrimaryScreen.WorkingArea;
Left = desktopWorkingArea.Right - Width - 12;
Top = desktopWorkingArea.Bottom - Height - 12;
}
private void ProgressForm_Load(object sender, EventArgs e)
{
Initialize();
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("VirtualPrinter.ProgressInfo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("6579d542-ef21-4cf7-a9ec-7360eceb3bbb")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace VirtualPrinter.ProgressInfo.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VirtualPrinter.ProgressInfo.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap waiting {
get {
object obj = ResourceManager.GetObject("waiting", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="waiting" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\waiting.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace VirtualPrinter.ProgressInfo.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View file

@ -0,0 +1,90 @@
<?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>{6579D542-EF21-4CF7-A9EC-7360ECEB3BBB}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>VirtualPrinter.ProgressInfo</RootNamespace>
<AssemblyName>VPDAgentProgress</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Files\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\printer.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="ProgressForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ProgressForm.Designer.cs">
<DependentUpon>ProgressForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="ProgressForm.resx">
<DependentUpon>ProgressForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VirtualPrinter.ProgressInfo.Core\VirtualPrinter.ProgressInfo.Core.csproj">
<Project>{24d28558-c825-43e6-85d2-7c59f4a97698}</Project>
<Name>VirtualPrinter.ProgressInfo.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\printer.ico" />
<Content Include="Resources\waiting.gif" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="NamedPipeWrapper" Version="1.5.3-Beta" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>