mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-21 12:49:43 +03:00
Move transfer helpers to sub namespaces
This commit is contained in:
parent
1c542fa4ee
commit
4395abdca1
@ -5,7 +5,7 @@ using Eto.Drawing;
|
||||
using Eto.Forms;
|
||||
using Eto.WinForms;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.ImportExport;
|
||||
using NAPS2.ImportExport.Profiles;
|
||||
using NAPS2.Logging;
|
||||
using NAPS2.Scan;
|
||||
|
||||
|
@ -7,7 +7,7 @@ using Eto.WinForms;
|
||||
using Eto.WinForms.Forms;
|
||||
using NAPS2.Config;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.ImportExport;
|
||||
using NAPS2.ImportExport.Profiles;
|
||||
using NAPS2.Lang.Resources;
|
||||
using NAPS2.Scan;
|
||||
using NAPS2.Serialization;
|
||||
|
@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using Google.Protobuf;
|
||||
using NAPS2.Lang.Resources;
|
||||
using NAPS2.Logging;
|
||||
using NAPS2.Operation;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.Images.Transforms;
|
||||
using NAPS2.ImportExport.Images;
|
||||
using NAPS2.Serialization;
|
||||
|
||||
namespace NAPS2.ImportExport
|
||||
|
@ -5,7 +5,7 @@ using NAPS2.Images;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.Serialization;
|
||||
|
||||
namespace NAPS2.ImportExport
|
||||
namespace NAPS2.ImportExport.Images
|
||||
{
|
||||
public class ImageTransfer : TransferHelper<IEnumerable<ScannedImage>, ImageTransferData>
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package NAPS2.ImportExport;
|
||||
package NAPS2.ImportExport.Images;
|
||||
|
||||
import "Serialization/SerializedImage.proto";
|
||||
|
||||
@ -8,9 +8,3 @@ message ImageTransferData {
|
||||
int32 processId = 1;
|
||||
repeated NAPS2.Serialization.SerializedImage serializedImages = 2;
|
||||
}
|
||||
|
||||
message ProfileTransferData {
|
||||
int32 processId = 1;
|
||||
string scanProfileXml = 2;
|
||||
bool locked = 3;
|
||||
}
|
@ -2,7 +2,7 @@ using System.Diagnostics;
|
||||
using NAPS2.Scan;
|
||||
using NAPS2.Serialization;
|
||||
|
||||
namespace NAPS2.ImportExport
|
||||
namespace NAPS2.ImportExport.Profiles
|
||||
{
|
||||
public class ProfileTransfer : TransferHelper<ScanProfile, ProfileTransferData>
|
||||
{
|
@ -0,0 +1,9 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package NAPS2.ImportExport.Profiles;
|
||||
|
||||
message ProfileTransferData {
|
||||
int32 processId = 1;
|
||||
string scanProfileXml = 2;
|
||||
bool locked = 3;
|
||||
}
|
@ -3,10 +3,19 @@ using Google.Protobuf;
|
||||
|
||||
namespace NAPS2.ImportExport
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic helper for transferring data through copy/paste or drag/drop.
|
||||
/// </summary>
|
||||
/// <typeparam name="TInput">The domain type to be transferred.</typeparam>
|
||||
/// <typeparam name="TData">The protobuf type representing the transferred data.</typeparam>
|
||||
public abstract class TransferHelper<TInput, TData> where TData : IMessage<TData>, new()
|
||||
{
|
||||
private readonly string _typeName = typeof(TData).FullName;
|
||||
|
||||
/// <summary>
|
||||
/// Clears the clipboard and stores the serialized input.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
public void SetClipboard(TInput input)
|
||||
{
|
||||
Clipboard.Instance.Clear();
|
||||
@ -34,6 +43,11 @@ namespace NAPS2.ImportExport
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the domain type to the protobuf type for serialization.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
protected abstract TData AsData(TInput input);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ using NAPS2.Recovery;
|
||||
using NAPS2.Scan;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.ImportExport.Images;
|
||||
using NAPS2.Remoting.Worker;
|
||||
using NAPS2.Wia;
|
||||
using NAPS2.Update;
|
||||
|
@ -9,7 +9,7 @@ using Eto.Forms;
|
||||
using Eto.WinForms;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.ImportExport;
|
||||
using NAPS2.ImportExport.Images;
|
||||
|
||||
namespace NAPS2.WinForms
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user