Ability to open a URL that is attached to a puzzle

This commit is contained in:
Tim Young 2017-10-25 10:28:51 -05:00
parent f929e84d29
commit 36b42e64d4
3 changed files with 52 additions and 8 deletions

View File

@ -1006,6 +1006,18 @@ namespace EduNetworkBuilder
return randomizedList;
}
public static bool OpenURLInExternalBrowser(string URL)
{
Uri uriResult;
bool result = Uri.TryCreate(URL, UriKind.Absolute, out uriResult)
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
if(result)
{
System.Diagnostics.Process.Start(URL);
}
return false;
}
public static List<TreeNode> GetAllNodes(this TreeView _self)
{
List<TreeNode> result = new List<TreeNode>();

View File

@ -238,6 +238,23 @@ namespace EduNetworkBuilder
//Make a bunch of new buttons.
int count=0;
int offset = btnHelp.Height + 3;
if (myNetwork.NetURL.GetText() != "")
{
tButton = new Button();
tButton.Location = new Point(btnHelp.Location.X, rbHelp1.Location.Y + rbHelp1.Height + 5 + (offset * count));
//tButton.Text = (count + 1).ToString();
tButton.BackgroundImage = Properties.Resources.VidImage;
tButton.BackgroundImageLayout = ImageLayout.Stretch;
tButton.Width = btnHelp.Width;
tButton.Height = btnHelp.Height;
tButton.Click += btnRead_Click;
tButton.Name = myNetwork.PuzzleName + "_URL";
tButton.Tag = myNetwork.NetURL.GetText();
HelpPanel.Controls.Add(tButton);
myTooltip.SetToolTip(tButton, NB.Translate("_OpenURL") + " " + myNetwork.PuzzleName);
HelpTopicButtons.Add(tButton);
count++;
}
foreach (HelpTopics HT in myNetwork.SuggestedReadings)
{
tButton = new Button();
@ -270,18 +287,29 @@ namespace EduNetworkBuilder
private void btnRead_Click(object sender, EventArgs e)
{
Button me = (Button)sender;
HelpTopics HT = NB.TryParseEnum<HelpTopics>(me.Name, HelpTopics.None);
if(HT != HelpTopics.None)
if (me.Tag == null)
{
myNetwork.NoteActionDone(NetTestType.ReadContextHelp, me.Name, NB.Translate("_Read"));
NB.ReadContextHelp(HT);
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);
}
UpdateHelpTopicButtons();
UpdateForm();
UpdateMenu();
myNetwork.TestForCompletion(true);
}
else
{
//It should be a video URL
string URL = (string)me.Tag;
NB.OpenURLInExternalBrowser(URL);
}
UpdateHelpTopicButtons();
UpdateForm();
UpdateMenu();
myNetwork.TestForCompletion(true);
}
private void myTooltip_Popup(Object sender, PopupEventArgs e)
{
//In case we have a puzzle we are trying to solve

View File

@ -1985,4 +1985,8 @@
<value>Message / Title</value>
<comment>TW_Message = Message / Title</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>
</data>
</root>