mirror of
				https://github.com/soukoku/ntwain.git
				synced 2025-11-01 01:02:25 +08:00 
			
		
		
		
	Added named state enum.
This commit is contained in:
		| @@ -156,6 +156,9 @@ | ||||
|     <Compile Include="..\NTwain\SourceEnableMode.cs"> | ||||
|       <Link>SourceEnableMode.cs</Link> | ||||
|     </Compile> | ||||
|     <Compile Include="..\NTwain\State.cs"> | ||||
|       <Link>State.cs</Link> | ||||
|     </Compile> | ||||
|     <Compile Include="..\NTwain\TransferErrorEventArgs.cs"> | ||||
|       <Link>TransferErrorEventArgs.cs</Link> | ||||
|     </Compile> | ||||
|   | ||||
| @@ -57,6 +57,13 @@ namespace NTwain | ||||
|         /// <value>The state.</value> | ||||
|         int State { get; } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets the named state value as defined by the TWAIN spec. | ||||
|         /// </summary> | ||||
|         /// <value> | ||||
|         /// The state. | ||||
|         /// </value> | ||||
|         State StateEx { get; } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Quick flag to check if the DSM has been opened. | ||||
|   | ||||
| @@ -88,6 +88,7 @@ | ||||
|     </Compile> | ||||
|     <Compile Include="Properties\VersionInfo.cs" /> | ||||
|     <Compile Include="Internals\TentativeStateCommitable.cs" /> | ||||
|     <Compile Include="State.cs" /> | ||||
|     <Compile Include="TransferErrorEventArgs.cs" /> | ||||
|     <Compile Include="TransferReadyEventArgs.cs" /> | ||||
|     <Compile Include="Triplets\DGControl\DGControl.Callback2.cs" /> | ||||
|   | ||||
							
								
								
									
										43
									
								
								NTwain/State.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								NTwain/State.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
|  | ||||
| namespace NTwain | ||||
| { | ||||
|     /// <summary> | ||||
|     /// The logical state of a TWAIN session. | ||||
|     /// </summary> | ||||
|     public enum State | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// The starting state, corresponds to state 1. | ||||
|         /// </summary> | ||||
|         DsmUnloaded = 1, | ||||
|         /// <summary> | ||||
|         /// The DSM library has been loaded, corresponds to state 2. | ||||
|         /// </summary> | ||||
|         DsmLoaded = 2, | ||||
|         /// <summary> | ||||
|         /// The DSM has been opened, corresponds to state 3. | ||||
|         /// </summary> | ||||
|         DsmOpened = 3, | ||||
|         /// <summary> | ||||
|         /// A data source has been opened, corresponds to state 4. | ||||
|         /// </summary> | ||||
|         SourceOpened = 4, | ||||
|         /// <summary> | ||||
|         /// A data source has been enabled, corresponds to state 5. | ||||
|         /// </summary> | ||||
|         SourceEnabled = 5, | ||||
|         /// <summary> | ||||
|         /// Data is ready for transfer from the source, corresponds to state 6. | ||||
|         /// </summary> | ||||
|         TransferReady = 6, | ||||
|         /// <summary> | ||||
|         /// Data is being transferred, corresponds to state 7. | ||||
|         /// </summary> | ||||
|         Transferring = 7 | ||||
|     }; | ||||
|  | ||||
| } | ||||
| @@ -41,7 +41,10 @@ namespace NTwain | ||||
|  | ||||
|             _appId = appId; | ||||
|             _ownedSources = new Dictionary<string, DataSource>(); | ||||
|             ((ITwainSessionInternal)this).ChangeState(1, false); | ||||
|             if (PlatformInfo.Current.IsSupported) | ||||
|             { | ||||
|                 ((ITwainSessionInternal)this).ChangeState(2, false); | ||||
|             } | ||||
| #if DEBUG | ||||
|             // defaults to false on release since it's only useful during dev | ||||
|             EnforceState = true; | ||||
| @@ -144,7 +147,7 @@ namespace NTwain | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         int _state; | ||||
|         int _state = 1; | ||||
|         /// <summary> | ||||
|         /// Gets the current state number as defined by the TWAIN spec. | ||||
|         /// </summary> | ||||
| @@ -165,6 +168,20 @@ namespace NTwain | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets the named state value as defined by the TWAIN spec. | ||||
|         /// </summary> | ||||
|         /// <value> | ||||
|         /// The state. | ||||
|         /// </value> | ||||
|         public State StateEx | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return (State)_state; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Quick flag to check if the DSM has been opened. | ||||
|         /// </summary> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 soukoku
					soukoku