forked from jadaradix/dsgamemaker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHelpViewer.cs
More file actions
71 lines (67 loc) · 3.09 KB
/
HelpViewer.cs
File metadata and controls
71 lines (67 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
namespace DS_Game_Maker
{
public partial class HelpViewer
{
public HelpViewer()
{
InitializeComponent();
}
private void HelpViewer_Load(object sender, EventArgs e)
{
MainTreeView.Nodes.Clear();
string FContent = DSGMlib.PathToString(Constants.AppDirectory + "help/topics.dat");
foreach (string P in DSGMlib.StringToLines(FContent))
{
byte ID = Convert.ToByte(P.Substring(0, P.IndexOf(",")));
string Name = P.Substring(P.IndexOf(",") + 1);
MainTreeView.Nodes.Add(ID.ToString(), Name, 0, 0);
}
foreach (string P in DSGMlib.StringToLines(DSGMlib.PathToString(Constants.AppDirectory + "help/files.dat")))
{
byte ID = Convert.ToByte(P.Substring(0, P.IndexOf(",")));
string Name = P.Substring(P.IndexOf(",") + 1);
Name = Name.Substring(0, Name.LastIndexOf(","));
MainTreeView.Nodes[ID].Nodes.Add(ID.ToString(), Name, 1, 1);
}
GoToPage("Introduction", "intro");
}
public void GoToPage(string Title, string FName)
{
string FString = DSGMlib.PathToString(Constants.AppDirectory + "Help/head.html").Replace("$TITLE$", Name) + Constants.vbCrLf + Constants.vbCrLf;
if (System.IO.File.Exists(Constants.AppDirectory + "Help/" + FName + ".html"))
{
FString += DSGMlib.PathToString(Constants.AppDirectory + "Help/" + FName + ".html") + Constants.vbCrLf + Constants.vbCrLf;
}
else
{
FString += DSGMlib.PathToString(Constants.AppDirectory + "Help/todo.html").Replace("$TITLE$", Name) + Constants.vbCrLf + Constants.vbCrLf + Constants.vbCrLf + Constants.vbCrLf;
}
FString += DSGMlib.PathToString(Constants.AppDirectory + "Help/foot.html");
System.IO.File.WriteAllText(Constants.AppDirectory + "Help/display.html", FString);
DocBrowser.Navigate(Constants.AppDirectory + "Help/display.html");
}
private void MainTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Parent is null)
return;
string Name = e.Node.Text;
byte ID = (byte)e.Node.Parent.Index;
string FName = string.Empty;
foreach (string P in DSGMlib.StringToLines(DSGMlib.PathToString(Constants.AppDirectory + "help/files.dat")))
{
if (P.StartsWith(ID.ToString() + "," + Name + ","))
FName = P.Substring(ID.ToString().Length + 1 + Name.Length + 1);
}
GoToPage(Name, FName);
}
private void DocBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (e.Url.ToString().Contains("&ext") | e.Url.ToString().Contains("?ext"))
{
e.Cancel = true;
DSGMlib.URL(e.Url.ToString().Replace("&ext", string.Empty).Replace("?ext", string.Empty));
}
}
}
}