Skip to content

Commit

Permalink
first build of v3.1
Browse files Browse the repository at this point in the history
**experimental**

*proper* fix for virtualbox biosdate bug
refined xaml structure
  • Loading branch information
driver1998 committed Oct 13, 2017
1 parent 6771470 commit e4a60b5
Show file tree
Hide file tree
Showing 15 changed files with 767 additions and 715 deletions.
6 changes: 3 additions & 3 deletions VMGuide.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("VMGuide Core")]
[assembly: AssemblyDescription("Build 20170331")]
[assembly: AssemblyDescription("Build 20171014")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VMGuide Core")]
Expand All @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
91 changes: 58 additions & 33 deletions VMGuide.Core/vmware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,45 +289,71 @@ public override DateTime BIOSDate

public class VMware
{
public static string[] Firmwares = { "bios", "efi" };
static string[] fw_des = { "BIOS", "UEFI" };

public static string[] SoundCards = { "sb16", "es1371", "hdaudio", "none" };
static string[] snd_des = { "Sound Blaster 16", "Sound Blaster PCI", "HD Audio", "None" };

public static string[] NICs = { "vlance", "e1000", "e1000e", "vmxnet", "vmxnet3" };
static string[] nic_des = { "AMD PCnet", "Intel E1000", "Intel E1000e", "VMware VMXNet", "VMware VMXNet3" };


public static string ValueToDescripton(string value)
private static Dictionary<string, string> firmwares;
public static Dictionary<string, string> Firmwares
{
int index = -1, i;
string ret = value;
get
{
if (firmwares == null)
{
firmwares = new Dictionary<string, string>()
{
{"bios" ,"BIOS"},
{"efi" ,"UEFI"},
};
}
return firmwares;
}
}

for (i = 0; i < 3; i++)
private static Dictionary<string, string> soundcards;
public static Dictionary<string, string> SoundCards
{
get
{
switch (i)
if (soundcards == null)
{
case 0:
index = Array.IndexOf(Firmwares, value.ToLower());
if (index != -1) ret = fw_des[index];
break;
case 1:
index = Array.IndexOf(SoundCards, value.ToLower());
if (index != -1) ret = snd_des[index];
break;
case 2:
index = Array.IndexOf(NICs, value.ToLower());
if (index != -1) ret = nic_des[index];
break;
soundcards = new Dictionary<string, string>()
{
{"sb16" ,"Sound Blaster 16"},
{"es1371" ,"Sound Blaster PCI ES1371"},
{"hdaudio" ,"HD Audio"},
{"none" ,"None"},
};
}
return soundcards;
}
}

if (index != -1) break;
private static Dictionary<string, string> nics;
public static Dictionary<string, string> NICs
{
get
{
if (nics == null)
{
nics = new Dictionary<string, string>()
{
{"vlance" ,"AMD PCnet-PCI II Am79C970A"},
{"e1000" ,"Intel E1000"},
{"e1000e" ,"Intel E1000e"},
{"vmxnet" ,"VMware VMXNet"},
{"vmxnet3" ,"VMware VMXNet3"},
};
}
return nics;
}

return ret;
}


public static string ValueToDescripton(string value)
{
if (Firmwares.ContainsKey(value)) return Firmwares[value];
if (SoundCards.ContainsKey(value)) return SoundCards[value];
if (NICs.ContainsKey(value)) return NICs[value];
return "";
}
/*
public static string DescriptionToValue(string des)
{
int index = -1, i;
Expand Down Expand Up @@ -356,7 +382,7 @@ public static string DescriptionToValue(string des)
return ret;
}

*/
public static void SearchVM(ref List<VirtualMachine> VMList)
{
/*
Expand All @@ -382,8 +408,7 @@ public static void SearchVM(ref List<VirtualMachine> VMList)
name = "pref.mruVM\\d+.filename";
}

if (File.Exists(ConfigFile) == false)
{ continue; }
if (File.Exists(ConfigFile) == false) continue;
config = new VMXFile(ConfigFile);
values = config.ReadValues(name);

Expand Down
12 changes: 12 additions & 0 deletions VMGuide.GUI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VMGuide"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<local:BooleanToCollapseConverter x:Key="BooleanToCollapseConverter"/>
<local:BooleanReverseConverter x:Key="BooleanReverseConverter"/>
<local:BooleanReverseToCollapseConverter x:Key="BooleanReverseToCollapseConverter"/>

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

</Application>

2 changes: 1 addition & 1 deletion VMGuide.GUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void Main (string[] args)
}
else if (File.Exists(args[0]))
{
Home.PreLoadFile = args[0];
HomePage.PreLoadFile = args[0];
}
}

Expand Down
68 changes: 68 additions & 0 deletions VMGuide.GUI/Converters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace VMGuide
{
//boolean转是否为collapse
//true<->visible false<->collapse
public sealed class BooleanToCollapseConverter : IValueConverter
{
public object Convert(object value, Type type, object para, CultureInfo culture)
{
return (value is bool) ? ((bool)value ? Visibility.Visible : Visibility.Collapsed) : Visibility.Visible;
}
public object ConvertBack(object value, Type type, object para, CultureInfo culture)
{
return (value is Visibility) ? (value.Equals(Visibility.Visible) ? true : false) : false;
}
}

//boolean取反
public sealed class BooleanReverseConverter : IValueConverter
{
public object Convert(object value, Type type, object para, CultureInfo culture)
{
return (value is bool) ? !((bool)value) : false;
}
public object ConvertBack(object value, Type type, object para, CultureInfo culture)
{
return (value is bool) ? !((bool)value) : false;
}
}

//boolean转是否为collapse,与BooleanToCollapseConverter结果相反
//true<->collapse false<->visible
public sealed class BooleanReverseToCollapseConverter : IValueConverter
{
public object Convert(object value, Type type, object para, CultureInfo culture)
{
var val = (value is bool) ? !((bool)value) : false;
return val ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type type, object para, CultureInfo culture)
{
return (value is Visibility) ? (value.Equals(Visibility.Visible) ? false : true) : false;
}
}

//VMware中设定值与对应的描述文本互相转换
public sealed class VMwareValueToDescriptionConverter : IValueConverter
{

public object Convert(object value, Type type, object para, CultureInfo culture)
{
if (value == null) { return ""; } else { return VMware.ValueToDescripton(value.ToString()); }

}
public object ConvertBack(object value, Type type, object para, CultureInfo culture)
{
throw new NotImplementedException();
}
}


}
Loading

0 comments on commit e4a60b5

Please sign in to comment.