Skip to content

Commit e4a60b5

Browse files
committed
first build of v3.1
**experimental** *proper* fix for virtualbox biosdate bug refined xaml structure
1 parent 6771470 commit e4a60b5

File tree

15 files changed

+767
-715
lines changed

15 files changed

+767
-715
lines changed

VMGuide.Core/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// 控制。更改这些特性值可修改
77
// 与程序集关联的信息。
88
[assembly: AssemblyTitle("VMGuide Core")]
9-
[assembly: AssemblyDescription("Build 20170331")]
9+
[assembly: AssemblyDescription("Build 20171014")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("VMGuide Core")]
@@ -32,5 +32,5 @@
3232
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
3333
// 方法是按如下所示使用“*”: :
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("1.1.0.0")]
36+
[assembly: AssemblyFileVersion("1.1.0.0")]

VMGuide.Core/vmware.cs

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -289,45 +289,71 @@ public override DateTime BIOSDate
289289

290290
public class VMware
291291
{
292-
public static string[] Firmwares = { "bios", "efi" };
293-
static string[] fw_des = { "BIOS", "UEFI" };
294-
295-
public static string[] SoundCards = { "sb16", "es1371", "hdaudio", "none" };
296-
static string[] snd_des = { "Sound Blaster 16", "Sound Blaster PCI", "HD Audio", "None" };
297-
298-
public static string[] NICs = { "vlance", "e1000", "e1000e", "vmxnet", "vmxnet3" };
299-
static string[] nic_des = { "AMD PCnet", "Intel E1000", "Intel E1000e", "VMware VMXNet", "VMware VMXNet3" };
300-
301-
302-
public static string ValueToDescripton(string value)
292+
private static Dictionary<string, string> firmwares;
293+
public static Dictionary<string, string> Firmwares
303294
{
304-
int index = -1, i;
305-
string ret = value;
295+
get
296+
{
297+
if (firmwares == null)
298+
{
299+
firmwares = new Dictionary<string, string>()
300+
{
301+
{"bios" ,"BIOS"},
302+
{"efi" ,"UEFI"},
303+
};
304+
}
305+
return firmwares;
306+
}
307+
}
306308

307-
for (i = 0; i < 3; i++)
309+
private static Dictionary<string, string> soundcards;
310+
public static Dictionary<string, string> SoundCards
311+
{
312+
get
308313
{
309-
switch (i)
314+
if (soundcards == null)
310315
{
311-
case 0:
312-
index = Array.IndexOf(Firmwares, value.ToLower());
313-
if (index != -1) ret = fw_des[index];
314-
break;
315-
case 1:
316-
index = Array.IndexOf(SoundCards, value.ToLower());
317-
if (index != -1) ret = snd_des[index];
318-
break;
319-
case 2:
320-
index = Array.IndexOf(NICs, value.ToLower());
321-
if (index != -1) ret = nic_des[index];
322-
break;
316+
soundcards = new Dictionary<string, string>()
317+
{
318+
{"sb16" ,"Sound Blaster 16"},
319+
{"es1371" ,"Sound Blaster PCI ES1371"},
320+
{"hdaudio" ,"HD Audio"},
321+
{"none" ,"None"},
322+
};
323323
}
324+
return soundcards;
325+
}
326+
}
324327

325-
if (index != -1) break;
328+
private static Dictionary<string, string> nics;
329+
public static Dictionary<string, string> NICs
330+
{
331+
get
332+
{
333+
if (nics == null)
334+
{
335+
nics = new Dictionary<string, string>()
336+
{
337+
{"vlance" ,"AMD PCnet-PCI II Am79C970A"},
338+
{"e1000" ,"Intel E1000"},
339+
{"e1000e" ,"Intel E1000e"},
340+
{"vmxnet" ,"VMware VMXNet"},
341+
{"vmxnet3" ,"VMware VMXNet3"},
342+
};
343+
}
344+
return nics;
326345
}
327-
328-
return ret;
329346
}
330347

348+
349+
public static string ValueToDescripton(string value)
350+
{
351+
if (Firmwares.ContainsKey(value)) return Firmwares[value];
352+
if (SoundCards.ContainsKey(value)) return SoundCards[value];
353+
if (NICs.ContainsKey(value)) return NICs[value];
354+
return "";
355+
}
356+
/*
331357
public static string DescriptionToValue(string des)
332358
{
333359
int index = -1, i;
@@ -356,7 +382,7 @@ public static string DescriptionToValue(string des)
356382
357383
return ret;
358384
}
359-
385+
*/
360386
public static void SearchVM(ref List<VirtualMachine> VMList)
361387
{
362388
/*
@@ -382,8 +408,7 @@ public static void SearchVM(ref List<VirtualMachine> VMList)
382408
name = "pref.mruVM\\d+.filename";
383409
}
384410

385-
if (File.Exists(ConfigFile) == false)
386-
{ continue; }
411+
if (File.Exists(ConfigFile) == false) continue;
387412
config = new VMXFile(ConfigFile);
388413
values = config.ReadValues(name);
389414

VMGuide.GUI/App.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,17 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="clr-namespace:VMGuide"
55
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<local:BooleanToCollapseConverter x:Key="BooleanToCollapseConverter"/>
9+
<local:BooleanReverseConverter x:Key="BooleanReverseConverter"/>
10+
<local:BooleanReverseToCollapseConverter x:Key="BooleanReverseToCollapseConverter"/>
11+
12+
<ResourceDictionary.MergedDictionaries>
13+
<ResourceDictionary Source="Styles.xaml"/>
14+
</ResourceDictionary.MergedDictionaries>
15+
</ResourceDictionary>
16+
</Application.Resources>
17+
618
</Application>
719

VMGuide.GUI/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static void Main (string[] args)
3333
}
3434
else if (File.Exists(args[0]))
3535
{
36-
Home.PreLoadFile = args[0];
36+
HomePage.PreLoadFile = args[0];
3737
}
3838
}
3939

VMGuide.GUI/Converters.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Globalization;
5+
using System.Windows;
6+
using System.Windows.Data;
7+
8+
namespace VMGuide
9+
{
10+
//boolean转是否为collapse
11+
//true<->visible false<->collapse
12+
public sealed class BooleanToCollapseConverter : IValueConverter
13+
{
14+
public object Convert(object value, Type type, object para, CultureInfo culture)
15+
{
16+
return (value is bool) ? ((bool)value ? Visibility.Visible : Visibility.Collapsed) : Visibility.Visible;
17+
}
18+
public object ConvertBack(object value, Type type, object para, CultureInfo culture)
19+
{
20+
return (value is Visibility) ? (value.Equals(Visibility.Visible) ? true : false) : false;
21+
}
22+
}
23+
24+
//boolean取反
25+
public sealed class BooleanReverseConverter : IValueConverter
26+
{
27+
public object Convert(object value, Type type, object para, CultureInfo culture)
28+
{
29+
return (value is bool) ? !((bool)value) : false;
30+
}
31+
public object ConvertBack(object value, Type type, object para, CultureInfo culture)
32+
{
33+
return (value is bool) ? !((bool)value) : false;
34+
}
35+
}
36+
37+
//boolean转是否为collapse,与BooleanToCollapseConverter结果相反
38+
//true<->collapse false<->visible
39+
public sealed class BooleanReverseToCollapseConverter : IValueConverter
40+
{
41+
public object Convert(object value, Type type, object para, CultureInfo culture)
42+
{
43+
var val = (value is bool) ? !((bool)value) : false;
44+
return val ? Visibility.Visible : Visibility.Collapsed;
45+
}
46+
public object ConvertBack(object value, Type type, object para, CultureInfo culture)
47+
{
48+
return (value is Visibility) ? (value.Equals(Visibility.Visible) ? false : true) : false;
49+
}
50+
}
51+
52+
//VMware中设定值与对应的描述文本互相转换
53+
public sealed class VMwareValueToDescriptionConverter : IValueConverter
54+
{
55+
56+
public object Convert(object value, Type type, object para, CultureInfo culture)
57+
{
58+
if (value == null) { return ""; } else { return VMware.ValueToDescripton(value.ToString()); }
59+
60+
}
61+
public object ConvertBack(object value, Type type, object para, CultureInfo culture)
62+
{
63+
throw new NotImplementedException();
64+
}
65+
}
66+
67+
68+
}

0 commit comments

Comments
 (0)