mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-22 05:10:29 +03:00
Comment all classes WIP
This commit is contained in:
parent
70e976b4f5
commit
e30dffc419
@ -8,7 +8,7 @@ using NAPS2.Scan.Images;
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for document scanning drivers (e.g. WIA, TWAIN).
|
||||
/// An interface for document scanning drivers (WIA, TWAIN, SANE).
|
||||
/// </summary>
|
||||
public interface IScanDriver
|
||||
{
|
||||
|
@ -4,6 +4,9 @@ using System.Linq;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface used to create instances of IScanDriver based on the driver name.
|
||||
/// </summary>
|
||||
public interface IScanDriverFactory
|
||||
{
|
||||
IScanDriver Create(string driverName);
|
||||
|
@ -8,6 +8,10 @@ using NAPS2.Util;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// A high-level interface used for scanning.
|
||||
/// This abstracts away the logic of obtaining and using an instance of IScanDriver.
|
||||
/// </summary>
|
||||
public interface IScanPerformer
|
||||
{
|
||||
Task PerformScan(ScanProfile scanProfile, ScanParams scanParams, IWin32Window dialogParent, ISaveNotify notify, Action<ScannedImage> imageCallback);
|
||||
|
@ -7,6 +7,12 @@ using System.Xml.Serialization;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// A set of key-value options used for scanning.
|
||||
///
|
||||
/// This is only relevant for SANE. Currently NAPS2 does not actually support viewing/setting custom options.
|
||||
/// If someone was so inclined they could manually set them in the profiles.xml file.
|
||||
/// </summary>
|
||||
public class KeyValueScanOptions : Dictionary<string, string>, IXmlSerializable
|
||||
{
|
||||
public KeyValueScanOptions()
|
||||
|
@ -6,6 +6,10 @@ using System.Resources;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// An attribute used for enum values that assigns a string from a resources file.
|
||||
/// The string value is accessed using the ScanEnumExtensions.Description extension method.
|
||||
/// </summary>
|
||||
public class LocalizedDescriptionAttribute : DescriptionAttribute
|
||||
{
|
||||
private readonly string resourceName;
|
||||
|
@ -5,6 +5,9 @@ using System.Xml.Serialization;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// Used for compatibility when reading old profiles.xml files.
|
||||
/// </summary>
|
||||
[XmlInclude(typeof(OldExtendedScanSettings))]
|
||||
[XmlType("ScanSettings")]
|
||||
public class OldScanSettings
|
||||
@ -22,6 +25,9 @@ namespace NAPS2.Scan
|
||||
public bool IsDefault { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used for compatibility when reading old profiles.xml files.
|
||||
/// </summary>
|
||||
[XmlType("ExtendedScanSettings")]
|
||||
public class OldExtendedScanSettings : OldScanSettings
|
||||
{
|
||||
|
@ -4,6 +4,10 @@ using System.Linq;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// A representation for which patch code, if any, has been detected on a document.
|
||||
/// http://www.alliancegroup.co.uk/patch-codes.htm
|
||||
/// </summary>
|
||||
public enum PatchCode
|
||||
{
|
||||
None,
|
||||
|
@ -6,6 +6,10 @@ using ZXing;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// A wrapper around the ZXing library that detects patch codes.
|
||||
/// http://www.alliancegroup.co.uk/patch-codes.htm
|
||||
/// </summary>
|
||||
public class PatchCodeDetector
|
||||
{
|
||||
public static PatchCode Detect(Bitmap bitmap)
|
||||
|
@ -5,6 +5,11 @@ using NAPS2.Config;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// A class used to help keep profile names consistent across forms.
|
||||
///
|
||||
/// TODO: This should probably be replaced by an event handler system.
|
||||
/// </summary>
|
||||
public class ProfileNameTracker
|
||||
{
|
||||
private readonly IUserConfigManager userConfigManager;
|
||||
|
@ -4,6 +4,9 @@ using System.Linq;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// The representation of a scanning device identified by a driver.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ScanDevice
|
||||
{
|
||||
|
@ -7,6 +7,9 @@ using NAPS2.Scan.Images;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// A base class for IScanDriver implementing common error handling.
|
||||
/// </summary>
|
||||
public abstract class ScanDriverBase : IScanDriver
|
||||
{
|
||||
public abstract string DriverName { get; }
|
||||
|
@ -4,6 +4,10 @@ using System.Linq;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// Scan configuration that is separate from the user profile.
|
||||
/// This lets scans behave a bit differently in the Batch Scan window, NAPS2.Console, etc.
|
||||
/// </summary>
|
||||
public class ScanParams
|
||||
{
|
||||
public bool DetectPatchCodes { get; set; }
|
||||
|
@ -11,6 +11,10 @@ using NAPS2.Util;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// A high-level interface used for scanning.
|
||||
/// This abstracts away the logic of obtaining and using an instance of IScanDriver.
|
||||
/// </summary>
|
||||
public class ScanPerformer : IScanPerformer
|
||||
{
|
||||
private readonly IScanDriverFactory driverFactory;
|
||||
|
@ -9,6 +9,9 @@ using NAPS2.Lang.Resources;
|
||||
|
||||
namespace NAPS2.Scan
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that stores user configuration for scanning, including device selection and other options.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ScanProfile
|
||||
{
|
||||
@ -115,6 +118,9 @@ namespace NAPS2.Scan
|
||||
public KeyValueScanOptions KeyValueOptions { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User configuration for the Auto Save feature, which saves to a file immediately after scanning.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AutoSaveSettings
|
||||
{
|
||||
@ -134,6 +140,9 @@ namespace NAPS2.Scan
|
||||
public SaveSeparator Separator { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The type of TWAIN driver implementation (this option is provided for compatibility).
|
||||
/// </summary>
|
||||
public enum TwainImpl
|
||||
{
|
||||
[LocalizedDescription(typeof(SettingsResources), "TwainImpl_Default")]
|
||||
@ -148,6 +157,9 @@ namespace NAPS2.Scan
|
||||
X64
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The physical source of the scanned image (flatbed, feeder).
|
||||
/// </summary>
|
||||
public enum ScanSource
|
||||
{
|
||||
[LocalizedDescription(typeof(SettingsResources), "Source_Glass")]
|
||||
@ -158,6 +170,9 @@ namespace NAPS2.Scan
|
||||
Duplex
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color depth used for scanning.
|
||||
/// </summary>
|
||||
public enum ScanBitDepth
|
||||
{
|
||||
[LocalizedDescription(typeof(SettingsResources), "BitDepth_24Color")]
|
||||
@ -168,6 +183,9 @@ namespace NAPS2.Scan
|
||||
BlackWhite
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The resolution used for scanning.
|
||||
/// </summary>
|
||||
public enum ScanDpi
|
||||
{
|
||||
[LocalizedDescription(typeof(SettingsResources), "Dpi_100")]
|
||||
@ -188,6 +206,9 @@ namespace NAPS2.Scan
|
||||
Dpi1200
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The physical location of the page relative to the scan area.
|
||||
/// </summary>
|
||||
public enum ScanHorizontalAlign
|
||||
{
|
||||
[LocalizedDescription(typeof(SettingsResources), "HorizontalAlign_Left")]
|
||||
@ -198,6 +219,9 @@ namespace NAPS2.Scan
|
||||
Right
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A scale factor used to shrink the scanned image.
|
||||
/// </summary>
|
||||
public enum ScanScale
|
||||
{
|
||||
[LocalizedDescription(typeof(SettingsResources), "Scale_1_1")]
|
||||
@ -210,6 +234,9 @@ namespace NAPS2.Scan
|
||||
OneToEight
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The page size used for scanning.
|
||||
/// </summary>
|
||||
public enum ScanPageSize
|
||||
{
|
||||
[LocalizedDescription(typeof(SettingsResources), "PageSize_Letter")]
|
||||
@ -237,6 +264,9 @@ namespace NAPS2.Scan
|
||||
Custom
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for a particular page size.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class PageDimensions
|
||||
{
|
||||
@ -272,6 +302,9 @@ namespace NAPS2.Scan
|
||||
public static bool operator !=(PageDimensions x, PageDimensions y) => !(x == y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for a user-created custom page size.
|
||||
/// </summary>
|
||||
public class NamedPageSize
|
||||
{
|
||||
public string Name { get; set; }
|
||||
@ -279,6 +312,9 @@ namespace NAPS2.Scan
|
||||
public PageDimensions Dimens { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper attribute used to assign physical dimensions to the ScanPageSize enum.
|
||||
/// </summary>
|
||||
public class PageDimensionsAttribute : Attribute
|
||||
{
|
||||
public PageDimensionsAttribute(string width, string height, PageSizeUnit unit)
|
||||
@ -294,6 +330,9 @@ namespace NAPS2.Scan
|
||||
public PageDimensions PageDimensions { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The unit used for Width and Height in PageDimensions.
|
||||
/// </summary>
|
||||
public enum PageSizeUnit
|
||||
{
|
||||
[LocalizedDescription(typeof(SettingsResources), "PageSizeUnit_Inch")]
|
||||
@ -304,6 +343,9 @@ namespace NAPS2.Scan
|
||||
Millimetre
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper extensions that get additional information from scan-related objects and enumerations.
|
||||
/// </summary>
|
||||
public static class ScanEnumExtensions
|
||||
{
|
||||
public static decimal WidthInMm(this PageDimensions pageDimensions)
|
||||
|
@ -5,6 +5,9 @@ using System.Windows.Forms;
|
||||
|
||||
namespace NAPS2.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// A trivial implementation of IWin32Window for use when serializing window handles cross-process.
|
||||
/// </summary>
|
||||
public class Win32Window : IWin32Window
|
||||
{
|
||||
public Win32Window(IntPtr hwnd)
|
||||
|
@ -5,6 +5,10 @@ using System.Windows.Forms;
|
||||
|
||||
namespace NAPS2.Worker
|
||||
{
|
||||
/// <summary>
|
||||
/// A basic implementation of an invisible form used in NAPS2.Worker.exe as a parent
|
||||
/// for any dialogs that may need to be displayed.
|
||||
/// </summary>
|
||||
public class BackgroundForm : Form
|
||||
{
|
||||
public BackgroundForm()
|
||||
|
@ -2,12 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.ServiceModel;
|
||||
using NAPS2.Operation;
|
||||
using NAPS2.Recovery;
|
||||
using NAPS2.Scan;
|
||||
|
||||
namespace NAPS2.Worker
|
||||
{
|
||||
/// <summary>
|
||||
/// The WCF service interface for NAPS2.Worker.exe.
|
||||
/// </summary>
|
||||
[ServiceContract]
|
||||
public interface IWorkerService
|
||||
{
|
||||
|
@ -4,6 +4,9 @@ using System.Linq;
|
||||
|
||||
namespace NAPS2.Worker
|
||||
{
|
||||
/// <summary>
|
||||
/// A factory interface to spawn NAPS2.Worker.exe instances as needed.
|
||||
/// </summary>
|
||||
public interface IWorkerServiceFactory
|
||||
{
|
||||
WorkerContext Create();
|
||||
|
@ -6,6 +6,11 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAPS2.Worker
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper class to provide access to Job Objects. This is used to group NAPS2.Worker.exe processes with
|
||||
/// the calling executable, so that there are no zombie processes left behind if the caller terminates.
|
||||
/// https://docs.microsoft.com/en-us/windows/desktop/procthread/job-objects
|
||||
/// </summary>
|
||||
public class Job : IDisposable
|
||||
{
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
|
@ -4,6 +4,9 @@ using System.Linq;
|
||||
|
||||
namespace NAPS2.Worker
|
||||
{
|
||||
/// <summary>
|
||||
/// A class storing the objects the client needs to use a NAPS2.Worker.exe instance.
|
||||
/// </summary>
|
||||
public class WorkerContext : IDisposable
|
||||
{
|
||||
public IWorkerService Service { get; set; }
|
||||
|
@ -11,6 +11,9 @@ using NAPS2.Platform;
|
||||
|
||||
namespace NAPS2.Worker
|
||||
{
|
||||
/// <summary>
|
||||
/// A class to manage the lifecycle of NAPS2.Worker.exe instances and hook up the WCF channels.
|
||||
/// </summary>
|
||||
public static class WorkerManager
|
||||
{
|
||||
public const string PIPE_NAME_FORMAT = "net.pipe://localhost/NAPS2.Worker/{0}";
|
||||
|
@ -4,8 +4,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.ServiceModel;
|
||||
using System.Windows.Forms;
|
||||
using NAPS2.ImportExport.Pdf;
|
||||
using NAPS2.Operation;
|
||||
using NAPS2.Recovery;
|
||||
using NAPS2.Scan;
|
||||
using NAPS2.Scan.Twain;
|
||||
@ -13,6 +11,9 @@ using NAPS2.Util;
|
||||
|
||||
namespace NAPS2.Worker
|
||||
{
|
||||
/// <summary>
|
||||
/// The WCF service implementation for NAPS2.Worker.exe.
|
||||
/// </summary>
|
||||
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single,
|
||||
IncludeExceptionDetailInFaults = true,
|
||||
ConcurrencyMode = ConcurrencyMode.Multiple)]
|
||||
|
Loading…
Reference in New Issue
Block a user