Compare commits
23 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
1e95ee1a13 | 1 year ago |
|
|
8deea834eb | 1 year ago |
|
|
ff5f61f559 | 2 years ago |
|
|
7d8dd3be2b | 2 years ago |
|
|
ea1ed5070c | 2 years ago |
|
|
009ca19489 | 2 years ago |
|
|
ca42a9b64d | 2 years ago |
|
|
a6aae221ac | 2 years ago |
|
|
ce243991b6 | 3 years ago |
|
|
a812b8b5af | 3 years ago |
|
|
b15eda12f8 | 3 years ago |
|
|
48eff7e5ec | 3 years ago |
|
|
ffd11da975 | 3 years ago |
|
|
8a73f602b5 | 3 years ago |
|
|
4c5b8c5055 | 3 years ago |
|
|
a0774b48c1 | 3 years ago |
|
|
cc23dfe0ca | 3 years ago |
|
|
1729eaa343 | 3 years ago |
|
|
7ba066f6cf | 3 years ago |
|
|
23615584a6 | 3 years ago |
|
|
98b3fb8ad7 | 3 years ago |
|
|
90c8f12c53 | 3 years ago |
|
|
cfd0fd806d | 3 years ago |
28 changed files with 9930 additions and 401 deletions
@ -0,0 +1,381 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.IO; |
||||||
|
using System.Security.Cryptography; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region CRC8 |
||||||
|
public class CRC8_2 |
||||||
|
{ |
||||||
|
//CRC8Calc crc_dallas = new CRC8Calc(CRC8_POLY.CRC8_DALLAS_MAXIM); |
||||||
|
//checksum = crc_dallas.Checksum(testVal); |
||||||
|
//CRC8Calc crc = new CRC8Calc(CRC8_POLY.CRC8_CCITT); |
||||||
|
//checksum = crc.Checksum(testVal); |
||||||
|
|
||||||
|
public enum CRC8_POLY |
||||||
|
{ |
||||||
|
CRC8 = 0xd5, |
||||||
|
CRC8_CCITT = 0x07, |
||||||
|
CRC8_DALLAS_MAXIM = 0x31, |
||||||
|
CRC8_SAE_J1850 = 0x1D, |
||||||
|
CRC_8_WCDMA = 0x9b, |
||||||
|
}; |
||||||
|
private byte[] table = new byte[256]; |
||||||
|
|
||||||
|
public byte Checksum(params byte[] val) |
||||||
|
{ |
||||||
|
if (val == null) |
||||||
|
throw new ArgumentNullException("val"); |
||||||
|
byte c = 0; |
||||||
|
foreach (byte b in val) |
||||||
|
c = table[c ^ b]; |
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
public byte[] Table |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return this.table; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
this.table = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public byte[] GenerateTable(CRC8_POLY polynomial) |
||||||
|
{ |
||||||
|
byte[] csTable = new byte[256]; |
||||||
|
for (int i = 0; i < 256; ++i) |
||||||
|
{ |
||||||
|
int curr = i; |
||||||
|
for (int j = 0; j < 8; ++j) |
||||||
|
{ |
||||||
|
if ((curr & 0x80) != 0) |
||||||
|
curr = (curr << 1) ^ (int)polynomial; |
||||||
|
else |
||||||
|
curr <<= 1; |
||||||
|
} |
||||||
|
csTable[i] = (byte)curr; |
||||||
|
} |
||||||
|
return csTable; |
||||||
|
} |
||||||
|
|
||||||
|
public CRC8_2(CRC8_POLY polynomial) |
||||||
|
{ |
||||||
|
this.table = this.GenerateTable(polynomial); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static class CRC8_3 |
||||||
|
{ |
||||||
|
static byte[] CRC8_TABLE = new byte[]{ |
||||||
|
0, 94, 188, 226, 97, 63, 221, 131, 194, 156, 126, 32, 163, 253, 31, 65, |
||||||
|
157, 195, 33, 127, 252, 162, 64, 30, 95, 1, 227, 189, 62, 96, 130, 220, |
||||||
|
35, 125, 159, 193, 66, 28, 254, 160, 225, 191, 93, 3, 128, 222, 60, 98, |
||||||
|
190, 224, 2, 92, 223, 129, 99, 61, 124, 34, 192, 158, 29, 67, 161, 255, |
||||||
|
70, 24, 250, 164, 39, 121, 155, 197, 132, 218, 56, 102, 229, 187, 89, 7, |
||||||
|
219, 133, 103, 57, 186, 228, 6, 88, 25, 71, 165, 251, 120, 38, 196, 154, |
||||||
|
101, 59, 217, 135, 4, 90, 184, 230, 167, 249, 27, 69, 198, 152, 122, 36, |
||||||
|
248, 166, 68, 26, 153, 199, 37, 123, 58, 100, 134, 216, 91, 5, 231, 185, |
||||||
|
140, 210, 48, 110, 237, 179, 81, 15, 78, 16, 242, 172, 47, 113, 147, 205, |
||||||
|
17, 79, 173, 243, 112, 46, 204, 146, 211, 141, 111, 49, 178, 236, 14, 80, |
||||||
|
175, 241, 19, 77, 206, 144, 114, 44, 109, 51, 209, 143, 12, 82, 176, 238, |
||||||
|
50, 108, 142, 208, 83, 13, 239, 177, 240, 174, 76, 18, 145, 207, 45, 115, |
||||||
|
202, 148, 118, 40, 171, 245, 23, 73, 8, 86, 180, 234, 105, 55, 213, 139, |
||||||
|
87, 9, 235, 181, 54, 104, 138, 212, 149, 203, 41, 119, 244, 170, 72, 22, |
||||||
|
233, 183, 85, 11, 136, 214, 52, 106, 43, 117, 151, 201, 74, 20, 246, 168, |
||||||
|
116, 42, 200, 150, 21, 75, 169, 247, 182, 232, 10, 84, 215, 137, 107, 53 |
||||||
|
}; |
||||||
|
|
||||||
|
public static byte Calculate(byte[] data, byte init = 0) |
||||||
|
{ |
||||||
|
byte result = init; |
||||||
|
for (var i = 0; i < data.Length; i++) |
||||||
|
{ |
||||||
|
result = CRC8_TABLE[result ^ data[i]]; |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region CRC16 |
||||||
|
public static class Crc16_1 |
||||||
|
{ |
||||||
|
static Byte[] auchCRCHi = new Byte[] |
||||||
|
{ |
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, |
||||||
|
0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, |
||||||
|
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, |
||||||
|
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, |
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, |
||||||
|
0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, |
||||||
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, |
||||||
|
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, |
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, |
||||||
|
0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, |
||||||
|
0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, |
||||||
|
0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, |
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, |
||||||
|
0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, |
||||||
|
0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, |
||||||
|
0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, |
||||||
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, |
||||||
|
0x40 |
||||||
|
}; |
||||||
|
static Byte[] auchCRCLo = new Byte[] |
||||||
|
{ |
||||||
|
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, |
||||||
|
0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, |
||||||
|
0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, |
||||||
|
0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, |
||||||
|
0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7, |
||||||
|
0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, |
||||||
|
0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, |
||||||
|
0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, |
||||||
|
0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, |
||||||
|
0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, |
||||||
|
0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, |
||||||
|
0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, |
||||||
|
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91, |
||||||
|
0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, |
||||||
|
0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, |
||||||
|
0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, |
||||||
|
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, |
||||||
|
0x40 |
||||||
|
}; |
||||||
|
|
||||||
|
public static UInt16 CRC16(ref Byte[] d, UInt16 len) |
||||||
|
{ |
||||||
|
Byte crc_hi = 0xFF; |
||||||
|
Byte crc_lo = 0xFF; |
||||||
|
Byte j = 0; |
||||||
|
do |
||||||
|
{ |
||||||
|
Byte i = (Byte)(crc_hi ^ d[j++]); |
||||||
|
crc_hi = (Byte)(crc_lo ^ (Byte)auchCRCHi[i]); |
||||||
|
crc_lo = (Byte)(auchCRCLo[i]); |
||||||
|
} while (--len != 0); |
||||||
|
return (UInt16)((crc_hi << 8) | crc_lo); |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region CRC32 |
||||||
|
public static class Crc32_1 |
||||||
|
{ |
||||||
|
private static readonly uint[] crcTable = new uint[256]; |
||||||
|
|
||||||
|
static Crc32_1() |
||||||
|
{ |
||||||
|
const uint polynomial = 0xDEADDEAD; |
||||||
|
for (uint i = 0; i < 256; i++) |
||||||
|
{ |
||||||
|
uint crc = i; |
||||||
|
for (int j = 0; j < 8; j++) |
||||||
|
{ |
||||||
|
if ((crc & 1) == 1) |
||||||
|
{ |
||||||
|
crc = (crc >> 1) ^ polynomial; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
crc >>= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
crcTable[i] = crc; |
||||||
|
} |
||||||
|
} |
||||||
|
public static uint Calculate(byte[] data) |
||||||
|
{ |
||||||
|
uint crc = 0xFFFFFFFF; |
||||||
|
|
||||||
|
foreach (byte b in data) |
||||||
|
{ |
||||||
|
byte tableIndex = (byte)(((crc) & 0xFF) ^ b); |
||||||
|
crc = crcTable[tableIndex] ^ (crc >> 8); |
||||||
|
} |
||||||
|
|
||||||
|
return ~crc; |
||||||
|
} |
||||||
|
} |
||||||
|
public class Crc32_2 : HashAlgorithm |
||||||
|
{ |
||||||
|
public const UInt32 DefaultPolynomial = 0xedb88320; |
||||||
|
public const UInt32 DefaultSeed = 0xffffffff; |
||||||
|
|
||||||
|
private UInt32 hash; |
||||||
|
private UInt32 seed; |
||||||
|
private UInt32[] table; |
||||||
|
private static UInt32[] defaultTable; |
||||||
|
|
||||||
|
public Crc32_2() |
||||||
|
{ |
||||||
|
table = InitializeTable(DefaultPolynomial); |
||||||
|
seed = DefaultSeed; |
||||||
|
Initialize(); |
||||||
|
} |
||||||
|
|
||||||
|
public Crc32_2(UInt32 polynomial, UInt32 seed) |
||||||
|
{ |
||||||
|
table = InitializeTable(polynomial); |
||||||
|
this.seed = seed; |
||||||
|
Initialize(); |
||||||
|
} |
||||||
|
|
||||||
|
public override void Initialize() |
||||||
|
{ |
||||||
|
hash = seed; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void HashCore(byte[] buffer, int start, int length) |
||||||
|
{ |
||||||
|
hash = CalculateHash(table, hash, buffer, start, length); |
||||||
|
} |
||||||
|
|
||||||
|
protected override byte[] HashFinal() |
||||||
|
{ |
||||||
|
byte[] hashBuffer = UInt32ToBigEndianBytes(~hash); |
||||||
|
this.HashValue = hashBuffer; |
||||||
|
return hashBuffer; |
||||||
|
} |
||||||
|
|
||||||
|
public override int HashSize |
||||||
|
{ |
||||||
|
get { return 32; } |
||||||
|
} |
||||||
|
|
||||||
|
public static UInt32 Compute(byte[] buffer) |
||||||
|
{ |
||||||
|
return ~CalculateHash(InitializeTable(DefaultPolynomial), DefaultSeed, buffer, 0, buffer.Length); |
||||||
|
} |
||||||
|
|
||||||
|
public static UInt32 Compute(UInt32 seed, byte[] buffer) |
||||||
|
{ |
||||||
|
return ~CalculateHash(InitializeTable(DefaultPolynomial), seed, buffer, 0, buffer.Length); |
||||||
|
} |
||||||
|
|
||||||
|
public static UInt32 Compute(UInt32 polynomial, UInt32 seed, byte[] buffer) |
||||||
|
{ |
||||||
|
return ~CalculateHash(InitializeTable(polynomial), seed, buffer, 0, buffer.Length); |
||||||
|
} |
||||||
|
|
||||||
|
private static UInt32[] InitializeTable(UInt32 polynomial) |
||||||
|
{ |
||||||
|
if (polynomial == DefaultPolynomial && defaultTable != null) |
||||||
|
return defaultTable; |
||||||
|
|
||||||
|
UInt32[] createTable = new UInt32[256]; |
||||||
|
for (int i = 0; i < 256; i++) |
||||||
|
{ |
||||||
|
UInt32 entry = (UInt32)i; |
||||||
|
for (int j = 0; j < 8; j++) |
||||||
|
if ((entry & 1) == 1) |
||||||
|
entry = (entry >> 1) ^ polynomial; |
||||||
|
else |
||||||
|
entry = entry >> 1; |
||||||
|
createTable[i] = entry; |
||||||
|
} |
||||||
|
|
||||||
|
if (polynomial == DefaultPolynomial) |
||||||
|
defaultTable = createTable; |
||||||
|
|
||||||
|
return createTable; |
||||||
|
} |
||||||
|
|
||||||
|
private static UInt32 CalculateHash(UInt32[] table, UInt32 seed, byte[] buffer, int start, int size) |
||||||
|
{ |
||||||
|
UInt32 crc = seed; |
||||||
|
for (int i = start; i < size; i++) |
||||||
|
unchecked |
||||||
|
{ |
||||||
|
crc = (crc >> 8) ^ table[buffer[i] ^ crc & 0xff]; |
||||||
|
} |
||||||
|
return crc; |
||||||
|
} |
||||||
|
|
||||||
|
private byte[] UInt32ToBigEndianBytes(UInt32 x) |
||||||
|
{ |
||||||
|
return new byte[] { |
||||||
|
(byte)((x >> 24) & 0xff), |
||||||
|
(byte)((x >> 16) & 0xff), |
||||||
|
(byte)((x >> 8) & 0xff), |
||||||
|
(byte)(x & 0xff) |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
public string Get(string FilePath) |
||||||
|
{ |
||||||
|
Crc32_2 crc32 = new Crc32_2(); |
||||||
|
String hash = String.Empty; |
||||||
|
|
||||||
|
using (FileStream fs = File.Open(FilePath, FileMode.Open)) |
||||||
|
foreach (byte b in crc32.ComputeHash(fs)) hash += b.ToString("x2").ToLower(); |
||||||
|
|
||||||
|
return hash; |
||||||
|
} |
||||||
|
} |
||||||
|
public class Crc32_3 |
||||||
|
{ |
||||||
|
private readonly uint[] _table; |
||||||
|
private const uint Poly = 0xedb88320; |
||||||
|
|
||||||
|
private uint ComputeChecksum(IEnumerable<byte> bytes) |
||||||
|
{ |
||||||
|
var crc = 0xffffffff; |
||||||
|
foreach (var t in bytes) |
||||||
|
{ |
||||||
|
var index = (byte)((crc & 0xff) ^ t); |
||||||
|
crc = (crc >> 8) ^ _table[index]; |
||||||
|
} |
||||||
|
return ~crc; |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<byte> ComputeChecksumBytes(IEnumerable<byte> bytes) |
||||||
|
{ |
||||||
|
return BitConverter.GetBytes(ComputeChecksum(bytes)); |
||||||
|
} |
||||||
|
|
||||||
|
public Crc32_3() |
||||||
|
{ |
||||||
|
_table = new uint[256]; |
||||||
|
for (uint i = 0; i < _table.Length; ++i) |
||||||
|
{ |
||||||
|
var temp = i; |
||||||
|
for (var j = 8; j > 0; --j) |
||||||
|
if ((temp & 1) == 1) |
||||||
|
temp = (temp >> 1) ^ Poly; |
||||||
|
else |
||||||
|
temp >>= 1; |
||||||
|
_table[i] = temp; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
public class Crc32_4 |
||||||
|
{ |
||||||
|
byte[] GetCRC32(IEnumerable<byte> bytes) |
||||||
|
{ |
||||||
|
var crcTable = new uint[256]; |
||||||
|
uint crc; |
||||||
|
|
||||||
|
for (uint i = 0; i < 256; i++) |
||||||
|
{ |
||||||
|
crc = i; |
||||||
|
for (uint j = 0; j < 8; j++) |
||||||
|
crc = (crc & 1) != 0 ? (crc >> 1) ^ 0xEDB88320 : crc >> 1; |
||||||
|
|
||||||
|
crcTable[i] = crc; |
||||||
|
} |
||||||
|
|
||||||
|
crc = bytes.Aggregate(0xFFFFFFFF, (current, s) => crcTable[(current ^ s) & 0xFF] ^ (current >> 8)); |
||||||
|
|
||||||
|
crc ^= 0xFFFFFFFF; |
||||||
|
return BitConverter.GetBytes(crc); |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
@ -0,0 +1,150 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Reflection; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Windows.Forms.VisualStyles; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Drawing.Imaging; |
||||||
|
using System.Globalization; |
||||||
|
using static System.Net.Mime.MediaTypeNames; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Net.NetworkInformation; |
||||||
|
using System.Net; |
||||||
|
using System.Management; |
||||||
|
using System.IO.Ports; |
||||||
|
using System.IO; |
||||||
|
using System.Security.Cryptography; |
||||||
|
using System.Windows.Forms.Design; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region Циклический буфер |
||||||
|
public class CircularBuffer<T> |
||||||
|
{ |
||||||
|
T[] _buffer; |
||||||
|
Int32 _head; |
||||||
|
Int32 _tail; |
||||||
|
Int32 _length; |
||||||
|
Int32 _bufferSize; |
||||||
|
Int32 _pos; |
||||||
|
Object _lock = new object(); |
||||||
|
public CircularBuffer(Int32 bufferSize) |
||||||
|
{ |
||||||
|
_buffer = new T[bufferSize]; |
||||||
|
_bufferSize = bufferSize; |
||||||
|
_head = bufferSize - 1; |
||||||
|
_tail = 0; |
||||||
|
_length = 0; |
||||||
|
} |
||||||
|
public Int32 Count |
||||||
|
{ |
||||||
|
get { return _length; } |
||||||
|
} |
||||||
|
public Int32 Head |
||||||
|
{ |
||||||
|
get { return _head; } |
||||||
|
} |
||||||
|
public Int32 Tail |
||||||
|
{ |
||||||
|
get { return _tail; } |
||||||
|
} |
||||||
|
public bool IsEmpty |
||||||
|
{ |
||||||
|
get { return _length == 0; } |
||||||
|
} |
||||||
|
public bool IsFull |
||||||
|
{ |
||||||
|
get { return _length == _bufferSize; } |
||||||
|
} |
||||||
|
public bool IsNoData |
||||||
|
{ |
||||||
|
get { return _tail + _pos >= _head; } |
||||||
|
} |
||||||
|
public T Dequeue() |
||||||
|
{ |
||||||
|
if (IsEmpty) throw new InvalidOperationException("Queue exhausted"); |
||||||
|
|
||||||
|
T dequeued = _buffer[_tail]; |
||||||
|
_tail = NextPosition(_tail); |
||||||
|
_length--; |
||||||
|
return dequeued; |
||||||
|
} |
||||||
|
public T Peek(int pos) |
||||||
|
{ |
||||||
|
_pos = pos; |
||||||
|
if (IsEmpty) throw new InvalidOperationException("Queue exhausted"); |
||||||
|
if (_tail + pos > _head) throw new InvalidOperationException("End data"); |
||||||
|
|
||||||
|
T dequeued = _buffer[_tail + pos]; |
||||||
|
return dequeued; |
||||||
|
} |
||||||
|
public T Peek() |
||||||
|
{ |
||||||
|
if (IsEmpty) throw new InvalidOperationException("Queue exhausted"); |
||||||
|
if (_tail > _head) throw new InvalidOperationException("End data"); |
||||||
|
T dequeued = _buffer[_tail]; |
||||||
|
return dequeued; |
||||||
|
} |
||||||
|
private int NextPosition(int position) |
||||||
|
{ |
||||||
|
return (position + 1) % _bufferSize; |
||||||
|
} |
||||||
|
public void Enqueue(T toAdd) |
||||||
|
{ |
||||||
|
_head = NextPosition(_head); |
||||||
|
_buffer[_head] = toAdd; |
||||||
|
if (IsFull) |
||||||
|
_tail = NextPosition(_tail); |
||||||
|
else |
||||||
|
_length++; |
||||||
|
} |
||||||
|
} |
||||||
|
public class CircularBuffer2<T> |
||||||
|
{ |
||||||
|
T[] _buffer; |
||||||
|
Int32 _head; |
||||||
|
Int32 _tail; |
||||||
|
Int32 _length; |
||||||
|
Int32 _bufferSize; |
||||||
|
Int32 _pos; |
||||||
|
Object _lock = new object(); |
||||||
|
public CircularBuffer2(Int32 bufferSize) |
||||||
|
{ |
||||||
|
_buffer = new T[bufferSize]; |
||||||
|
_bufferSize = bufferSize; |
||||||
|
_head = bufferSize - 1; |
||||||
|
_tail = 0; |
||||||
|
_length = 0; |
||||||
|
} |
||||||
|
public T Dequeue() |
||||||
|
{ |
||||||
|
T dequeued = _buffer[_tail]; |
||||||
|
_tail = (_tail + 1) % _bufferSize; |
||||||
|
_length--; |
||||||
|
return dequeued; |
||||||
|
} |
||||||
|
public T Peek() |
||||||
|
{ |
||||||
|
if (_length == 0) throw new InvalidOperationException("No data"); |
||||||
|
return _buffer[_tail]; |
||||||
|
} |
||||||
|
private int NextPosition(int position) |
||||||
|
{ |
||||||
|
return (position + 1) % _bufferSize; |
||||||
|
} |
||||||
|
public void Enqueue(T toAdd) |
||||||
|
{ |
||||||
|
_head = (_head + 1) % _bufferSize; |
||||||
|
_buffer[_head] = toAdd; |
||||||
|
if (_length == _bufferSize) |
||||||
|
_tail = (_tail + 1) % _bufferSize; |
||||||
|
else |
||||||
|
_length++; |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region Расширенные методы RichTextBox |
||||||
|
public static class RichTextBoxExtensions |
||||||
|
{ |
||||||
|
public static void AppendText(this RichTextBox box, string text, Color color) |
||||||
|
{ |
||||||
|
if (box.InvokeRequired) |
||||||
|
{ |
||||||
|
box.Invoke((MethodInvoker)(delegate |
||||||
|
{ |
||||||
|
box.SelectionStart = box.TextLength; |
||||||
|
box.SelectionLength = 0; |
||||||
|
box.SelectionColor = color; |
||||||
|
box.AppendText(text); |
||||||
|
box.SelectionColor = box.ForeColor; |
||||||
|
box.ScrollToCaret(); |
||||||
|
})); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
box.SelectionStart = box.TextLength; |
||||||
|
box.SelectionLength = 0; |
||||||
|
box.SelectionColor = color; |
||||||
|
box.AppendText(text); |
||||||
|
box.SelectionColor = box.ForeColor; |
||||||
|
box.ScrollToCaret(); |
||||||
|
} |
||||||
|
} |
||||||
|
public static void AppendText(this RichTextBox box, string text, Color bgcolor, Color fgcolor) |
||||||
|
{ |
||||||
|
if (box.InvokeRequired) |
||||||
|
{ |
||||||
|
box.Invoke((MethodInvoker)(delegate |
||||||
|
{ |
||||||
|
box.SelectionStart = box.TextLength; |
||||||
|
box.SelectionLength = 0; |
||||||
|
box.SelectionColor = fgcolor; |
||||||
|
box.SelectionBackColor = bgcolor; |
||||||
|
box.AppendText(text); |
||||||
|
box.SelectionColor = box.ForeColor; |
||||||
|
box.SelectionBackColor = box.BackColor; |
||||||
|
box.ScrollToCaret(); |
||||||
|
})); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
box.SelectionStart = box.TextLength; |
||||||
|
box.SelectionLength = 0; |
||||||
|
box.SelectionColor = fgcolor; |
||||||
|
box.SelectionBackColor = bgcolor; |
||||||
|
box.AppendText(text); |
||||||
|
box.SelectionColor = box.ForeColor; |
||||||
|
box.SelectionBackColor = box.BackColor; |
||||||
|
box.ScrollToCaret(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
@ -0,0 +1,171 @@ |
|||||||
|
using System.Reflection; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region Методы доступа к атрибутам сборки |
||||||
|
public static class ASMBL |
||||||
|
{ |
||||||
|
public static string AssemblyTitle |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); |
||||||
|
if (attributes.Length > 0) |
||||||
|
{ |
||||||
|
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; |
||||||
|
if (titleAttribute.Title != "") |
||||||
|
{ |
||||||
|
return titleAttribute.Title; |
||||||
|
} |
||||||
|
} |
||||||
|
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); |
||||||
|
} |
||||||
|
} |
||||||
|
public static string AssemblyVersion |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return Assembly.GetExecutingAssembly().GetName().Version.ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
public static string AssemblyDescription |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
{ |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ((AssemblyDescriptionAttribute)attributes[0]).Description; |
||||||
|
} |
||||||
|
} |
||||||
|
public static string AssemblyProduct |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
{ |
||||||
|
return ""; |
||||||
|
} |
||||||
|
#if DEBUG |
||||||
|
return ((AssemblyProductAttribute)attributes[0]).Product + " Debug version"; |
||||||
|
#else |
||||||
|
return ((AssemblyProductAttribute)attributes[0]).Product + " Release version"; |
||||||
|
#endif |
||||||
|
} |
||||||
|
} |
||||||
|
public static string AssemblyCopyright |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
{ |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; |
||||||
|
} |
||||||
|
} |
||||||
|
public static string AssemblyCompany |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
{ |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ((AssemblyCompanyAttribute)attributes[0]).Company; |
||||||
|
} |
||||||
|
} |
||||||
|
public static string AssemblyConfiguration |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
return "Debug version"; |
||||||
|
#else |
||||||
|
return "Release version"; |
||||||
|
#endif |
||||||
|
} |
||||||
|
} |
||||||
|
public static string[] AssemblyConf |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
string[] s = new string[11]; |
||||||
|
|
||||||
|
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false); |
||||||
|
#if DEBUG |
||||||
|
s[0] = "Debug version"; |
||||||
|
#else |
||||||
|
s[0] = "Release version"; |
||||||
|
#endif |
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyAlgorithmIdAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[1] = "AssemblyAlgorithmId = "; |
||||||
|
else |
||||||
|
s[1] = "AssemblyAlgorithmId = " + ((AssemblyAlgorithmIdAttribute)attributes[0]).AlgorithmId; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[2] = "AssemblyCompany = "; |
||||||
|
else |
||||||
|
s[2] = "AssemblyCompany = " + ((AssemblyCompanyAttribute)attributes[0]).Company; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[3] = "AssemblyCopyright = "; |
||||||
|
else |
||||||
|
s[3] = "AssemblyCopyright = " + ((AssemblyCopyrightAttribute)attributes[0]).Copyright; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[4] = "AssemblyDescription = "; |
||||||
|
else |
||||||
|
s[4] = "AssemblyDescription = " + ((AssemblyDescriptionAttribute)attributes[0]).Description; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[5] = "AssemblyFileVersion = "; |
||||||
|
else |
||||||
|
s[5] = "AssemblyFileVersion = " + ((AssemblyFileVersionAttribute)attributes[0]).Version; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[6] = "AssemblyInformationalVersion = "; |
||||||
|
else |
||||||
|
s[6] = "AssemblyInformationalVersion = " + ((AssemblyInformationalVersionAttribute)attributes[0]).InformationalVersion; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[7] = "AssemblyProduct = "; |
||||||
|
else |
||||||
|
s[7] = "AssemblyProduct = " + ((AssemblyProductAttribute)attributes[0]).Product; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[8] = "AssemblyTitle = "; |
||||||
|
else |
||||||
|
s[8] = "AssemblyTitle = " + ((AssemblyTitleAttribute)attributes[0]).Title; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTrademarkAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[9] = "AssemblyTrademark = "; |
||||||
|
else |
||||||
|
s[9] = "AssemblyTrademark = " + ((AssemblyTrademarkAttribute)attributes[0]).Trademark; |
||||||
|
|
||||||
|
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyVersionAttribute), false); |
||||||
|
if (attributes.Length == 0) |
||||||
|
s[10] = "AssemblyVersion = "; |
||||||
|
else |
||||||
|
s[10] = "AssemblyVersion = " + ((AssemblyVersionAttribute)attributes[0]).Version; |
||||||
|
|
||||||
|
return s; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
@ -0,0 +1,106 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region Работа с INI файлами |
||||||
|
public class IniFile |
||||||
|
{ |
||||||
|
[DllImport("kernel32.dll")] |
||||||
|
private extern static int GetPrivateProfileString(String AppName, String KeyName, String Default, StringBuilder ReturnedString, UInt32 Size, String FileName); |
||||||
|
[DllImport("kernel32.dll")] |
||||||
|
private extern static int WritePrivateProfileString(String AppName, String KeyName, String Str, String FileName); |
||||||
|
public IniFile(string filename) |
||||||
|
{ |
||||||
|
IniFileName = filename; |
||||||
|
//if (!File.Exists(filename)) |
||||||
|
// File.Create(filename); |
||||||
|
IniFileName = new FileInfo(IniFileName).FullName.ToString(); |
||||||
|
} |
||||||
|
public String IniFileName |
||||||
|
{ |
||||||
|
get; |
||||||
|
set; |
||||||
|
} |
||||||
|
|
||||||
|
//Читаем ini-файл и возвращаем значение указного ключа из заданной секции. |
||||||
|
public string ReadINI(string Section, string Key) |
||||||
|
{ |
||||||
|
var RetVal = new StringBuilder(255); |
||||||
|
if (GetPrivateProfileString(Section, Key, "", RetVal, 255, IniFileName).ToString().Length > 0) |
||||||
|
return RetVal.ToString(); |
||||||
|
else |
||||||
|
return null; |
||||||
|
} |
||||||
|
//Записываем в ini-файл. Запись происходит в выбранную секцию в выбранный ключ. |
||||||
|
public void Write(string Section, string Key, string Value) |
||||||
|
{ |
||||||
|
WritePrivateProfileString(Section, Key, Value, IniFileName); |
||||||
|
} |
||||||
|
public void WriteINI(string Section, string Key, string Value) |
||||||
|
{ |
||||||
|
WritePrivateProfileString(Section, Key, Value, IniFileName); |
||||||
|
} |
||||||
|
|
||||||
|
//Удаляем ключ из выбранной секции. |
||||||
|
public void DeleteKey(string Key, string Section = null) |
||||||
|
{ |
||||||
|
Write(Section, Key, null); |
||||||
|
} |
||||||
|
//Удаляем выбранную секцию |
||||||
|
public void DeleteSection(string Section = null) |
||||||
|
{ |
||||||
|
Write(Section, null, null); |
||||||
|
} |
||||||
|
//Проверяем, есть ли такой ключ, в этой секции |
||||||
|
public bool KeyExists(string Key, string Section = null) |
||||||
|
{ |
||||||
|
return ReadINI(Section, Key).Length > 0; |
||||||
|
} |
||||||
|
|
||||||
|
public String GetString(String section, String key) |
||||||
|
{ |
||||||
|
StringBuilder s1 = new StringBuilder(255); |
||||||
|
s1.Append(ReadINI(section, key).ToString()); |
||||||
|
return s1.ToString(); |
||||||
|
} |
||||||
|
public Int64 GetInt(String section, String key) |
||||||
|
{ |
||||||
|
StringBuilder s1 = new StringBuilder(255); |
||||||
|
s1.Append(ReadINI(section, key).ToString()); |
||||||
|
return Int64.Parse(s1.ToString()); |
||||||
|
} |
||||||
|
public Boolean GetBool(String section, String key) |
||||||
|
{ |
||||||
|
StringBuilder s1 = new StringBuilder(255); |
||||||
|
s1.Append(ReadINI(section, key).ToString()); |
||||||
|
return Boolean.Parse(s1.ToString()); |
||||||
|
} |
||||||
|
public Double GetDouble(String section, String key) |
||||||
|
{ |
||||||
|
StringBuilder s1 = new StringBuilder(255); |
||||||
|
s1.Append(ReadINI(section, key).ToString()); |
||||||
|
return Double.Parse(s1.ToString()); |
||||||
|
} |
||||||
|
public void SetString(String section, String key, String val) |
||||||
|
{ |
||||||
|
Write(section, key, val); |
||||||
|
} |
||||||
|
public void SetInt(String section, String key, Int64 val) |
||||||
|
{ |
||||||
|
Write(section, key, val.ToString()); |
||||||
|
} |
||||||
|
public void SetDouble(String section, String key, Double val) |
||||||
|
{ |
||||||
|
Write(section, key, val.ToString()); |
||||||
|
} |
||||||
|
public void SetBool(String section, String key, Boolean val) |
||||||
|
{ |
||||||
|
Write(section, key, val.ToString()); |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
@ -0,0 +1,132 @@ |
|||||||
|
using System; |
||||||
|
/* |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Reflection; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Windows.Forms.VisualStyles; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Drawing.Imaging; |
||||||
|
using System.Globalization; |
||||||
|
using static System.Net.Mime.MediaTypeNames; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Net.NetworkInformation; |
||||||
|
using System.Net; |
||||||
|
using System.Management; |
||||||
|
using System.IO.Ports; |
||||||
|
using System.IO; |
||||||
|
using System.Security.Cryptography; |
||||||
|
using System.Windows.Forms.Design; |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region Медианный фильтр |
||||||
|
public class GMedian<T> where T : IComparable<T> |
||||||
|
{ |
||||||
|
private T[] buf; |
||||||
|
byte _count = 0; |
||||||
|
UInt16 _num = 0; |
||||||
|
|
||||||
|
public GMedian(UInt16 num) |
||||||
|
{ |
||||||
|
buf = new T[num]; |
||||||
|
_count = 0; |
||||||
|
_num = num; |
||||||
|
} |
||||||
|
public T filtered(T newVal) |
||||||
|
{ |
||||||
|
buf[_count] = newVal; |
||||||
|
if ((_count < _num - 1) && (buf[_count].CompareTo(buf[_count + 1]) > 0)) |
||||||
|
{ |
||||||
|
for (int i = _count; i < _num - 1; i++) |
||||||
|
{ |
||||||
|
if (buf[i].CompareTo(buf[i + 1]) > 0) |
||||||
|
{ |
||||||
|
T buff = buf[i]; |
||||||
|
buf[i] = buf[i + 1]; |
||||||
|
buf[i + 1] = buff; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
if ((_count > 0) && (buf[_count - 1].CompareTo(buf[_count])) > 0) |
||||||
|
{ |
||||||
|
for (int i = _count; i > 0; i--) |
||||||
|
{ |
||||||
|
if (buf[i].CompareTo(buf[i - 1]) < 0) |
||||||
|
{ |
||||||
|
T buff = buf[i]; |
||||||
|
buf[i] = buf[i - 1]; |
||||||
|
buf[i - 1] = buff; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (++_count >= _num) _count = 0; |
||||||
|
return buf[_num / 2]; |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Медианный фильтр 2 |
||||||
|
public class GMedian3 |
||||||
|
{ |
||||||
|
public UInt16 filtered(UInt16 value) |
||||||
|
{ // возвращает фильтрованное значение |
||||||
|
bufUI16[_counter] = value; |
||||||
|
if (++_counter > 2) |
||||||
|
_counter = 0; |
||||||
|
return (Math.Max(bufUI16[0], bufUI16[1]) == Math.Max(bufUI16[1], bufUI16[2])) ? Math.Max(bufUI16[0], bufUI16[2]) : Math.Max(bufUI16[1], Math.Min(bufUI16[0], bufUI16[2])); |
||||||
|
} |
||||||
|
public Int16 filtered(Int16 value) |
||||||
|
{ // возвращает фильтрованное значение |
||||||
|
bufI16[_counter] = value; |
||||||
|
if (++_counter > 2) |
||||||
|
_counter = 0; |
||||||
|
return (Math.Max(bufI16[0], bufI16[1]) == Math.Max(bufI16[1], bufI16[2])) ? Math.Max(bufI16[0], bufI16[2]) : Math.Max(bufI16[1], Math.Min(bufI16[0], bufI16[2])); |
||||||
|
} |
||||||
|
public UInt32 filtered(UInt32 value) |
||||||
|
{ // возвращает фильтрованное значение |
||||||
|
bufUI32[_counter] = value; |
||||||
|
if (++_counter > 2) |
||||||
|
_counter = 0; |
||||||
|
return (Math.Max(bufUI32[0], bufUI32[1]) == Math.Max(bufUI32[1], bufUI32[2])) ? Math.Max(bufUI32[0], bufUI32[2]) : Math.Max(bufUI32[1], Math.Min(bufUI32[0], bufUI32[2])); |
||||||
|
} |
||||||
|
public Int32 filtered(Int32 value) |
||||||
|
{ // возвращает фильтрованное значение |
||||||
|
bufI32[_counter] = value; |
||||||
|
if (++_counter > 2) |
||||||
|
_counter = 0; |
||||||
|
return (Math.Max(bufI32[0], bufI32[1]) == Math.Max(bufI32[1], bufI32[2])) ? Math.Max(bufI32[0], bufI32[2]) : Math.Max(bufI32[1], Math.Min(bufI32[0], bufI32[2])); |
||||||
|
} |
||||||
|
public float filtered(float value) |
||||||
|
{ // возвращает фильтрованное значение |
||||||
|
buff[_counter] = value; |
||||||
|
if (++_counter > 2) |
||||||
|
_counter = 0; |
||||||
|
return (Math.Max(buff[0], buff[1]) == Math.Max(buff[1], buff[2])) ? Math.Max(buff[0], buff[2]) : Math.Max(buff[1], Math.Min(buff[0], buff[2])); |
||||||
|
} |
||||||
|
public Double filtered(Double value) |
||||||
|
{ // возвращает фильтрованное значение |
||||||
|
bufd[_counter] = value; |
||||||
|
if (++_counter > 2) |
||||||
|
_counter = 0; |
||||||
|
return (Math.Max(bufd[0], bufd[1]) == Math.Max(bufd[1], bufd[2])) ? Math.Max(bufd[0], bufd[2]) : Math.Max(bufd[1], Math.Min(bufd[0], bufd[2])); |
||||||
|
} |
||||||
|
|
||||||
|
UInt16[] bufUI16 = new UInt16[3]; |
||||||
|
Int16[] bufI16 = new Int16[3]; |
||||||
|
UInt32[] bufUI32 = new UInt32[3]; |
||||||
|
Int32[] bufI32 = new Int32[3]; |
||||||
|
Double[] bufd = new Double[3]; |
||||||
|
Single[] buff = new Single[3]; |
||||||
|
Byte _counter = 0; |
||||||
|
}; |
||||||
|
#endregion |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,253 @@ |
|||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Windows.Forms.Design; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region Компоненты меню |
||||||
|
[System.ComponentModel.DesignerCategory("code")] |
||||||
|
[ToolStripItemDesignerAvailability( |
||||||
|
ToolStripItemDesignerAvailability.ContextMenuStrip | |
||||||
|
ToolStripItemDesignerAvailability.MenuStrip | |
||||||
|
ToolStripItemDesignerAvailability.StatusStrip | |
||||||
|
ToolStripItemDesignerAvailability.ToolStrip)] |
||||||
|
public partial class ToolStripTrackBar : ToolStripControlHost |
||||||
|
{ |
||||||
|
public ToolStripTrackBar() : base(CreateControlInstance()) |
||||||
|
{ |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Create a strongly typed property called TrackBar - handy to prevent casting everywhere. |
||||||
|
/// </summary> |
||||||
|
public TrackBar TrackBar |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return Control as TrackBar; |
||||||
|
} |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Create the actual control, note this is static so it can be called from the |
||||||
|
/// constructor. |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <returns></returns> |
||||||
|
private static Control CreateControlInstance() |
||||||
|
{ |
||||||
|
TrackBar t = new TrackBar(); |
||||||
|
t.AutoSize = false; |
||||||
|
// Add other initialization code here. |
||||||
|
return t; |
||||||
|
} |
||||||
|
[DefaultValue(0)] |
||||||
|
public int Value |
||||||
|
{ |
||||||
|
get { return TrackBar.Value; } |
||||||
|
set { TrackBar.Value = value; } |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Attach to events we want to re-wrap |
||||||
|
/// </summary> |
||||||
|
/// <param name="control"></param> |
||||||
|
[DefaultValue(0)] |
||||||
|
public int Minimum |
||||||
|
{ |
||||||
|
get { return TrackBar.Minimum; } |
||||||
|
set { TrackBar.Minimum = value; } |
||||||
|
} |
||||||
|
[DefaultValue(100)] |
||||||
|
public int Maximum |
||||||
|
{ |
||||||
|
get { return TrackBar.Maximum; } |
||||||
|
set { TrackBar.Maximum = value; } |
||||||
|
} |
||||||
|
[DefaultValue(10)] |
||||||
|
public int TickFrequency |
||||||
|
{ |
||||||
|
get { return TrackBar.TickFrequency; } |
||||||
|
set { TrackBar.TickFrequency = value; } |
||||||
|
} |
||||||
|
public TickStyle TickStyle |
||||||
|
{ |
||||||
|
get { return TrackBar.TickStyle; } |
||||||
|
set { TrackBar.TickStyle = value; } |
||||||
|
} |
||||||
|
protected override void OnSubscribeControlEvents(Control control) |
||||||
|
{ |
||||||
|
base.OnSubscribeControlEvents(control); |
||||||
|
TrackBar trackBar = control as TrackBar; |
||||||
|
trackBar.ValueChanged += new EventHandler(trackBar_ValueChanged); |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Detach from events. |
||||||
|
/// </summary> |
||||||
|
/// <param name="control"></param> |
||||||
|
protected override void OnUnsubscribeControlEvents(Control control) |
||||||
|
{ |
||||||
|
base.OnUnsubscribeControlEvents(control); |
||||||
|
TrackBar trackBar = control as TrackBar; |
||||||
|
trackBar.ValueChanged -= new EventHandler(trackBar_ValueChanged); |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Routing for event |
||||||
|
/// TrackBar.ValueChanged -> ToolStripTrackBar.ValueChanged |
||||||
|
/// </summary> |
||||||
|
/// <param name="sender"></param> |
||||||
|
/// <param name="e"></param> |
||||||
|
void trackBar_ValueChanged(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
// when the trackbar value changes, fire an event. |
||||||
|
if (this.ValueChanged != null) |
||||||
|
{ |
||||||
|
ValueChanged(sender, e); |
||||||
|
} |
||||||
|
} |
||||||
|
// add an event that is subscribable from the designer. |
||||||
|
public event EventHandler ValueChanged; |
||||||
|
// set other defaults that are interesting |
||||||
|
protected override Size DefaultSize |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return new Size(200, 16); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[System.ComponentModel.DesignerCategory("code")] |
||||||
|
[ToolStripItemDesignerAvailability( |
||||||
|
ToolStripItemDesignerAvailability.ContextMenuStrip | |
||||||
|
ToolStripItemDesignerAvailability.MenuStrip | |
||||||
|
ToolStripItemDesignerAvailability.StatusStrip | |
||||||
|
ToolStripItemDesignerAvailability.ToolStrip)] |
||||||
|
public partial class ToolStripNumericUpDown : ToolStripControlHost |
||||||
|
{ |
||||||
|
public ToolStripNumericUpDown() : base(CreateControlInstance()) |
||||||
|
{ |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Create a strongly typed property called TrackBar - handy to prevent casting everywhere. |
||||||
|
/// </summary> |
||||||
|
public NumericUpDown NumericUpDown |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return Control as NumericUpDown; |
||||||
|
} |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Create the actual control, note this is static so it can be called from the |
||||||
|
/// constructor. |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <returns></returns> |
||||||
|
private static Control CreateControlInstance() |
||||||
|
{ |
||||||
|
NumericUpDown t = new NumericUpDown(); |
||||||
|
t.AutoSize = false; |
||||||
|
// Add other initialization code here. |
||||||
|
return t; |
||||||
|
} |
||||||
|
[DefaultValue(0)] |
||||||
|
public int Value |
||||||
|
{ |
||||||
|
get { return (int)NumericUpDown.Value; } |
||||||
|
set { NumericUpDown.Value = value; } |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Attach to events we want to re-wrap |
||||||
|
/// </summary> |
||||||
|
/// <param name="control"></param> |
||||||
|
[DefaultValue(0)] |
||||||
|
public int Minimum |
||||||
|
{ |
||||||
|
get { return (int)NumericUpDown.Minimum; } |
||||||
|
set { NumericUpDown.Minimum = value; } |
||||||
|
} |
||||||
|
[DefaultValue(100)] |
||||||
|
public int Maximum |
||||||
|
{ |
||||||
|
get { return (int)NumericUpDown.Maximum; } |
||||||
|
set { NumericUpDown.Maximum = value; } |
||||||
|
} |
||||||
|
[DefaultValue(10)] |
||||||
|
public int Increment |
||||||
|
{ |
||||||
|
get { return (int)NumericUpDown.Increment; } |
||||||
|
set { NumericUpDown.Increment = value; } |
||||||
|
} |
||||||
|
protected override void OnSubscribeControlEvents(Control control) |
||||||
|
{ |
||||||
|
base.OnSubscribeControlEvents(control); |
||||||
|
NumericUpDown t = control as NumericUpDown; |
||||||
|
t.ValueChanged += new EventHandler(updown_ValueChanged); |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Detach from events. |
||||||
|
/// </summary> |
||||||
|
/// <param name="control"></param> |
||||||
|
protected override void OnUnsubscribeControlEvents(Control control) |
||||||
|
{ |
||||||
|
base.OnUnsubscribeControlEvents(control); |
||||||
|
NumericUpDown t = control as NumericUpDown; |
||||||
|
t.ValueChanged -= new EventHandler(updown_ValueChanged); |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Routing for event |
||||||
|
/// TrackBar.ValueChanged -> ToolStripTrackBar.ValueChanged |
||||||
|
/// </summary> |
||||||
|
/// <param name="sender"></param> |
||||||
|
/// <param name="e"></param> |
||||||
|
void updown_ValueChanged(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
// when the trackbar value changes, fire an event. |
||||||
|
if (this.ValueChanged != null) |
||||||
|
{ |
||||||
|
ValueChanged(sender, e); |
||||||
|
} |
||||||
|
} |
||||||
|
// add an event that is subscribable from the designer. |
||||||
|
public event EventHandler ValueChanged; |
||||||
|
// set other defaults that are interesting |
||||||
|
protected override Size DefaultSize |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return new Size(200, 16); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[System.ComponentModel.DesignerCategory("code")] |
||||||
|
[ToolStripItemDesignerAvailability( |
||||||
|
ToolStripItemDesignerAvailability.ContextMenuStrip | |
||||||
|
ToolStripItemDesignerAvailability.MenuStrip | |
||||||
|
ToolStripItemDesignerAvailability.StatusStrip | |
||||||
|
ToolStripItemDesignerAvailability.ToolStrip)] |
||||||
|
public partial class ToolStripLabel : ToolStripControlHost |
||||||
|
{ |
||||||
|
public ToolStripLabel() : base(CreateControlInstance()) |
||||||
|
{ |
||||||
|
} |
||||||
|
public Label Label |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return Control as Label; |
||||||
|
} |
||||||
|
} |
||||||
|
private static Control CreateControlInstance() |
||||||
|
{ |
||||||
|
Label t = new Label(); |
||||||
|
t.AutoSize = false; |
||||||
|
t.Height = 15; |
||||||
|
// t.Width = 120; |
||||||
|
t.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; |
||||||
|
// Add other initialization code here. |
||||||
|
return t; |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
@ -0,0 +1,128 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Net.NetworkInformation; |
||||||
|
using System.Net; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region Работа с сетевыми адаптерами |
||||||
|
public class SetNet |
||||||
|
{ |
||||||
|
public void setIP(string caption, string ipaddress, Boolean dhcp) |
||||||
|
{ |
||||||
|
// SetIP(EthStatic, "/c netsh interface ip set address \"" + EthName + "\" static " + Properties.Settings.Default.EthIPac + " " + Properties.Settings.Default.Subnet + " " + Properties.Settings.Default.EthDnsac + " & netsh interface ip set dns \"" + EthName + "\" static " + Properties.Settings.Default.EthDnsac); |
||||||
|
String arg = ""; |
||||||
|
if (!dhcp) |
||||||
|
{ |
||||||
|
arg = $"/c netsh interface ipv4 set address \"{caption}\" static \"{ipaddress}\" \"255.0.0.0\""; |
||||||
|
// arg = $"/c netsh interface ipv4 set address \"{caption}\" static \"{ipaddress}\" \"255.0.0.0\" \"192.168.1.2\" & netsh interface ipv4 set dns \"{caption}\" static \"192.168.1.2\""; |
||||||
|
// arg = $"/c netsh interface ip set address \"{caption}\" static \"{ipaddress}\" \"255.0.0.0\" \"192.168.1.2\" & netsh interface ip set dns \"{caption}\" static \"192.168.1.2\""; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
arg = $"/c netsh interface ipv4 set address \"{caption}\" dhcp & netsh interface ipv4 set dns \"{caption}\" dhcp"; |
||||||
|
// arg = $"/c netsh interface ip set address \"{caption}\" dhcp & netsh interface ip set dns \"{caption}\" dhcp"; |
||||||
|
} |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
ProcessStartInfo psi = new ProcessStartInfo("cmd.exe"); |
||||||
|
psi.UseShellExecute = true; |
||||||
|
psi.WindowStyle = ProcessWindowStyle.Hidden; |
||||||
|
psi.Verb = "runas"; |
||||||
|
psi.Arguments = arg; |
||||||
|
Process ps = Process.Start(psi); |
||||||
|
ps.WaitForExit(); |
||||||
|
if (ps.HasExited) |
||||||
|
{ |
||||||
|
MessageBox.Show("Адрес изменен", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception ex) |
||||||
|
{ |
||||||
|
MessageBox.Show(ex.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
public List<String[]> getadapters() |
||||||
|
{ |
||||||
|
List<String[]> adapters = new List<string[]>(); |
||||||
|
String ip = ""; |
||||||
|
String dns = ""; |
||||||
|
String nic = ""; |
||||||
|
String gw = ""; |
||||||
|
String dhcp = ""; |
||||||
|
String ipen = ""; |
||||||
|
String sub = ""; |
||||||
|
|
||||||
|
string[] NwDesc = { "TAP", "VMware", "Windows", "Virtual", "WAN", "Microsoft", "NDIS", "Bluetooth" }; // Adapter types (Description) to be ommited |
||||||
|
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) |
||||||
|
{ |
||||||
|
if (ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet && !NwDesc.Any(ni.Description.Contains)) // check for adapter type and its description |
||||||
|
{ |
||||||
|
nic = ni.Name; |
||||||
|
Console.WriteLine($"Name: {nic} # Desc: {ni.Description} # Mac: {ni.GetPhysicalAddress().ToString()} # Status: {ni.OperationalStatus}"); |
||||||
|
|
||||||
|
if (ni.GetIPProperties().UnicastAddresses.Count == 0) |
||||||
|
ip = ""; |
||||||
|
else |
||||||
|
{ |
||||||
|
foreach (UnicastIPAddressInformation ips in ni.GetIPProperties().UnicastAddresses) |
||||||
|
{ |
||||||
|
if (ips.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) |
||||||
|
{ |
||||||
|
ip = ips.Address.ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (ni.GetIPProperties().DnsAddresses.Count == 0) |
||||||
|
dns = ""; |
||||||
|
else |
||||||
|
{ |
||||||
|
foreach (IPAddress dnsAdress in ni.GetIPProperties().DnsAddresses) |
||||||
|
{ |
||||||
|
if (dnsAdress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) |
||||||
|
{ |
||||||
|
dns = dnsAdress.ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (ni.GetIPProperties().GatewayAddresses.Count == 0) |
||||||
|
gw = ""; |
||||||
|
else |
||||||
|
{ |
||||||
|
foreach (GatewayIPAddressInformation gwAdress in ni.GetIPProperties().GatewayAddresses) |
||||||
|
{ |
||||||
|
gw = gwAdress.Address.ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
if (ni.GetIPProperties().DhcpServerAddresses.Count == 0) |
||||||
|
dhcp = ""; |
||||||
|
else |
||||||
|
{ |
||||||
|
foreach (IPAddress dhcpAdress in ni.GetIPProperties().DhcpServerAddresses) |
||||||
|
{ |
||||||
|
dhcp = dhcpAdress.ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
sub = "255.255.255.0"; |
||||||
|
if (ni.OperationalStatus.ToString() == "Down") |
||||||
|
ipen = "False"; |
||||||
|
else |
||||||
|
ipen = "True"; |
||||||
|
|
||||||
|
// Caption IPAddress IPSubnet DHCPEnabled IPEnabled |
||||||
|
Console.WriteLine($"{nic}-{ip}-{sub}-{dhcp}-{ipen}"); |
||||||
|
adapters.Add(new String[] { ni.Description, ip, sub, (dhcp == "" ? "False" : "True"), ipen, nic }); |
||||||
|
} |
||||||
|
} |
||||||
|
return adapters; |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,84 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Reflection; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Windows.Forms.VisualStyles; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Drawing.Imaging; |
||||||
|
using System.Globalization; |
||||||
|
using static System.Net.Mime.MediaTypeNames; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Net.NetworkInformation; |
||||||
|
using System.Net; |
||||||
|
using System.Management; |
||||||
|
using System.IO.Ports; |
||||||
|
using System.IO; |
||||||
|
using System.Security.Cryptography; |
||||||
|
using System.Windows.Forms.Design; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
#region Параметры командной строки |
||||||
|
public class ParParse |
||||||
|
{ |
||||||
|
private List<(bool, String, String, bool, String)> Pars = new List<(bool, string, string, bool, string)>(); |
||||||
|
private int _num = 0; |
||||||
|
private (bool, string, string, bool, string) nullitem = (false, null, null, false, null); |
||||||
|
public int NumofPar { get; } |
||||||
|
public (bool, string, string, bool, string) GetPar(UInt16 num) |
||||||
|
{ |
||||||
|
if (Pars[num].Item1) |
||||||
|
return Pars[num]; |
||||||
|
else |
||||||
|
return nullitem; |
||||||
|
} |
||||||
|
public (bool, string, string, bool, string) GetPar(String par) |
||||||
|
{ |
||||||
|
for (int j = 0; j < _num; j++) |
||||||
|
{ |
||||||
|
if ((par == Pars[j].Item2 || par == Pars[j].Item3) && Pars[j].Item1) |
||||||
|
return Pars[j]; |
||||||
|
} |
||||||
|
return nullitem; |
||||||
|
} |
||||||
|
public void AddPar(String shrt, String lng, Boolean key) |
||||||
|
{ |
||||||
|
Pars.Add((false, shrt, lng, key, "")); |
||||||
|
_num = Pars.Count; |
||||||
|
} |
||||||
|
public int Parse(String[] arg) |
||||||
|
{ |
||||||
|
int rez = 0; |
||||||
|
if (_num == 0) |
||||||
|
return -1; |
||||||
|
|
||||||
|
if (arg.Length == 0) |
||||||
|
return -1; |
||||||
|
|
||||||
|
for (int i = 0; i < arg.Length; i++) |
||||||
|
{ |
||||||
|
for (int j = 0; j < _num; j++) |
||||||
|
{ |
||||||
|
if (arg[i] == Pars[j].Item2 || arg[i] == Pars[j].Item3) |
||||||
|
{ |
||||||
|
(bool, string, string, bool, string) tmp = Pars[j]; |
||||||
|
if (Pars[j].Item4) |
||||||
|
{ |
||||||
|
tmp.Item5 = arg[i + 1]; |
||||||
|
} |
||||||
|
tmp.Item1 = true; |
||||||
|
Pars[j] = tmp; |
||||||
|
rez++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return rez; |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,87 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
public class ParParse |
||||||
|
{ |
||||||
|
private List<(bool, string, string, bool, string, string)> Pars = new List<(bool, string, string, bool, string, string)>(); |
||||||
|
private int _num = 0; |
||||||
|
private (bool, string, string, bool, string, string) nullitem = (false, null, null, false, null,null); |
||||||
|
public int NumofPar { get; } |
||||||
|
|
||||||
|
public ParParse() |
||||||
|
{ |
||||||
|
AddPar("-h","--help",false, "Использование"); |
||||||
|
} |
||||||
|
public (bool, string, string, bool, string, string) GetPar(UInt16 num) |
||||||
|
{ |
||||||
|
if (Pars[num].Item1) |
||||||
|
return Pars[num]; |
||||||
|
else |
||||||
|
return nullitem; |
||||||
|
} |
||||||
|
public (bool, string, string, bool, string, string) GetPar(string par) |
||||||
|
{ |
||||||
|
for (int j = 0; j < _num; j++) |
||||||
|
{ |
||||||
|
if ((par == Pars[j].Item2 || par == Pars[j].Item3) && Pars[j].Item1) |
||||||
|
return Pars[j]; |
||||||
|
} |
||||||
|
return nullitem; |
||||||
|
} |
||||||
|
public void AddPar(string shrt, string lng, Boolean key, string info) |
||||||
|
{ |
||||||
|
Pars.Add((false, shrt, lng, key, "", info)); |
||||||
|
_num = Pars.Count; |
||||||
|
} |
||||||
|
public int Parse(String[] arg) |
||||||
|
{ |
||||||
|
int rez = 0; |
||||||
|
if (_num == 0) |
||||||
|
return -1; |
||||||
|
|
||||||
|
if (arg.Length == 0) |
||||||
|
return -1; |
||||||
|
|
||||||
|
for (int i = 0; i < arg.Length; i++) |
||||||
|
{ |
||||||
|
for (int j = 0; j < _num; j++) |
||||||
|
{ |
||||||
|
if (arg[i] == Pars[j].Item2 || arg[i] == Pars[j].Item3) |
||||||
|
{ |
||||||
|
(bool, string, string, bool, string, string) tmp = Pars[j]; |
||||||
|
if (Pars[j].Item4) |
||||||
|
{ |
||||||
|
tmp.Item5 = arg[i + 1]; |
||||||
|
} |
||||||
|
tmp.Item1 = true; |
||||||
|
Pars[j] = tmp; |
||||||
|
rez++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return rez; |
||||||
|
} |
||||||
|
public void help() |
||||||
|
{ |
||||||
|
string s = ""; |
||||||
|
for (int i = 0; i < _num; i++) |
||||||
|
{ |
||||||
|
if (Pars[i].Item3 != "") |
||||||
|
s += $" {Pars[i].Item2}|{Pars[i].Item3}"; |
||||||
|
else |
||||||
|
s += $" {Pars[i].Item2}"; |
||||||
|
} |
||||||
|
Console.WriteLine($"Использование:\r\nGetVer3.exe{s}"); |
||||||
|
for (int i = 0; i < _num; i++) |
||||||
|
{ |
||||||
|
if (Pars[i].Item3 != "") |
||||||
|
Console.WriteLine($"{Pars[i].Item2} {Pars[i].Item3}\t{Pars[i].Item6}"); |
||||||
|
else |
||||||
|
Console.WriteLine($"{Pars[i].Item2}\t{Pars[i].Item6}"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,86 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
public class ParParse |
||||||
|
{ |
||||||
|
private List<(bool, string, string, bool, string, string)> Pars = new List<(bool, string, string, bool, string, string)>(); |
||||||
|
private int _num = 0; |
||||||
|
private (bool, string, string, bool, string, string) nullitem = (false, null, null, false, null,null); |
||||||
|
public int NumofPar { get; } |
||||||
|
|
||||||
|
public ParParse() |
||||||
|
{ |
||||||
|
AddPar("-h","--help",false, "Использование"); |
||||||
|
} |
||||||
|
public (bool, string, string, bool, string, string) GetPar(UInt16 num) |
||||||
|
{ |
||||||
|
if (Pars[num].Item1) |
||||||
|
return Pars[num]; |
||||||
|
else |
||||||
|
return nullitem; |
||||||
|
} |
||||||
|
public (bool, string, string, bool, string, string) GetPar(string par) |
||||||
|
{ |
||||||
|
for (int j = 0; j < _num; j++) |
||||||
|
{ |
||||||
|
if ((par == Pars[j].Item2 || par == Pars[j].Item3) && Pars[j].Item1) |
||||||
|
return Pars[j]; |
||||||
|
} |
||||||
|
return nullitem; |
||||||
|
} |
||||||
|
public void AddPar(string shrt, string lng, Boolean key, string info) |
||||||
|
{ |
||||||
|
Pars.Add((false, shrt, lng, key, "", info)); |
||||||
|
_num = Pars.Count; |
||||||
|
} |
||||||
|
public int Parse(String[] arg) |
||||||
|
{ |
||||||
|
int rez = 0; |
||||||
|
if (_num == 0) |
||||||
|
return -1; |
||||||
|
|
||||||
|
if (arg.Length == 0) |
||||||
|
return -1; |
||||||
|
|
||||||
|
for (int i = 0; i < arg.Length; i++) |
||||||
|
{ |
||||||
|
for (int j = 0; j < _num; j++) |
||||||
|
{ |
||||||
|
if (arg[i] == Pars[j].Item2 || arg[i] == Pars[j].Item3) |
||||||
|
{ |
||||||
|
(bool, string, string, bool, string, string) tmp = Pars[j]; |
||||||
|
if (Pars[j].Item4) |
||||||
|
{ |
||||||
|
tmp.Item5 = arg[i + 1]; |
||||||
|
} |
||||||
|
tmp.Item1 = true; |
||||||
|
Pars[j] = tmp; |
||||||
|
rez++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return rez; |
||||||
|
} |
||||||
|
public void help() |
||||||
|
{ |
||||||
|
string s = ""; |
||||||
|
for (int i = 0; i < _num; i++) |
||||||
|
{ |
||||||
|
if (Pars[i].Item3 != "") |
||||||
|
s += $" {Pars[i].Item2}|{Pars[i].Item3}"; |
||||||
|
else |
||||||
|
s += $" {Pars[i].Item2}"; |
||||||
|
} |
||||||
|
Console.WriteLine($"Использование:\r\nGetVer3.exe{s}"); |
||||||
|
for (int i = 0; i < _num; i++) |
||||||
|
{ |
||||||
|
if (Pars[i].Item3 != "") |
||||||
|
Console.WriteLine($"{Pars[i].Item2} {Pars[i].Item3}\t{Pars[i].Item6}"); |
||||||
|
else |
||||||
|
Console.WriteLine($"{Pars[i].Item2}\t{Pars[i].Item6}"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -1,97 +0,0 @@ |
|||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Linq; |
|
||||||
using System.Text; |
|
||||||
using System.Threading.Tasks; |
|
||||||
using System.Drawing; |
|
||||||
using System.Drawing.Imaging; |
|
||||||
|
|
||||||
namespace Grav01 |
|
||||||
{ |
|
||||||
public unsafe class UnsafeBitmap |
|
||||||
{ |
|
||||||
Bitmap bitmap; |
|
||||||
// three elements used for MakeGreyUnsafe |
|
||||||
int width; |
|
||||||
BitmapData bitmapData = null; |
|
||||||
Byte* pBase = null; |
|
||||||
public UnsafeBitmap(Bitmap bitmap) |
|
||||||
{ |
|
||||||
this.bitmap = new Bitmap(bitmap); |
|
||||||
} |
|
||||||
public UnsafeBitmap(int width, int height) |
|
||||||
{ |
|
||||||
this.bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb); |
|
||||||
} |
|
||||||
public void Dispose() |
|
||||||
{ |
|
||||||
bitmap.Dispose(); |
|
||||||
} |
|
||||||
public Bitmap Bitmap |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return (bitmap); |
|
||||||
} |
|
||||||
} |
|
||||||
private Point PixelSize |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
GraphicsUnit unit = GraphicsUnit.Pixel; |
|
||||||
RectangleF bounds = bitmap.GetBounds(ref unit); |
|
||||||
|
|
||||||
return new Point((int)bounds.Width, (int)bounds.Height); |
|
||||||
} |
|
||||||
} |
|
||||||
public void LockBitmap() |
|
||||||
{ |
|
||||||
GraphicsUnit unit = GraphicsUnit.Pixel; |
|
||||||
RectangleF boundsF = bitmap.GetBounds(ref unit); |
|
||||||
Rectangle bounds = new Rectangle((int)boundsF.X, |
|
||||||
(int)boundsF.Y, |
|
||||||
(int)boundsF.Width, |
|
||||||
(int)boundsF.Height); |
|
||||||
|
|
||||||
// Figure out the number of bytes in a row |
|
||||||
// This is rounded up to be a multiple of 4 |
|
||||||
// bytes, since a scan line in an image must always be a multiple of 4 bytes |
|
||||||
// in length. |
|
||||||
width = (int)boundsF.Width * sizeof(PixelData); |
|
||||||
if (width % 4 != 0) |
|
||||||
{ |
|
||||||
width = 4 * (width / 4 + 1); |
|
||||||
} |
|
||||||
bitmapData = |
|
||||||
bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); |
|
||||||
pBase = (Byte*)bitmapData.Scan0.ToPointer(); |
|
||||||
} |
|
||||||
public PixelData GetPixel(int x, int y) |
|
||||||
{ |
|
||||||
PixelData returnValue = *PixelAt(x, y); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
public void SetPixel(int x, int y, PixelData colour) |
|
||||||
{ |
|
||||||
PixelData* pixel = PixelAt(x, y); |
|
||||||
*pixel = colour; |
|
||||||
} |
|
||||||
public void UnlockBitmap() |
|
||||||
{ |
|
||||||
bitmap.UnlockBits(bitmapData); |
|
||||||
bitmapData = null; |
|
||||||
pBase = null; |
|
||||||
} |
|
||||||
public PixelData* PixelAt(int x, int y) |
|
||||||
{ |
|
||||||
return (PixelData*)(pBase + y * width + x * sizeof(PixelData)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public struct PixelData |
|
||||||
{ |
|
||||||
public byte blue; |
|
||||||
public byte green; |
|
||||||
public byte red; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,417 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Security.AccessControl; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
public enum MscVer |
||||||
|
{ |
||||||
|
// ReSharper disable InconsistentNaming |
||||||
|
// |
||||||
|
// MSC 1.0 _MSC_VER == 100 |
||||||
|
// MSC 2.0 _MSC_VER == 200 |
||||||
|
// MSC 3.0 _MSC_VER == 300 |
||||||
|
// MSC 4.0 _MSC_VER == 400 |
||||||
|
// MSC 5.0 _MSC_VER == 500 |
||||||
|
// MSC 6.0 _MSC_VER == 600 |
||||||
|
// MSC 7.0 _MSC_VER == 700 |
||||||
|
// MSVC++ 1.0 _MSC_VER == 800 |
||||||
|
// MSVC++ 2.0 _MSC_VER == 900 |
||||||
|
// MSVC++ 4.0 _MSC_VER == 1000 (Developer Studio 4.0) |
||||||
|
// MSVC++ 4.2 _MSC_VER == 1020 (Developer Studio 4.2) |
||||||
|
// MSVC++ 5.0 _MSC_VER == 1100 (Visual Studio 97 version 5.0) |
||||||
|
// MSVC++ 6.0 _MSC_VER == 1200 (Visual Studio 6.0 version 6.0) |
||||||
|
// MSVC++ 7.0 _MSC_VER == 1300 (Visual Studio .NET 2002 version 7.0) |
||||||
|
// MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio .NET 2003 version 7.1) |
||||||
|
|
||||||
|
Vs_2005 = 1400, // MSVC++ 8.0 |
||||||
|
Vs_2008 = 1500, // MSVC++ 9.0 |
||||||
|
Vs_2010 = 1600, // MSVC++ 10.0 |
||||||
|
Vs_2012 = 1700, // MSVC++ 11.0 |
||||||
|
Vs_2013 = 1800, // MSVC++ 12.0 |
||||||
|
Vs_2015 = 1900, // MSVC++ 14.0 |
||||||
|
Vs_2017_15_0 = 1910, // MSVC++ 14.10 |
||||||
|
Vs_2017_15_3 = 1911, // MSVC++ 14.11 |
||||||
|
Vs_2017_15_5 = 1912, // MSVC++ 14.12 |
||||||
|
Vs_2017_15_6 = 1913, // MSVC++ 14.13 |
||||||
|
Vs_2017_15_7 = 1914, // MSVC++ 14.14 |
||||||
|
Vs_2017_15_8 = 1915, // MSVC++ 14.15 |
||||||
|
Vs_2017_15_9 = 1916, // MSVC++ 14.16 |
||||||
|
Vs_2019_16_0 = 1920, // MSVC++ 14.2 |
||||||
|
Vs_2022_17_0 = 1930, // MSVC++ 14.30 |
||||||
|
Vs_2022_17_1 = 1931 // MSVC++ 14.31 |
||||||
|
} |
||||||
|
public enum ArchType |
||||||
|
{ |
||||||
|
// ReSharper disable InconsistentNaming |
||||||
|
x86, |
||||||
|
x64, |
||||||
|
IA64 |
||||||
|
} |
||||||
|
public static class Msi |
||||||
|
{ |
||||||
|
public static bool IsInstalled(IEnumerable<Guid> productCodes) |
||||||
|
{ |
||||||
|
return productCodes.Any(IsInstalled); |
||||||
|
} |
||||||
|
|
||||||
|
public static bool IsInstalled(Guid productCode) |
||||||
|
{ |
||||||
|
var state = MsiQueryProductState($"{{{productCode}}}"); |
||||||
|
|
||||||
|
return state == InstallState.INSTALLSTATE_LOCAL || |
||||||
|
state == InstallState.INSTALLSTATE_DEFAULT; |
||||||
|
} |
||||||
|
|
||||||
|
[DllImport("msi.dll", CharSet = CharSet.Unicode, SetLastError = true)] |
||||||
|
private static extern InstallState MsiQueryProductState(string product); |
||||||
|
} |
||||||
|
|
||||||
|
public enum InstallState |
||||||
|
{ |
||||||
|
// ReSharper disable InconsistentNaming |
||||||
|
INSTALLSTATE_NOTUSED = -7, // component disabled |
||||||
|
INSTALLSTATE_BADCONFIG = -6, // configuration datacorrupt |
||||||
|
INSTALLSTATE_INCOMPLETE = -5, // installationsuspended or in progress |
||||||
|
INSTALLSTATE_SOURCEABSENT = -4, // run from source,source is unavailable |
||||||
|
INSTALLSTATE_MOREDATA = -3, // return bufferoverflow |
||||||
|
INSTALLSTATE_INVALIDARG = -2, // invalid functionargument |
||||||
|
INSTALLSTATE_UNKNOWN = -1, // unrecognized productor feature |
||||||
|
INSTALLSTATE_BROKEN = 0, // broken |
||||||
|
INSTALLSTATE_ADVERTISED = 1, // advertised feature |
||||||
|
INSTALLSTATE_REMOVED = 1, // component being removed(action state, not settable) |
||||||
|
INSTALLSTATE_ABSENT = 2, // uninstalled (or actionstate absent but clients remain) |
||||||
|
INSTALLSTATE_LOCAL = 3, // installed on local drive |
||||||
|
INSTALLSTATE_SOURCE = 4, // run from source, CD ornet |
||||||
|
INSTALLSTATE_DEFAULT = 5, // use default, local orsource |
||||||
|
} |
||||||
|
|
||||||
|
public class VcRuntimeVersion |
||||||
|
{ |
||||||
|
public Guid ProductCode { get; set; } |
||||||
|
public MscVer MscVer { get; set; } |
||||||
|
public ArchType Architecture { get; set; } |
||||||
|
public string Version { get; set; } |
||||||
|
|
||||||
|
public VcRuntimeVersion(Guid productCode, MscVer mscVer, ArchType architecture, string version = "") |
||||||
|
{ |
||||||
|
ProductCode = productCode; |
||||||
|
MscVer = mscVer; |
||||||
|
Architecture = architecture; |
||||||
|
Version = version; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static class VcRuntime |
||||||
|
{ |
||||||
|
public static IEnumerable<VcRuntimeVersion> GetInstalled(Func<VcRuntimeVersion, bool> predicate) |
||||||
|
{ |
||||||
|
return KnownRuntimeVersions.Where(predicate).Where(n => Msi.IsInstalled(n.ProductCode)); |
||||||
|
} |
||||||
|
|
||||||
|
public static List<VcRuntimeVersion> KnownRuntimeVersions => new List<VcRuntimeVersion> |
||||||
|
{ |
||||||
|
// https://en.wikipedia.org/wiki/Microsoft_Visual_C++ |
||||||
|
// https://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library |
||||||
|
|
||||||
|
// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) |
||||||
|
// ================================================= |
||||||
|
// 8.0.50727.42 |
||||||
|
// 8.0.50727.762 |
||||||
|
// 8.0.50727.4053 |
||||||
|
// todo 8.0.50727.5592 (can't find guids. see https://blogs.msdn.microsoft.com/astebner/2007/01/24/updated-vc-8-0-runtime-redistributable-packages-are-included-in-visual-studio-2005-sp1/) |
||||||
|
// 8.0.50727.6195 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{C1C4F017-81CC-94C4-C8FB-1542C0981A2A}"), MscVer.Vs_2005, ArchType.x86, "6.0.2900.2180"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{1AF2A8DA-7E60-D0B4-29D7-E6453B3D0182}"), MscVer.Vs_2005, ArchType.x64, "6.0.2900.2180"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{A49F249F-0C91-497F-86DF-B2585E8E76B7}"), MscVer.Vs_2005, ArchType.x86, "8.0.50727.42"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{6E8E85E8-CE4B-4FF5-91F7-04999C9FAE6A}"), MscVer.Vs_2005, ArchType.x64, "8.0.50727.42"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{03ED71EA-F531-4927-AABD-1C31BCE8E187}"), MscVer.Vs_2005, ArchType.IA64, "8.0.50727.42"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{7299052B-02A4-4627-81F2-1818DA5D550D}"), MscVer.Vs_2005, ArchType.x86, "8.0.50727.762"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{071C9B48-7C32-4621-A0AC-3F809523288F}"), MscVer.Vs_2005, ArchType.x64, "8.0.50727.762"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{0F8FB34E-675E-42ED-850B-29D98C2ECE08}"), MscVer.Vs_2005, ArchType.IA64, "8.0.50727.762"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{837B34E3-7C30-493C-8F6A-2B0F04E2912C}"), MscVer.Vs_2005, ArchType.x86, "8.0.50727.4053"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{6CE5BAE9-D3CA-4B99-891A-1DC6C118A5FC}"), MscVer.Vs_2005, ArchType.x64, "8.0.50727.4053"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{85025851-A784-46D8-950D-05CB3CA43A13}"), MscVer.Vs_2005, ArchType.IA64, "8.0.50727.4053"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{710F4C1C-CC18-4C49-8CBF-51240C89A1A2}"), MscVer.Vs_2005, ArchType.x86, "8.0.50727.6195"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{AD8A2FA1-06E7-4B0D-927D-6E54B3D31028}"), MscVer.Vs_2005, ArchType.x64, "8.0.50727.6195"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C2F60BDA-462A-4A72-8E4D-CA431A56E9EA}"), MscVer.Vs_2005, ArchType.IA64, "8.0.50727.6195"), |
||||||
|
|
||||||
|
// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) |
||||||
|
// ================================================= |
||||||
|
// 9.0.21022.8 |
||||||
|
// todo 9.0.30411 |
||||||
|
// todo 9.0.30729.1 |
||||||
|
// 9.0.30729.17 |
||||||
|
// 9.0.30729.4148 |
||||||
|
// todo 9.0.30729.5570 |
||||||
|
// 9.0.30729.5677 |
||||||
|
// 9.0.30729.6161 (see https://blogs.msdn.microsoft.com/astebner/2009/01/29/mailbag-how-to-detect-the-presence-of-the-visual-c-9-0-runtime-redistributable-package/) |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}"), MscVer.Vs_2008, ArchType.x86, "9.0.21022.8"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{350AA351-21FA-3270-8B7A-835434E766AD}"), MscVer.Vs_2008, ArchType.x64, "9.0.21022.8"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{2B547B43-DB50-3139-9EBE-37D419E0F5FA}"), MscVer.Vs_2008, ArchType.IA64, "9.0.21022.8"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{9A25302D-30C0-39D9-BD6F-21E6EC160475}"), MscVer.Vs_2008, ArchType.x86, "9.0.30729.17"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{8220EEFE-38CD-377E-8595-13398D740ACE}"), MscVer.Vs_2008, ArchType.x64, "9.0.30729.17"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{5827ECE1-AEB0-328E-B813-6FC68622C1F9}"), MscVer.Vs_2008, ArchType.IA64, "9.0.30729.17"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{1F1C2DFC-2D24-3E06-BCB8-725134ADF989}"), MscVer.Vs_2008, ArchType.x86, "9.0.30729.4148"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{4B6C7001-C7D6-3710-913E-5BC23FCE91E6}"), MscVer.Vs_2008, ArchType.x64, "9.0.30729.4148"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{977AD349-C2A8-39DD-9273-285C08987C7B}"), MscVer.Vs_2008, ArchType.IA64, "9.0.30729.4148"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{6E815EB9-6CCE-9A53-884E-7857C57002F0}"), MscVer.Vs_2008, ArchType.x86, "9.0.30729.5677"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{67D6ECF5-CD5F-BA73-2B8B-22BAC8DE1B4D}"), MscVer.Vs_2008, ArchType.x64, "9.0.30729.5677"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{9BE518E6-ECC6-35A9-88E4-87755C07200F}"), MscVer.Vs_2008, ArchType.x86, "9.0.30729.6161"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{5FCE6D76-F5DC-37AB-B2B8-22AB8CEDB1D4}"), MscVer.Vs_2008, ArchType.x64, "9.0.30729.6161"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{515643D1-4E9E-342F-A75A-D1F16448DC04}"), MscVer.Vs_2008, ArchType.IA64, "9.0.30729.6161"), |
||||||
|
|
||||||
|
// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) |
||||||
|
// ================================================= |
||||||
|
// 10.0.30319.1 |
||||||
|
// todo 10.0.30319.415 |
||||||
|
// 10.0.40219.1 |
||||||
|
// 10.0.40219.325 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{196BB40D-1578-3D01-B289-BEFC77A11A1E}"), MscVer.Vs_2010, ArchType.x86, "10.0.30319.1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}"), MscVer.Vs_2010, ArchType.x64, "10.0.30319.1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C1A35166-4301-38E9-BA67-02823AD72A1B}"), MscVer.Vs_2010, ArchType.IA64, "10.0.30319.1"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}"), MscVer.Vs_2010, ArchType.x86, "10.0.40219.1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{1D8E6291-B0D5-35EC-8441-6616F567A0F7}"), MscVer.Vs_2010, ArchType.x64, "10.0.40219.1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}"), MscVer.Vs_2010, ArchType.IA64, "10.0.40219.1"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{1D5E3C0F-EDA1-E123-1876-86FED06E995A}"), MscVer.Vs_2010, ArchType.x86, "10.0.40219.325"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{1926E8D1-5D0B-CE53-4814-66615F760A7F}"), MscVer.Vs_2010, ArchType.x64, "10.0.40219.325"), |
||||||
|
|
||||||
|
// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) |
||||||
|
// ================================================= |
||||||
|
// todo 11.0.50727.1 |
||||||
|
// todo 11.0.51106.1 |
||||||
|
// todo 11.0.60610.1 |
||||||
|
// 11.0.61030 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{33D1FD90-4274-48A1-9BC1-97E33D9C2D6F}"), MscVer.Vs_2012, ArchType.x86, "11.0.61030"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{CA67548A-5EBE-413A-B50C-4B9CEB6D66C6}"), MscVer.Vs_2012, ArchType.x64, "11.0.61030"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{BD95A8CD-1D9F-35AD-981A-3E7925026EBB}"), MscVer.Vs_2012, ArchType.x86, "11.0.61030 - Minimum runtime (Update 4)"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}"), MscVer.Vs_2012, ArchType.x64, "11.0.61030 - Minimum runtime (Update 4)"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B175520C-86A2-35A7-8619-86DC379688B9}"), MscVer.Vs_2012, ArchType.x86, "11.0.61030 - Additional runtime (Update 4)"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{37B8F9C7-03FB-3253-8781-2517C99D7C00}"), MscVer.Vs_2012, ArchType.x64, "11.0.61030 - Additional runtime (Update 4)"), |
||||||
|
|
||||||
|
// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) |
||||||
|
// ================================================= |
||||||
|
// todo 12.0.21005.1 |
||||||
|
// 12.0.30501 |
||||||
|
// 12.0.40660 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{F65DB027-AFF3-4070-886A-0D87064AABB1}"), MscVer.Vs_2013, ArchType.x86, "12.0.30501"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{050D4FC8-5D48-4B8F-8972-47C82C46020F}"), MscVer.Vs_2013, ArchType.x64, "12.0.30501"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{13A4EE12-23EA-3371-91EE-EFB36DDFFF3E}"), MscVer.Vs_2013, ArchType.x86, "12.0.30501 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{A749D8E6-B613-3BE3-8F5F-045C84EBA29B}"), MscVer.Vs_2013, ArchType.x64, "12.0.30501 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{F8CFEB22-A2E7-3971-9EDA-4B11EDEFC185}"), MscVer.Vs_2013, ArchType.x86, "12.0.30501 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{929FBD26-9020-399B-9A7A-751D61F0B942}"), MscVer.Vs_2013, ArchType.x64, "12.0.30501 - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{61087a79-ac85-455c-934d-1fa22cc64f36}"), MscVer.Vs_2013, ArchType.x86, "12.0.40660"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{ef6b00ec-13e1-4c25-9064-b2f383cb8412}"), MscVer.Vs_2013, ArchType.x64, "12.0.40660"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{E30D8B21-D82D-3211-82CC-0F0A5D1495E8}"), MscVer.Vs_2013, ArchType.x86, "12.0.40660 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{CB0836EC-B072-368D-82B2-D3470BF95707}"), MscVer.Vs_2013, ArchType.x64, "12.0.40660 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{7DAD0258-515C-3DD4-8964-BD714199E0F7}"), MscVer.Vs_2013, ArchType.x86, "12.0.40660 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{5740BD44-B58D-321A-AFC0-6D3D4556DD6C}"), MscVer.Vs_2013, ArchType.x64, "12.0.40660 - Additional runtime"), |
||||||
|
|
||||||
|
// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) |
||||||
|
// ================================================= |
||||||
|
// 14.0.23026 |
||||||
|
// 14.0.23506 |
||||||
|
// 14.0.23918 |
||||||
|
// 14.0.24123 |
||||||
|
// todo 14.0.24210 (can't find 14.0.24210 installer - 03 Feb 2019) |
||||||
|
// 14.0.24212 |
||||||
|
// 14.0.24215 |
||||||
|
// 14.0.24215.1 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{74D0E5DB-B326-4DAE-A6B2-445B9DE1836E}"), MscVer.Vs_2015, ArchType.x86, "14.0.23026"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{E46ECA4F-393B-40DF-9F49-076FAF788D83}"), MscVer.Vs_2015, ArchType.x64, "14.0.23026"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{A2563E55-3BEC-3828-8D67-E5E8B9E8B675}"), MscVer.Vs_2015, ArchType.x86, "14.0.23026 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{0D3E9E15-DE7A-300B-96F1-B4AF12B96488}"), MscVer.Vs_2015, ArchType.x64, "14.0.23026 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{BE960C1C-7BAD-3DE6-8B1A-2616FE532845}"), MscVer.Vs_2015, ArchType.x86, "14.0.23026 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{BC958BD2-5DAC-3862-BB1A-C1BE0790438D}"), MscVer.Vs_2015, ArchType.x64, "14.0.23026 - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{23DAF363-3020-4059-B3AE-DC4AD39FED19}"), MscVer.Vs_2015, ArchType.x86, "14.0.23506"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{3EE5E5BB-B7CC-4556-8861-A00A82977D6C}"), MscVer.Vs_2015, ArchType.x64, "14.0.23506"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{65AD78AD-D23D-3A1E-9305-3AE65CD522C2}"), MscVer.Vs_2015, ArchType.x86, "14.0.23506 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{A1C31BA5-5438-3A07-9EEE-A5FB2D0FDE36}"), MscVer.Vs_2015, ArchType.x64, "14.0.23506 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{1045AB6F-6151-3634-8C2C-EE308AA1A6A7}"), MscVer.Vs_2015, ArchType.x86, "14.0.23506 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B0B194F8-E0CE-33FE-AA11-636428A4B73D}"), MscVer.Vs_2015, ArchType.x64, "14.0.23506 - Additional Runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{2E085FD2-A3E4-4B39-8E10-6B8D35F55244}"), MscVer.Vs_2015, ArchType.x86, "14.0.23918"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{DAB68466-3A7D-41A8-A5CF-415E3FF8EF71}"), MscVer.Vs_2015, ArchType.x64, "14.0.23918"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{262779DB-23A3-4517-BBCD-A05A9FF0570B}"), MscVer.Vs_2015, ArchType.x86, "14.0.23918 - Redistributable"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{9F647882-65A3-4A6A-83CE-5E601E3D10A6}"), MscVer.Vs_2015, ArchType.x64, "14.0.23918 - Redistributable"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B5FC62F5-A367-37A5-9FD2-A6E137C0096F}"), MscVer.Vs_2015, ArchType.x86, "14.0.23918 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{7B50D081-E670-3B43-A460-0E2CDB5CE984}"), MscVer.Vs_2015, ArchType.x64, "14.0.23918 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{BD9CFD69-EB91-354E-9C98-D439E6091932}"), MscVer.Vs_2015, ArchType.x86, "14.0.23918 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{DFFEB619-5455-3697-B145-243D936DB95B}"), MscVer.Vs_2015, ArchType.x64, "14.0.23918 - Additional Runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{206898CC-4B41-4D98-AC28-9F9AE57F91FE}"), MscVer.Vs_2015, ArchType.x86, "14.0.24123"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{2CBCEDBB-F38C-48A3-A3E1-6C6FD821A7F4}"), MscVer.Vs_2015, ArchType.x64, "14.0.24123"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{06AE3BCC-7612-39D3-9F3B-B6601D877D02}"), MscVer.Vs_2015, ArchType.x86, "14.0.24123 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{FDBE9DB4-7A91-3A28-B27E-705EF7CFAE57}"), MscVer.Vs_2015, ArchType.x64, "14.0.24123 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{03AC7A79-F8AF-38FC-9DA0-98DAB4F4B1CD}"), MscVer.Vs_2015, ArchType.x86, "14.0.24123 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{21134089-9B59-34C8-BE11-929D26AD5207}"), MscVer.Vs_2015, ArchType.x64, "14.0.24123 - Additional Runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{8FD71E98-EE44-3844-9DAD-9CB0BBBC603C}"), MscVer.Vs_2015, ArchType.x86, "14.0.24210"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C0B2C673-ECAA-372D-94E5-E89440D087AD}"), MscVer.Vs_2015, ArchType.x64, "14.0.24210"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{462F63A8-6347-4894-A1B3-DBFE3A4C981D}"), MscVer.Vs_2015, ArchType.x86, "14.0.24212"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{323DAD84-0974-4D90-A1C1-E006C7FDBB7D}"), MscVer.Vs_2015, ArchType.x64, "14.0.24212"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{37B55901-995A-3650-80B1-BBFD047E2911}"), MscVer.Vs_2015, ArchType.x86, "14.0.24212 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{FAAD7243-0141-3987-AA2F-E56B20F80E41}"), MscVer.Vs_2015, ArchType.x64, "14.0.24212 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{844ECB74-9B63-3D5C-958C-30BD23F19EE4}"), MscVer.Vs_2015, ArchType.x86, "14.0.24212 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{F20396E5-D84E-3505-A7A8-7358F0155F6C}"), MscVer.Vs_2015, ArchType.x64, "14.0.24212 - Additional Runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{BBF2AC74-720C-3CB3-8291-5E34039232FA}"), MscVer.Vs_2015, ArchType.x86, "14.0.24215 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{50A2BC33-C9CD-3BF1-A8FF-53C10A0B183C}"), MscVer.Vs_2015, ArchType.x64, "14.0.24215 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C956892E-D1F3-3781-935C-8D9060E7CD7E}"), MscVer.Vs_2015, ArchType.x86, "14.0.24215 - Debug runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{406CC721-9FAD-3610-B44E-3130F84358D8}"), MscVer.Vs_2015, ArchType.x64, "14.0.24215 - Debug runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{69BCE4AC-9572-3271-A2FB-9423BDA36A43}"), MscVer.Vs_2015, ArchType.x86, "14.0.24215 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{EF1EC6A9-17DE-3DA9-B040-686A1E8A8B04}"), MscVer.Vs_2015, ArchType.x64, "14.0.24215 - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{E2803110-78B3-4664-A479-3611A381656A}"), MscVer.Vs_2015, ArchType.x86, "14.0.24215.1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{D992C12E-CAB2-426F-BDE3-FB8C53950B0D}"), MscVer.Vs_2015, ArchType.x64, "14.0.24215.1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{BBF2AC74-720C-3CB3-8291-5E34039232FA}"), MscVer.Vs_2015, ArchType.x86, "14.0.24215.1 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{50A2BC33-C9CD-3BF1-A8FF-53C10A0B183C}"), MscVer.Vs_2015, ArchType.x64, "14.0.24215.1 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{69BCE4AC-9572-3271-A2FB-9423BDA36A43}"), MscVer.Vs_2015, ArchType.x86, "14.0.24215.1 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{EF1EC6A9-17DE-3DA9-B040-686A1E8A8B04}"), MscVer.Vs_2015, ArchType.x64, "14.0.24215.1 - Additional Runtime"), |
||||||
|
|
||||||
|
// MSVC++ 14.1 _MSC_VER >= 1910 (Visual Studio 2017) |
||||||
|
// ================================================= |
||||||
|
// 14.10.24629.0-rc1 |
||||||
|
// 14.10.24911-rc5 |
||||||
|
// 14.10.24930-rc6 |
||||||
|
// 14.10.25008 MSVC++ 14.1 _MSC_VER == 1910 (Visual Studio 2017 version 15.0) |
||||||
|
// 14.11.25325 MSVC++ 14.11 _MSC_VER == 1911 (Visual Studio 2017 version 15.3) |
||||||
|
// 14.12.25810 MSVC++ 14.12 _MSC_VER == 1912 (Visual Studio 2017 version 15.5) |
||||||
|
// todo 14.13.26020 MSVC++ 14.13 _MSC_VER == 1913 (Visual Studio 2017 version 15.6) |
||||||
|
// 14.14.26405 MSVC++ 14.14 _MSC_VER == 1914 (Visual Studio 2017 version 15.7) |
||||||
|
// 14.14.26429.4 |
||||||
|
// todo 14.15.26706 MSVC++ 14.15 _MSC_VER == 1915 (Visual Studio 2017 version 15.8) |
||||||
|
// 14.16.27012.6 MSVC++ 14.16 _MSC_VER == 1916 (Visual Studio 2017 version 15.9) - todo incomplete, find all guids |
||||||
|
// 14.16.27024.1 |
||||||
|
// todo 14.16.27026.1 |
||||||
|
// 14.16.27027 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{7d9c81d7-a921-4503-8518-38fc0c94b692}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24629.0-rc1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{c60f2e5a-912d-426c-a6b1-8a80bebab424}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24629.0-rc1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{27B6EB53-CB9C-3461-B05D-EB5210EBA3D4}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24629 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C8086B63-C436-3F8B-8064-CE8F27815C5F}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24629 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{44EC2AE5-F313-3E2A-8167-9923138ED5B4}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24629 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{ADC1B84A-D61D-3B2F-854A-8F872E51BB65}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24629 - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{C64E9A20-DF31-4B11-ADA1-00909EB1B508}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24911-rc5"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{0A898FD4-A90B-46E2-8F20-46DDB3F24B6E}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24911-rc5"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{0C1C3F23-69C2-3D3D-9865-F8B6215289CD}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24911-rc5 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{F0793C5B-0227-3294-91DE-0385602C6CBC}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24911-rc5 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{568BE2F1-A2B2-3705-BF3E-8E6197382A46}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24911-rc5 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{E9A123F9-306E-3A29-88B9-5CD521D9109D}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24911-rc5 - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{3E053C90-8E3B-4A1B-AB2E-AFB57D20F4B0}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24930-rc6"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{20B93B94-495D-4022-A84F-F598998991BF}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24930-rc6"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{984D10BE-0781-3A9D-80FB-03540E0C3B42}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24930-rc6 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{9F50D497-02C0-3BBB-9103-BFE6204FA318}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24930-rc6 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{9AAEB713-D24D-37A4-8FBC-7A24739D3156}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.24930-rc6 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{A8755EE8-AD62-37FE-B106-243DC209CF52}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.24930-rc6 - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{C239CEA1-D49E-4E16-8E87-8C055765F7EC}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.25008-rtm"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{F1E7E313-06DF-4C56-96A9-99FDFD149C51}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.25008-rtm"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C6CDA568-CD91-3CA0-9EDE-DAD98A13D6E1}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.25008-rtm - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{8D50D8C6-1E3D-3BAB-B2B7-A5399EA1EBD1}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.25008-rtm - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{2F8A908C-0CCD-3BDD-9212-DC6696525139}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.25008-rtm - Debug runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B0763AF1-2B66-33B7-B6AF-78E123AEA826}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.25008-rtm - Debug runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{E6222D59-608C-3018-B86B-69BD241ACDE5}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.10.25008-rtm - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C668F044-4825-330D-8F9F-3CBFC9F2AB89}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.10.25008-rtm - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{404c9c27-8377-4fd1-b607-7ca635db4e49}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.11.25325"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{6c6356fe-cbfa-4944-9bed-a9e99f45cb7a}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.11.25325"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{029DA848-1A80-34D3-BFC1-A6447BFC8E7F}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.11.25325 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B0037450-526D-3448-A370-CACBD87769A0}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.11.25325 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{568CD07E-0824-3EEB-AEC1-8FD51F3C85CF}"), MscVer.Vs_2017_15_0, ArchType.x86, "14.11.25325 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B13B3E11-1555-353F-A63A-8933EE104FBD}"), MscVer.Vs_2017_15_0, ArchType.x64, "14.11.25325 - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{404c9c27-8377-4fd1-b607-7ca635db4e49}"), MscVer.Vs_2017_15_3, ArchType.x86, "14.11.25325"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{6c6356fe-cbfa-4944-9bed-a9e99f45cb7a}"), MscVer.Vs_2017_15_3, ArchType.x64, "14.11.25325"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{029DA848-1A80-34D3-BFC1-A6447BFC8E7F}"), MscVer.Vs_2017_15_3, ArchType.x86, "14.11.25325 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B0037450-526D-3448-A370-CACBD87769A0}"), MscVer.Vs_2017_15_3, ArchType.x64, "14.11.25325 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{568CD07E-0824-3EEB-AEC1-8FD51F3C85CF}"), MscVer.Vs_2017_15_3, ArchType.x86, "14.11.25325 - Additional runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B13B3E11-1555-353F-A63A-8933EE104FBD}"), MscVer.Vs_2017_15_3, ArchType.x64, "14.11.25325 - Additional runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{E2EE15E2-A480-4BC5-BFB7-E9803D1D9823}"), MscVer.Vs_2017_15_5, ArchType.x64, "14.12.25810"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{56e11d69-7cc9-40a5-a4f9-8f6190c4d84d}"), MscVer.Vs_2017_15_5, ArchType.x86, "14.12.25810"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{2CD849A7-86A1-34A6-B8F9-D72F5B21A9AE}"), MscVer.Vs_2017_15_5, ArchType.x64, "14.12.25810 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{7FED75A1-600C-394B-8376-712E2A8861F2}"), MscVer.Vs_2017_15_5, ArchType.x86, "14.12.25810 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C99E2ADC-0347-336E-A603-F1992B09D582}"), MscVer.Vs_2017_15_5, ArchType.x64, "14.12.25810 - Minimum runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{828952EB-5572-3666-8CA9-000B6CE79350}"), MscVer.Vs_2017_15_5, ArchType.x86, "14.12.25810 - Minimum runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{EC9C2282-A836-48A6-9E41-C2F0BF8D678B}"), MscVer.Vs_2017_15_5, ArchType.x86, "14.14.26405"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{5B295BA9-EF89-4AEB-8ACC-B61ADB0B9B5F}"), MscVer.Vs_2017_15_5, ArchType.x64, "14.14.26405"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{644544A0-318A-344C-964C-4DBE2FB5F864}"), MscVer.Vs_2017_15_5, ArchType.x86, "14.14.26405 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{BCA8F863-9BAB-3398-B8E4-E1D0959D0943}"), MscVer.Vs_2017_15_5, ArchType.x64, "14.14.26405 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{36BF9A30-89CD-30BD-804D-09148F99DC67}"), MscVer.Vs_2017_15_5, ArchType.x86, "14.14.26405 - Debug Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{874453C7-F1A2-3087-AE5B-A4D4C83B29B4}"), MscVer.Vs_2017_15_5, ArchType.x64, "14.14.26405 - Debug Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{2BCACFA1-2BE1-373C-9051-76A9661D9FC4}"), MscVer.Vs_2017_15_5, ArchType.x86, "14.14.26405 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{A2999714-5C2C-3729-A911-4AE198B7B2FD}"), MscVer.Vs_2017_15_5, ArchType.x64, "14.14.26405 - Additional Runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{7753EC39-3039-3629-98BE-447C5D869C09}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.14.26429 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{03EBF679-E886-38AD-8E70-28658449F7F9}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.14.26429 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{6F0267F3-7467-350D-A8C8-33B72E3658D8}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.14.26429 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B12F584A-DE7A-3EE3-8EC4-8A64DBC0F2A7}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.14.26429 - Additional Runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{67f67547-9693-4937-aa13-56e296bd40f6}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.16.27012"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{427ada59-85e7-4bc8-b8d5-ebf59db60423}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.16.27012"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{3ECD99CB-EDAF-45DA-AD9C-2C4875F375FB}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.16.27012 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{7B77DE7F-5219-435E-9CE1-FC77F1D4CCAD}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.16.27012 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{DF5B1280-A057-4536-9D03-3BCAA0D4C6F0}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.16.27012 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{DD6BC8D7-4582-4677-BAAC-4AB933E6C315}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.16.27012 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{BC1F17EB-F70C-4A9D-BAFE-BFFCF3DE24E2}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.16.27012 - Debug Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{4FCD7550-A8CF-47FF-AEA9-E0B03F9E82E7}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.16.27012 - Debug Runtime"), |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{2ff11a2a-f7ac-4a6c-8cd4-c7bb974f3642}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.16.27024.1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{5fb2083a-f3cc-4b78-93ff-bd9788b5de01}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.16.27024.1"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{5EEFCEFB-E5F7-4C82-99A5-813F04AA4FBD}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.16.27024.1 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{F1B0FB3A-E0EA-47A6-9383-3650655403B0}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.16.27024.1 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{7258184A-EC44-4B1A-A7D3-68D85A35BFD0}"), MscVer.Vs_2017_15_7, ArchType.x86, "14.16.27024.1 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{9D29FC96-9EEE-4253-943F-96B3BBFDD0B6}"), MscVer.Vs_2017_15_7, ArchType.x64, "14.16.27024.1 - Additional Runtime"), |
||||||
|
|
||||||
|
// MSVC++ 16.0 _MSC_VER >= 1920 (Visual Studio 2019) |
||||||
|
// ================================================= |
||||||
|
// 14.20.27508 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{F3241984-5A0E-4632-9025-AA16E0780A4B}"), MscVer.Vs_2019_16_0, ArchType.x64, "14.20.27508 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{B96F6FA1-530F-42F1-9F71-33C583716340}"), MscVer.Vs_2019_16_0, ArchType.x86, "14.20.27508 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{4931385B-094D-4DC5-BD6A-5188FE9C51DF}"), MscVer.Vs_2019_16_0, ArchType.x64, "14.20.27508 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{C9DE51F8-7846-4621-815D-E8AFD3E3C0FF}"), MscVer.Vs_2019_16_0, ArchType.x86, "14.20.27508 - Additional Runtime"), |
||||||
|
|
||||||
|
// MSVC++ 17.0 _MSC_VER >= 1930 (Visual Studio 2022) |
||||||
|
// ================================================= |
||||||
|
// 14.30.30704 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{662A0088-6FCD-45DD-9EA7-68674058AED5}"), MscVer.Vs_2022_17_0, ArchType.x64, "14.30.30704 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{F6080405-9FA8-4CAA-9982-14E95D1A3DAC}"), MscVer.Vs_2022_17_0, ArchType.x86, "14.30.30704 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{6DB765A8-05AF-49A1-A71D-6F645EE3CE41}"), MscVer.Vs_2022_17_0, ArchType.x64, "14.30.30704 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{BF08E976-B92E-4336-B56F-2171179476C4}"), MscVer.Vs_2022_17_0, ArchType.x86, "14.30.30704 - Additional Runtime"), |
||||||
|
|
||||||
|
// 14.31.31103 |
||||||
|
|
||||||
|
new VcRuntimeVersion(Guid.Parse("{A181A302-3F6D-4BAD-97A8-A426A6499D78}"), MscVer.Vs_2022_17_1, ArchType.x64, "14.31.31103 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{799E3FFF-705C-461F-B400-6DE27398B3E5}"), MscVer.Vs_2022_17_1, ArchType.x86, "14.31.31103 - Minimum Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{A977984B-9244-49E3-BD24-43F0A8009667}"), MscVer.Vs_2022_17_1, ArchType.x64, "14.31.31103 - Additional Runtime"), |
||||||
|
new VcRuntimeVersion(Guid.Parse("{5720EC03-F26F-40B7-980C-50B5D420B5DE}"), MscVer.Vs_2022_17_1, ArchType.x86, "14.31.31103 - Additional Runtime") |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,292 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Drawing; |
||||||
|
using System.Data; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Reflection.Emit; |
||||||
|
using System.Windows.Forms.VisualStyles; |
||||||
|
|
||||||
|
namespace Control2 |
||||||
|
{ |
||||||
|
public partial class AdvancedLabel : UserControl |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Обязательная переменная конструктора. |
||||||
|
/// </summary> |
||||||
|
private System.ComponentModel.IContainer components = null; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Освободить все используемые ресурсы. |
||||||
|
/// </summary> |
||||||
|
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param> |
||||||
|
protected override void Dispose(bool disposing) |
||||||
|
{ |
||||||
|
if (disposing && (components != null)) |
||||||
|
{ |
||||||
|
components.Dispose(); |
||||||
|
} |
||||||
|
base.Dispose(disposing); |
||||||
|
} |
||||||
|
|
||||||
|
#region Код, автоматически созданный конструктором компонентов |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Требуемый метод для поддержки конструктора — не изменяйте |
||||||
|
/// содержимое этого метода с помощью редактора кода. |
||||||
|
/// </summary> |
||||||
|
private void InitializeComponent() |
||||||
|
{ |
||||||
|
this.label1 = new System.Windows.Forms.Label(); |
||||||
|
this.label2 = new System.Windows.Forms.Label(); |
||||||
|
this.SuspendLayout(); |
||||||
|
// |
||||||
|
// label1 |
||||||
|
// |
||||||
|
this.label1.AutoEllipsis = true; |
||||||
|
this.label1.Dock = System.Windows.Forms.DockStyle.Left; |
||||||
|
this.label1.Location = new System.Drawing.Point(0, 0); |
||||||
|
this.label1.Name = "label1"; |
||||||
|
this.label1.Size = new System.Drawing.Size(35, 16); |
||||||
|
this.label1.TabIndex = 0; |
||||||
|
this.label1.Text = "label1"; |
||||||
|
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; |
||||||
|
this.label1.Click += new System.EventHandler(this.label1_Click); |
||||||
|
this.label1.Resize += new System.EventHandler(this.label1_Resize); |
||||||
|
// |
||||||
|
// label2 |
||||||
|
// |
||||||
|
this.label2.AutoEllipsis = true; |
||||||
|
this.label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; |
||||||
|
this.label2.Dock = System.Windows.Forms.DockStyle.Right; |
||||||
|
this.label2.Location = new System.Drawing.Point(56, 0); |
||||||
|
this.label2.Name = "label2"; |
||||||
|
this.label2.Size = new System.Drawing.Size(56, 16); |
||||||
|
this.label2.TabIndex = 1; |
||||||
|
this.label2.Text = "label2"; |
||||||
|
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; |
||||||
|
this.label2.Click += new System.EventHandler(this.label2_Click); |
||||||
|
// |
||||||
|
// AdvancedLabel |
||||||
|
// |
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||||
|
this.AutoSize = true; |
||||||
|
this.Controls.Add(this.label2); |
||||||
|
this.Controls.Add(this.label1); |
||||||
|
this.MinimumSize = new System.Drawing.Size(70, 16); |
||||||
|
this.Name = "AdvancedLabel"; |
||||||
|
this.Size = new System.Drawing.Size(112, 16); |
||||||
|
this.Load += new System.EventHandler(this.AdvancedLabel_Load); |
||||||
|
this.ResumeLayout(false); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
private System.Windows.Forms.Label label1; |
||||||
|
private System.Windows.Forms.Label label2; |
||||||
|
public AdvancedLabel() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
public String Txt |
||||||
|
{ |
||||||
|
get => label1.Text; |
||||||
|
set |
||||||
|
{ |
||||||
|
if (InvokeRequired) |
||||||
|
label1.BeginInvoke((MethodInvoker)(() => label1.Text = value)); |
||||||
|
else |
||||||
|
label1.Text = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public String Value |
||||||
|
{ |
||||||
|
get => label2.Text; |
||||||
|
set |
||||||
|
{ |
||||||
|
if (InvokeRequired) |
||||||
|
label2.BeginInvoke((MethodInvoker)(() => label2.Text = value)); |
||||||
|
else |
||||||
|
label2.Text = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public void Val<T>(T value) |
||||||
|
{ |
||||||
|
label2.Text = value.ToString(); |
||||||
|
} |
||||||
|
public Int32 Width1 |
||||||
|
{ |
||||||
|
get => label1.Width; |
||||||
|
set |
||||||
|
{ |
||||||
|
Width = value + label2.Width + Space; |
||||||
|
label1.Width = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public Int32 Width2 |
||||||
|
{ |
||||||
|
get => label2.Width; |
||||||
|
set |
||||||
|
{ |
||||||
|
label2.Width = value; |
||||||
|
Width = value + label1.Width + Space; |
||||||
|
} |
||||||
|
} |
||||||
|
public Int32 Space |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return Width - label1.Width - label2.Width; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
Width = value + label1.Width + label2.Width; |
||||||
|
// label2.Left = value + label1.Width; |
||||||
|
} |
||||||
|
} |
||||||
|
public Int32 LabelWidth |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return label1.Width + Space + label2.Width; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
Width = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public System.Drawing.ContentAlignment ValAlign |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return label2.TextAlign; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
label2.TextAlign = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public BorderStyle Border |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return label2.BorderStyle; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
label2.BorderStyle = value; |
||||||
|
} |
||||||
|
} |
||||||
|
private void label1_Resize(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
// label2.Top = label1.Top; |
||||||
|
// label2.Left = label1.Left + label1.Width + 6; |
||||||
|
} |
||||||
|
|
||||||
|
private void label1_Click(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void AdvancedLabel_Load(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void label2_Click(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
public class AdvancedRadioButton : CheckBox |
||||||
|
{ |
||||||
|
public enum Level { Parent, Form }; |
||||||
|
|
||||||
|
[Category("AdvancedRadioButton"), |
||||||
|
Description("Gets or sets the level that specifies which RadioButton controls are affected."), |
||||||
|
DefaultValue(Level.Parent)] |
||||||
|
public Level GroupNameLevel { get; set; } |
||||||
|
|
||||||
|
[Category("AdvancedRadioButton"), |
||||||
|
Description("Gets or sets the name that specifies which RadioButton controls are mutually exclusive.")] |
||||||
|
public string GroupName { get; set; } |
||||||
|
|
||||||
|
protected override void OnCheckedChanged(EventArgs e) |
||||||
|
{ |
||||||
|
base.OnCheckedChanged(e); |
||||||
|
|
||||||
|
if (Checked) |
||||||
|
{ |
||||||
|
var arbControls = (dynamic)null; |
||||||
|
switch (GroupNameLevel) |
||||||
|
{ |
||||||
|
case Level.Parent: |
||||||
|
if (this.Parent != null) |
||||||
|
arbControls = GetAll(this.Parent, typeof(AdvancedRadioButton)); |
||||||
|
break; |
||||||
|
case Level.Form: |
||||||
|
Form form = this.FindForm(); |
||||||
|
if (form != null) |
||||||
|
arbControls = GetAll(this.FindForm(), typeof(AdvancedRadioButton)); |
||||||
|
break; |
||||||
|
} |
||||||
|
if (arbControls != null) |
||||||
|
foreach (Control control in arbControls) |
||||||
|
if (control != this && |
||||||
|
(control as AdvancedRadioButton).GroupName == this.GroupName) |
||||||
|
(control as AdvancedRadioButton).Checked = false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnClick(EventArgs e) |
||||||
|
{ |
||||||
|
if (!Checked) |
||||||
|
base.OnClick(e); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnPaint(PaintEventArgs pevent) |
||||||
|
{ |
||||||
|
CheckBoxRenderer.DrawParentBackground(pevent.Graphics, pevent.ClipRectangle, this); |
||||||
|
|
||||||
|
RadioButtonState radioButtonState; |
||||||
|
if (Checked) |
||||||
|
{ |
||||||
|
radioButtonState = RadioButtonState.CheckedNormal; |
||||||
|
if (Focused) |
||||||
|
radioButtonState = RadioButtonState.CheckedHot; |
||||||
|
if (!Enabled) |
||||||
|
radioButtonState = RadioButtonState.CheckedDisabled; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
radioButtonState = RadioButtonState.UncheckedNormal; |
||||||
|
if (Focused) |
||||||
|
radioButtonState = RadioButtonState.UncheckedHot; |
||||||
|
if (!Enabled) |
||||||
|
radioButtonState = RadioButtonState.UncheckedDisabled; |
||||||
|
} |
||||||
|
|
||||||
|
Size glyphSize = RadioButtonRenderer.GetGlyphSize(pevent.Graphics, radioButtonState); |
||||||
|
Rectangle rect = pevent.ClipRectangle; |
||||||
|
rect.Width -= glyphSize.Width; |
||||||
|
rect.Location = new Point(rect.Left + glyphSize.Width, rect.Top); |
||||||
|
|
||||||
|
RadioButtonRenderer.DrawRadioButton(pevent.Graphics, new System.Drawing.Point(0, rect.Height / 2 - glyphSize.Height / 2), rect, this.Text, this.Font, this.Focused, radioButtonState); |
||||||
|
} |
||||||
|
|
||||||
|
private IEnumerable<Control> GetAll(Control control, Type type) |
||||||
|
{ |
||||||
|
var controls = control.Controls.Cast<Control>(); |
||||||
|
|
||||||
|
return controls.SelectMany(ctrl => GetAll(ctrl, type)) |
||||||
|
.Concat(controls) |
||||||
|
.Where(c => c.GetType() == type); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> |
||||||
|
<CodeSnippet Format="1.0.0"> |
||||||
|
<Header> |
||||||
|
<Title>ifDEBUG</Title> |
||||||
|
<Shortcut>ifdebug</Shortcut> |
||||||
|
</Header> |
||||||
|
<Author>DK</Author> |
||||||
|
<Description>insert #if DEBUG</Description> |
||||||
|
<Snippet> |
||||||
|
<Code Language="CSharp"> |
||||||
|
<![CDATA[#if DEBUG #endif]]> |
||||||
|
</Code> |
||||||
|
</Snippet> |
||||||
|
</CodeSnippet> |
||||||
|
</CodeSnippets> |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> |
||||||
|
<CodeSnippet Format="1.0.0"> |
||||||
|
<Header> |
||||||
|
<Title>ivk</Title> |
||||||
|
<Shortcut>ivk</Shortcut> |
||||||
|
</Header> |
||||||
|
<Author>DK</Author> |
||||||
|
<Description>insert Invoke((MethodInvoker)</Description> |
||||||
|
<Snippet> |
||||||
|
<Code Language="CSharp"> |
||||||
|
<![CDATA[ this.Invoke((MethodInvoker)(delegate |
||||||
|
{ |
||||||
|
})); |
||||||
|
]]> |
||||||
|
</Code> |
||||||
|
</Snippet> |
||||||
|
</CodeSnippet> |
||||||
|
</CodeSnippets> |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
//using System.IO.Ports; |
||||||
|
//using System.Runtime.InteropServices; |
||||||
|
using Microsoft.Win32; |
||||||
|
|
||||||
|
namespace UTIL |
||||||
|
{ |
||||||
|
public class Reg |
||||||
|
{ |
||||||
|
private RegistryKey rk; |
||||||
|
public Reg(RegistryKey k, string path) |
||||||
|
{ |
||||||
|
rk = k.OpenSubKey(path, true); |
||||||
|
if (rk == null) |
||||||
|
{ |
||||||
|
rk = k.CreateSubKey(path, true); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
public string ReadKey(string keyname) |
||||||
|
{ |
||||||
|
if (rk.GetValue(keyname) != null) |
||||||
|
return rk.GetValue(keyname).ToString(); |
||||||
|
else |
||||||
|
return null; |
||||||
|
} |
||||||
|
public void WriteKey(string keyname, string val) |
||||||
|
{ |
||||||
|
rk.SetValue(keyname, val); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,370 @@ |
|||||||
|
using System; |
||||||
|
//using System.Collections.Generic; |
||||||
|
//using System.ComponentModel; |
||||||
|
//using System.Data; |
||||||
|
//using System.Drawing; |
||||||
|
//using System.IO.Ports; |
||||||
|
//using System.Linq; |
||||||
|
//using System.Text; |
||||||
|
//using System.Threading; |
||||||
|
//using System.Threading.Tasks; |
||||||
|
//using System.Windows.Forms; |
||||||
|
//using System.Xml.Linq; |
||||||
|
//using UDPLIB; |
||||||
|
using UTIL; |
||||||
|
//using PIV; |
||||||
|
//using static UDPLIB.CallBack; |
||||||
|
//using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; |
||||||
|
//using System.Reflection.Emit; |
||||||
|
//using System.Drawing.Drawing2D; |
||||||
|
//using System.Drawing.Imaging; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
//using System.Net.Sockets; |
||||||
|
//using System.IO; |
||||||
|
//using System.Net.Http; |
||||||
|
//using Microsoft.Win32; |
||||||
|
|
||||||
|
namespace nTCP |
||||||
|
{ |
||||||
|
public static class TCP |
||||||
|
{ |
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||||
|
public static unsafe struct tcpControlHeader_s |
||||||
|
{ |
||||||
|
public UInt16 signature; |
||||||
|
public UInt16 cmd; |
||||||
|
public UInt32 length; |
||||||
|
} |
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||||
|
public unsafe struct tcpControlStatus_s |
||||||
|
{ |
||||||
|
public tcpControlHeader_s hdr; |
||||||
|
public UInt16 cmd; |
||||||
|
public Byte status; |
||||||
|
public Byte ext; |
||||||
|
} |
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||||
|
public unsafe struct tcpControlVPFE_SensorCfg_s |
||||||
|
{ |
||||||
|
public tcpControlHeader_s hdr; |
||||||
|
public VPFE_sensorCfg_s cfg; |
||||||
|
} |
||||||
|
[StructLayout(LayoutKind.Explicit, Size = 20)] |
||||||
|
public unsafe struct tcpControlVPFE_CCM_s |
||||||
|
{ |
||||||
|
[FieldOffset(0)] |
||||||
|
public tcpControlHeader_s hdr; |
||||||
|
[FieldOffset(8)] |
||||||
|
public UInt16[] k; |
||||||
|
} |
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||||
|
public unsafe struct VPFE_roi_s |
||||||
|
{ |
||||||
|
public UInt16 x; |
||||||
|
public UInt16 y; |
||||||
|
public UInt16 width; |
||||||
|
public UInt16 height; |
||||||
|
} |
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)] |
||||||
|
public unsafe struct VPFE_sensorCfg_s |
||||||
|
{ |
||||||
|
public UInt32 expTimeUs; |
||||||
|
public UInt32 framePeriodUs; |
||||||
|
public VPFE_roi_s roi; |
||||||
|
} |
||||||
|
|
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_SENSOR_CFG = 0x0004; |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_CCM = 0x0005; |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_AE = 0x0006; // Set Auto Exposure |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_AWB = 0x0007; // Set Auto White Balance |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_GC = 0x0008; // Set Gamma correction |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_ABL = 0x0009; |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VIDEO_FORMAT = 0x0010; |
||||||
|
|
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_SENSOR_CFG = 0x0084; |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_CCM = 0x0085; |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_AE = 0x0086; // Get Auto Exposure |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_AWB = 0x0087; // Get Auto White Balance |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_GC = 0x0088; // Get Gamma correction |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_ABL = 0x0089; |
||||||
|
|
||||||
|
private static Int32 _tcpControlHeader = Marshal.SizeOf(typeof(tcpControlHeader_s)); |
||||||
|
private static Int32 _tcpControlStatus = Marshal.SizeOf(typeof(tcpControlStatus_s)); |
||||||
|
private static Int32 _tcpControlVPFE_SensorCfg = Marshal.SizeOf(typeof(tcpControlVPFE_SensorCfg_s)); |
||||||
|
private static Int32 _tcpControlVPFE_CCM = Marshal.SizeOf(typeof(tcpControlVPFE_CCM_s)); |
||||||
|
|
||||||
|
private static Int32 _VPFE_roi = Marshal.SizeOf(typeof(VPFE_roi_s)); |
||||||
|
private static Int32 _VPFE_sensorCfg = Marshal.SizeOf(typeof(VPFE_sensorCfg_s)); |
||||||
|
private static Int32 _VPFE_CCM = 12; |
||||||
|
|
||||||
|
public static (Int32, Int32, Int32) ggg() |
||||||
|
{ |
||||||
|
tcpControlVPFE_SensorCfg_s. |
||||||
|
return (_tcpControlVPFE_SensorCfg, _tcpControlVPFE_CCM, _tcpControlStatus); |
||||||
|
} |
||||||
|
|
||||||
|
//RTPMsgHeader |
||||||
|
private const UInt32 _len_pack = 60; |
||||||
|
private const UInt32 _len_head = 20; |
||||||
|
private static UInt32 _len_data = _len_pack - _len_head; |
||||||
|
|
||||||
|
private static Byte _VerPXCC = 2; |
||||||
|
private static Byte _Ver = 2; // версия протокола (текущая версия 2) |
||||||
|
private static Byte _P = 0; // = 0 (не используется заполнение в конце пакета) |
||||||
|
private static Byte _X = 0; // = 0 (не используются дополнительные заголовки) |
||||||
|
private static Byte _CC = 0; // = 0 (CSRC - идентификаторы не используются); |
||||||
|
private static Byte _MPT; |
||||||
|
private static Byte _M; // маркерный бит. |
||||||
|
private static Byte _PT = 99; // поле идентифицирует формат трафика RTP и определяет его интерпретацию. Задается 99 |
||||||
|
private static UInt32 _Seqcounter = 0; |
||||||
|
private static UInt16 _SeqCounter_Hi; |
||||||
|
private static UInt16 _SeqCounter_Low; |
||||||
|
private static Byte _rejim_oes; |
||||||
|
private static Byte _zahvat; |
||||||
|
private static Byte _color; |
||||||
|
private static Byte _status; |
||||||
|
|
||||||
|
public static Byte MH_VerPXCC |
||||||
|
{ |
||||||
|
get => _VerPXCC; |
||||||
|
set |
||||||
|
{ |
||||||
|
_VerPXCC = value; |
||||||
|
_Ver = (Byte)(value & 0x03); |
||||||
|
_P = (Byte)((value >> 2) & 0x01); |
||||||
|
_X = (Byte)((value >> 3) & 0x01); |
||||||
|
_CC = (Byte)((value >> 4) & 0x0F); |
||||||
|
} |
||||||
|
} |
||||||
|
public static Byte MH_MPT |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return (Byte)((_PT << 1) | _M); |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
_MPT = value; |
||||||
|
_M = (Byte)(value & 0x01); |
||||||
|
_PT = (Byte)((value >> 1) & 0x7F); |
||||||
|
} |
||||||
|
} |
||||||
|
public static Byte MH_M // маркерный бит. |
||||||
|
{ |
||||||
|
get => _M; |
||||||
|
set |
||||||
|
{ |
||||||
|
_M = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public static Byte MH_PT // поле идентифицирует формат трафика RTP и определяет его интерпретацию. Задается 99 |
||||||
|
{ |
||||||
|
get => _PT; |
||||||
|
set |
||||||
|
{ |
||||||
|
_PT = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public static UInt16 MH_SeqCounter_Low // Номер последовательности (младшие 16 бит) |
||||||
|
{ |
||||||
|
get => _SeqCounter_Low; |
||||||
|
set |
||||||
|
{ |
||||||
|
_SeqCounter_Low = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public static UInt32 MH_Timestamp; // Метка времени (90 кГц отсчеты), одинакова для всех пакетов кадра |
||||||
|
public static UInt32 MH_SSRC; // 12345678 (идентификатор источника информации) |
||||||
|
public static UInt16 MH_SeqCounter_Hi // Номер последовательности (старшие 16 бит) |
||||||
|
{ |
||||||
|
get => _SeqCounter_Hi; |
||||||
|
set |
||||||
|
{ |
||||||
|
_SeqCounter_Hi = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public static UInt16 MH_DataLen = (UInt16)_len_data; // Количество байт данных строки, включенной в пакет |
||||||
|
public static UInt16 MH_RowNumber; // Номер строки |
||||||
|
public static UInt16 MH_Offset; // Смещение первого пиксела в строке (= 0) |
||||||
|
|
||||||
|
//RTPVideoSupplementalData |
||||||
|
public static UInt16 SD_Width; // Ширина (пиксели) |
||||||
|
public static UInt16 SD_Height; // Высота (пиксели) |
||||||
|
public static float SD_AzUpr; // (град) |
||||||
|
public static float SD_ElUpr; // (град) |
||||||
|
|
||||||
|
public static Int32 SD_Shirota; // Широта БЛА (1е-7 град) |
||||||
|
public static Int32 SD_Dolgota; // Долгота БЛА (1е-7 град) |
||||||
|
public static Int32 SD_Vysota; // Высота БЛА (0,01 м) |
||||||
|
|
||||||
|
public static Int16 SD_Course; // Курс БЛА (0,01 град) |
||||||
|
public static Int16 SD_Roll; // Крен БЛА (0,01 град) |
||||||
|
public static Int16 SD_Pitch; // Тангаж БЛА (0,01 град) |
||||||
|
|
||||||
|
public static UInt16 rez0; // координата центра цели в растре изображения по горизонтали |
||||||
|
public static UInt16 rez1; //координата центра цели в растре изображения по вертикали |
||||||
|
public static UInt16 rez2; //координата центра цели в растре изображения по вертикали |
||||||
|
|
||||||
|
public static Byte rez3; // размер цели в растре эталонного изображения по горизонтали |
||||||
|
public static Byte rez4; // размер цели в растре эталонного изображения по вертикали |
||||||
|
|
||||||
|
public static Byte SD_rejim_oes // Режим ОЭС: «0» – Обзор, «1» – АС |
||||||
|
{ |
||||||
|
get => _rejim_oes; |
||||||
|
set => _rejim_oes = value; |
||||||
|
} |
||||||
|
public static Byte SD_zahvat // Захват: «0» – отсутствие захвата, «1» – налачие захвата |
||||||
|
{ |
||||||
|
get => _zahvat; |
||||||
|
set => _zahvat = value; |
||||||
|
} |
||||||
|
public static Byte SD_color // Цвет изображения: «1» – цветное, «0» – монохромное |
||||||
|
{ |
||||||
|
get => _color; |
||||||
|
set => _color = value; |
||||||
|
} |
||||||
|
public static Byte SD_Status |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
_status = 0; |
||||||
|
_status |= (Byte)(_rejim_oes << 0); |
||||||
|
_status |= (Byte)(_zahvat << 1); |
||||||
|
_status |= (Byte)(_color << 2); |
||||||
|
return _status; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
_status = value; |
||||||
|
_rejim_oes = (Byte)((value >> 0) & 0x01); |
||||||
|
_zahvat = (Byte)((value >> 1) & 0x01); |
||||||
|
_color = (Byte)((value >> 2) & 0x01); |
||||||
|
} |
||||||
|
} |
||||||
|
public static Byte rez5; |
||||||
|
|
||||||
|
public static UInt32 SeqCounter |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return (UInt32)((_SeqCounter_Hi << 16) | _SeqCounter_Low); |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
_SeqCounter_Low = (UInt16)value; |
||||||
|
_SeqCounter_Hi = (UInt16)((value >> 16) & 0xFFFF); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static Byte[] DataH0 = new Byte[_len_pack]; |
||||||
|
//public static Byte[] DataH0 = new Byte[76]; |
||||||
|
public static Byte[] DataH1 = new Byte[_len_head]; |
||||||
|
|
||||||
|
public static void MakeDataH0() |
||||||
|
{ |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_VerPXCC), 0, DataH0, 0, 1); // 0 - 0 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_MPT), 0, DataH0, 1, 1); // 1 - 1 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Low), 0, DataH0, 2, 2); // 2 - 3 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_Timestamp), 0, DataH0, 4, 4); // 4 - 7 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SSRC), 0, DataH0, 8, 4); // 8 - 11 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Hi), 0, DataH0, 12, 2); // 12 - 13 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_DataLen), 0, DataH0, 14, 2); // 14 - 15 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_RowNumber), 0, DataH0, 16, 2); // 16 - 17 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_Offset), 0, DataH0, 18, 2); // 18 - 19 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Width), 0, DataH0, 20, 2); // 20 - 21 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Height), 0, DataH0, 22, 2); // 22 - 23 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_AzUpr), 0, DataH0, 24, 4); // 24 - 27 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_ElUpr), 0, DataH0, 28, 4); // 28 - 31 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Shirota), 0, DataH0, 32, 4); // 32 - 35 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Dolgota), 0, DataH0, 36, 4); // 36 - 39 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Vysota), 0, DataH0, 40, 4); // 40 - 43 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Course), 0, DataH0, 44, 2); // 44 - 45 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Roll), 0, DataH0, 46, 2); // 46 - 47 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Pitch), 0, DataH0, 48, 2); // 48 - 49 |
||||||
|
Array.Copy(BitConverter.GetBytes(rez0), 0, DataH0, 50, 2); // 50 - 51 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(rez1), 0, DataH0, 52, 2); // 52 - 53 |
||||||
|
Array.Copy(BitConverter.GetBytes(rez2), 0, DataH0, 54, 2); // 54 - 55 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(rez3), 0, DataH0, 56, 1); // 56 - 56 |
||||||
|
Array.Copy(BitConverter.GetBytes(rez4), 0, DataH0, 57, 1); // 57 - 57 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Status), 0, DataH0, 58, 1); // 58 - 58 |
||||||
|
Array.Copy(BitConverter.GetBytes(rez5), 0, DataH0, 59, 1); // 59 - 59 |
||||||
|
} |
||||||
|
public static void MakeDataH1() |
||||||
|
{ |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_VerPXCC), 0, DataH1, 0, 1); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_MPT), 0, DataH1, 1, 1); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Low), 0, DataH1, 2, 2); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_Timestamp), 0, DataH1, 4, 4); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SSRC), 0, DataH1, 8, 4); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Hi), 0, DataH1, 12, 2); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_DataLen), 0, DataH1, 14, 2); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_RowNumber), 0, DataH1, 16, 2); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_Offset), 0, DataH1, 18, 2); |
||||||
|
} |
||||||
|
public static void GetDataH0() |
||||||
|
{ |
||||||
|
MH_VerPXCC = DataH0[0]; |
||||||
|
MH_MPT = DataH0[1]; |
||||||
|
MH_SeqCounter_Low = BitConverter.ToUInt16(DataH0, 2); |
||||||
|
MH_Timestamp = BitConverter.ToUInt32(DataH0, 4); |
||||||
|
MH_SSRC = BitConverter.ToUInt32(DataH0, 8); |
||||||
|
MH_SeqCounter_Hi = BitConverter.ToUInt16(DataH0, 12); |
||||||
|
MH_DataLen = BitConverter.ToUInt16(DataH0, 14); |
||||||
|
MH_RowNumber = BitConverter.ToUInt16(DataH0, 16); |
||||||
|
MH_Offset = BitConverter.ToUInt16(DataH0, 18); |
||||||
|
SD_Width = BitConverter.ToUInt16(DataH0, 20); |
||||||
|
SD_Height = BitConverter.ToUInt16(DataH0, 22); |
||||||
|
SD_AzUpr = BitConverter.ToSingle(DataH0, 24); |
||||||
|
SD_ElUpr = BitConverter.ToSingle(DataH0, 28); |
||||||
|
SD_Shirota = BitConverter.ToInt32(DataH0, 32); |
||||||
|
SD_Dolgota = BitConverter.ToInt32(DataH0, 36); |
||||||
|
SD_Vysota = BitConverter.ToInt32(DataH0, 40); |
||||||
|
SD_Course = BitConverter.ToInt16(DataH0, 44); |
||||||
|
SD_Roll = BitConverter.ToInt16(DataH0, 46); |
||||||
|
SD_Pitch = BitConverter.ToInt16(DataH0, 48); |
||||||
|
rez0 = BitConverter.ToUInt16(DataH0, 50); |
||||||
|
rez1 = BitConverter.ToUInt16(DataH0, 52); |
||||||
|
rez2 = BitConverter.ToUInt16(DataH0, 54); |
||||||
|
rez3 = DataH0[56]; |
||||||
|
rez4 = DataH0[57]; |
||||||
|
SD_Status = DataH0[58]; |
||||||
|
rez5 = DataH0[59]; |
||||||
|
} |
||||||
|
public static void GetDataH1() |
||||||
|
{ |
||||||
|
MH_VerPXCC = DataH0[0]; |
||||||
|
MH_MPT = DataH0[1]; |
||||||
|
MH_SeqCounter_Low = BitConverter.ToUInt16(DataH0, 2); |
||||||
|
MH_Timestamp = BitConverter.ToUInt32(DataH0, 4); |
||||||
|
MH_SSRC = BitConverter.ToUInt32(DataH0, 8); |
||||||
|
MH_SeqCounter_Hi = BitConverter.ToUInt16(DataH0, 12); |
||||||
|
MH_DataLen = BitConverter.ToUInt16(DataH0, 14); |
||||||
|
MH_RowNumber = BitConverter.ToUInt16(DataH0, 16); |
||||||
|
MH_Offset = BitConverter.ToUInt16(DataH0, 18); |
||||||
|
} |
||||||
|
|
||||||
|
private static T BuffToStruct<T>(byte[] arr) |
||||||
|
{ |
||||||
|
GCHandle handle = GCHandle.Alloc(arr, GCHandleType.Pinned); |
||||||
|
T stuff = (T)Marshal.PtrToStructure( |
||||||
|
handle.AddrOfPinnedObject(), typeof(T)); |
||||||
|
handle.Free(); |
||||||
|
return stuff; |
||||||
|
} |
||||||
|
private static byte[] StructToBuff<T>(T value) where T : struct
|
||||||
|
{ |
||||||
|
byte[] arr = new byte[Marshal.SizeOf(value)]; // создать массив |
||||||
|
GCHandle gch = GCHandle.Alloc(arr, GCHandleType.Pinned); // зафиксировать в памяти |
||||||
|
IntPtr ptr = Marshal.UnsafeAddrOfPinnedArrayElement(arr, 0); // и взять его адрес |
||||||
|
Marshal.StructureToPtr(value, ptr, true); // копировать в массив |
||||||
|
gch.Free(); // снять фиксацию |
||||||
|
return arr; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,402 @@ |
|||||||
|
using System; |
||||||
|
//using System.Collections.Generic; |
||||||
|
//using System.ComponentModel; |
||||||
|
//using System.Data; |
||||||
|
//using System.Drawing; |
||||||
|
//using System.IO.Ports; |
||||||
|
//using System.Linq; |
||||||
|
//using System.Text; |
||||||
|
//using System.Threading; |
||||||
|
//using System.Threading.Tasks; |
||||||
|
//using System.Windows.Forms; |
||||||
|
//using System.Xml.Linq; |
||||||
|
//using UDPLIB; |
||||||
|
using UTIL; |
||||||
|
//using PIV; |
||||||
|
//using UDPLIB.CallBack; |
||||||
|
//using System.Windows.Forms.VisualStyles.VisualStyleElement.Button; |
||||||
|
//using System.Reflection.Emit; |
||||||
|
//using System.Drawing.Drawing2D; |
||||||
|
//using System.Drawing.Imaging; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Drawing; |
||||||
|
//using System.Net.Sockets; |
||||||
|
//using System.IO; |
||||||
|
//using System.Net.Http; |
||||||
|
//using Microsoft.Win32; |
||||||
|
|
||||||
|
namespace nTCP |
||||||
|
{ |
||||||
|
public class TCP |
||||||
|
{ |
||||||
|
public const UInt16 TCP_CONTROL_SIGNATURE = 0x4D58; |
||||||
|
|
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_SENSOR_CFG = 0x0004; |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_CCM = 0x0005; |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_AE = 0x0006; // Set Auto Exposure |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_AWB = 0x0007; // Set Auto White Balance |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_GC = 0x0008; // Set Gamma correction |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VPFE_ABL = 0x0009; |
||||||
|
public const UInt16 OES_CNTRL_CMD_SET_VIDEO_FORMAT = 0x0010; |
||||||
|
|
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_SENSOR_CFG = 0x0084; |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_CCM = 0x0085; |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_AE = 0x0086; // Get Auto Exposure |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_AWB = 0x0087; // Get Auto White Balance |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_GC = 0x0088; // Get Gamma correction |
||||||
|
public const UInt16 OES_CNTRL_CMD_GET_VPFE_ABL = 0x0089; |
||||||
|
|
||||||
|
private Int32 _tcpControlHeader = 8; |
||||||
|
private Int32 _tcpControlStatus = 12; |
||||||
|
private Int32 _tcpControlVPFE_SensorCfg = 24; |
||||||
|
private Int32 _tcpControlVPFE_CCM = 20; |
||||||
|
|
||||||
|
private Int32 _VPFE_roi = 8; |
||||||
|
private Int32 _VPFE_sensorCfg = 16; |
||||||
|
private Int32 _VPFE_CCM = 12; |
||||||
|
//private tcpControlVPFE_SensorCfg_s pack_SensorCfg = new tcpControlVPFE_SensorCfg_s(); |
||||||
|
//private tcpControlVPFE_CCM_s pack_VPFE_CCM = new tcpControlVPFE_CCM_s(); |
||||||
|
//private tcpControlStatus_s pack_Status_s = new tcpControlStatus_s(); |
||||||
|
|
||||||
|
public TCP() |
||||||
|
{ |
||||||
|
//pack_SensorCfg.hdr.signature = TCP_CONTROL_SIGNATURE; |
||||||
|
} |
||||||
|
public Byte[] class2buf(SensorCfg_t c) |
||||||
|
{ |
||||||
|
Byte[] buf = new Byte[_tcpControlVPFE_SensorCfg]; |
||||||
|
|
||||||
|
c.length = 16; |
||||||
|
Array.Copy(BitConverter.GetBytes(c.signature), 0, buf, 0, 2); // 0 - 0 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.cmd), 0, buf, 2, 2); // 2 - 2 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.length), 0, buf, 4, 4); // 4 - 4 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.expTimeUs), 0, buf, 8, 4); // 8 - 7 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.framePeriodUs), 0, buf, 12, 4); // 12 - 11 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.x), 0, buf, 16, 2); // 16 - 13 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.y), 0, buf, 18, 2); // 18 - 17 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.width), 0, buf, 20, 2); // 20 - 19 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.height), 0, buf, 22, 2); // 22 - 21 |
||||||
|
|
||||||
|
return buf; |
||||||
|
} |
||||||
|
public Byte[] class2buf(Status_t c) |
||||||
|
{ |
||||||
|
Byte[] buf = new Byte[_tcpControlStatus]; |
||||||
|
|
||||||
|
c.length = 4; |
||||||
|
Array.Copy(BitConverter.GetBytes(c.signature), 0, buf, 0, 2); // 0 - 0 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.cmd), 0, buf, 2, 2); // 2 - 2 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.length), 0, buf, 4, 4); // 4 - 4 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.cmd2), 0, buf, 8, 2); // 8 - 7 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.status), 0, buf, 10, 1); // 8 - 7 |
||||||
|
Array.Copy(BitConverter.GetBytes(c.ext), 0, buf, 11, 1); // 8 - 7 |
||||||
|
|
||||||
|
return buf; |
||||||
|
} |
||||||
|
public Status_t buf2Status(Byte[] buf) |
||||||
|
{ |
||||||
|
Status_t ret = new Status_t(); |
||||||
|
|
||||||
|
ret.signature = BitConverter.ToUInt16(buf, 0); |
||||||
|
ret.cmd = BitConverter.ToUInt16(buf, 2); |
||||||
|
ret.length = BitConverter.ToUInt32(buf, 4); |
||||||
|
ret.cmd2 = BitConverter.ToUInt16(buf, 8); |
||||||
|
ret.status = buf[10]; |
||||||
|
ret.ext = buf[11]; |
||||||
|
|
||||||
|
return ret; |
||||||
|
} |
||||||
|
public SensorCfg_t buf2SensorCfg(Byte[] buf) |
||||||
|
{ |
||||||
|
SensorCfg_t ret = new SensorCfg_t(); |
||||||
|
|
||||||
|
ret.signature = BitConverter.ToUInt16(buf, 0); |
||||||
|
ret.cmd = BitConverter.ToUInt16(buf, 2); |
||||||
|
ret.length = BitConverter.ToUInt32(buf, 4); |
||||||
|
ret.expTimeUs = BitConverter.ToUInt32(buf, 8); |
||||||
|
ret.framePeriodUs = BitConverter.ToUInt32(buf, 12); |
||||||
|
ret.x = BitConverter.ToUInt16(buf, 16); |
||||||
|
ret.y = BitConverter.ToUInt16(buf, 18); |
||||||
|
ret.width = BitConverter.ToUInt16(buf, 20); |
||||||
|
ret.height = BitConverter.ToUInt16(buf, 22); |
||||||
|
|
||||||
|
return ret; |
||||||
|
} |
||||||
|
public (Int32, Int32, Int32) ggg() |
||||||
|
{ |
||||||
|
return (_tcpControlVPFE_SensorCfg, _tcpControlVPFE_CCM, _tcpControlStatus); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
//RTPMsgHeader |
||||||
|
private const UInt32 _len_pack = 60; |
||||||
|
private const UInt32 _len_head = 20; |
||||||
|
private UInt32 _len_data = _len_pack - _len_head; |
||||||
|
|
||||||
|
private Byte _VerPXCC = 2; |
||||||
|
private Byte _Ver = 2; // версия протокола (текущая версия 2) |
||||||
|
private Byte _P = 0; // = 0 (не используется заполнение в конце пакета) |
||||||
|
private Byte _X = 0; // = 0 (не используются дополнительные заголовки) |
||||||
|
private Byte _CC = 0; // = 0 (CSRC - идентификаторы не используются); |
||||||
|
private Byte _MPT; |
||||||
|
private Byte _M; // маркерный бит. |
||||||
|
private Byte _PT = 99; // поле идентифицирует формат трафика RTP и определяет его интерпретацию. Задается 99 |
||||||
|
private UInt32 _Seqcounter = 0; |
||||||
|
private UInt16 _SeqCounter_Hi; |
||||||
|
private UInt16 _SeqCounter_Low; |
||||||
|
private Byte _rejim_oes; |
||||||
|
private Byte _zahvat; |
||||||
|
private Byte _color; |
||||||
|
private Byte _status; |
||||||
|
|
||||||
|
public Byte MH_VerPXCC |
||||||
|
{ |
||||||
|
get => _VerPXCC; |
||||||
|
set |
||||||
|
{ |
||||||
|
_VerPXCC = value; |
||||||
|
_Ver = (Byte)(value & 0x03); |
||||||
|
_P = (Byte)((value >> 2) & 0x01); |
||||||
|
_X = (Byte)((value >> 3) & 0x01); |
||||||
|
_CC = (Byte)((value >> 4) & 0x0F); |
||||||
|
} |
||||||
|
} |
||||||
|
public Byte MH_MPT |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return (Byte)((_PT << 1) | _M); |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
_MPT = value; |
||||||
|
_M = (Byte)(value & 0x01); |
||||||
|
_PT = (Byte)((value >> 1) & 0x7F); |
||||||
|
} |
||||||
|
} |
||||||
|
public Byte MH_M // маркерный бит. |
||||||
|
{ |
||||||
|
get => _M; |
||||||
|
set |
||||||
|
{ |
||||||
|
_M = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public Byte MH_PT // поле идентифицирует формат трафика RTP и определяет его интерпретацию. Задается 99 |
||||||
|
{ |
||||||
|
get => _PT; |
||||||
|
set |
||||||
|
{ |
||||||
|
_PT = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public UInt16 MH_SeqCounter_Low // Номер последовательности (младшие 16 бит) |
||||||
|
{ |
||||||
|
get => _SeqCounter_Low; |
||||||
|
set |
||||||
|
{ |
||||||
|
_SeqCounter_Low = value; |
||||||
|
} |
||||||
|
} |
||||||
|
public UInt32 MH_Timestamp; // Метка времени (90 кГц отсчеты), одинакова для всех пакетов кадра |
||||||
|
public UInt32 MH_SSRC; // 12345678 (идентификатор источника информации) |
||||||
|
public UInt16 MH_SeqCounter_Hi // Номер последовательности (старшие 16 бит) |
||||||
|
{ |
||||||
|
get => _SeqCounter_Hi; |
||||||
|
set |
||||||
|
{ |
||||||
|
_SeqCounter_Hi = value; |
||||||
|
} |
||||||
|
} |
||||||
|
// public UInt16 MH_DataLen = (UInt16)_len_data; // Количество байт данных строки, включенной в пакет |
||||||
|
public UInt16 MH_RowNumber; // Номер строки |
||||||
|
public UInt16 MH_Offset; // Смещение первого пиксела в строке (= 0) |
||||||
|
|
||||||
|
//RTPVideoSupplementalData |
||||||
|
public UInt16 SD_Width; // Ширина (пиксели) |
||||||
|
public UInt16 SD_Height; // Высота (пиксели) |
||||||
|
public float SD_AzUpr; // (град) |
||||||
|
public float SD_ElUpr; // (град) |
||||||
|
|
||||||
|
public Int32 SD_Shirota; // Широта БЛА (1е-7 град) |
||||||
|
public Int32 SD_Dolgota; // Долгота БЛА (1е-7 град) |
||||||
|
public Int32 SD_Vysota; // Высота БЛА (0,01 м) |
||||||
|
|
||||||
|
public Int16 SD_Course; // Курс БЛА (0,01 град) |
||||||
|
public Int16 SD_Roll; // Крен БЛА (0,01 град) |
||||||
|
public Int16 SD_Pitch; // Тангаж БЛА (0,01 град) |
||||||
|
|
||||||
|
public UInt16 rez0; // координата центра цели в растре изображения по горизонтали |
||||||
|
public UInt16 rez1; //координата центра цели в растре изображения по вертикали |
||||||
|
public UInt16 rez2; //координата центра цели в растре изображения по вертикали |
||||||
|
|
||||||
|
public Byte rez3; // размер цели в растре эталонного изображения по горизонтали |
||||||
|
public Byte rez4; // размер цели в растре эталонного изображения по вертикали |
||||||
|
|
||||||
|
public Byte SD_rejim_oes // Режим ОЭС: «0» – Обзор, «1» – АС |
||||||
|
{ |
||||||
|
get => _rejim_oes; |
||||||
|
set => _rejim_oes = value; |
||||||
|
} |
||||||
|
public Byte SD_zahvat // Захват: «0» – отсутствие захвата, «1» – налачие захвата |
||||||
|
{ |
||||||
|
get => _zahvat; |
||||||
|
set => _zahvat = value; |
||||||
|
} |
||||||
|
public Byte SD_color // Цвет изображения: «1» – цветное, «0» – монохромное |
||||||
|
{ |
||||||
|
get => _color; |
||||||
|
set => _color = value; |
||||||
|
} |
||||||
|
public Byte SD_Status |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
_status = 0; |
||||||
|
_status |= (Byte)(_rejim_oes << 0); |
||||||
|
_status |= (Byte)(_zahvat << 1); |
||||||
|
_status |= (Byte)(_color << 2); |
||||||
|
return _status; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
_status = value; |
||||||
|
_rejim_oes = (Byte)((value >> 0) & 0x01); |
||||||
|
_zahvat = (Byte)((value >> 1) & 0x01); |
||||||
|
_color = (Byte)((value >> 2) & 0x01); |
||||||
|
} |
||||||
|
} |
||||||
|
public Byte rez5; |
||||||
|
|
||||||
|
public UInt32 SeqCounter |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return (UInt32)((_SeqCounter_Hi << 16) | _SeqCounter_Low); |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
_SeqCounter_Low = (UInt16)value; |
||||||
|
_SeqCounter_Hi = (UInt16)((value >> 16) & 0xFFFF); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Byte[] DataH0 = new Byte[_len_pack]; |
||||||
|
//public Byte[] DataH0 = new Byte[76]; |
||||||
|
public Byte[] DataH1 = new Byte[_len_head]; |
||||||
|
|
||||||
|
public void MakeDataH0() |
||||||
|
{ |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_VerPXCC), 0, DataH0, 0, 1); // 0 - 0 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_MPT), 0, DataH0, 1, 1); // 1 - 1 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Low), 0, DataH0, 2, 2); // 2 - 3 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_Timestamp), 0, DataH0, 4, 4); // 4 - 7 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SSRC), 0, DataH0, 8, 4); // 8 - 11 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Hi), 0, DataH0, 12, 2); // 12 - 13 |
||||||
|
// Array.Copy(BitConverter.GetBytes(MH_DataLen), 0, DataH0, 14, 2); // 14 - 15 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_RowNumber), 0, DataH0, 16, 2); // 16 - 17 |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_Offset), 0, DataH0, 18, 2); // 18 - 19 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Width), 0, DataH0, 20, 2); // 20 - 21 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Height), 0, DataH0, 22, 2); // 22 - 23 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_AzUpr), 0, DataH0, 24, 4); // 24 - 27 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_ElUpr), 0, DataH0, 28, 4); // 28 - 31 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Shirota), 0, DataH0, 32, 4); // 32 - 35 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Dolgota), 0, DataH0, 36, 4); // 36 - 39 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Vysota), 0, DataH0, 40, 4); // 40 - 43 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Course), 0, DataH0, 44, 2); // 44 - 45 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Roll), 0, DataH0, 46, 2); // 46 - 47 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Pitch), 0, DataH0, 48, 2); // 48 - 49 |
||||||
|
Array.Copy(BitConverter.GetBytes(rez0), 0, DataH0, 50, 2); // 50 - 51 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(rez1), 0, DataH0, 52, 2); // 52 - 53 |
||||||
|
Array.Copy(BitConverter.GetBytes(rez2), 0, DataH0, 54, 2); // 54 - 55 |
||||||
|
|
||||||
|
Array.Copy(BitConverter.GetBytes(rez3), 0, DataH0, 56, 1); // 56 - 56 |
||||||
|
Array.Copy(BitConverter.GetBytes(rez4), 0, DataH0, 57, 1); // 57 - 57 |
||||||
|
Array.Copy(BitConverter.GetBytes(SD_Status), 0, DataH0, 58, 1); // 58 - 58 |
||||||
|
Array.Copy(BitConverter.GetBytes(rez5), 0, DataH0, 59, 1); // 59 - 59 |
||||||
|
} |
||||||
|
public void MakeDataH1() |
||||||
|
{ |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_VerPXCC), 0, DataH1, 0, 1); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_MPT), 0, DataH1, 1, 1); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Low), 0, DataH1, 2, 2); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_Timestamp), 0, DataH1, 4, 4); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SSRC), 0, DataH1, 8, 4); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_SeqCounter_Hi), 0, DataH1, 12, 2); |
||||||
|
// Array.Copy(BitConverter.GetBytes(MH_DataLen), 0, DataH1, 14, 2); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_RowNumber), 0, DataH1, 16, 2); |
||||||
|
Array.Copy(BitConverter.GetBytes(MH_Offset), 0, DataH1, 18, 2); |
||||||
|
} |
||||||
|
public void GetDataH0() |
||||||
|
{ |
||||||
|
MH_VerPXCC = DataH0[0]; |
||||||
|
MH_MPT = DataH0[1]; |
||||||
|
MH_SeqCounter_Low = BitConverter.ToUInt16(DataH0, 2); |
||||||
|
MH_Timestamp = BitConverter.ToUInt32(DataH0, 4); |
||||||
|
MH_SSRC = BitConverter.ToUInt32(DataH0, 8); |
||||||
|
MH_SeqCounter_Hi = BitConverter.ToUInt16(DataH0, 12); |
||||||
|
// MH_DataLen = BitConverter.ToUInt16(DataH0, 14); |
||||||
|
MH_RowNumber = BitConverter.ToUInt16(DataH0, 16); |
||||||
|
MH_Offset = BitConverter.ToUInt16(DataH0, 18); |
||||||
|
SD_Width = BitConverter.ToUInt16(DataH0, 20); |
||||||
|
SD_Height = BitConverter.ToUInt16(DataH0, 22); |
||||||
|
SD_AzUpr = BitConverter.ToSingle(DataH0, 24); |
||||||
|
SD_ElUpr = BitConverter.ToSingle(DataH0, 28); |
||||||
|
SD_Shirota = BitConverter.ToInt32(DataH0, 32); |
||||||
|
SD_Dolgota = BitConverter.ToInt32(DataH0, 36); |
||||||
|
SD_Vysota = BitConverter.ToInt32(DataH0, 40); |
||||||
|
SD_Course = BitConverter.ToInt16(DataH0, 44); |
||||||
|
SD_Roll = BitConverter.ToInt16(DataH0, 46); |
||||||
|
SD_Pitch = BitConverter.ToInt16(DataH0, 48); |
||||||
|
rez0 = BitConverter.ToUInt16(DataH0, 50); |
||||||
|
rez1 = BitConverter.ToUInt16(DataH0, 52); |
||||||
|
rez2 = BitConverter.ToUInt16(DataH0, 54); |
||||||
|
rez3 = DataH0[56]; |
||||||
|
rez4 = DataH0[57]; |
||||||
|
SD_Status = DataH0[58]; |
||||||
|
rez5 = DataH0[59]; |
||||||
|
} |
||||||
|
public void GetDataH1() |
||||||
|
{ |
||||||
|
MH_VerPXCC = DataH0[0]; |
||||||
|
MH_MPT = DataH0[1]; |
||||||
|
MH_SeqCounter_Low = BitConverter.ToUInt16(DataH0, 2); |
||||||
|
MH_Timestamp = BitConverter.ToUInt32(DataH0, 4); |
||||||
|
MH_SSRC = BitConverter.ToUInt32(DataH0, 8); |
||||||
|
MH_SeqCounter_Hi = BitConverter.ToUInt16(DataH0, 12); |
||||||
|
// MH_DataLen = BitConverter.ToUInt16(DataH0, 14); |
||||||
|
MH_RowNumber = BitConverter.ToUInt16(DataH0, 16); |
||||||
|
MH_Offset = BitConverter.ToUInt16(DataH0, 18); |
||||||
|
} |
||||||
|
*/ |
||||||
|
public delegate void Event_newmsg(); |
||||||
|
public Event_newmsg Event_newmsg_Handler; |
||||||
|
|
||||||
|
} |
||||||
|
public class Status_t |
||||||
|
{ |
||||||
|
public UInt16 signature = TCP.TCP_CONTROL_SIGNATURE; |
||||||
|
public UInt16 cmd = 0; |
||||||
|
public UInt32 length = 0; |
||||||
|
public UInt16 cmd2 = 0; |
||||||
|
public Byte status = 0; |
||||||
|
public Byte ext = 0; |
||||||
|
} |
||||||
|
public class SensorCfg_t |
||||||
|
{ |
||||||
|
public UInt16 signature = TCP.TCP_CONTROL_SIGNATURE; |
||||||
|
public UInt16 cmd = 0; |
||||||
|
public UInt32 length = 0; |
||||||
|
public UInt32 expTimeUs = 0; |
||||||
|
public UInt32 framePeriodUs = 0; |
||||||
|
public UInt16 x = 0; |
||||||
|
public UInt16 y = 0; |
||||||
|
public UInt16 width = 0; |
||||||
|
public UInt16 height = 0; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,336 @@ |
|||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using System.Net.Sockets; |
||||||
|
using System.Net; |
||||||
|
using System.Text; |
||||||
|
using System.Threading; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Summary description for Class1 |
||||||
|
/// </summary> |
||||||
|
namespace TCPSRVCLI |
||||||
|
{ |
||||||
|
public class TCPSrvCli |
||||||
|
{ |
||||||
|
private String _address; |
||||||
|
private int _port; |
||||||
|
private int _mode = -1; // -1 error, 0 server, 1 client |
||||||
|
private bool _enabled = false; |
||||||
|
private bool _connected = false; |
||||||
|
private StreamWriter sw = null; |
||||||
|
private StreamReader sr = null; |
||||||
|
private TcpClient client; |
||||||
|
Thread recv_thread = null; |
||||||
|
private TcpListener listner = null; |
||||||
|
|
||||||
|
public delegate void Recv_Mess_s(String s); |
||||||
|
public delegate void Recv_Mess_b(char[] arr); |
||||||
|
public static Recv_Mess_s onRecvS; |
||||||
|
public static Recv_Mess_b onRecvB; |
||||||
|
|
||||||
|
public bool Connected { get => _connected; } |
||||||
|
public int Mode { get => _mode; } |
||||||
|
|
||||||
|
public TCPSrvCli(String address = "127.0.0.1", int port = 12000) |
||||||
|
{ |
||||||
|
_address = address; |
||||||
|
_port = port; |
||||||
|
|
||||||
|
if (InitSrv()) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine("I a'm server"); |
||||||
|
#endif |
||||||
|
_connected = true; |
||||||
|
return; |
||||||
|
} |
||||||
|
if (InitCli()) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine("I a'm client"); |
||||||
|
#endif |
||||||
|
_connected = true; |
||||||
|
return; |
||||||
|
} |
||||||
|
_connected = false; |
||||||
|
} |
||||||
|
public bool InitCli() |
||||||
|
{ |
||||||
|
|
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine("Start Client"); |
||||||
|
#endif |
||||||
|
int timeout = 100; |
||||||
|
do |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
client = new TcpClient(); |
||||||
|
client.Connect(new IPEndPoint(IPAddress.Parse(_address), _port)); |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.Write("."); |
||||||
|
#endif |
||||||
|
Thread.Sleep(1000); |
||||||
|
} |
||||||
|
} while (!client.Connected && timeout-- > 0); |
||||||
|
|
||||||
|
if (timeout < 2) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine("\r\nError connect Client " + timeout.ToString()); |
||||||
|
#endif |
||||||
|
return false; |
||||||
|
} |
||||||
|
Console.WriteLine(); |
||||||
|
_enabled = true; |
||||||
|
sw = new StreamWriter(client.GetStream()); |
||||||
|
sr = new StreamReader(client.GetStream()); |
||||||
|
sw.AutoFlush = true; |
||||||
|
_connected = true; |
||||||
|
|
||||||
|
if (client.Connected) |
||||||
|
{ |
||||||
|
recv_thread = new Thread(new ThreadStart(Recv)); |
||||||
|
recv_thread.Start(); |
||||||
|
} |
||||||
|
_mode = 1; |
||||||
|
return true; |
||||||
|
} |
||||||
|
public bool InitSrv() |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine("Start Server"); |
||||||
|
#endif |
||||||
|
try |
||||||
|
{ |
||||||
|
listner = new TcpListener(new IPEndPoint(IPAddress.Parse(_address), _port)); |
||||||
|
listner.Start(); |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine("Error start Server"); |
||||||
|
#endif |
||||||
|
_mode = -1; |
||||||
|
return false; |
||||||
|
} |
||||||
|
_mode = 0; |
||||||
|
_enabled = true; |
||||||
|
_connected = true; |
||||||
|
|
||||||
|
client = listner.AcceptTcpClient(); |
||||||
|
sr = new StreamReader(client.GetStream()); |
||||||
|
sw = new StreamWriter(client.GetStream()); |
||||||
|
sw.AutoFlush = true; |
||||||
|
|
||||||
|
recv_thread = new Thread(new ThreadStart(Recv)); |
||||||
|
recv_thread.Start(); |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
public void Stop() |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
_enabled = false; |
||||||
|
if (_mode == 0) |
||||||
|
{ |
||||||
|
client.Close(); |
||||||
|
listner.Stop(); |
||||||
|
} |
||||||
|
if (_mode == 1) |
||||||
|
{ |
||||||
|
client.Close(); |
||||||
|
} |
||||||
|
sr.Close(); |
||||||
|
sw.Close(); |
||||||
|
_connected = false; |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine(ee); |
||||||
|
#endif |
||||||
|
} |
||||||
|
} |
||||||
|
private void Recv() |
||||||
|
{ |
||||||
|
while (_enabled) |
||||||
|
{ |
||||||
|
if (client.Available > 0) |
||||||
|
{ |
||||||
|
char[] s = new char[client.Available]; |
||||||
|
sr.Read(s, 0, s.Length); |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine(s.Length); |
||||||
|
#endif |
||||||
|
if (s[s.Length - 2] == '\r' && s[s.Length - 1] == '\n') |
||||||
|
onRecvS(new String(s)); |
||||||
|
else |
||||||
|
onRecvB(s); |
||||||
|
} |
||||||
|
} |
||||||
|
client.Close(); |
||||||
|
} |
||||||
|
public void Send(String s) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
if (client.Connected) |
||||||
|
{ |
||||||
|
sw.WriteLine(s); |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine("Send string error"); |
||||||
|
#endif |
||||||
|
Stop(); |
||||||
|
if (_mode == 0) |
||||||
|
{ |
||||||
|
InitSrv(); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (_mode == 1) |
||||||
|
{ |
||||||
|
InitCli(); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
public void Send(Byte[] b) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
if (client.Connected) |
||||||
|
{ |
||||||
|
sw.Write(Encoding.UTF8.GetChars(b)); |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine("Send array error"); |
||||||
|
#endif |
||||||
|
Stop(); |
||||||
|
if (_mode == 0) |
||||||
|
{ |
||||||
|
InitSrv(); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (_mode == 1) |
||||||
|
{ |
||||||
|
InitCli(); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class UDPSrvCli |
||||||
|
{ |
||||||
|
private String _address; |
||||||
|
private int _l_port; |
||||||
|
private int _r_port; |
||||||
|
private bool _enabled = false; |
||||||
|
private bool _connected = false; |
||||||
|
|
||||||
|
public delegate void Recv_Mess_s(String s); |
||||||
|
public delegate void Recv_Mess_b(Byte[] arr); |
||||||
|
public static Recv_Mess_s onRecvS; |
||||||
|
public static Recv_Mess_b onRecvB; |
||||||
|
|
||||||
|
public bool Connected { get => _connected; } |
||||||
|
public int LocalPort { get => _l_port; } |
||||||
|
public int RemotePort { get => _r_port; } |
||||||
|
|
||||||
|
public UDPSrvCli(String address = "127.0.0.1", int lport = 21000, int rport = 21001) |
||||||
|
{ |
||||||
|
_address = address; |
||||||
|
_l_port = lport; |
||||||
|
_r_port = rport; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
using (UdpClient tmp = new UdpClient(_l_port)) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine($"Client {_l_port}: OK"); |
||||||
|
#endif |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
_l_port = 21001; |
||||||
|
_r_port = 21000; |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine($"Client {_l_port}: OK"); |
||||||
|
#endif |
||||||
|
} |
||||||
|
Task.Run(ReceiveMessageAsync); |
||||||
|
|
||||||
|
_connected = true; |
||||||
|
_enabled = true; |
||||||
|
return; |
||||||
|
} |
||||||
|
async Task ReceiveMessageAsync() |
||||||
|
{ |
||||||
|
using (UdpClient receiver = new UdpClient(_l_port)) |
||||||
|
{ |
||||||
|
while (_enabled) |
||||||
|
{ |
||||||
|
var result = await receiver.ReceiveAsync(); |
||||||
|
if (result.Buffer[result.Buffer.Length - 2] == '\r' && result.Buffer[result.Buffer.Length - 1] == '\n') |
||||||
|
onRecvS(Encoding.UTF8.GetString(result.Buffer)); |
||||||
|
else |
||||||
|
onRecvB(result.Buffer); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public async void Send(String s) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
using (UdpClient sender = new UdpClient()) |
||||||
|
{ |
||||||
|
byte[] data = Encoding.UTF8.GetBytes($"{s}\r\n"); |
||||||
|
await sender.SendAsync(data, data.Length, new IPEndPoint(IPAddress.Parse(_address), _r_port)); |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine(ee); |
||||||
|
#endif |
||||||
|
} |
||||||
|
} |
||||||
|
public async void Send(Byte[] b) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
using (UdpClient sender = new UdpClient()) |
||||||
|
{ |
||||||
|
await sender.SendAsync(b, b.Length, new IPEndPoint(IPAddress.Parse(_address), _r_port)); |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
Console.WriteLine(ee); |
||||||
|
#endif |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void Stop() |
||||||
|
{ |
||||||
|
_enabled = false; |
||||||
|
_connected = false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,765 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Net.Sockets; |
||||||
|
using System.Net; |
||||||
|
using System.Text; |
||||||
|
using System.Threading; |
||||||
|
using nRTP; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Drawing; |
||||||
|
using System.Drawing.Imaging; |
||||||
|
using System.IO; |
||||||
|
using System.Reflection; |
||||||
|
using UTIL; |
||||||
|
|
||||||
|
namespace UDPLIB |
||||||
|
{ |
||||||
|
public class Data |
||||||
|
{ |
||||||
|
public static string Ver = "1.1.3.270"; |
||||||
|
protected static string IPAddr = "192.168.1.2"; |
||||||
|
protected static Int32 LocalPort = 5004; |
||||||
|
protected static Int32 RemotePort = 5006; |
||||||
|
#if DEBUG |
||||||
|
public static string Conf = "Debug"; |
||||||
|
#else |
||||||
|
public static string Conf = "Release"; |
||||||
|
#endif |
||||||
|
|
||||||
|
} |
||||||
|
public class UDPreceive : Data |
||||||
|
{ |
||||||
|
|
||||||
|
Thread UDPreceiveThread = null; |
||||||
|
Thread sendFrameThread = null; |
||||||
|
Stopwatch fpstimer; |
||||||
|
private volatile bool listening = false; |
||||||
|
UInt16 iwidth = 0; |
||||||
|
UInt16 iheight = 0; |
||||||
|
List<Byte[]> udata50 = new List<byte[]>(); |
||||||
|
List<Byte[]> udata51 = new List<byte[]>(); |
||||||
|
UInt32 cnt_frames = 0; |
||||||
|
Res2 rrr2 = new Res2(); // класс ресурсов на замену Res |
||||||
|
|
||||||
|
#region Прием данных |
||||||
|
public UDPreceive(Int32 localPortUDP) |
||||||
|
{ |
||||||
|
LocalPort = localPortUDP; |
||||||
|
for (int i = 0; i < 2500; i++) |
||||||
|
{ |
||||||
|
udata50.Add(new Byte[0]); |
||||||
|
udata51.Add(new Byte[0]); |
||||||
|
} |
||||||
|
fpstimer = new Stopwatch(); |
||||||
|
|
||||||
|
UDPreceiveThread = new Thread(new ThreadStart(UDPReceive7)); |
||||||
|
listening = true; |
||||||
|
UDPreceiveThread.Start(); |
||||||
|
cnt_frames = 0; |
||||||
|
} |
||||||
|
public UDPreceive() |
||||||
|
{ |
||||||
|
for (int i = 0; i < 2500; i++) |
||||||
|
{ |
||||||
|
udata50.Add(new Byte[0]); |
||||||
|
udata51.Add(new Byte[0]); |
||||||
|
} |
||||||
|
fpstimer = new Stopwatch(); |
||||||
|
|
||||||
|
UDPreceiveThread = new Thread(new ThreadStart(UDPReceive7)); |
||||||
|
listening = true; |
||||||
|
UDPreceiveThread.Start(); |
||||||
|
cnt_frames = 0; |
||||||
|
} |
||||||
|
public void Stop() |
||||||
|
{ |
||||||
|
listening = false; |
||||||
|
UDPreceiveThread.Abort(); |
||||||
|
cnt_frames = 0; |
||||||
|
} |
||||||
|
public Boolean IsAlive |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
if (UDPreceiveThread == null || !UDPreceiveThread.IsAlive) |
||||||
|
return false; |
||||||
|
else |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
void UDPReceive7() |
||||||
|
{ |
||||||
|
UdpClient receiver = null; |
||||||
|
IPEndPoint endPoint = null; |
||||||
|
EndPoint remoteIp = null; |
||||||
|
DialogResult res = DialogResult.OK; |
||||||
|
try |
||||||
|
{ |
||||||
|
// receiver = new UdpClient(localPort); |
||||||
|
receiver = new UdpClient(LocalPort); |
||||||
|
endPoint = new IPEndPoint(IPAddress.Any, LocalPort); |
||||||
|
remoteIp = new IPEndPoint(IPAddress.Any, 0); |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
res = MessageBox.Show("Порт " + LocalPort.ToString() + " используется како-то программой. \r\n" + |
||||||
|
"Прием видео невозможен. Перезапустите программу.", "Ошибка!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); |
||||||
|
System.Diagnostics.Process.GetCurrentProcess().Kill(); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
Int32 numrow = 0; |
||||||
|
Int32 numlist = 0; |
||||||
|
Int32 prevnumrow = 0; |
||||||
|
Byte[] imgarr = new Byte[1]; |
||||||
|
Byte[] blackline = null; |
||||||
|
fpstimer.Start(); |
||||||
|
|
||||||
|
while (listening) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
UInt32 packetsize = 0; |
||||||
|
UInt32 ssrc = 0; |
||||||
|
if (receiver.Available == 0) |
||||||
|
continue; |
||||||
|
byte[] data = receiver.Receive(ref endPoint); |
||||||
|
numrow = BitConverter.ToUInt16(data, 16); |
||||||
|
packetsize = (UInt32)data.Length; |
||||||
|
ssrc = BitConverter.ToUInt32(data, 8); |
||||||
|
prevnumrow = numrow; |
||||||
|
if (ssrc == 12345678) |
||||||
|
{ |
||||||
|
switch (numlist) |
||||||
|
{ |
||||||
|
case 0: |
||||||
|
udata50[numrow] = data; |
||||||
|
break; |
||||||
|
case 1: |
||||||
|
udata51[numrow] = data; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
if (numrow == 0 && ssrc == 12345678) // Packet 0 |
||||||
|
{ |
||||||
|
|
||||||
|
blackline = new Byte[iwidth * 3 + 20]; |
||||||
|
|
||||||
|
RTP.DataH0 = data; |
||||||
|
rrr2.rawheader = data; |
||||||
|
RTP.GetDataH0(); |
||||||
|
|
||||||
|
iwidth = RTP.SD_Width; |
||||||
|
iheight = RTP.SD_Height; |
||||||
|
|
||||||
|
Res.Iwidth = RTP.SD_Width; |
||||||
|
Res.Iheight = RTP.SD_Height; |
||||||
|
Res.AzUpr = RTP.SD_AzUpr; |
||||||
|
Res.ElUpr = RTP.SD_ElUpr; |
||||||
|
Res.Course = RTP.SD_Course; |
||||||
|
Res.Roll = RTP.SD_Roll; |
||||||
|
Res.Pitch = RTP.SD_Pitch; |
||||||
|
Res.Shirota = RTP.SD_Shirota; |
||||||
|
Res.Dolgota = RTP.SD_Dolgota; |
||||||
|
Res.Vysota = RTP.SD_Vysota; |
||||||
|
|
||||||
|
Res.rejim_oes = RTP.SD_rejim_oes; |
||||||
|
Res.zahvat = RTP.SD_zahvat; |
||||||
|
Res.color = RTP.SD_color; |
||||||
|
|
||||||
|
rrr2.Iwidth = RTP.SD_Width; |
||||||
|
rrr2.Iheight = RTP.SD_Height; |
||||||
|
rrr2.AzUpr = RTP.SD_AzUpr; |
||||||
|
rrr2.ElUpr = RTP.SD_ElUpr; |
||||||
|
rrr2.Course = RTP.SD_Course; |
||||||
|
rrr2.Roll = RTP.SD_Roll; |
||||||
|
rrr2.Pitch = RTP.SD_Pitch; |
||||||
|
rrr2.Shirota = RTP.SD_Shirota; |
||||||
|
rrr2.Dolgota = RTP.SD_Dolgota; |
||||||
|
rrr2.Vysota = RTP.SD_Vysota; |
||||||
|
|
||||||
|
rrr2.rejim_oes = RTP.SD_rejim_oes; |
||||||
|
rrr2.zahvat = RTP.SD_zahvat; |
||||||
|
rrr2.color = RTP.SD_color; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
if (data[1] == 0xC7 && iheight != 0 && iwidth != 0) |
||||||
|
{ |
||||||
|
switch (numlist) |
||||||
|
{ |
||||||
|
case 0: |
||||||
|
{ |
||||||
|
Thread sendFrame0 = new Thread(new ParameterizedThreadStart(processFrame7)); |
||||||
|
sendFrame0.Start(new thrdata(0, iwidth, iheight)); |
||||||
|
sendFrame0.IsBackground = true; |
||||||
|
} |
||||||
|
numlist = 1; |
||||||
|
break; |
||||||
|
case 1: |
||||||
|
{ |
||||||
|
Thread sendFrame1 = new Thread(new ParameterizedThreadStart(processFrame7)); |
||||||
|
sendFrame1.Start(new thrdata(1, iwidth, iheight)); |
||||||
|
sendFrame1.IsBackground = true; |
||||||
|
} |
||||||
|
numlist = 0; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
using (StreamWriter sw = new StreamWriter(System.IO.File.OpenWrite("udplib.log"))) |
||||||
|
{ |
||||||
|
sw.WriteLine($"{DateTime.Now.ToString("HH:mm:ss:fff ")} Error dll recv\r\n{ee.Message}"); |
||||||
|
} |
||||||
|
#endif |
||||||
|
} |
||||||
|
} |
||||||
|
receiver.Close(); |
||||||
|
Res.Fps = 0; |
||||||
|
rrr2.Fps = 0; |
||||||
|
Res.Lost = 0; |
||||||
|
rrr2.Lost = 0; |
||||||
|
CallBack.Event_newimg_Handler2(rrr2); |
||||||
|
} |
||||||
|
void processFrame7(object obj) |
||||||
|
{ |
||||||
|
Int32 lost = 0; |
||||||
|
UInt32 lostfix = 0; |
||||||
|
try |
||||||
|
{ |
||||||
|
thrdata arr = obj as thrdata; |
||||||
|
List<Byte[]> udata = new List<byte[]>(); |
||||||
|
ushort prevnumrow = 0, numrow = 0; |
||||||
|
UInt32 cnt_frame = 0; |
||||||
|
int iwi = 0; |
||||||
|
int ihe = 0; |
||||||
|
switch (arr.arr) |
||||||
|
{ |
||||||
|
case 0: |
||||||
|
udata.AddRange(udata50); |
||||||
|
break; |
||||||
|
case 1: |
||||||
|
udata.AddRange(udata51); |
||||||
|
break; |
||||||
|
} |
||||||
|
//udata50.Clear(); |
||||||
|
//udata51.Clear(); |
||||||
|
iwi = BitConverter.ToUInt16(udata[0], 20); |
||||||
|
ihe = BitConverter.ToUInt16(udata[0], 22); |
||||||
|
// проверка потерянных строк |
||||||
|
lost = 0; |
||||||
|
lostfix = 0; |
||||||
|
UInt32 ts = BitConverter.ToUInt32(udata[0], 4); |
||||||
|
for (int i = 0; i < ihe; i++) |
||||||
|
{ |
||||||
|
//Console.WriteLine($"{i}\t{udata[i].Length}"); |
||||||
|
if (BitConverter.ToUInt32(udata[i], 4) != ts) |
||||||
|
lost++; |
||||||
|
if (udata[i].Length == 0) |
||||||
|
lostfix++; |
||||||
|
} |
||||||
|
Res.Lost = (float)lost / (float)ihe; |
||||||
|
rrr2.Lost = (float)lost / (float)ihe; |
||||||
|
Res.LostFix = lostfix; |
||||||
|
rrr2.LostFix = lostfix; |
||||||
|
//Console.WriteLine($"-Lost: {(float)lost / (float)ihe * 100:F4}% {lost} {ihe} {udata.Count}"); |
||||||
|
|
||||||
|
Bitmap img = new Bitmap(iwi, ihe, System.Drawing.Imaging.PixelFormat.Format24bppRgb); |
||||||
|
Rectangle rect = new Rectangle(0, 0, iwi, ihe); |
||||||
|
|
||||||
|
unsafe |
||||||
|
{ |
||||||
|
BitmapData bmpData = img.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, img.PixelFormat); |
||||||
|
byte* curpos = ((Byte*)bmpData.Scan0); |
||||||
|
|
||||||
|
prevnumrow = numrow; |
||||||
|
cnt_frame++; |
||||||
|
int dd = 0; |
||||||
|
int ff = 0; |
||||||
|
try |
||||||
|
{ |
||||||
|
for (int h = 1; h < ihe + 1; h++) |
||||||
|
{ |
||||||
|
dd = h; |
||||||
|
for (int w = 20; w < iwi * 3 + 20; w += 3) |
||||||
|
{ |
||||||
|
ff = w; |
||||||
|
if (udata[h].Length < (iwi * 3 + 20)) |
||||||
|
{ |
||||||
|
curpos += 3; |
||||||
|
break; |
||||||
|
} |
||||||
|
*(curpos++) = udata[h][w + 2]; |
||||||
|
*(curpos++) = udata[h][w + 1]; |
||||||
|
*(curpos++) = udata[h][w + 0]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
Console.WriteLine($"!!! {ee.Message} {dd} {ff} {udata[dd].Length}"); |
||||||
|
return; |
||||||
|
} |
||||||
|
udata.Clear(); |
||||||
|
img.UnlockBits(bmpData); |
||||||
|
} |
||||||
|
Res.Clearimg = (Bitmap)img.Clone(); |
||||||
|
Res.Bmp = img; |
||||||
|
|
||||||
|
rrr2.Clearimg = (Bitmap)img.Clone(); |
||||||
|
rrr2.Bmp = img; |
||||||
|
|
||||||
|
fpstimer.Stop(); |
||||||
|
// Res.Fps = gk.filtered(1000F / fpstimer.ElapsedMilliseconds); |
||||||
|
Res.Fps = 1000F / fpstimer.ElapsedMilliseconds; |
||||||
|
Res.Frames = cnt_frames++; |
||||||
|
rrr2.Fps = 1000F / fpstimer.ElapsedMilliseconds; |
||||||
|
rrr2.Frames = cnt_frames++; |
||||||
|
// Res.Fps = 1000F / fpstimer.ElapsedMilliseconds; |
||||||
|
fpstimer.Reset(); |
||||||
|
fpstimer.Start(); |
||||||
|
CallBack.Event_newimg_Handler2(rrr2); |
||||||
|
} |
||||||
|
catch (Exception) |
||||||
|
{ |
||||||
|
#if DEBUG |
||||||
|
using (StreamWriter sw = new StreamWriter(System.IO.File.OpenWrite("udplib.log"))) |
||||||
|
{ |
||||||
|
sw.WriteLine(DateTime.Now.ToString("HH:mm:ss:fff ") + "Error lib process"); |
||||||
|
} |
||||||
|
#endif |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
|
|
||||||
|
public class UDPTransmit : Data |
||||||
|
{ |
||||||
|
UdpClient transmitter = null; |
||||||
|
IPEndPoint endPoint = null; |
||||||
|
UInt16 pntX = 0; |
||||||
|
UInt16 pntY = 0; |
||||||
|
UInt16 pntlx = 0; |
||||||
|
UInt16 pntly = 0; |
||||||
|
|
||||||
|
public UDPTransmit(String IPaddr, Int32 remotePortUDP, (UInt16, UInt16, UInt16, UInt16) p) |
||||||
|
{ |
||||||
|
transmitter = new UdpClient(); |
||||||
|
endPoint = new IPEndPoint(IPAddress.Parse(IPaddr), remotePortUDP); |
||||||
|
|
||||||
|
pntX = p.Item1; // X координата |
||||||
|
pntY = p.Item2; // Y координата |
||||||
|
pntlx = p.Item3; // ширина эталона |
||||||
|
pntly = p.Item4; // высота эталона |
||||||
|
|
||||||
|
Res.Crop = Res.Clearimg.Clone(new Rectangle(pntX - pntlx / 2, pntY - pntly / 2, pntlx, pntly), PixelFormat.Format24bppRgb); |
||||||
|
Thread UDPtransmitThread = new Thread(new ThreadStart(UDPtransmitFrame)); |
||||||
|
UDPtransmitThread.Start(); |
||||||
|
} |
||||||
|
public UDPTransmit((UInt16, UInt16, UInt16, UInt16) p) |
||||||
|
{ |
||||||
|
transmitter = new UdpClient(); |
||||||
|
endPoint = new IPEndPoint(IPAddress.Parse(IPAddr), RemotePort); |
||||||
|
|
||||||
|
pntX = p.Item1; // X координата |
||||||
|
pntY = p.Item2; // Y координата |
||||||
|
pntlx = p.Item3; // ширина эталона |
||||||
|
pntly = p.Item4; // высота эталона |
||||||
|
|
||||||
|
Res.Crop = Res.Clearimg.Clone(new Rectangle(pntX - pntlx / 2, pntY - pntly / 2, pntlx, pntly), PixelFormat.Format24bppRgb); |
||||||
|
Thread UDPtransmitThread = new Thread(new ThreadStart(UDPtransmitFrame)); |
||||||
|
UDPtransmitThread.Start(); |
||||||
|
} |
||||||
|
public UDPTransmit(String IPaddr, Int32 remotePortUDP, Bitmap crop) |
||||||
|
{ |
||||||
|
transmitter = new UdpClient(); |
||||||
|
endPoint = new IPEndPoint(IPAddress.Parse(IPaddr), remotePortUDP); |
||||||
|
Res.Crop = crop; |
||||||
|
Thread UDPtransmitThread = new Thread(new ThreadStart(UDPtransmitFrame)); |
||||||
|
UDPtransmitThread.Start(); |
||||||
|
} |
||||||
|
|
||||||
|
void UDPtransmitFrame() |
||||||
|
{ |
||||||
|
transmitter.Connect(endPoint); |
||||||
|
|
||||||
|
// RTPMsgHeader |
||||||
|
RTPet.MH_VerPXCC = 2; |
||||||
|
RTPet.MH_MPT = 0xC6; |
||||||
|
RTPet.SeqCounter = 0; //! |
||||||
|
RTPet.MH_Timestamp = (uint)DateTimeOffset.Now.ToUnixTimeSeconds(); //! |
||||||
|
RTPet.MH_PT = 99; |
||||||
|
RTPet.MH_M = 0; |
||||||
|
RTPet.MH_SSRC = 12345678; |
||||||
|
RTPet.MH_DataLen = (UInt16)(RTPet.DataH0.Length - RTPet.DataH1.Length); |
||||||
|
RTPet.MH_RowNumber = 0; |
||||||
|
RTPet.MH_Offset = 0; |
||||||
|
|
||||||
|
// RTPVideoSupplementalData |
||||||
|
RTPet.SD_Width = (ushort)Res.Crop.Width; |
||||||
|
RTPet.SD_Height = (ushort)Res.Crop.Height; |
||||||
|
RTPet.SD_AzUpr = RTP.SD_AzUpr; |
||||||
|
RTPet.SD_ElUpr = RTP.SD_ElUpr; |
||||||
|
RTPet.SD_Shirota = RTP.SD_Shirota; |
||||||
|
RTPet.SD_Dolgota = RTP.SD_Dolgota; |
||||||
|
RTPet.SD_Vysota = RTP.SD_Vysota; |
||||||
|
RTPet.SD_Course = RTP.SD_Course; |
||||||
|
RTPet.SD_Roll = RTP.SD_Roll; |
||||||
|
RTPet.SD_Pitch = RTP.SD_Pitch; |
||||||
|
RTPet.SD_X = pntX; |
||||||
|
RTPet.SD_Y = pntY; |
||||||
|
RTPet.SD_lx = (Byte)pntlx; |
||||||
|
RTPet.SD_ly = (Byte)pntly; |
||||||
|
RTPet.SD_rejim_oes = RTP.SD_rejim_oes; |
||||||
|
RTPet.SD_color = RTP.SD_color; |
||||||
|
|
||||||
|
RTPet.MakeDataH0(); |
||||||
|
transmitter.Send(RTPet.DataH0, RTPet.DataH0.Length); |
||||||
|
|
||||||
|
Byte[] dataudp = new Byte[20 + RTPet.SD_Width * 3]; |
||||||
|
|
||||||
|
Byte[] dataimg = new Byte[RTPet.SD_Width * 3]; |
||||||
|
for (int i = 0; i < RTPet.SD_Height; i++) |
||||||
|
{ |
||||||
|
// RTPMsgHeader |
||||||
|
RTPet.MH_VerPXCC = 2; |
||||||
|
if (i == RTPet.SD_Height - 1) |
||||||
|
{ |
||||||
|
RTPet.MH_PT = 99; |
||||||
|
RTPet.MH_M = 1; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
RTPet.MH_PT = 99; |
||||||
|
RTPet.MH_M = 0; |
||||||
|
} |
||||||
|
++RTPet.SeqCounter; |
||||||
|
RTPet.MH_RowNumber = (ushort)(i + 1); |
||||||
|
RTPet.MH_DataLen = (ushort)(RTPet.SD_Width * 3); |
||||||
|
RTPet.MakeDataH1(); |
||||||
|
uint ccc = 0; |
||||||
|
try |
||||||
|
{ |
||||||
|
for (int j = 0; j < RTPet.SD_Width; j++) |
||||||
|
{ |
||||||
|
Color c = Res.Crop.GetPixel(j, i); |
||||||
|
dataimg[ccc++] = c.B; |
||||||
|
dataimg[ccc++] = c.G; |
||||||
|
dataimg[ccc++] = c.R; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
Console.WriteLine(ee.Message); |
||||||
|
Console.WriteLine("Error 4 getpixel"); |
||||||
|
return; |
||||||
|
} |
||||||
|
Array.Copy(RTPet.DataH1, dataudp, RTPet.DataH1.Length); |
||||||
|
Array.Copy(dataimg, 0, dataudp, RTPet.DataH1.Length, dataimg.Length); |
||||||
|
transmitter.Send(dataudp, dataudp.Length); |
||||||
|
} |
||||||
|
transmitter.Close(); |
||||||
|
CallBack.Event_crop_transmitted_Handler(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public class UDPTransmitSim : Data |
||||||
|
{ |
||||||
|
UdpClient transmitter = null; |
||||||
|
IPEndPoint endPoint = null; |
||||||
|
Point pnt; |
||||||
|
Int32 sizeX = 0; |
||||||
|
Int32 sizeY = 0; |
||||||
|
Int32 delayMS = 0; |
||||||
|
public Bitmap img = null; // Resources.che1; |
||||||
|
volatile Boolean flag = false; |
||||||
|
Thread UDPtransmitThread = null; |
||||||
|
Stopwatch fpstmr; |
||||||
|
private UInt32 cnt_frame = 0; |
||||||
|
float fps = 0; |
||||||
|
|
||||||
|
public UDPTransmitSim(String ipaddr, Int32 remotePortUDP, Int32 sizeX, Int32 sizeY, Int32 delayMS) |
||||||
|
{ |
||||||
|
transmitter = new UdpClient(); |
||||||
|
endPoint = new IPEndPoint(IPAddress.Parse(ipaddr), remotePortUDP); |
||||||
|
this.sizeX = sizeX; |
||||||
|
this.sizeY = sizeY; |
||||||
|
this.delayMS = delayMS; |
||||||
|
|
||||||
|
img = new Bitmap(Res.Sim, new Size(sizeX, sizeY)); |
||||||
|
|
||||||
|
UDPtransmitThread = new Thread(new ThreadStart(UDPtransmitFrame)); |
||||||
|
UDPtransmitThread.Start(); |
||||||
|
Start(); |
||||||
|
fpstmr = new Stopwatch(); |
||||||
|
} |
||||||
|
public UDPTransmitSim(Int32 sizeX, Int32 sizeY, Int32 delayMS) |
||||||
|
{ |
||||||
|
transmitter = new UdpClient(); |
||||||
|
endPoint = new IPEndPoint(IPAddress.Parse(IPAddr), RemotePort); |
||||||
|
this.sizeX = sizeX; |
||||||
|
this.sizeY = sizeY; |
||||||
|
this.delayMS = delayMS; |
||||||
|
|
||||||
|
img = new Bitmap(Res.Sim, new Size(sizeX, sizeY)); |
||||||
|
|
||||||
|
UDPtransmitThread = new Thread(new ThreadStart(UDPtransmitFrame)); |
||||||
|
UDPtransmitThread.Start(); |
||||||
|
Start(); |
||||||
|
fpstmr = new Stopwatch(); |
||||||
|
} |
||||||
|
public UDPTransmitSim(String IPaddr, Int32 remotePortUDP, Int32 delayMS, Bitmap i) |
||||||
|
{ |
||||||
|
transmitter = new UdpClient(); |
||||||
|
endPoint = new IPEndPoint(IPAddress.Parse(IPaddr), remotePortUDP); |
||||||
|
sizeX = i.Width; |
||||||
|
sizeY = i.Height; |
||||||
|
this.delayMS = delayMS; |
||||||
|
|
||||||
|
img = new Bitmap(i); |
||||||
|
|
||||||
|
UDPtransmitThread = new Thread(new ThreadStart(UDPtransmitFrame)); |
||||||
|
UDPtransmitThread.Start(); |
||||||
|
Start(); |
||||||
|
fpstmr = new Stopwatch(); |
||||||
|
} |
||||||
|
public void Start() |
||||||
|
{ |
||||||
|
flag = true; |
||||||
|
} |
||||||
|
public void Stop() |
||||||
|
{ |
||||||
|
flag = false; |
||||||
|
} |
||||||
|
void UDPtransmitFrame() |
||||||
|
{ |
||||||
|
transmitter.Connect(endPoint); |
||||||
|
Res.Frames = 0; |
||||||
|
//cnt_frame = 0; |
||||||
|
|
||||||
|
while (flag) |
||||||
|
{ |
||||||
|
fpstmr.Start(); |
||||||
|
// RTPMsgHeader |
||||||
|
RTP.MH_VerPXCC = 2; |
||||||
|
RTP.MH_MPT = 0xC6; |
||||||
|
RTP.SeqCounter = 0; //! |
||||||
|
RTP.MH_Timestamp = (uint)DateTimeOffset.Now.ToUnixTimeSeconds(); //! |
||||||
|
RTP.MH_PT = 99; |
||||||
|
RTP.MH_M = 0; |
||||||
|
RTP.MH_SSRC = 12345678; |
||||||
|
RTP.MH_DataLen = (UInt16)(RTP.DataH0.Length - RTP.DataH1.Length); |
||||||
|
RTP.MH_RowNumber = 0; |
||||||
|
RTP.MH_Offset = 0; |
||||||
|
|
||||||
|
// RTPVideoSupplementalData |
||||||
|
RTP.SD_Width = (UInt16)sizeX; |
||||||
|
RTP.SD_Height = (UInt16)sizeY; |
||||||
|
RTP.SD_AzUpr = 0; |
||||||
|
RTP.SD_ElUpr = 0; |
||||||
|
|
||||||
|
RTP.SD_Shirota = Res.Shirota; |
||||||
|
RTP.SD_Dolgota = Res.Dolgota; |
||||||
|
RTP.SD_Vysota = Res.Vysota; |
||||||
|
RTP.SD_Course = Res.Course; |
||||||
|
RTP.SD_Roll = Res.Roll; |
||||||
|
RTP.SD_Pitch = Res.Pitch; |
||||||
|
//RTP.SD_X = pntX; |
||||||
|
//RTP.SD_Y = pntY; |
||||||
|
//RTP.SD_lx = (Byte)pntlx; |
||||||
|
//RTP.SD_ly = (Byte)pntly; |
||||||
|
RTP.SD_rejim_oes = Res.rejim_oes; |
||||||
|
RTP.SD_color = Res.color; |
||||||
|
RTP.SD_zahvat = Res.zahvat; |
||||||
|
|
||||||
|
// Console.WriteLine($"{RTP.SD_rejim_oes} {RTP.SD_zahvat} {RTP.SD_color} {RTP.SD_Status} {Res.status}"); |
||||||
|
//Console.WriteLine($"{RTP.SD_color} {RTP.SD_zahvat} {RTP.SD_rejim_oes} {RTP.SD_Status}"); |
||||||
|
|
||||||
|
RTP.MakeDataH0(); |
||||||
|
transmitter.Send(RTP.DataH0, RTP.DataH0.Length); |
||||||
|
|
||||||
|
Byte[] dataudp = new Byte[20 + RTP.SD_Width * 3]; |
||||||
|
|
||||||
|
Byte[] dataimg = new Byte[RTP.SD_Width * 3]; |
||||||
|
for (int i = 0; i < sizeY; i++) |
||||||
|
{ |
||||||
|
// RTPMsgHeader |
||||||
|
RTP.MH_VerPXCC = 2; |
||||||
|
if (i == (sizeY - 1)) |
||||||
|
{ |
||||||
|
RTP.MH_PT = 99; |
||||||
|
RTP.MH_M = 1; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
RTP.MH_PT = 99; |
||||||
|
RTP.MH_M = 0; |
||||||
|
} |
||||||
|
++RTP.SeqCounter; |
||||||
|
RTP.MH_RowNumber = (ushort)(i + 1); |
||||||
|
RTP.MH_DataLen = (ushort)(RTP.SD_Width * 3); |
||||||
|
RTP.MakeDataH1(); |
||||||
|
uint ccc = 0; |
||||||
|
try |
||||||
|
{ |
||||||
|
for (int j = 0; j < sizeX; j++) |
||||||
|
{ |
||||||
|
Color c = img.GetPixel(j, i); |
||||||
|
dataimg[ccc++] = c.R; |
||||||
|
dataimg[ccc++] = c.G; |
||||||
|
dataimg[ccc++] = c.B; |
||||||
|
} |
||||||
|
} |
||||||
|
catch (Exception ee) |
||||||
|
{ |
||||||
|
Console.WriteLine(ee.Message); |
||||||
|
Console.WriteLine("Error 4 getpixel"); |
||||||
|
return; |
||||||
|
} |
||||||
|
Array.Copy(RTP.DataH1, dataudp, RTP.DataH1.Length); |
||||||
|
Array.Copy(dataimg, 0, dataudp, RTP.DataH1.Length, dataimg.Length); |
||||||
|
transmitter.Send(dataudp, dataudp.Length); |
||||||
|
} |
||||||
|
Res.Frames++; |
||||||
|
// transmitter.Close(); |
||||||
|
fpstmr.Stop(); |
||||||
|
fps = 1000F / fpstmr.ElapsedMilliseconds; |
||||||
|
Res.Fps = fps; |
||||||
|
fpstmr.Reset(); |
||||||
|
cnt_frame++; |
||||||
|
CallBack.Event_transmitted_Handler(); |
||||||
|
Thread.Sleep(delayMS); |
||||||
|
} |
||||||
|
Res.Frames = 0; |
||||||
|
Res.Fps = 0; |
||||||
|
CallBack.Event_transmitted_Handler(); |
||||||
|
transmitter.Close(); |
||||||
|
transmitter.Dispose(); |
||||||
|
} |
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
if (img != null) |
||||||
|
{ |
||||||
|
UDPtransmitThread.Abort(); |
||||||
|
img.Dispose(); |
||||||
|
} |
||||||
|
flag = false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
class thrdata |
||||||
|
{ |
||||||
|
public uint arr; |
||||||
|
public uint iw; |
||||||
|
public uint ih; |
||||||
|
public thrdata(uint a, uint w, uint h) |
||||||
|
{ |
||||||
|
arr = a; |
||||||
|
iw = w; |
||||||
|
ih = h; |
||||||
|
} |
||||||
|
} |
||||||
|
public static class Res |
||||||
|
{ |
||||||
|
public static Bitmap Bmp { set; get; } |
||||||
|
public static Bitmap Sim { set; get; } |
||||||
|
public static Bitmap Crop { set; get; } |
||||||
|
public static Bitmap Clearimg { set; get; } |
||||||
|
public static UInt16 Iwidth { set; get; } |
||||||
|
public static UInt16 Iheight { set; get; } |
||||||
|
public static UInt32 Frames { set; get; } |
||||||
|
public static float Fps { set; get; } |
||||||
|
public static float Lost { set; get; } |
||||||
|
public static UInt32 LostFix { set; get; } |
||||||
|
public static float AzUpr { set; get; } |
||||||
|
public static float ElUpr { set; get; } |
||||||
|
public static Int16 Course { set; get; } |
||||||
|
public static Int16 Roll { set; get; } |
||||||
|
public static Int16 Pitch { set; get; } |
||||||
|
public static Int32 Shirota { set; get; } |
||||||
|
public static Int32 Dolgota { set; get; } |
||||||
|
public static Int32 Vysota { set; get; } |
||||||
|
public static UInt16 X { set; get; } |
||||||
|
public static UInt16 Y { set; get; } |
||||||
|
public static Byte lx { set; get; } |
||||||
|
public static Byte ly { set; get; } |
||||||
|
public static Byte rejim_oes { set; get; } // Режим ОЭС: «0» – Обзор, «1» – АС |
||||||
|
public static Byte zahvat { set; get; } // Захват: «0» – отсутствие захвата, «1» – наличие захвата |
||||||
|
public static Byte color { set; get; } // Цвет изображения: «1» – цветное, «0» – монохромное |
||||||
|
public static String Version { get => Data.Ver; } |
||||||
|
public static String Configuration { get => Data.Conf; } |
||||||
|
public static Boolean status_rs { set; get; } |
||||||
|
public static Boolean status_eth { set; get; } |
||||||
|
public static float Az { set; get; } |
||||||
|
public static float El { set; get; } |
||||||
|
//public static Byte status |
||||||
|
//{ |
||||||
|
// get |
||||||
|
// { |
||||||
|
// status = 0; |
||||||
|
// status |= (Byte)(rejim_oes << 0); |
||||||
|
// status |= (Byte)(zahvat << 1); |
||||||
|
// status |= (Byte)(color << 2); |
||||||
|
// return status; |
||||||
|
// } |
||||||
|
// set |
||||||
|
// { |
||||||
|
// status = value; |
||||||
|
// rejim_oes = (Byte)((value >> 0) & 0x01); |
||||||
|
// zahvat = (Byte)((value >> 1) & 0x01); |
||||||
|
// color = (Byte)((value >> 2) & 0x01); |
||||||
|
// } |
||||||
|
//} |
||||||
|
} |
||||||
|
public class Res2 |
||||||
|
{ |
||||||
|
public Bitmap Bmp; |
||||||
|
public Bitmap Crop; |
||||||
|
public Bitmap Clearimg; |
||||||
|
public UInt16 Iwidth; |
||||||
|
public UInt16 Iheight; |
||||||
|
public UInt32 Frames; |
||||||
|
public float Lost; |
||||||
|
public UInt32 LostFix; |
||||||
|
public float Fps; |
||||||
|
public float AzUpr; |
||||||
|
public float ElUpr; |
||||||
|
public Int32 Shirota; |
||||||
|
public Int32 Dolgota; |
||||||
|
public Int32 Vysota; |
||||||
|
public Int16 Course; |
||||||
|
public Int16 Roll; |
||||||
|
public Int16 Pitch; |
||||||
|
public UInt16 X; |
||||||
|
public UInt16 Y; |
||||||
|
public Byte lx; |
||||||
|
public Byte ly; |
||||||
|
public Byte rejim_oes; // Режим ОЭС: «0» – Обзор, «1» – АС |
||||||
|
public Byte zahvat; // Захват: «0» – отсутствие захвата, «1» – налачие захвата |
||||||
|
public Byte color; // Цвет изображения: «1» – цветное, «0» – монохромное |
||||||
|
public String Version { get => Data.Ver; } |
||||||
|
public String Configuration { get => Data.Conf; } |
||||||
|
public Boolean status_rs { set; get; } |
||||||
|
public Boolean status_eth { set; get; } |
||||||
|
public Byte[] rawheader; |
||||||
|
} |
||||||
|
public static class CallBack |
||||||
|
{ |
||||||
|
public delegate void Event_newimg(); |
||||||
|
public static Event_newimg Event_newimg_Handler; |
||||||
|
|
||||||
|
public delegate void Event_crop_transmitted(); |
||||||
|
public static Event_crop_transmitted Event_crop_transmitted_Handler; |
||||||
|
|
||||||
|
public delegate void Event_newimg2(Res2 data); |
||||||
|
public static Event_newimg2 Event_newimg_Handler2; |
||||||
|
|
||||||
|
public delegate void Event_transmitted(); |
||||||
|
public static Event_transmitted Event_transmitted_Handler; |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue