1. ToFirstMonitor and ToSecondMonitor console app.added, 2. GenCode128 project added.
This commit is contained in:
parent
630f7d1e54
commit
f10be22c0b
8
.gitignore
vendored
8
.gitignore
vendored
@ -10,6 +10,8 @@ Encrypt/bin/
|
||||
Encrypt/obj/
|
||||
GemCard/bin
|
||||
GemCard/obj
|
||||
GenCode128/bin
|
||||
GenCode128/obj
|
||||
GraphLib/bin
|
||||
GraphLib/obj
|
||||
TracingDB/bin
|
||||
@ -24,8 +26,10 @@ Statistics/bin/
|
||||
Statistics/obj/
|
||||
TBF/bin/
|
||||
TBF/obj/
|
||||
TBFSetup/Debug/
|
||||
TBFSetup/Release/
|
||||
ToFirstMonitor/bin/
|
||||
ToFirstMonitor/obj/
|
||||
ToSecondMonitor/bin/
|
||||
ToSecondMonitor/obj/
|
||||
Users/bin/
|
||||
Users/obj/
|
||||
UserManagement/bin/
|
||||
|
||||
51
GenCode128/AssemblyInfo.cs
Normal file
51
GenCode128/AssemblyInfo.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System.Reflection;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("GenCode128")]
|
||||
[assembly: AssemblyDescription("GenCode128")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Chris Wuestefeld")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("2006 Chris Wuestefeld")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
139
GenCode128/Code128Code.cs
Normal file
139
GenCode128/Code128Code.cs
Normal file
@ -0,0 +1,139 @@
|
||||
namespace GenCode128
|
||||
{
|
||||
/// <summary>
|
||||
/// Static tools for determining codes for individual characters in the content
|
||||
/// </summary>
|
||||
public static class Code128Code
|
||||
{
|
||||
private const int CShift = 98;
|
||||
private const int CCodeA = 101;
|
||||
private const int CCodeB = 100;
|
||||
private const int CStartA = 103;
|
||||
private const int CStartB = 104;
|
||||
private const int CStop = 106;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates which code sets can represent a character -- CodeA, CodeB, or either
|
||||
/// </summary>
|
||||
public enum CodeSetAllowed
|
||||
{
|
||||
CodeA,
|
||||
CodeB,
|
||||
CodeAorB
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Code128 code value(s) to represent an ASCII character, with
|
||||
/// optional look-ahead for length optimization
|
||||
/// </summary>
|
||||
/// <param name="charAscii">The ASCII value of the character to translate</param>
|
||||
/// <param name="lookAheadAscii">The next character in sequence (or -1 if none)</param>
|
||||
/// <param name="currentCodeSet">The current codeset, that the returned codes need to follow;
|
||||
/// if the returned codes change that, then this value will be changed to reflect it</param>
|
||||
/// <returns>An array of integers representing the codes that need to be output to produce the
|
||||
/// given character</returns>
|
||||
public static int[] CodesForChar(int charAscii, int lookAheadAscii, ref CodeSet currentCodeSet)
|
||||
{
|
||||
int[] result;
|
||||
var shifter = -1;
|
||||
|
||||
if (!CharCompatibleWithCodeset(charAscii, currentCodeSet))
|
||||
{
|
||||
// if we have a lookahead character AND if the next character is ALSO not compatible
|
||||
if ((lookAheadAscii != -1) && !CharCompatibleWithCodeset(lookAheadAscii, currentCodeSet))
|
||||
{
|
||||
// we need to switch code sets
|
||||
switch (currentCodeSet)
|
||||
{
|
||||
case CodeSet.CodeA:
|
||||
shifter = CCodeB;
|
||||
currentCodeSet = CodeSet.CodeB;
|
||||
break;
|
||||
case CodeSet.CodeB:
|
||||
shifter = CCodeA;
|
||||
currentCodeSet = CodeSet.CodeA;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no need to switch code sets, a temporary SHIFT will suffice
|
||||
shifter = CShift;
|
||||
}
|
||||
}
|
||||
|
||||
if (shifter != -1)
|
||||
{
|
||||
result = new int[2];
|
||||
result[0] = shifter;
|
||||
result[1] = CodeValueForChar(charAscii);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new int[1];
|
||||
result[0] = CodeValueForChar(charAscii);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells us which codesets a given character value is allowed in
|
||||
/// </summary>
|
||||
/// <param name="charAscii">ASCII value of character to look at</param>
|
||||
/// <returns>Which codeset(s) can be used to represent this character</returns>
|
||||
public static CodeSetAllowed CodesetAllowedForChar(int charAscii)
|
||||
{
|
||||
if (charAscii >= 32 && charAscii <= 95)
|
||||
{
|
||||
return CodeSetAllowed.CodeAorB;
|
||||
}
|
||||
else
|
||||
{
|
||||
return charAscii < 32 ? CodeSetAllowed.CodeA : CodeSetAllowed.CodeB;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if a character can be represented in a given codeset
|
||||
/// </summary>
|
||||
/// <param name="charAscii">character to check for</param>
|
||||
/// <param name="currentCodeSet">codeset context to test</param>
|
||||
/// <returns>true if the codeset contains a representation for the ASCII character</returns>
|
||||
public static bool CharCompatibleWithCodeset(int charAscii, CodeSet currentCodeSet)
|
||||
{
|
||||
var csa = CodesetAllowedForChar(charAscii);
|
||||
return csa == CodeSetAllowed.CodeAorB || (csa == CodeSetAllowed.CodeA && currentCodeSet == CodeSet.CodeA)
|
||||
|| (csa == CodeSetAllowed.CodeB && currentCodeSet == CodeSet.CodeB);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the integer code128 code value for a character (assuming the appropriate code set)
|
||||
/// </summary>
|
||||
/// <param name="charAscii">character to convert</param>
|
||||
/// <returns>code128 symbol value for the character</returns>
|
||||
public static int CodeValueForChar(int charAscii)
|
||||
{
|
||||
return charAscii >= 32 ? charAscii - 32 : charAscii + 64;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the appropriate START code depending on the codeset we want to be in
|
||||
/// </summary>
|
||||
/// <param name="cs">The codeset you want to start in</param>
|
||||
/// <returns>The code128 code to start a barcode in that codeset</returns>
|
||||
public static int StartCodeForCodeSet(CodeSet cs)
|
||||
{
|
||||
return cs == CodeSet.CodeA ? CStartA : CStartB;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the Code128 stop code
|
||||
/// </summary>
|
||||
/// <returns>the stop code</returns>
|
||||
public static int StopCode()
|
||||
{
|
||||
return CStop;
|
||||
}
|
||||
}
|
||||
}
|
||||
97
GenCode128/Code128Content.cs
Normal file
97
GenCode128/Code128Content.cs
Normal file
@ -0,0 +1,97 @@
|
||||
namespace GenCode128
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Represent the set of code values to be output into barcode form
|
||||
/// </summary>
|
||||
public class Code128Content
|
||||
{
|
||||
/// <summary>
|
||||
/// Create content based on a string of ASCII data
|
||||
/// </summary>
|
||||
/// <param name="asciiData">the string that should be represented</param>
|
||||
public Code128Content(string asciiData)
|
||||
{
|
||||
this.Codes = this.StringToCode128(asciiData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides the Code128 code values representing the object's string
|
||||
/// </summary>
|
||||
public int[] Codes
|
||||
{
|
||||
get { return codes; }
|
||||
set { codes = value; }
|
||||
}
|
||||
int[] codes;
|
||||
|
||||
/// <summary>
|
||||
/// Transform the string into integers representing the Code128 codes
|
||||
/// necessary to represent it
|
||||
/// </summary>
|
||||
/// <param name="asciiData">String to be encoded</param>
|
||||
/// <returns>Code128 representation</returns>
|
||||
private int[] StringToCode128(string asciiData)
|
||||
{
|
||||
// turn the string into ascii byte data
|
||||
var asciiBytes = Encoding.ASCII.GetBytes(asciiData);
|
||||
|
||||
// decide which codeset to start with
|
||||
var csa1 = asciiBytes.Length > 0
|
||||
? Code128Code.CodesetAllowedForChar(asciiBytes[0])
|
||||
: Code128Code.CodeSetAllowed.CodeAorB;
|
||||
var csa2 = asciiBytes.Length > 1
|
||||
? Code128Code.CodesetAllowedForChar(asciiBytes[1])
|
||||
: Code128Code.CodeSetAllowed.CodeAorB;
|
||||
var currentCodeSet = this.GetBestStartSet(csa1, csa2);
|
||||
|
||||
// set up the beginning of the barcode
|
||||
// assume no codeset changes, account for start, checksum, and stop
|
||||
var codes = new ArrayList(asciiBytes.Length + 3) { Code128Code.StartCodeForCodeSet(currentCodeSet) };
|
||||
|
||||
// add the codes for each character in the string
|
||||
for (var i = 0; i < asciiBytes.Length; i++)
|
||||
{
|
||||
int thischar = asciiBytes[i];
|
||||
var nextchar = asciiBytes.Length > i + 1 ? asciiBytes[i + 1] : -1;
|
||||
|
||||
codes.AddRange(Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet));
|
||||
}
|
||||
|
||||
// calculate the check digit
|
||||
var checksum = (int)codes[0];
|
||||
for (var i = 1; i < codes.Count; i++)
|
||||
{
|
||||
checksum += i * (int)codes[i];
|
||||
}
|
||||
|
||||
codes.Add(checksum % 103);
|
||||
|
||||
codes.Add(Code128Code.StopCode());
|
||||
|
||||
var result = codes.ToArray(typeof(int)) as int[];
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the best starting code set based on the the first two
|
||||
/// characters of the string to be encoded
|
||||
/// </summary>
|
||||
/// <param name="csa1">First character of input string</param>
|
||||
/// <param name="csa2">Second character of input string</param>
|
||||
/// <returns>The codeset determined to be best to start with</returns>
|
||||
private CodeSet GetBestStartSet(Code128Code.CodeSetAllowed csa1, Code128Code.CodeSetAllowed csa2)
|
||||
{
|
||||
var vote = 0;
|
||||
|
||||
vote += csa1 == Code128Code.CodeSetAllowed.CodeA ? 1 : 0;
|
||||
vote += csa1 == Code128Code.CodeSetAllowed.CodeB ? -1 : 0;
|
||||
vote += csa2 == Code128Code.CodeSetAllowed.CodeA ? 1 : 0;
|
||||
vote += csa2 == Code128Code.CodeSetAllowed.CodeB ? -1 : 0;
|
||||
|
||||
return vote > 0 ? CodeSet.CodeA : CodeSet.CodeB; // ties go to codeB due to my own prejudices
|
||||
}
|
||||
}
|
||||
}
|
||||
188
GenCode128/Code128Rendering.cs
Normal file
188
GenCode128/Code128Rendering.cs
Normal file
@ -0,0 +1,188 @@
|
||||
namespace GenCode128
|
||||
{
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Code128Rendering.
|
||||
/// </summary>
|
||||
public static class Code128Rendering
|
||||
{
|
||||
private const int CQuietWidth = 10;
|
||||
|
||||
// Code patterns:
|
||||
// in principle these rows should each have 6 elements
|
||||
// however, the last one -- STOP -- has 7. The cost of the
|
||||
// extra integers is trivial, and this lets the code flow
|
||||
// much more elegantly
|
||||
private static readonly int[,] CPatterns =
|
||||
{
|
||||
{ 2, 1, 2, 2, 2, 2, 0, 0 }, // 0
|
||||
{ 2, 2, 2, 1, 2, 2, 0, 0 }, // 1
|
||||
{ 2, 2, 2, 2, 2, 1, 0, 0 }, // 2
|
||||
{ 1, 2, 1, 2, 2, 3, 0, 0 }, // 3
|
||||
{ 1, 2, 1, 3, 2, 2, 0, 0 }, // 4
|
||||
{ 1, 3, 1, 2, 2, 2, 0, 0 }, // 5
|
||||
{ 1, 2, 2, 2, 1, 3, 0, 0 }, // 6
|
||||
{ 1, 2, 2, 3, 1, 2, 0, 0 }, // 7
|
||||
{ 1, 3, 2, 2, 1, 2, 0, 0 }, // 8
|
||||
{ 2, 2, 1, 2, 1, 3, 0, 0 }, // 9
|
||||
{ 2, 2, 1, 3, 1, 2, 0, 0 }, // 10
|
||||
{ 2, 3, 1, 2, 1, 2, 0, 0 }, // 11
|
||||
{ 1, 1, 2, 2, 3, 2, 0, 0 }, // 12
|
||||
{ 1, 2, 2, 1, 3, 2, 0, 0 }, // 13
|
||||
{ 1, 2, 2, 2, 3, 1, 0, 0 }, // 14
|
||||
{ 1, 1, 3, 2, 2, 2, 0, 0 }, // 15
|
||||
{ 1, 2, 3, 1, 2, 2, 0, 0 }, // 16
|
||||
{ 1, 2, 3, 2, 2, 1, 0, 0 }, // 17
|
||||
{ 2, 2, 3, 2, 1, 1, 0, 0 }, // 18
|
||||
{ 2, 2, 1, 1, 3, 2, 0, 0 }, // 19
|
||||
{ 2, 2, 1, 2, 3, 1, 0, 0 }, // 20
|
||||
{ 2, 1, 3, 2, 1, 2, 0, 0 }, // 21
|
||||
{ 2, 2, 3, 1, 1, 2, 0, 0 }, // 22
|
||||
{ 3, 1, 2, 1, 3, 1, 0, 0 }, // 23
|
||||
{ 3, 1, 1, 2, 2, 2, 0, 0 }, // 24
|
||||
{ 3, 2, 1, 1, 2, 2, 0, 0 }, // 25
|
||||
{ 3, 2, 1, 2, 2, 1, 0, 0 }, // 26
|
||||
{ 3, 1, 2, 2, 1, 2, 0, 0 }, // 27
|
||||
{ 3, 2, 2, 1, 1, 2, 0, 0 }, // 28
|
||||
{ 3, 2, 2, 2, 1, 1, 0, 0 }, // 29
|
||||
{ 2, 1, 2, 1, 2, 3, 0, 0 }, // 30
|
||||
{ 2, 1, 2, 3, 2, 1, 0, 0 }, // 31
|
||||
{ 2, 3, 2, 1, 2, 1, 0, 0 }, // 32
|
||||
{ 1, 1, 1, 3, 2, 3, 0, 0 }, // 33
|
||||
{ 1, 3, 1, 1, 2, 3, 0, 0 }, // 34
|
||||
{ 1, 3, 1, 3, 2, 1, 0, 0 }, // 35
|
||||
{ 1, 1, 2, 3, 1, 3, 0, 0 }, // 36
|
||||
{ 1, 3, 2, 1, 1, 3, 0, 0 }, // 37
|
||||
{ 1, 3, 2, 3, 1, 1, 0, 0 }, // 38
|
||||
{ 2, 1, 1, 3, 1, 3, 0, 0 }, // 39
|
||||
{ 2, 3, 1, 1, 1, 3, 0, 0 }, // 40
|
||||
{ 2, 3, 1, 3, 1, 1, 0, 0 }, // 41
|
||||
{ 1, 1, 2, 1, 3, 3, 0, 0 }, // 42
|
||||
{ 1, 1, 2, 3, 3, 1, 0, 0 }, // 43
|
||||
{ 1, 3, 2, 1, 3, 1, 0, 0 }, // 44
|
||||
{ 1, 1, 3, 1, 2, 3, 0, 0 }, // 45
|
||||
{ 1, 1, 3, 3, 2, 1, 0, 0 }, // 46
|
||||
{ 1, 3, 3, 1, 2, 1, 0, 0 }, // 47
|
||||
{ 3, 1, 3, 1, 2, 1, 0, 0 }, // 48
|
||||
{ 2, 1, 1, 3, 3, 1, 0, 0 }, // 49
|
||||
{ 2, 3, 1, 1, 3, 1, 0, 0 }, // 50
|
||||
{ 2, 1, 3, 1, 1, 3, 0, 0 }, // 51
|
||||
{ 2, 1, 3, 3, 1, 1, 0, 0 }, // 52
|
||||
{ 2, 1, 3, 1, 3, 1, 0, 0 }, // 53
|
||||
{ 3, 1, 1, 1, 2, 3, 0, 0 }, // 54
|
||||
{ 3, 1, 1, 3, 2, 1, 0, 0 }, // 55
|
||||
{ 3, 3, 1, 1, 2, 1, 0, 0 }, // 56
|
||||
{ 3, 1, 2, 1, 1, 3, 0, 0 }, // 57
|
||||
{ 3, 1, 2, 3, 1, 1, 0, 0 }, // 58
|
||||
{ 3, 3, 2, 1, 1, 1, 0, 0 }, // 59
|
||||
{ 3, 1, 4, 1, 1, 1, 0, 0 }, // 60
|
||||
{ 2, 2, 1, 4, 1, 1, 0, 0 }, // 61
|
||||
{ 4, 3, 1, 1, 1, 1, 0, 0 }, // 62
|
||||
{ 1, 1, 1, 2, 2, 4, 0, 0 }, // 63
|
||||
{ 1, 1, 1, 4, 2, 2, 0, 0 }, // 64
|
||||
{ 1, 2, 1, 1, 2, 4, 0, 0 }, // 65
|
||||
{ 1, 2, 1, 4, 2, 1, 0, 0 }, // 66
|
||||
{ 1, 4, 1, 1, 2, 2, 0, 0 }, // 67
|
||||
{ 1, 4, 1, 2, 2, 1, 0, 0 }, // 68
|
||||
{ 1, 1, 2, 2, 1, 4, 0, 0 }, // 69
|
||||
{ 1, 1, 2, 4, 1, 2, 0, 0 }, // 70
|
||||
{ 1, 2, 2, 1, 1, 4, 0, 0 }, // 71
|
||||
{ 1, 2, 2, 4, 1, 1, 0, 0 }, // 72
|
||||
{ 1, 4, 2, 1, 1, 2, 0, 0 }, // 73
|
||||
{ 1, 4, 2, 2, 1, 1, 0, 0 }, // 74
|
||||
{ 2, 4, 1, 2, 1, 1, 0, 0 }, // 75
|
||||
{ 2, 2, 1, 1, 1, 4, 0, 0 }, // 76
|
||||
{ 4, 1, 3, 1, 1, 1, 0, 0 }, // 77
|
||||
{ 2, 4, 1, 1, 1, 2, 0, 0 }, // 78
|
||||
{ 1, 3, 4, 1, 1, 1, 0, 0 }, // 79
|
||||
{ 1, 1, 1, 2, 4, 2, 0, 0 }, // 80
|
||||
{ 1, 2, 1, 1, 4, 2, 0, 0 }, // 81
|
||||
{ 1, 2, 1, 2, 4, 1, 0, 0 }, // 82
|
||||
{ 1, 1, 4, 2, 1, 2, 0, 0 }, // 83
|
||||
{ 1, 2, 4, 1, 1, 2, 0, 0 }, // 84
|
||||
{ 1, 2, 4, 2, 1, 1, 0, 0 }, // 85
|
||||
{ 4, 1, 1, 2, 1, 2, 0, 0 }, // 86
|
||||
{ 4, 2, 1, 1, 1, 2, 0, 0 }, // 87
|
||||
{ 4, 2, 1, 2, 1, 1, 0, 0 }, // 88
|
||||
{ 2, 1, 2, 1, 4, 1, 0, 0 }, // 89
|
||||
{ 2, 1, 4, 1, 2, 1, 0, 0 }, // 90
|
||||
{ 4, 1, 2, 1, 2, 1, 0, 0 }, // 91
|
||||
{ 1, 1, 1, 1, 4, 3, 0, 0 }, // 92
|
||||
{ 1, 1, 1, 3, 4, 1, 0, 0 }, // 93
|
||||
{ 1, 3, 1, 1, 4, 1, 0, 0 }, // 94
|
||||
{ 1, 1, 4, 1, 1, 3, 0, 0 }, // 95
|
||||
{ 1, 1, 4, 3, 1, 1, 0, 0 }, // 96
|
||||
{ 4, 1, 1, 1, 1, 3, 0, 0 }, // 97
|
||||
{ 4, 1, 1, 3, 1, 1, 0, 0 }, // 98
|
||||
{ 1, 1, 3, 1, 4, 1, 0, 0 }, // 99
|
||||
{ 1, 1, 4, 1, 3, 1, 0, 0 }, // 100
|
||||
{ 3, 1, 1, 1, 4, 1, 0, 0 }, // 101
|
||||
{ 4, 1, 1, 1, 3, 1, 0, 0 }, // 102
|
||||
{ 2, 1, 1, 4, 1, 2, 0, 0 }, // 103
|
||||
{ 2, 1, 1, 2, 1, 4, 0, 0 }, // 104
|
||||
{ 2, 1, 1, 2, 3, 2, 0, 0 }, // 105
|
||||
{ 2, 3, 3, 1, 1, 1, 2, 0 } // 106
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Make an image of a Code128 barcode for a given string
|
||||
/// </summary>
|
||||
/// <param name="inputData">Message to be encoded</param>
|
||||
/// <param name="barWeight">Base thickness for bar width (1 or 2 works well)</param>
|
||||
/// <param name="addQuietZone">Add required horizontal margins (use if output is tight)</param>
|
||||
/// <returns>An Image of the Code128 barcode representing the message</returns>
|
||||
public static Image MakeBarcodeImage(string inputData, int barWeight, bool addQuietZone)
|
||||
{
|
||||
// get the Code128 codes to represent the message
|
||||
var content = new Code128Content(inputData);
|
||||
var codes = content.Codes;
|
||||
|
||||
var width = (((codes.Length - 3) * 11) + 35) * barWeight;
|
||||
var height = Convert.ToInt32(Math.Ceiling(Convert.ToSingle(width) * .15F));
|
||||
|
||||
if (addQuietZone)
|
||||
{
|
||||
width += 2 * CQuietWidth * barWeight; // on both sides
|
||||
}
|
||||
|
||||
// get surface to draw on
|
||||
Image myImage = new Bitmap(width, height);
|
||||
using (var gr = Graphics.FromImage(myImage))
|
||||
{
|
||||
// set to white so we don't have to fill the spaces with white
|
||||
gr.FillRectangle(Brushes.White, 0, 0, width, height);
|
||||
|
||||
// skip quiet zone
|
||||
var cursor = addQuietZone ? CQuietWidth * barWeight : 0;
|
||||
|
||||
for (var codeIdx = 0; codeIdx < codes.Length; codeIdx++)
|
||||
{
|
||||
var code = codes[codeIdx];
|
||||
|
||||
// take the bars two at a time: a black and a white
|
||||
for (var bar = 0; bar < 8; bar += 2)
|
||||
{
|
||||
var barWidth = CPatterns[code, bar] * barWeight;
|
||||
var spcWidth = CPatterns[code, bar + 1] * barWeight;
|
||||
|
||||
// if width is zero, don't try to draw it
|
||||
if (barWidth > 0)
|
||||
{
|
||||
gr.FillRectangle(Brushes.Black, cursor, 0, barWidth, height);
|
||||
}
|
||||
|
||||
// note that we never need to draw the space, since we
|
||||
// initialized the graphics to all white
|
||||
|
||||
// advance cursor beyond this pair
|
||||
cursor += barWidth + spcWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return myImage;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
GenCode128/CodeSet.cs
Normal file
9
GenCode128/CodeSet.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace GenCode128
|
||||
{
|
||||
public enum CodeSet
|
||||
{
|
||||
CodeA,
|
||||
CodeB
|
||||
//// CodeC // not supported
|
||||
}
|
||||
}
|
||||
147
GenCode128/GenCode128.csproj
Normal file
147
GenCode128/GenCode128.csproj
Normal file
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{32817BF9-E380-4467-9C7F-936F4B122BC7}</ProjectGuid>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>GenCode128</AssemblyName>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
<DefaultClientScript>JScript</DefaultClientScript>
|
||||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>GenCode128</RootNamespace>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
<Optimize>false</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugType>full</DebugType>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
<Optimize>true</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugType>none</DebugType>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing">
|
||||
<Name>System.Drawing</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<Name>System.Windows.Forms</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.XML</Name>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Code128Code.cs" />
|
||||
<Compile Include="CodeSet.cs" />
|
||||
<Compile Include="AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Code128Content.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Code128Rendering.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
26
TBF.sln
26
TBF.sln
@ -53,6 +53,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encrypt", "Encrypt\Encrypt.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestClient", "RestClient\RestClient.csproj", "{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToFirstMonitor", "ToFirstMonitor\ToFirstMonitor.csproj", "{13515B7B-43E6-44BC-87B8-2E345A98B741}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToSecondMonitor", "ToSecondMonitor\ToSecondMonitor.csproj", "{6F18660F-0EFB-4253-B92C-205E18D34442}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenCode128", "GenCode128\GenCode128.csproj", "{32817BF9-E380-4467-9C7F-936F4B122BC7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -217,6 +223,26 @@ Global
|
||||
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{46E3B0E1-209F-4550-B0DD-D7E2C039B3CE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{13515B7B-43E6-44BC-87B8-2E345A98B741}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{6F18660F-0EFB-4253-B92C-205E18D34442}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
6
ToFirstMonitor/App.config
Normal file
6
ToFirstMonitor/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
82
ToFirstMonitor/Program.cs
Normal file
82
ToFirstMonitor/Program.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using TBF;
|
||||
|
||||
namespace ToFirstMonitor
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static LocalSettings ls;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (!Directory.Exists(TBF.Program.ConfigDir)) return;
|
||||
|
||||
Environment.CurrentDirectory = TBF.Program.ConfigDir;
|
||||
ls = LocalSettings.Load(TBF.Program.LocalSettingsFileName);
|
||||
if (ls == null || ls.TestBenches == null)
|
||||
{
|
||||
/// Loading local seetings from regular config file failed. Use the backup
|
||||
ls = LocalSettings.Load(TBF.Program.LocalSettingsBackupName);
|
||||
if (ls == null || ls.TestBenches == null)
|
||||
{
|
||||
/// Neither config.xml, nor config.backup.xml could be loaded
|
||||
Console.WriteLine(string.Format("Could not load file {0}, nor {1}.", TBF.Program.LocalSettingsFileName, TBF.Program.LocalSettingsBackupName));
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Loading local seetings from the regular config file was successful. Update the backup
|
||||
File.Copy(TBF.Program.LocalSettingsFileName, TBF.Program.LocalSettingsBackupName, true);
|
||||
}
|
||||
|
||||
///
|
||||
/// Process local settings so that windows are shifted to the 1st monitor
|
||||
///
|
||||
LeftToFirstMonitor(ref ls.MainWndLeft);
|
||||
LeftToFirstMonitor(ref ls.ComponentsDlgLeft);
|
||||
LeftToFirstMonitor(ref ls.PopupResultsLeft);
|
||||
LeftToFirstMonitor(ref ls.PathsDlgLeft);
|
||||
LeftToFirstMonitor(ref ls.TransitionsDlgLeft);
|
||||
LeftToFirstMonitor(ref ls.MetrologyDlgLeft);
|
||||
LeftToFirstMonitor(ref ls.ConditionsDlgLeft);
|
||||
LeftToFirstMonitor(ref ls.UncertaintyDlgLeft);
|
||||
LeftToFirstMonitor(ref ls.ProceduresDlgLeft);
|
||||
LeftToFirstMonitor(ref ls.OneProcedureDlgLeft);
|
||||
LeftToFirstMonitor(ref ls.EnduranceDlgLeft);
|
||||
ls.Save();
|
||||
|
||||
Console.WriteLine("All windows were shifted to the first monitor");
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
|
||||
static void LeftToFirstMonitor(ref int left)
|
||||
{
|
||||
while (left >= 1920)
|
||||
{
|
||||
left -= 1920;
|
||||
}
|
||||
|
||||
if (left < 0)
|
||||
{
|
||||
left = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void LeftToSecondMonitor(ref int left)
|
||||
{
|
||||
while (left < 1920)
|
||||
{
|
||||
left += 1920;
|
||||
}
|
||||
|
||||
if (left >= 3840)
|
||||
{
|
||||
left = 1920;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
ToFirstMonitor/Properties/AssemblyInfo.cs
Normal file
36
ToFirstMonitor/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ToFirstMonitor")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ToFirstMonitor")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("df7a2c29-8a33-448e-be51-d58355674f64")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
76
ToFirstMonitor/ToFirstMonitor.csproj
Normal file
76
ToFirstMonitor/ToFirstMonitor.csproj
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.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>{13515B7B-43E6-44BC-87B8-2E345A98B741}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ToFirstMonitor</RootNamespace>
|
||||
<AssemblyName>ToFirstMonitor</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</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>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>ToFirstMonitor.Program</StartupObject>
|
||||
</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="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Config\Config.csproj">
|
||||
<Project>{743df7db-c7b6-42eb-986d-0f485e5588e4}</Project>
|
||||
<Name>Config</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TBF\TBF.csproj">
|
||||
<Project>{8648fd92-cda1-4c3a-b5f9-fe547ce1fa48}</Project>
|
||||
<Name>TBF</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Users\Users.csproj">
|
||||
<Project>{6e5cb0e9-e1b6-4e5d-ac6e-b1049e180f2b}</Project>
|
||||
<Name>Users</Name>
|
||||
</ProjectReference>
|
||||
</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
ToSecondMonitor/App.config
Normal file
6
ToSecondMonitor/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
82
ToSecondMonitor/Program.cs
Normal file
82
ToSecondMonitor/Program.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using TBF;
|
||||
|
||||
namespace ToSecondMonitor
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static LocalSettings ls;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (!Directory.Exists(TBF.Program.ConfigDir)) return;
|
||||
|
||||
Environment.CurrentDirectory = TBF.Program.ConfigDir;
|
||||
ls = LocalSettings.Load(TBF.Program.LocalSettingsFileName);
|
||||
if (ls == null || ls.TestBenches == null)
|
||||
{
|
||||
/// Loading local seetings from regular config file failed. Use the backup
|
||||
ls = LocalSettings.Load(TBF.Program.LocalSettingsBackupName);
|
||||
if (ls == null || ls.TestBenches == null)
|
||||
{
|
||||
/// Neither config.xml, nor config.backup.xml could be loaded
|
||||
Console.WriteLine(string.Format("Could not load file {0}, nor {1}.", TBF.Program.LocalSettingsFileName, TBF.Program.LocalSettingsBackupName));
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Loading local seetings from the regular config file was successful. Update the backup
|
||||
File.Copy(TBF.Program.LocalSettingsFileName, TBF.Program.LocalSettingsBackupName, true);
|
||||
}
|
||||
|
||||
///
|
||||
/// Process local settings so that windows are shifted to the 1st monitor
|
||||
///
|
||||
LeftToSecondMonitor(ref ls.MainWndLeft);
|
||||
LeftToSecondMonitor(ref ls.ComponentsDlgLeft);
|
||||
LeftToSecondMonitor(ref ls.PopupResultsLeft);
|
||||
LeftToSecondMonitor(ref ls.PathsDlgLeft);
|
||||
LeftToSecondMonitor(ref ls.TransitionsDlgLeft);
|
||||
LeftToSecondMonitor(ref ls.MetrologyDlgLeft);
|
||||
LeftToSecondMonitor(ref ls.ConditionsDlgLeft);
|
||||
LeftToSecondMonitor(ref ls.UncertaintyDlgLeft);
|
||||
LeftToSecondMonitor(ref ls.ProceduresDlgLeft);
|
||||
LeftToSecondMonitor(ref ls.OneProcedureDlgLeft);
|
||||
LeftToSecondMonitor(ref ls.EnduranceDlgLeft);
|
||||
ls.Save();
|
||||
|
||||
Console.WriteLine("All windows were shifted to the second monitor");
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
|
||||
static void LeftToFirstMonitor(ref int left)
|
||||
{
|
||||
while (left >= 1920)
|
||||
{
|
||||
left -= 1920;
|
||||
}
|
||||
|
||||
if (left < 0)
|
||||
{
|
||||
left = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void LeftToSecondMonitor(ref int left)
|
||||
{
|
||||
while (left < 1920)
|
||||
{
|
||||
left += 1920;
|
||||
}
|
||||
|
||||
if (left >= 3840)
|
||||
{
|
||||
left = 1920;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
ToSecondMonitor/Properties/AssemblyInfo.cs
Normal file
36
ToSecondMonitor/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ToSecondMonitor")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ToSecondMonitor")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("72eaee31-c6f6-4b57-92ff-8f664d867bf5")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
73
ToSecondMonitor/ToSecondMonitor.csproj
Normal file
73
ToSecondMonitor/ToSecondMonitor.csproj
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.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>{6F18660F-0EFB-4253-B92C-205E18D34442}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ToSecondMonitor</RootNamespace>
|
||||
<AssemblyName>ToSecondMonitor</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</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>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="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Config\Config.csproj">
|
||||
<Project>{743df7db-c7b6-42eb-986d-0f485e5588e4}</Project>
|
||||
<Name>Config</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TBF\TBF.csproj">
|
||||
<Project>{8648fd92-cda1-4c3a-b5f9-fe547ce1fa48}</Project>
|
||||
<Name>TBF</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Users\Users.csproj">
|
||||
<Project>{6e5cb0e9-e1b6-4e5d-ac6e-b1049e180f2b}</Project>
|
||||
<Name>Users</Name>
|
||||
</ProjectReference>
|
||||
</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>
|
||||
@ -10,6 +10,8 @@ rmdir /s /q Encrypt\bin
|
||||
rmdir /s /q Encrypt\obj
|
||||
rmdir /s /q GemCard\bin
|
||||
rmdir /s /q GemCard\obj
|
||||
rmdir /s /q GenCode128\bin
|
||||
rmdir /s /q GenCode128\obj
|
||||
rmdir /s /q GraphLib\bin
|
||||
rmdir /s /q GraphLib\obj
|
||||
rmdir /s /q TracingDB\bin
|
||||
@ -24,8 +26,10 @@ rmdir /s /q Statistics\bin
|
||||
rmdir /s /q Statistics\obj
|
||||
rmdir /s /q TBF\bin
|
||||
rmdir /s /q TBF\obj
|
||||
rmdir /s /q TBFSetup\Debug
|
||||
rmdir /s /q TBFSetup\Release
|
||||
rmdir /s /q ToFirstMonitor\bin
|
||||
rmdir /s /q ToFirstMonitor\obj
|
||||
rmdir /s /q ToSecondMonitor\bin
|
||||
rmdir /s /q ToSecondMonitor\obj
|
||||
rmdir /s /q Users\bin
|
||||
rmdir /s /q Users\obj
|
||||
rmdir /s /q UserManagement\bin
|
||||
|
||||
Loading…
Reference in New Issue
Block a user