private void file_Build_ListItem_SelectedIndexChanged(object sender, EventArgs e) { if (file_Build_ListItem.SelectedItem != null) { string name = file_Build_ListItem.SelectedItem.ToString(); int index = _listApps.FindIndex(x => x.Name == name); if (index >= 0) { _app = _listApps[index]; project_BindUI(); } } }
private static void ReadFile() { if (!File.Exists(_file)) { WriteFile(); return; } using (Stream file = File.OpenRead(_file)) { _app = Serializer.Deserialize <oApp>(file); } }
public static List <string> get_DefineDefault() { oApp app = null; if (!File.Exists(_file)) { return(null); } using (Stream file = File.OpenRead(_file)) app = Serializer.Deserialize <oApp>(file); return(app.Defines); }
void build_AddNew() { if (!Directory.Exists(m_explorer_PathCurrent)) { MessageBox.Show("Please chose folder contain source CPP in tab Explorer!", _CONST.APP_NAME); return; } string defValue = Path.GetFileName(m_explorer_PathCurrent); string name = Prompt.ShowDialog("Input build file name:", _CONST.APP_NAME, defValue); if (!string.IsNullOrEmpty(name)) { string _file = Path.Combine(m_build_PathRoot, name + ".bgcc"); if (!File.Exists(_file)) { _app = new oApp() { Name = name, PathRootCpp = m_explorer_PathCurrent }; if (tabGCC.Tag != null) { _app.update_GCC((oGCC)tabGCC.Tag); } if (tabDefine.Tag != null) { _app.set_Define((List <string>)tabDefine.Tag); } using (Stream ms = new FileStream(_file, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write)) Serializer.Serialize(ms, _app); project_loadInit(); int index = _listApps.FindIndex(x => x.Name == name); if (index >= 0) { _app = _listApps[index]; project_BindUI(); } } else { MessageBox.Show("File " + name + ".bgcc exist, Input other name...", _CONST.APP_NAME); build_AddNew(); } } }
void project_loadInit() { _listApps = Directory.GetFiles(m_build_PathRoot, "*.bgcc") .Select(x => Serializer.Deserialize <oApp>(File.OpenRead(x))) .Where(x => x != null && Directory.Exists(x.PathRootCpp)) .ToList(); file_Build_ListItem.DataSource = null; file_Build_ListItem.DataSource = _listApps.Select(x => x.Name).ToArray(); if (_listApps.Count > 0) { _app = _listApps[0]; project_BindUI(); } else { fileBrowser1.SelectPath(@"C:\", true); } }