using System; using System.Collections.Generic; using System.Linq; using System.Text; // add using System.Windows.Forms; using System.Xml; namespace C64NET35 { public class CProject { private XmlDocument mXMLConfig = new XmlDocument(); private CItems mItems = new CItems(); private bool mbDebug = false; private bool mbConfirmLaunch = false; private StringBuilder msDebugLog = new StringBuilder(); public string ProductName { get { return Application.ProductName; } } public string ProductVersion { get { return Application.ProductVersion; } } public bool ConfirmLaunch { get { return mbConfirmLaunch; } } public bool Debug { get { return mbDebug; } } public bool Begin() { string s1, s2; XmlNodeList nList; string sQuery; string sXMLFilename = @".\Project.xml"; try { mXMLConfig.Load(sXMLFilename); // attribute sample1 nList = null; sQuery = "/Company/System/Project[@Debug]"; nList = mXMLConfig.SelectNodes(sQuery); if ((nList != null) && (nList.Count > 0)) { XmlElement e1 = (XmlElement)nList[0]; s1 = e1.Attributes["Debug"].Value; if (s1 == "1") mbDebug = true; } // attribute sample2 nList = null; sQuery = "/Company[@ID='ChampTek']/System[@ID='CCD']/Project[@ID='C64NET35' and @Debug]"; nList = mXMLConfig.SelectNodes(sQuery); if ((nList != null) && (nList.Count > 0)) { XmlElement e1 = (XmlElement)nList[0]; s1 = e1.Attributes["Debug"].Value; if (s1 == "1") mbDebug = true; } sQuery = "/Company[@ID='ChampTek']/System[@ID='CCD']/Project[@ID='C64NET35' and @ComfirmLaunch='1']"; nList = mXMLConfig.SelectNodes(sQuery); if ((nList != null) && (nList.Count > 0)) { mbConfirmLaunch = true; } //// 以第一組為準. (todo: 可多組) // XmlElement e1 = (XmlElement) nList[0]; // // debug // s1 = e1.Attributes["Debug"].Value; // if (s1 == "1") // mbDebug = true; // //XmlNode root = doc.DocumentElement; // //nodeList = root.SelectNodes("descendant::book[author/last-name='Smith']"); // //title[@lang='eng'] // // ConfirmLaunch // s1 = e1.Attributes["ComfirmLaunch"].Value; // if (s1 == "1") // mbConfirmLaunch = true; //} // Project Items. nList = null; sQuery = "/Company/System/Project/Item"; nList = mXMLConfig.SelectNodes(sQuery); if ((nList != null) && (nList.Count > 0)) { for (int i = 0; i < nList.Count; i++) { s1 = nList[i].Attributes["ID"].Value; s2 = nList[i].InnerText; if (mItems.Contains(s1)) { PopupMsg("Duplicated Key=" + s1 + Environment.NewLine + "File=" + sXMLFilename + Environment.NewLine + "Attribute=" + sQuery + Environment.NewLine + "Value=" + s2 ); } else { mItems.Add(new CItem(s1, s2)); } } } //Application.Run(new FMAIN()); if (MessageBox.Show("Ready to launch ?" , ProductName + ", " + ProductVersion , MessageBoxButtons.OKCancel, MessageBoxIcon.Information) != DialogResult.OK) { return false; } return true; } catch (Exception e1) { PopupMsg(e1.Message); return false; } } public void PopupMsg(string sMsg) { MessageBox.Show(sMsg, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } public bool AskOK(string sMsg) { return (MessageBox.Show(sMsg, ProductName, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK); } public void DebugClear() { if (!mbDebug) return; msDebugLog.Length = 0; } public void DebugAppendLine(string sMsg) { if (!mbDebug) return; msDebugLog.AppendLine(sMsg); } } }