-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
101 lines (90 loc) · 3.21 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Yocto-Visualization, a free application to visualize Yoctopuce Sensors.
*
* Application entry point
*
* - - - - - - - - - License information: - - - - - - - - -
*
* Copyright (C) 2017 and beyond by Yoctopuce Sarl, Switzerland.
*
* Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
* non-exclusive license to use, modify, copy and integrate this
* file into your software for the sole purpose of interfacing
* with Yoctopuce products.
*
* You may reproduce and distribute copies of this file in
* source or object form, as long as the sole purpose of this
* code is to interface with Yoctopuce products. You must retain
* this notice in the distributed source file.
*
* You should refer to Yoctopuce General Terms and Conditions
* for additional information regarding your rights and
* obligations.
*
* THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
* EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
* COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
* SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
* LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
* CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
* BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
* WARRANTY, OR OTHERWISE.
*
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace YoctoVisualisation
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(String[] args)
{
string errmsg = "";
constants.init(args);
if (constants.CheckMonoVersion(out errmsg))
{
int res = YAPI.FILE_NOT_FOUND;
res = YAPI.InitAPI(0, ref errmsg);
YAPI.RegisterLogFunction(LogManager.APIlog);
if (res == YAPI.SUCCESS)
{
YAPI.SetDeviceListValidity(3600);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (Debugger.IsAttached)
Application.Run(new StartForm(true));
else
try { Application.Run(new StartForm(false));}
catch (OutOfMemoryException)
{
string msg = ("Yocto-Visualization ran out of memory");
Console.Write(msg, "Oops", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
MessageBox.Show(msg);
}
catch (Exception e)
{
MessageBox.Show( constants.DumpException(e), "Oops",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
}
else MessageBox.Show("Initialization error: " + errmsg);
}
else MessageBox.Show(errmsg);
}
}
}