Can add a URL to help topics and puzzles. Clicking (or control-clicking) pulls up the video in a browser.
This commit is contained in:
parent
36b42e64d4
commit
abb4ac0a2f
@ -424,6 +424,7 @@
|
||||
</FileAssociation>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\URLs.xml" />
|
||||
<None Include="Resources\VidImage.png" />
|
||||
<None Include="Resources\noBeep.wav" />
|
||||
<None Include="Resources\tablet.png" />
|
||||
|
@ -316,6 +316,12 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
}
|
||||
|
||||
public class HelpURL
|
||||
{
|
||||
public string URL = "";
|
||||
public string LangTag = "";
|
||||
public string HelpTopicString = "";
|
||||
}
|
||||
|
||||
static class NB
|
||||
{
|
||||
@ -616,6 +622,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void PlaySound(NBSoundType What)
|
||||
{
|
||||
BuilderWindow BW = GetBuilderWin();
|
||||
@ -1238,5 +1245,82 @@ namespace EduNetworkBuilder
|
||||
return TraversalTechnology.none;
|
||||
}
|
||||
|
||||
#region Generic XML Funcs
|
||||
|
||||
|
||||
public static T LoadObjectFromXmlFile<T>(string XMLResourceToLoad) where T : new()
|
||||
{
|
||||
//Load in the sprite data
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
||||
|
||||
System.Reflection.Assembly thisExe;
|
||||
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
// Creates the ResourceManager.
|
||||
System.Resources.ResourceManager myManager = Properties.Resources.ResourceManager;
|
||||
|
||||
// Retrieves String and Image resources.
|
||||
object titem = myManager.GetObject(XMLResourceToLoad);
|
||||
byte[] item = (byte[])System.Text.Encoding.UTF8.GetBytes((string)titem);
|
||||
|
||||
try
|
||||
{
|
||||
return (T)serializer.Deserialize(new MemoryStream(item));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the given object instance to an XML file.
|
||||
/// <para>Only Public properties and variables will be written to the file. These can be any type though, even other classes.</para>
|
||||
/// <para>If there are public properties/variables that you do not want written to the file, decorate them with the [XmlIgnore] attribute.</para>
|
||||
/// <para>Object type must have a parameterless constructor.</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of object being written to the file.</typeparam>
|
||||
/// <param name="filePath">The file path to write the object instance to.</param>
|
||||
/// <param name="objectToWrite">The object instance to write to the file.</param>
|
||||
public static void WriteToXmlFile<T>(string filePath, T objectToWrite) where T : new()
|
||||
{
|
||||
TextWriter writer = null;
|
||||
try
|
||||
{
|
||||
var serializer = new XmlSerializer(typeof(T));
|
||||
writer = new StreamWriter(filePath);
|
||||
serializer.Serialize(writer, objectToWrite);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (writer != null)
|
||||
writer.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an object instance from an XML file.
|
||||
/// <para>Object type must have a parameterless constructor.</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of object to read from the file.</typeparam>
|
||||
/// <param name="filePath">The file path to read the object instance from.</param>
|
||||
/// <returns>Returns a new instance of the object read from the XML file.</returns>
|
||||
public static T ReadFromXmlFile<T>(string filePath) where T : new()
|
||||
{
|
||||
TextReader reader = null;
|
||||
try
|
||||
{
|
||||
var serializer = new XmlSerializer(typeof(T));
|
||||
reader = new StreamReader(filePath);
|
||||
return (T)serializer.Deserialize(reader);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (reader != null)
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ namespace EduNetworkBuilder
|
||||
|
||||
public PersonClass CurrentUser;
|
||||
|
||||
private List<HelpURL> HelpURLs = new List<HelpURL>();
|
||||
|
||||
public BuilderWindow(string FirstArg="")
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -65,6 +67,8 @@ namespace EduNetworkBuilder
|
||||
|
||||
LastPath = OurSettings.LastPath;
|
||||
|
||||
HelpURLs = NB.LoadObjectFromXmlFile<List<HelpURL>>("URLs");
|
||||
|
||||
if(!OurSettings.LanguageHasBeenChosen)
|
||||
NB.ChangeLanguage(OurSettings);
|
||||
LanguagifyComponents();
|
||||
@ -258,14 +262,26 @@ namespace EduNetworkBuilder
|
||||
foreach (HelpTopics HT in myNetwork.SuggestedReadings)
|
||||
{
|
||||
tButton = new Button();
|
||||
string URL = URLFromHelpTopic(HT);
|
||||
tButton.Location = new Point(btnHelp.Location.X, rbHelp1.Location.Y + rbHelp1.Height + 5 + (offset * count));
|
||||
tButton.Text = (count + 1).ToString();
|
||||
tButton.Width = btnHelp.Width;
|
||||
tButton.Height = btnHelp.Height;
|
||||
tButton.Click += btnRead_Click;
|
||||
tButton.Name = HT.ToString();
|
||||
if(URL != "")
|
||||
{
|
||||
//We have a URL for this.
|
||||
tButton.BackgroundImage = Properties.Resources.VidImage;
|
||||
tButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
tButton.Tag = URL;
|
||||
tButton.ForeColor = Color.White;
|
||||
}
|
||||
HelpPanel.Controls.Add(tButton);
|
||||
myTooltip.SetToolTip(tButton, NB.Translate("_ReadContext") + " " + NB.Translate(NB.GetHelpTopicTitle(HT)));
|
||||
string ttip = NB.Translate("_ReadContext") + " " + NB.Translate(NB.GetHelpTopicTitle(HT));
|
||||
if (URL != "")
|
||||
ttip += "\n" + NB.Translate("_HasURL");
|
||||
myTooltip.SetToolTip(tButton, ttip);
|
||||
HelpTopicButtons.Add(tButton);
|
||||
count++;
|
||||
}
|
||||
@ -279,6 +295,20 @@ namespace EduNetworkBuilder
|
||||
this.ResumeLayout();
|
||||
}
|
||||
|
||||
string URLFromHelpTopic(HelpTopics what, string lang="")
|
||||
{
|
||||
string topic = what.ToString();
|
||||
if (lang == "") lang = ChosenLanguage;
|
||||
foreach(HelpURL one in HelpURLs)
|
||||
{
|
||||
if(one.HelpTopicString == topic && one.LangTag == lang)
|
||||
{
|
||||
return one.URL;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the context_read clicks
|
||||
/// </summary>
|
||||
@ -287,13 +317,24 @@ namespace EduNetworkBuilder
|
||||
private void btnRead_Click(object sender, EventArgs e)
|
||||
{
|
||||
Button me = (Button)sender;
|
||||
if (me.Tag == null)
|
||||
bool isURL = false;
|
||||
isURL = Regex.IsMatch(me.Name, "_URL$");
|
||||
if (!isURL)
|
||||
{
|
||||
HelpTopics HT = NB.TryParseEnum<HelpTopics>(me.Name, HelpTopics.None);
|
||||
if (HT != HelpTopics.None)
|
||||
{
|
||||
myNetwork.NoteActionDone(NetTestType.ReadContextHelp, me.Name, NB.Translate("_Read"));
|
||||
NB.ReadContextHelp(HT);
|
||||
if (ModifierKeys == Keys.Control && me.Tag != null)
|
||||
{
|
||||
//It should be a video URL
|
||||
string URL = (string)me.Tag;
|
||||
NB.OpenURLInExternalBrowser(URL);
|
||||
}
|
||||
else
|
||||
{
|
||||
myNetwork.NoteActionDone(NetTestType.ReadContextHelp, me.Name, NB.Translate("_Read"));
|
||||
NB.ReadContextHelp(HT);
|
||||
}
|
||||
}
|
||||
UpdateHelpTopicButtons();
|
||||
UpdateForm();
|
||||
@ -302,9 +343,12 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
else
|
||||
{
|
||||
//It should be a video URL
|
||||
string URL = (string)me.Tag;
|
||||
NB.OpenURLInExternalBrowser(URL);
|
||||
if (me.Tag != null)
|
||||
{
|
||||
//It should be a video URL
|
||||
string URL = (string)me.Tag;
|
||||
NB.OpenURLInExternalBrowser(URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
21
EduNetworkBuilder/Properties/Resources.Designer.cs
generated
21
EduNetworkBuilder/Properties/Resources.Designer.cs
generated
@ -1230,6 +1230,27 @@ namespace EduNetworkBuilder.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?>
|
||||
///<ArrayOfHelpURL xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
/// <HelpURL>
|
||||
/// <URL>https://www.youtube.com/watch?v=YZbbWZqfC-Y</URL>
|
||||
/// <LangTag>en</LangTag>
|
||||
/// <HelpTopicString>DHCP</HelpTopicString>
|
||||
/// </HelpURL>
|
||||
/// <HelpURL>
|
||||
/// <URL>https://www.youtube.com/watch?v=YZbbWZqfC-Y</URL>
|
||||
/// <LangTag>en</LangTag>
|
||||
/// <HelpTopicString>DHCPServer</HelpTopicString>
|
||||
/// </HelpURL>
|
||||
///</ArrayOfHelpURL>.
|
||||
/// </summary>
|
||||
internal static string URLs {
|
||||
get {
|
||||
return ResourceManager.GetString("URLs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -484,6 +484,9 @@
|
||||
<data name="InternetHomeAndOffice" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\InternetHomeAndOffice.enbx;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="URLs" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\URLs.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="VidImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\VidImage.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -2,9 +2,10 @@
|
||||
<EduNetworkBuilder>
|
||||
<!--This is a network file for EduNetworkBuilder.-->
|
||||
<Network>
|
||||
<en_message>To learn how this program works, first we will acquaint you with the 'Help.' Most of the puzzles you do, you will want to do with as little help as possible. But, there is help when you need it. For this puzzle, click one of the four help-levels (round buttons) on the right. Then mouse-over the PC and see the messages. When you have moused-over for all the buttons (and pressed the ? box), this puzzle will be completed.</en_message>
|
||||
<fr_message>Pour apprendre comment ce programme fonctionne, nous allons d'abord vous familiariser avec l'aide. La plupart des énigmes que vous faites, vous voudrez faire avec le moins d'aide possible. Mais, il y a de l'aide quand vous en avez besoin. Pour ce puzzle, cliquez sur l'un des quatre niveaux d'aide (boutons ronds) sur la droite. Passez ensuite la souris sur le PC et voyez les messages. Lorsque vous avez survolé tous les boutons (et appuyé sur la touche?), Ce casse-tête sera terminé.</fr_message>
|
||||
<en_message>To learn how this program works, first we will acquaint you with the 'Help.' Most of the puzzles you do, you will want to do with as little help as possible. But, there is help when you need it. For this puzzle, click one of the four help-levels (round buttons) on the right. Then mouse-over the PC and see the messages. When you have moused-over for all the buttons (and pressed the ? box), this puzzle will be completed.</en_message>
|
||||
<en_title>Learn how help works</en_title>
|
||||
<en_url>https://www.youtube.com/watch?v=YZbbWZqfC-Y</en_url>
|
||||
<height>1024</height>
|
||||
<width>1024</width>
|
||||
<itemsize>100</itemsize>
|
||||
@ -13,7 +14,7 @@
|
||||
<sortorder>0</sortorder>
|
||||
<uniqueidentifier>106</uniqueidentifier>
|
||||
<startinghelplevel>full</startinghelplevel>
|
||||
<vlansenabled>False</vlansenabled>
|
||||
<vlansenabled>True</vlansenabled>
|
||||
<VLANPacketColors>False</VLANPacketColors>
|
||||
<device>
|
||||
<hostname>pc0</hostname>
|
||||
@ -41,7 +42,7 @@
|
||||
<nictype>lo</nictype>
|
||||
<uniqueidentifier>101</uniqueidentifier>
|
||||
<usesdhcp>False</usesdhcp>
|
||||
<ssid />
|
||||
<encryptionkey />
|
||||
<interface>
|
||||
<nicname>lo0</nicname>
|
||||
<myip>
|
||||
@ -66,7 +67,7 @@
|
||||
<nictype>eth</nictype>
|
||||
<uniqueidentifier>102</uniqueidentifier>
|
||||
<usesdhcp>False</usesdhcp>
|
||||
<ssid />
|
||||
<encryptionkey />
|
||||
<interface>
|
||||
<nicname>eth0</nicname>
|
||||
<myip>
|
||||
|
13
EduNetworkBuilder/Resources/URLs.xml
Normal file
13
EduNetworkBuilder/Resources/URLs.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ArrayOfHelpURL xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<HelpURL>
|
||||
<URL>https://www.youtube.com/watch?v=YZbbWZqfC-Y</URL>
|
||||
<LangTag>en</LangTag>
|
||||
<HelpTopicString>DHCP</HelpTopicString>
|
||||
</HelpURL>
|
||||
<HelpURL>
|
||||
<URL>https://www.youtube.com/watch?v=YZbbWZqfC-Y</URL>
|
||||
<LangTag>en</LangTag>
|
||||
<HelpTopicString>DHCPServer</HelpTopicString>
|
||||
</HelpURL>
|
||||
</ArrayOfHelpURL>
|
@ -1985,6 +1985,10 @@
|
||||
<value>Message / Title</value>
|
||||
<comment>TW_Message = Message / Title</comment>
|
||||
</data>
|
||||
<data name="_HasURL" xml:space="preserve">
|
||||
<value>This topic has a vidio. Press ctrl while clicking this button to launch a browser.</value>
|
||||
<comment>_HasURL = This topic has a vidio. Press ctrl while clicking this button to launch a browser.</comment>
|
||||
</data>
|
||||
<data name="_OpenURL" xml:space="preserve">
|
||||
<value>Open a URL for the puzzle:</value>
|
||||
<comment>_OpenURL = Open a URL for the puzzle:</comment>
|
||||
|
Loading…
Reference in New Issue
Block a user