Esempio n. 1
0
        public static RoyalGazetteList Load(String iFromFile)
        {
            StreamReader     lReader = null;
            XmlDocument      lXmlDoc = null;
            RoyalGazetteList RetVal  = null;

            try
            {
                if (!String.IsNullOrEmpty(iFromFile) && File.Exists(iFromFile))
                {
                    lReader = new StreamReader(iFromFile);
                    lXmlDoc = new XmlDocument();
                    lXmlDoc.LoadXml(lReader.ReadToEnd());
                    RetVal = RoyalGazetteList.Load(lXmlDoc);
                }
            }
            finally
            {
                if (lReader != null)
                {
                    lReader.Close();
                }
            }
            return(RetVal);
        }
Esempio n. 2
0
        private void openFileDialogXML_FileOk(Object sender, CancelEventArgs e)
        {
            this.Activate();
            String[]         files = openFileDialogXML.FileNames;
            RoyalGazetteList currentGazetteList = new RoyalGazetteList();

            foreach (String fileName in files)
            {
                RoyalGazetteList loadedGazetteList = RoyalGazetteList.Load(fileName);
                currentGazetteList.AddRange(loadedGazetteList);
            }
            ShowGazetteDialog(currentGazetteList);
        }
Esempio n. 3
0
        private void btn_GazetteLoad_Click(object sender, EventArgs e)
        {
            // DirectoryInfo lDirInfo = new DirectoryInfo("e:\\thailand\\dopa\\tambon\\gazette\\");

            string lDir = Path.Combine(Application.StartupPath, "gazette");

            if (Directory.Exists(lDir))
            {
                foreach (string lFilename in Directory.GetFiles(lDir, "Gazette*.XML"))
                {
                    RoyalGazetteList lCurrentGazetteList = RoyalGazetteList.Load(lFilename);
                    TambonHelper.GlobalGazetteList.AddRange(lCurrentGazetteList);
                }
                Boolean lHasEntries = (TambonHelper.GlobalGazetteList.Count > 0);
                btn_GazetteShow.Enabled    = lHasEntries;
                btn_GazetteShowAll.Enabled = lHasEntries;
            }
            else
            {
                MessageBox.Show(this, "Fatal error: Directory " + lDir + " is not existing." + Environment.NewLine + "Application will be terminated.", "Directory error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }