Example #1
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            // Don't define the model until the screen gets shown for the first time. Otherwise
            // the map control may end up saving an incorrect screen image.

            string fileName = Settings.Default.LastFile;

            if (File.Exists(fileName))
            {
                try
                {
                    ISpatialData data = CadastralFile.ReadFile(fileName);
                    m_Controller.MapModel = new SimpleMapModel(data);
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            // All properties are readonly, and by default they will show up in
            // a pale grey that's difficult to see. Change it to black so the
            // info can be seen without squinting (the fact that the fields can't
            // be edited will be apparent when the user tries to do it). Actually,
            // changing it to black seems to be a special case, where the text
            // continues to comes out grey. So change it to nearly black.
            propertyGrid.ViewForeColor = Color.FromArgb(1, 0, 0); //SystemColors.ControlText; // Color.Black;

            // Ensure the map control has focus, so that things like the ESC key will be recognized
            //mapControl.Focus();
        }
Example #2
0
        private void LoadForm_Shown(object sender, EventArgs e)
        {
            try
            {
                // Load the cadastral schema
                XmlSchema schema = GetSchema();

                ShowMessage("Checking data");
                string data = File.ReadAllText(m_FileName);

                using (StringReader sr = new StringReader(data))
                {
                    XmlReaderSettings xrs = new XmlReaderSettings();
                    xrs.ConformanceLevel = ConformanceLevel.Document;
                    xrs.ValidationType   = ValidationType.Schema;
                    xrs.Schemas.Add(schema);
                    xrs.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);

                    XmlReader reader = XmlReader.Create(sr, xrs);
                    while (reader.Read())
                    {
                        if (m_Errors.Count > 100)
                        {
                            throw new ApplicationException("Too many problems. Ignoring the rest of the file.");
                        }
                    }
                }

                if (m_Errors.Count == 1)
                {
                    ShowMessage("1 problem detected");
                }
                else
                {
                    ShowMessage(m_Errors.Count + " problems detected");
                }

                // Load the data into objects so long as there were no errors
                if (m_Errors.Count == 0)
                {
                    ShowMessage("Deserializing...");
                    m_Data = CadastralFile.ReadXmlString(data);
                    //using (StringReader sr = new StringReader(data))
                    //{
                    //    using (XmlReader xr = XmlReader.Create(sr))
                    //    {
                    //        XmlSerializer xs = new XmlSerializer(typeof(GeoSurveyPacketData));
                    //        GeoSurveyPacketData packet = (GeoSurveyPacketData)xs.Deserialize(xr);
                    //    }
                    //}
                    ShowMessage("Done");
                }
            }

            catch (Exception ex)
            {
                ShowMessage(ex.Message);
            }
        }
Example #3
0
 void OpenCadastralFile(string fileName)
 {
     using (LoadForm dial = new LoadForm(fileName))
     {
         if (dial.ShowDialog() == DialogResult.OK)
         {
             ISpatialData data = new CadastralFile(fileName, dial.Data);
             m_Controller.MapModel     = new SimpleMapModel(data);
             Settings.Default.LastFile = fileName;
             Settings.Default.Save();
         }
     }
 }
Example #4
0
 void OpenCadastralFile(string fileName)
 {
     using (LoadForm dial = new LoadForm(fileName))
     {
         if (dial.ShowDialog() == DialogResult.OK)
         {
             ISpatialData data = new CadastralFile(fileName, dial.Data);
             m_Controller.MapModel = new SimpleMapModel(data);
             Settings.Default.LastFile = fileName;
             Settings.Default.Save();
         }
     }
 }