diff --git a/EduNetworkBuilder/EduNetworkBuilder.csproj b/EduNetworkBuilder/EduNetworkBuilder.csproj index a7a7cea..f375c29 100644 --- a/EduNetworkBuilder/EduNetworkBuilder.csproj +++ b/EduNetworkBuilder/EduNetworkBuilder.csproj @@ -424,6 +424,7 @@ + diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index 3428d5b..fcb8a10 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -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(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 + { + + } + } + + /// + /// Writes the given object instance to an XML file. + /// Only Public properties and variables will be written to the file. These can be any type though, even other classes. + /// If there are public properties/variables that you do not want written to the file, decorate them with the [XmlIgnore] attribute. + /// Object type must have a parameterless constructor. + /// + /// The type of object being written to the file. + /// The file path to write the object instance to. + /// The object instance to write to the file. + public static void WriteToXmlFile(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(); + } + } + + /// + /// Reads an object instance from an XML file. + /// Object type must have a parameterless constructor. + /// + /// The type of object to read from the file. + /// The file path to read the object instance from. + /// Returns a new instance of the object read from the XML file. + public static T ReadFromXmlFile(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 + + } } diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 100208e..80afa12 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -57,6 +57,8 @@ namespace EduNetworkBuilder public PersonClass CurrentUser; + private List HelpURLs = new List(); + public BuilderWindow(string FirstArg="") { InitializeComponent(); @@ -65,6 +67,8 @@ namespace EduNetworkBuilder LastPath = OurSettings.LastPath; + HelpURLs = NB.LoadObjectFromXmlFile>("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 ""; + } + /// /// Called by the context_read clicks /// @@ -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(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); + } } } diff --git a/EduNetworkBuilder/Properties/Resources.Designer.cs b/EduNetworkBuilder/Properties/Resources.Designer.cs index 26eb6bd..71b32b3 100644 --- a/EduNetworkBuilder/Properties/Resources.Designer.cs +++ b/EduNetworkBuilder/Properties/Resources.Designer.cs @@ -1230,6 +1230,27 @@ namespace EduNetworkBuilder.Properties { } } + /// + /// 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>. + /// + internal static string URLs { + get { + return ResourceManager.GetString("URLs", resourceCulture); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/EduNetworkBuilder/Properties/Resources.resx b/EduNetworkBuilder/Properties/Resources.resx index 4aa0253..601227d 100644 --- a/EduNetworkBuilder/Properties/Resources.resx +++ b/EduNetworkBuilder/Properties/Resources.resx @@ -484,6 +484,9 @@ ..\Resources\InternetHomeAndOffice.enbx;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\URLs.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + ..\Resources\VidImage.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/EduNetworkBuilder/Resources/Level0-Help.enbx b/EduNetworkBuilder/Resources/Level0-Help.enbx index 8d04495..19ab072 100644 --- a/EduNetworkBuilder/Resources/Level0-Help.enbx +++ b/EduNetworkBuilder/Resources/Level0-Help.enbx @@ -2,9 +2,10 @@ - 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. 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é. + 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. Learn how help works + https://www.youtube.com/watch?v=YZbbWZqfC-Y 1024 1024 100 @@ -13,7 +14,7 @@ 0 106 full - False + True False pc0 @@ -41,7 +42,7 @@ lo 101 False - + lo0 @@ -66,7 +67,7 @@ eth 102 False - + eth0 diff --git a/EduNetworkBuilder/Resources/URLs.xml b/EduNetworkBuilder/Resources/URLs.xml new file mode 100644 index 0000000..e4b81b1 --- /dev/null +++ b/EduNetworkBuilder/Resources/URLs.xml @@ -0,0 +1,13 @@ + + + + https://www.youtube.com/watch?v=YZbbWZqfC-Y + en + DHCP + + + https://www.youtube.com/watch?v=YZbbWZqfC-Y + en + DHCPServer + + \ No newline at end of file diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index 6ca215e..2dc225d 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -1985,6 +1985,10 @@ Message / Title TW_Message = Message / Title + + This topic has a vidio. Press ctrl while clicking this button to launch a browser. + _HasURL = This topic has a vidio. Press ctrl while clicking this button to launch a browser. + Open a URL for the puzzle: _OpenURL = Open a URL for the puzzle: