Revize 8abb5582
Přidáno uživatelem Oto Šťáva před téměř 4 roky(ů)
deltarobot-vr-launcher/.gitignore | ||
---|---|---|
1 |
obj/ |
|
2 |
bin/ |
|
3 |
|
|
4 |
.idea/ |
deltarobot-vr-launcher/DeltaRobotVr.Launcher/ConfigurationProvider.cs | ||
---|---|---|
1 |
using System.Xml.Serialization; |
|
2 |
using System; |
|
3 |
using System.IO; |
|
4 |
|
|
5 |
namespace DeltaRobotVr.Launcher |
|
6 |
{ |
|
7 |
/// <summary> |
|
8 |
/// Singleton class responsible for providing configuration. |
|
9 |
/// </summary> |
|
10 |
[Serializable] |
|
11 |
public class ConfigurationProvider |
|
12 |
{ |
|
13 |
private static readonly string DefaultConfigFile = "config.xml"; |
|
14 |
private static readonly string DefaultConfigDirectory = "/.deltarobot-vr/"; |
|
15 |
private static string _homePath; |
|
16 |
private static string _configFile; |
|
17 |
public static readonly ConfigurationProvider Instance; |
|
18 |
|
|
19 |
public float VisualizationTranslateX = 0.0f; |
|
20 |
public float VisualizationTranslateY = 0.2f; |
|
21 |
public float VisualizationTranslateZ = -10.5f; |
|
22 |
|
|
23 |
|
|
24 |
public float VisualizationScaleOverall = 0.2f; |
|
25 |
public float VisualizationScaleX = 1.0f; |
|
26 |
public float VisualizationScaleY = 1.0f; |
|
27 |
public float VisualizationScaleZ = 1.0f; |
|
28 |
|
|
29 |
public int Port = 4242; |
|
30 |
|
|
31 |
public string Host = "192.168.254.16"; |
|
32 |
|
|
33 |
public string SceneName = "Village"; |
|
34 |
|
|
35 |
public string CurveColorHex = "#FFFF00CC"; |
|
36 |
|
|
37 |
|
|
38 |
static ConfigurationProvider() |
|
39 |
{ |
|
40 |
if (Environment.OSVersion.Platform == PlatformID.Unix || |
|
41 |
Environment.OSVersion.Platform == PlatformID.MacOSX) |
|
42 |
{ |
|
43 |
_homePath = Environment.GetEnvironmentVariable("HOME"); |
|
44 |
} |
|
45 |
else |
|
46 |
{ |
|
47 |
_homePath = Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%"); |
|
48 |
} |
|
49 |
|
|
50 |
_configFile = _homePath + DefaultConfigDirectory + DefaultConfigFile; |
|
51 |
|
|
52 |
if (!File.Exists(_configFile)) |
|
53 |
{ |
|
54 |
if (!Directory.Exists(_homePath + DefaultConfigDirectory)) |
|
55 |
{ |
|
56 |
Directory.CreateDirectory(_homePath + DefaultConfigDirectory); |
|
57 |
} |
|
58 |
SaveConfiguration(new ConfigurationProvider(), _configFile); |
|
59 |
} |
|
60 |
|
|
61 |
// Deserialize configuration |
|
62 |
Instance = LoadConfiguration(_configFile); |
|
63 |
} |
|
64 |
|
|
65 |
private ConfigurationProvider() |
|
66 |
{ |
|
67 |
} |
|
68 |
|
|
69 |
/// <summary> |
|
70 |
/// Load ConfigurationProvider instance from file. |
|
71 |
/// </summary> |
|
72 |
/// <param name="fileName">File to load configuration from</param> |
|
73 |
/// <returns></returns> |
|
74 |
private static ConfigurationProvider LoadConfiguration(String fileName) |
|
75 |
{ |
|
76 |
XmlSerializer serializer = new XmlSerializer(typeof(ConfigurationProvider)); |
|
77 |
|
|
78 |
using (Stream reader = new FileStream(fileName, FileMode.Open)) |
|
79 |
{ |
|
80 |
return (ConfigurationProvider)serializer.Deserialize(reader); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
/// <summary> |
|
85 |
/// Save ConfigurationProvider instance to file. |
|
86 |
/// </summary> |
|
87 |
/// <param name="cp">ConfigurationProvider instance to save</param> |
|
88 |
/// <param name="fileName">File to save configuration to</param> |
|
89 |
private static void SaveConfiguration(ConfigurationProvider cp, String fileName) |
|
90 |
{ |
|
91 |
XmlSerializer serializer = new XmlSerializer(typeof(ConfigurationProvider)); |
|
92 |
|
|
93 |
using (Stream writer = new FileStream(fileName, FileMode.Create)) |
|
94 |
{ |
|
95 |
serializer.Serialize(writer, cp); |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
/// <summary> |
|
100 |
/// Saves this ConfigurationProvider instance to the global file. |
|
101 |
/// </summary> |
|
102 |
public void Save() |
|
103 |
{ |
|
104 |
SaveConfiguration(this, _configFile); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
deltarobot-vr-launcher/DeltaRobotVr.Launcher/DeltaRobotVr.Launcher.csproj | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
3 |
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|
4 |
<PropertyGroup> |
|
5 |
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
6 |
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
7 |
<ProjectGuid>{3B359CF2-C5D8-4466-983F-E0467CDB1144}</ProjectGuid> |
|
8 |
<OutputType>Exe</OutputType> |
|
9 |
<AppDesignerFolder>Properties</AppDesignerFolder> |
|
10 |
<RootNamespace>DeltaRobotVr.Launcher</RootNamespace> |
|
11 |
<AssemblyName>DeltaRobotVr.Launcher</AssemblyName> |
|
12 |
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> |
|
13 |
<FileAlignment>512</FileAlignment> |
|
14 |
</PropertyGroup> |
|
15 |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
16 |
<PlatformTarget>AnyCPU</PlatformTarget> |
|
17 |
<DebugSymbols>true</DebugSymbols> |
|
18 |
<DebugType>full</DebugType> |
|
19 |
<Optimize>false</Optimize> |
|
20 |
<OutputPath>bin\Debug\</OutputPath> |
|
21 |
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
22 |
<ErrorReport>prompt</ErrorReport> |
|
23 |
<WarningLevel>4</WarningLevel> |
|
24 |
</PropertyGroup> |
|
25 |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
26 |
<PlatformTarget>AnyCPU</PlatformTarget> |
|
27 |
<DebugType>pdbonly</DebugType> |
|
28 |
<Optimize>true</Optimize> |
|
29 |
<OutputPath>bin\Release\</OutputPath> |
|
30 |
<DefineConstants>TRACE</DefineConstants> |
|
31 |
<ErrorReport>prompt</ErrorReport> |
|
32 |
<WarningLevel>4</WarningLevel> |
|
33 |
</PropertyGroup> |
|
34 |
<ItemGroup> |
|
35 |
<Reference Include="System" /> |
|
36 |
<Reference Include="System.Core" /> |
|
37 |
<Reference Include="System.Data" /> |
|
38 |
<Reference Include="System.Drawing" /> |
|
39 |
<Reference Include="System.Windows.Forms" /> |
|
40 |
<Reference Include="System.Xml" /> |
|
41 |
</ItemGroup> |
|
42 |
<ItemGroup> |
|
43 |
<Compile Include="ConfigurationProvider.cs" /> |
|
44 |
<Compile Include="LauncherForm.cs" /> |
|
45 |
<Compile Include="LayoutRectangle.cs" /> |
|
46 |
<Compile Include="Program.cs" /> |
|
47 |
<Compile Include="Properties\AssemblyInfo.cs" /> |
|
48 |
</ItemGroup> |
|
49 |
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|
50 |
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|
51 |
Other similar extension points exist, see Microsoft.Common.targets. |
|
52 |
<Target Name="BeforeBuild"> |
|
53 |
</Target> |
|
54 |
<Target Name="AfterBuild"> |
|
55 |
</Target> |
|
56 |
--> |
|
57 |
|
|
58 |
</Project> |
deltarobot-vr-launcher/DeltaRobotVr.Launcher/LauncherForm.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Diagnostics; |
|
3 |
using System.Drawing; |
|
4 |
using System.Globalization; |
|
5 |
using System.Windows.Forms; |
|
6 |
|
|
7 |
namespace DeltaRobotVr.Launcher |
|
8 |
{ |
|
9 |
public class LauncherForm : Form |
|
10 |
{ |
|
11 |
private readonly Label _serverLabel = new Label(); |
|
12 |
private readonly Label _serverHostLabel = new Label(); |
|
13 |
private readonly TextBox _serverHost = new TextBox(); |
|
14 |
private readonly Label _serverPortLabel = new Label(); |
|
15 |
private readonly TextBox _serverPort = new TextBox(); |
|
16 |
|
|
17 |
private readonly Label _curveTranslationLabel = new Label(); |
|
18 |
private readonly Label _curveTranslationXLabel = new Label(); |
|
19 |
private readonly TextBox _curveTranslationX = new TextBox(); |
|
20 |
private readonly Label _curveTranslationYLabel = new Label(); |
|
21 |
private readonly TextBox _curveTranslationY = new TextBox(); |
|
22 |
private readonly Label _curveTranslationZLabel = new Label(); |
|
23 |
private readonly TextBox _curveTranslationZ = new TextBox(); |
|
24 |
|
|
25 |
private readonly Label _curveScaleLabel = new Label(); |
|
26 |
private readonly Label _curveScaleXLabel = new Label(); |
|
27 |
private readonly TextBox _curveScaleX = new TextBox(); |
|
28 |
private readonly Label _curveScaleYLabel = new Label(); |
|
29 |
private readonly TextBox _curveScaleY = new TextBox(); |
|
30 |
private readonly Label _curveScaleZLabel = new Label(); |
|
31 |
private readonly TextBox _curveScaleZ = new TextBox(); |
|
32 |
private readonly Label _curveScaleOverallLabel = new Label(); |
|
33 |
private readonly TextBox _curveScaleOverall = new TextBox(); |
|
34 |
|
|
35 |
private readonly Label _curveColorLabel = new Label(); |
|
36 |
private readonly TextBox _curveColorHex = new TextBox(); |
|
37 |
private readonly Panel _curveColorPreviewPanel = new Panel(); |
|
38 |
private readonly Label _curveColorAlpha = new Label(); |
|
39 |
|
|
40 |
private readonly Label _sceneLabel = new Label(); |
|
41 |
private readonly ComboBox _scene = new ComboBox(); |
|
42 |
|
|
43 |
private readonly Button _launchButton = new Button(); |
|
44 |
|
|
45 |
private static readonly string[] Scenes = |
|
46 |
{ |
|
47 |
"BasicRoomScene", |
|
48 |
"NeonRoom", |
|
49 |
"Desert1", |
|
50 |
"Desert2", |
|
51 |
"Forest", |
|
52 |
"SciFiRoom", |
|
53 |
"PaintBooth", |
|
54 |
"Village", |
|
55 |
"CityStreetDay", |
|
56 |
"CityStreetNight" |
|
57 |
}; |
|
58 |
|
|
59 |
private const int Spacing = 6; |
|
60 |
private const int SectionSpacing = 4 * Spacing; |
|
61 |
private const int ControlHeight = 24; |
|
62 |
private const int LeftLabelWidth = 120; |
|
63 |
|
|
64 |
private const string VrAppExe = "deltarobot-vr.exe"; |
|
65 |
|
|
66 |
protected override void OnLoad(EventArgs e) |
|
67 |
{ |
|
68 |
base.OnLoad(e); |
|
69 |
|
|
70 |
Width = 640; |
|
71 |
Height = 520; |
|
72 |
|
|
73 |
Text = "Deltarobot VR Launcher"; |
|
74 |
|
|
75 |
// Scene |
|
76 |
_sceneLabel.Text = "Scene"; |
|
77 |
_sceneLabel.TextAlign = ContentAlignment.MiddleRight; |
|
78 |
Controls.Add(_sceneLabel); |
|
79 |
|
|
80 |
// Curve color |
|
81 |
_curveColorLabel.Text = "Curve color"; |
|
82 |
_curveColorLabel.TextAlign = ContentAlignment.MiddleRight; |
|
83 |
Controls.Add(_curveColorLabel); |
|
84 |
|
|
85 |
_curveColorHex.Text = ConfigurationProvider.Instance.CurveColorHex; |
|
86 |
_curveColorHex.TextChanged += CurveColorHex_Changed; |
|
87 |
Controls.Add(_curveColorHex); |
|
88 |
|
|
89 |
Controls.Add(_curveColorPreviewPanel); |
|
90 |
|
|
91 |
_curveColorAlpha.TextAlign = ContentAlignment.MiddleLeft; |
|
92 |
Controls.Add(_curveColorAlpha); |
|
93 |
|
|
94 |
UpdateCurveColor(); |
|
95 |
|
|
96 |
// Curve translation |
|
97 |
_curveTranslationLabel.Text = "Curve translation"; |
|
98 |
_curveTranslationLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
99 |
Controls.Add(_curveTranslationLabel); |
|
100 |
|
|
101 |
_curveTranslationXLabel.Text = "X (+ right; - left)"; |
|
102 |
_curveTranslationXLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
103 |
Controls.Add(_curveTranslationXLabel); |
|
104 |
|
|
105 |
_curveTranslationX.Text = ConfigurationProvider.Instance.VisualizationTranslateX.ToString("F"); |
|
106 |
Controls.Add(_curveTranslationX); |
|
107 |
|
|
108 |
_curveTranslationYLabel.Text = "Y (+ up; - down)"; |
|
109 |
_curveTranslationYLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
110 |
Controls.Add(_curveTranslationYLabel); |
|
111 |
|
|
112 |
_curveTranslationY.Text = ConfigurationProvider.Instance.VisualizationTranslateY.ToString("F"); |
|
113 |
Controls.Add(_curveTranslationY); |
|
114 |
|
|
115 |
_curveTranslationZLabel.Text = "Z (+ further; - closer)"; |
|
116 |
_curveTranslationZLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
117 |
Controls.Add(_curveTranslationZLabel); |
|
118 |
|
|
119 |
_curveTranslationZ.Text = ConfigurationProvider.Instance.VisualizationTranslateZ.ToString("F"); |
|
120 |
Controls.Add(_curveTranslationZ); |
|
121 |
|
|
122 |
// Curve scale |
|
123 |
_curveScaleLabel.Text = "Curve scale"; |
|
124 |
_curveScaleLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
125 |
Controls.Add(_curveScaleLabel); |
|
126 |
|
|
127 |
_curveScaleXLabel.Text = "X"; |
|
128 |
_curveScaleXLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
129 |
Controls.Add(_curveScaleXLabel); |
|
130 |
|
|
131 |
_curveScaleX.Text = ConfigurationProvider.Instance.VisualizationScaleX.ToString("F"); |
|
132 |
Controls.Add(_curveScaleX); |
|
133 |
|
|
134 |
_curveScaleYLabel.Text = "Y"; |
|
135 |
_curveScaleYLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
136 |
Controls.Add(_curveScaleYLabel); |
|
137 |
|
|
138 |
_curveScaleY.Text = ConfigurationProvider.Instance.VisualizationScaleY.ToString("F"); |
|
139 |
Controls.Add(_curveScaleY); |
|
140 |
|
|
141 |
_curveScaleZLabel.Text = "Z"; |
|
142 |
_curveScaleZLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
143 |
Controls.Add(_curveScaleZLabel); |
|
144 |
|
|
145 |
_curveScaleZ.Text = ConfigurationProvider.Instance.VisualizationScaleZ.ToString("F"); |
|
146 |
Controls.Add(_curveScaleZ); |
|
147 |
|
|
148 |
_curveScaleOverallLabel.Text = "Overall curve scale"; |
|
149 |
_curveScaleOverallLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
150 |
Controls.Add(_curveScaleOverallLabel); |
|
151 |
|
|
152 |
_curveScaleOverall.Text = ConfigurationProvider.Instance.VisualizationScaleOverall.ToString("F"); |
|
153 |
Controls.Add(_curveScaleOverall); |
|
154 |
|
|
155 |
// Server |
|
156 |
_serverLabel.Text = "Exercise data server"; |
|
157 |
_serverLabel.TextAlign = ContentAlignment.MiddleCenter; |
|
158 |
Controls.Add(_serverLabel); |
|
159 |
|
|
160 |
_serverHostLabel.Text = "Host"; |
|
161 |
_serverHostLabel.TextAlign = ContentAlignment.MiddleRight; |
|
162 |
Controls.Add(_serverHostLabel); |
|
163 |
|
|
164 |
_serverHost.Text = ConfigurationProvider.Instance.Host; |
|
165 |
Controls.Add(_serverHost); |
|
166 |
|
|
167 |
_serverPortLabel.Text = "Port"; |
|
168 |
_serverPortLabel.TextAlign = ContentAlignment.MiddleRight; |
|
169 |
Controls.Add(_serverPortLabel); |
|
170 |
|
|
171 |
_serverPort.Text = ConfigurationProvider.Instance.Port.ToString(); |
|
172 |
Controls.Add(_serverPort); |
|
173 |
|
|
174 |
foreach (var scene in Scenes) |
|
175 |
{ |
|
176 |
_scene.Items.Add(scene); |
|
177 |
} |
|
178 |
|
|
179 |
_scene.Text = ConfigurationProvider.Instance.SceneName; |
|
180 |
Controls.Add(_scene); |
|
181 |
|
|
182 |
// Launch button |
|
183 |
_launchButton.Text = "Save and Launch"; |
|
184 |
_launchButton.Click += LaunchButton_Click; |
|
185 |
Controls.Add(_launchButton); |
|
186 |
|
|
187 |
UpdateLayout(); |
|
188 |
CenterToScreen(); |
|
189 |
} |
|
190 |
|
|
191 |
protected override void OnResize(EventArgs e) |
|
192 |
{ |
|
193 |
base.OnResize(e); |
|
194 |
|
|
195 |
UpdateLayout(); |
|
196 |
} |
|
197 |
|
|
198 |
private void UpdateLayout() |
|
199 |
{ |
|
200 |
var lr = new LayoutRectangle(ClientRectangle); |
|
201 |
lr.Shrink(10); |
|
202 |
|
|
203 |
{ |
|
204 |
var rect = lr.RemoveFromTop(ControlHeight); |
|
205 |
_sceneLabel.Bounds = rect.RemoveFromLeft(LeftLabelWidth).ToRectangle(); |
|
206 |
rect.RemoveFromLeft(Spacing); |
|
207 |
_scene.Bounds = rect.ToRectangle(); |
|
208 |
} |
|
209 |
|
|
210 |
lr.RemoveFromTop(Spacing); |
|
211 |
|
|
212 |
{ |
|
213 |
var rect = lr.RemoveFromTop(ControlHeight); |
|
214 |
_curveColorLabel.Bounds = rect.RemoveFromLeft(LeftLabelWidth).ToRectangle(); |
|
215 |
rect.RemoveFromLeft(Spacing); |
|
216 |
_curveColorHex.Bounds = rect.RemoveFromLeft(96).ToRectangle(); |
|
217 |
rect.RemoveFromLeft(Spacing); |
|
218 |
_curveColorPreviewPanel.Bounds = rect.RemoveFromLeft(32).ToRectangle(); |
|
219 |
rect.RemoveFromLeft(Spacing); |
|
220 |
_curveColorAlpha.Bounds = rect.ToRectangle(); |
|
221 |
} |
|
222 |
|
|
223 |
lr.RemoveFromTop(SectionSpacing); |
|
224 |
|
|
225 |
{ |
|
226 |
_curveTranslationLabel.Bounds = lr.RemoveFromTop(ControlHeight).ToRectangle(); |
|
227 |
|
|
228 |
var rect = lr.RemoveFromTop(2 * ControlHeight); |
|
229 |
|
|
230 |
var third = rect.Width / 3; |
|
231 |
var xRect = rect.RemoveFromLeft(third); |
|
232 |
_curveTranslationXLabel.Bounds = xRect.RemoveFromTop(ControlHeight).ToRectangle(); |
|
233 |
_curveTranslationX.Bounds = xRect.ToRectangle(); |
|
234 |
|
|
235 |
var yRect = rect.RemoveFromLeft(third); |
|
236 |
_curveTranslationYLabel.Bounds = yRect.RemoveFromTop(ControlHeight).ToRectangle(); |
|
237 |
_curveTranslationY.Bounds = yRect.ToRectangle(); |
|
238 |
|
|
239 |
var zRect = rect; |
|
240 |
_curveTranslationZLabel.Bounds = zRect.RemoveFromTop(ControlHeight).ToRectangle(); |
|
241 |
_curveTranslationZ.Bounds = zRect.ToRectangle(); |
|
242 |
} |
|
243 |
|
|
244 |
lr.RemoveFromTop(SectionSpacing); |
|
245 |
|
|
246 |
{ |
|
247 |
_curveScaleLabel.Bounds = lr.RemoveFromTop(ControlHeight).ToRectangle(); |
|
248 |
|
|
249 |
var rect = lr.RemoveFromTop(4 * ControlHeight); |
|
250 |
|
|
251 |
var third = rect.Width / 3; |
|
252 |
var xRect = rect.RemoveFromLeft(third); |
|
253 |
_curveScaleXLabel.Bounds = xRect.RemoveFromTop(ControlHeight).ToRectangle(); |
|
254 |
_curveScaleX.Bounds = xRect.ToRectangle(); |
|
255 |
|
|
256 |
var yRect = rect.RemoveFromLeft(third); |
|
257 |
_curveScaleYLabel.Bounds = yRect.RemoveFromTop(ControlHeight).ToRectangle(); |
|
258 |
_curveScaleY.Bounds = yRect.RemoveFromTop(ControlHeight).ToRectangle(); |
|
259 |
_curveScaleOverallLabel.Bounds = yRect.RemoveFromTop(ControlHeight).ToRectangle(); |
|
260 |
_curveScaleOverall.Bounds = yRect.ToRectangle(); |
|
261 |
|
|
262 |
var zRect = rect; |
|
263 |
_curveScaleZLabel.Bounds = zRect.RemoveFromTop(ControlHeight).ToRectangle(); |
|
264 |
_curveScaleZ.Bounds = zRect.ToRectangle(); |
|
265 |
} |
|
266 |
|
|
267 |
lr.RemoveFromTop(SectionSpacing); |
|
268 |
|
|
269 |
_serverLabel.Bounds = lr.RemoveFromTop(ControlHeight).ToRectangle(); |
|
270 |
|
|
271 |
lr.RemoveFromTop(Spacing); |
|
272 |
|
|
273 |
{ |
|
274 |
var rect = lr.RemoveFromTop(ControlHeight); |
|
275 |
_serverHostLabel.Bounds = rect.RemoveFromLeft(LeftLabelWidth).ToRectangle(); |
|
276 |
rect.RemoveFromLeft(Spacing); |
|
277 |
_serverHost.Bounds = rect.RemoveFromLeft(250).ToRectangle(); |
|
278 |
} |
|
279 |
|
|
280 |
lr.RemoveFromTop(Spacing); |
|
281 |
|
|
282 |
{ |
|
283 |
var rect = lr.RemoveFromTop(ControlHeight); |
|
284 |
_serverPortLabel.Bounds = rect.RemoveFromLeft(LeftLabelWidth).ToRectangle(); |
|
285 |
rect.RemoveFromLeft(Spacing); |
|
286 |
_serverPort.Bounds = rect.RemoveFromLeft(64).ToRectangle(); |
|
287 |
} |
|
288 |
|
|
289 |
_launchButton.Bounds = lr.RemoveFromBottom(ControlHeight * 2).Shrink(10).ToRectangle(); |
|
290 |
} |
|
291 |
|
|
292 |
private void CurveColorHex_Changed(object sender, EventArgs args) |
|
293 |
{ |
|
294 |
UpdateCurveColor(); |
|
295 |
} |
|
296 |
|
|
297 |
private void LaunchButton_Click(object sender, EventArgs args) |
|
298 |
{ |
|
299 |
SaveAndLaunch(); |
|
300 |
} |
|
301 |
|
|
302 |
private void UpdateCurveColor() |
|
303 |
{ |
|
304 |
bool valid = true; |
|
305 |
int alpha = 255; |
|
306 |
_curveColorAlpha.ForeColor = Color.Black; |
|
307 |
|
|
308 |
var colorToParse = _curveColorHex.Text; |
|
309 |
if (colorToParse.StartsWith("#")) |
|
310 |
{ |
|
311 |
if (colorToParse.Length == 9) |
|
312 |
{ |
|
313 |
if (!int.TryParse(colorToParse.Substring(7, 2), NumberStyles.HexNumber, null, out alpha)) |
|
314 |
{ |
|
315 |
valid = false; |
|
316 |
} |
|
317 |
|
|
318 |
colorToParse = colorToParse.Substring(0, 7); |
|
319 |
} |
|
320 |
else if (colorToParse.Length != 7) |
|
321 |
{ |
|
322 |
valid = false; |
|
323 |
} |
|
324 |
} |
|
325 |
|
|
326 |
if (valid) |
|
327 |
{ |
|
328 |
try |
|
329 |
{ |
|
330 |
_curveColorPreviewPanel.BackColor = ColorTranslator.FromHtml(colorToParse); |
|
331 |
} |
|
332 |
catch (Exception) |
|
333 |
{ |
|
334 |
valid = false; |
|
335 |
} |
|
336 |
} |
|
337 |
|
|
338 |
if (valid) |
|
339 |
{ |
|
340 |
_curveColorAlpha.Text = $"(alpha: {alpha})"; |
|
341 |
} |
|
342 |
else |
|
343 |
{ |
|
344 |
_curveColorPreviewPanel.BackColor = Color.Fuchsia; |
|
345 |
_curveColorAlpha.ForeColor = Color.Red; |
|
346 |
_curveColorAlpha.Text = "(invalid)"; |
|
347 |
} |
|
348 |
} |
|
349 |
|
|
350 |
private void SaveAndLaunch() |
|
351 |
{ |
|
352 |
ConfigurationProvider conf = ConfigurationProvider.Instance; |
|
353 |
bool valid = true; |
|
354 |
|
|
355 |
conf.Host = _serverHost.Text; |
|
356 |
if (!int.TryParse(_serverPort.Text, out conf.Port)) |
|
357 |
{ |
|
358 |
MessageBox.Show(this, "Invalid port: must be a valid integer."); |
|
359 |
valid = false; |
|
360 |
} |
|
361 |
|
|
362 |
if (!float.TryParse(_curveTranslationX.Text, out conf.VisualizationTranslateX)) |
|
363 |
{ |
|
364 |
MessageBox.Show(this, "Invalid curve translation X: must be valid number."); |
|
365 |
valid = false; |
|
366 |
} |
|
367 |
|
|
368 |
if (!float.TryParse(_curveTranslationY.Text, out conf.VisualizationTranslateY)) |
|
369 |
{ |
|
370 |
MessageBox.Show(this, "Invalid curve translation Y: must be valid number."); |
|
371 |
valid = false; |
|
372 |
} |
|
373 |
|
|
374 |
if (!float.TryParse(_curveTranslationZ.Text, out conf.VisualizationTranslateZ)) |
|
375 |
{ |
|
376 |
MessageBox.Show(this, "Invalid curve translation Z: must be valid number."); |
|
377 |
valid = false; |
|
378 |
} |
|
379 |
|
|
380 |
if (!float.TryParse(_curveScaleX.Text, out conf.VisualizationScaleX)) |
|
381 |
{ |
|
382 |
MessageBox.Show(this, "Invalid curve scale X: must be valid number."); |
|
383 |
valid = false; |
|
384 |
} |
|
385 |
|
|
386 |
if (!float.TryParse(_curveScaleY.Text, out conf.VisualizationScaleY)) |
|
387 |
{ |
|
388 |
MessageBox.Show(this, "Invalid curve scale Y: must be valid number."); |
|
389 |
valid = false; |
|
390 |
} |
|
391 |
|
|
392 |
if (!float.TryParse(_curveScaleZ.Text, out conf.VisualizationScaleZ)) |
|
393 |
{ |
|
394 |
MessageBox.Show(this, "Invalid curve scale Z: must be valid number."); |
|
395 |
valid = false; |
|
396 |
} |
|
397 |
|
|
398 |
if (!float.TryParse(_curveScaleOverall.Text, out conf.VisualizationScaleOverall)) |
|
399 |
{ |
|
400 |
MessageBox.Show(this, "Invalid overall curve scale: must be valid number."); |
|
401 |
valid = false; |
|
402 |
} |
|
403 |
|
|
404 |
conf.SceneName = _scene.Text; |
|
405 |
|
|
406 |
conf.CurveColorHex = _curveColorHex.Text; |
|
407 |
|
|
408 |
if (valid) |
|
409 |
{ |
|
410 |
conf.Save(); |
|
411 |
|
|
412 |
try |
|
413 |
{ |
|
414 |
Process.Start(VrAppExe); |
|
415 |
} |
|
416 |
catch (Exception e) |
|
417 |
{ |
|
418 |
MessageBox.Show(this, $"Could not launch: {e.Message}"); |
|
419 |
} |
|
420 |
} |
|
421 |
} |
|
422 |
} |
|
423 |
} |
deltarobot-vr-launcher/DeltaRobotVr.Launcher/LayoutRectangle.cs | ||
---|---|---|
1 |
using System.Drawing; |
|
2 |
|
|
3 |
namespace DeltaRobotVr.Launcher |
|
4 |
{ |
|
5 |
|
|
6 |
/// <summary> |
|
7 |
/// A rectangle that allows creating layouts with subtractive methods. |
|
8 |
/// </summary> |
|
9 |
public struct LayoutRectangle |
|
10 |
{ |
|
11 |
public int Top; |
|
12 |
public int Right; |
|
13 |
public int Bottom; |
|
14 |
public int Left; |
|
15 |
|
|
16 |
public int Width => Right - Left; |
|
17 |
public int Height => Bottom - Top; |
|
18 |
|
|
19 |
public LayoutRectangle(int top, int right, int bottom, int left) |
|
20 |
{ |
|
21 |
Top = top; |
|
22 |
Right = right; |
|
23 |
Bottom = bottom; |
|
24 |
Left = left; |
|
25 |
} |
|
26 |
|
|
27 |
public LayoutRectangle(Rectangle rect) : this(rect.Top, rect.Right, rect.Bottom, rect.Left) |
|
28 |
{ |
|
29 |
} |
|
30 |
|
|
31 |
public Rectangle ToRectangle() => new Rectangle(Left, Top, Right - Left, Bottom - Top); |
|
32 |
|
|
33 |
public LayoutRectangle RemoveFromTop(int value) |
|
34 |
{ |
|
35 |
if (value > Height) |
|
36 |
{ |
|
37 |
value = Height; |
|
38 |
} |
|
39 |
|
|
40 |
var result = new LayoutRectangle(Top, Right, Top + value, Left); |
|
41 |
Top += value; |
|
42 |
return result; |
|
43 |
} |
|
44 |
|
|
45 |
public LayoutRectangle RemoveFromRight(int value) |
|
46 |
{ |
|
47 |
if (value > Width) |
|
48 |
{ |
|
49 |
value = Width; |
|
50 |
} |
|
51 |
|
|
52 |
var result = new LayoutRectangle(Top, Right, Bottom, Right - value); |
|
53 |
Right -= value; |
|
54 |
return result; |
|
55 |
} |
|
56 |
|
|
57 |
public LayoutRectangle RemoveFromBottom(int value) |
|
58 |
{ |
|
59 |
if (value > Height) |
|
60 |
{ |
|
61 |
value = Height; |
|
62 |
} |
|
63 |
|
|
64 |
var result = new LayoutRectangle(Bottom - value, Right, Bottom, Left); |
|
65 |
Bottom -= value; |
|
66 |
return result; |
|
67 |
} |
|
68 |
|
|
69 |
public LayoutRectangle RemoveFromLeft(int value) |
|
70 |
{ |
|
71 |
if (value > Width) |
|
72 |
{ |
|
73 |
value = Width; |
|
74 |
} |
|
75 |
|
|
76 |
var result = new LayoutRectangle(Top, Left + value, Bottom, Left); |
|
77 |
Left += value; |
|
78 |
return result; |
|
79 |
} |
|
80 |
|
|
81 |
public LayoutRectangle Shrink(int value) |
|
82 |
{ |
|
83 |
Top += value; |
|
84 |
Right -= value; |
|
85 |
Bottom -= value; |
|
86 |
Left += value; |
|
87 |
return this; |
|
88 |
} |
|
89 |
} |
|
90 |
} |
deltarobot-vr-launcher/DeltaRobotVr.Launcher/Program.cs | ||
---|---|---|
1 |
using System.Globalization; |
|
2 |
using System.Threading; |
|
3 |
using System.Windows.Forms; |
|
4 |
|
|
5 |
namespace DeltaRobotVr.Launcher |
|
6 |
{ |
|
7 |
internal class Program |
|
8 |
{ |
|
9 |
public static void Main() |
|
10 |
{ |
|
11 |
CultureInfo cultureInfo = new CultureInfo("en-US"); |
|
12 |
Thread.CurrentThread.CurrentCulture = cultureInfo; |
|
13 |
Thread.CurrentThread.CurrentUICulture = cultureInfo; |
|
14 |
CultureInfo.DefaultThreadCurrentCulture = cultureInfo; |
|
15 |
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; |
|
16 |
|
|
17 |
Application.Run(new LauncherForm()); |
|
18 |
} |
|
19 |
} |
|
20 |
} |
deltarobot-vr-launcher/DeltaRobotVr.Launcher/Properties/AssemblyInfo.cs | ||
---|---|---|
1 |
using System.Reflection; |
|
2 |
using System.Runtime.InteropServices; |
|
3 |
|
|
4 |
// General Information about an assembly is controlled through the following |
|
5 |
// set of attributes. Change these attribute values to modify the information |
|
6 |
// associated with an assembly. |
|
7 |
[assembly: AssemblyTitle("deltarobot_vr_launcher")] |
|
8 |
[assembly: AssemblyDescription("")] |
|
9 |
[assembly: AssemblyConfiguration("")] |
|
10 |
[assembly: AssemblyCompany("")] |
|
11 |
[assembly: AssemblyProduct("deltarobot_vr_launcher")] |
|
12 |
[assembly: AssemblyCopyright("Copyright © 2021")] |
|
13 |
[assembly: AssemblyTrademark("")] |
|
14 |
[assembly: AssemblyCulture("")] |
|
15 |
|
|
16 |
// Setting ComVisible to false makes the types in this assembly not visible |
|
17 |
// to COM components. If you need to access a type in this assembly from |
|
18 |
// COM, set the ComVisible attribute to true on that type. |
|
19 |
[assembly: ComVisible(false)] |
|
20 |
|
|
21 |
// The following GUID is for the ID of the typelib if this project is exposed to COM |
|
22 |
[assembly: Guid("3B359CF2-C5D8-4466-983F-E0467CDB1144")] |
|
23 |
|
|
24 |
// Version information for an assembly consists of the following four values: |
|
25 |
// |
|
26 |
// Major Version |
|
27 |
// Minor Version |
|
28 |
// Build Number |
|
29 |
// Revision |
|
30 |
// |
|
31 |
// You can specify all the values or you can default the Build and Revision Numbers |
|
32 |
// by using the '*' as shown below: |
|
33 |
// [assembly: AssemblyVersion("1.0.*")] |
|
34 |
[assembly: AssemblyVersion("1.0.0.0")] |
|
35 |
[assembly: AssemblyFileVersion("1.0.0.0")] |
deltarobot-vr-launcher/deltarobot-vr-launcher.sln | ||
---|---|---|
1 |
|
|
2 |
Microsoft Visual Studio Solution File, Format Version 12.00 |
|
3 |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeltaRobotVr.Launcher", "DeltaRobotVr.Launcher\DeltaRobotVr.Launcher.csproj", "{3B359CF2-C5D8-4466-983F-E0467CDB1144}" |
|
4 |
EndProject |
|
5 |
Global |
|
6 |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|
7 |
Debug|Any CPU = Debug|Any CPU |
|
8 |
Release|Any CPU = Release|Any CPU |
|
9 |
EndGlobalSection |
|
10 |
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|
11 |
{3B359CF2-C5D8-4466-983F-E0467CDB1144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
12 |
{3B359CF2-C5D8-4466-983F-E0467CDB1144}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
13 |
{3B359CF2-C5D8-4466-983F-E0467CDB1144}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
14 |
{3B359CF2-C5D8-4466-983F-E0467CDB1144}.Release|Any CPU.Build.0 = Release|Any CPU |
|
15 |
EndGlobalSection |
|
16 |
EndGlobal |
deltarobot-vr/Assets/DeltaRobotVr/ConfigurationProvider.cs | ||
---|---|---|
55 | 55 |
{ |
56 | 56 |
Directory.CreateDirectory(homePath + DefaultConfigDirectory); |
57 | 57 |
} |
58 |
saveConfiguration(new ConfigurationProvider(), configFile);
|
|
58 |
SaveConfiguration(new ConfigurationProvider(), configFile);
|
|
59 | 59 |
} |
60 | 60 |
|
61 | 61 |
// Deserialize configuration |
62 |
Instance = loadConfiguration(configFile);
|
|
62 |
Instance = LoadConfiguration(configFile);
|
|
63 | 63 |
} |
64 | 64 |
|
65 | 65 |
private ConfigurationProvider() |
... | ... | |
71 | 71 |
/// </summary> |
72 | 72 |
/// <param name="fileName">File to load configuration from</param> |
73 | 73 |
/// <returns></returns> |
74 |
private static ConfigurationProvider loadConfiguration(String fileName)
|
|
74 |
private static ConfigurationProvider LoadConfiguration(String fileName)
|
|
75 | 75 |
{ |
76 | 76 |
XmlSerializer serializer = new XmlSerializer(typeof(ConfigurationProvider)); |
77 | 77 |
|
... | ... | |
90 | 90 |
/// </summary> |
91 | 91 |
/// <param name="cp">ConfigurationProvider instance to save</param> |
92 | 92 |
/// <param name="fileName">File to save configuration to</param> |
93 |
private static void saveConfiguration(ConfigurationProvider cp, String fileName)
|
|
93 |
private static void SaveConfiguration(ConfigurationProvider cp, String fileName)
|
|
94 | 94 |
{ |
95 | 95 |
XmlSerializer serializer = new XmlSerializer(typeof(ConfigurationProvider)); |
96 | 96 |
|
Také k dispozici: Unified diff
Re #9001 - Launcher