-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCFGTab.cs
70 lines (59 loc) · 1.87 KB
/
CFGTab.cs
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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KAGIDE
{
internal class CFGTab : TabPage
{
private CFGTabControl content;
private BlobCFG Data;
private bool OnlyRead = false;
public CFGTab(string path, bool onlyread)
{
this.Text = Path.GetFileName(path);
this.Tag = path;
this.Data = new BlobCFG(path);
this.OnlyRead = onlyread;
Data.Load();
var toolStrip = new ToolStrip();
if (!OnlyRead)
{
var saveButton = new ToolStripButton("Save");
toolStrip.Items.Add(saveButton);
saveButton.Click += (sender, e) =>
{
// Save the file
CommitSave(path);
};
}
var closeButton = new ToolStripButton("Close");
toolStrip.Items.Add(closeButton);
closeButton.Alignment = ToolStripItemAlignment.Right;
closeButton.Click += (sender, e) => {
// Close the tab
//Tabs.TabPages.Remove(Page);
TabManager.CloseTab((string)this.Tag);
};
content = new CFGTabControl(Data);
content.Dock = DockStyle.None;
content.Location = new Point(0, toolStrip.Height); // Set the location below the ToolStrip
Controls.Add(toolStrip);
Controls.Add(content);
}
private bool CommitSave(string path)
{
if (!OnlyRead)
{
Data.Save();
this.Text = Path.GetFileName((string)this.Tag);
return true;
}
return false;
}
}
}