public Collection <TopologyTestCase> LoadTestCases(string path)
        {
            Collection <TopologyTestCase> testCases = new Collection <TopologyTestCase>();
            DirectoryInfo dirInfo = new DirectoryInfo(path);

            foreach (var item in dirInfo.GetFiles("*.xml"))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(item.FullName);
                XmlNode             rootNode          = doc.SelectSingleNode("//Case");
                Collection <string> topologyTestCases = GetTestCases();

                XmlNode          nodeTypeName     = rootNode.SelectSingleNode("./TypeName");
                TopologyTestCase topologyTestCase = null;

                if (topologyTestCases.Contains(nodeTypeName.InnerText))
                {
                    topologyTestCase = (TopologyTestCase)Activator.CreateInstance(Type.GetType(nodeTypeName.InnerText));
                }

                topologyTestCase.FromXml(rootNode);
                testCases.Add(topologyTestCase);
            }

            return(testCases);
        }
        private void lbTestCases_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listboxNames.SelectedValue != null && listboxNames.SelectedValue.ToString() != typeof(System.Data.DataRowView).ToString())
            {
                fromEvent = true;
                txtCaseDescription.Text = loadedTopologyTestCases[listboxNames.SelectedIndex].Description;
                ClearAll();

                TopologyTestCase testCase = loadedTopologyTestCases[listboxNames.SelectedIndex];
                winformsMap1.CurrentExtent = testCase.GetBoundingBox();
                winformsMap1.CurrentExtent.ScaleUp(30);
                string typeName = testCase.GetType().Name.Replace("TopologyTestCase", "");

                int count = 0;
                foreach (var item in cmbTopologyRules.Items)
                {
                    if (item.ToString() == typeName)
                    {
                        break;
                    }
                    count++;
                }
                cmbTopologyRules.SelectedIndex = count;

                testCase.Draw(winformsMap1);
                currentTopologyTestCase = testCase.Clone();
            }
        }
        private void btnSaveCaseInCurrentExtent_Click(object sender, EventArgs e)
        {
            SaveTestCaseDialog saveTestCaseDialog = new SaveTestCaseDialog(currentTopologyTestCase.GetType().Name, "", testCasesFilePath, winformsMap1.CurrentExtent);

            if (saveTestCaseDialog.ShowDialog() == DialogResult.OK)
            {
                TopologyTestCase topologyTestCase = currentTopologyTestCase.GenerateTestCaseWithinExtent(winformsMap1.CurrentExtent);
                topologyTestCase.Name        = saveTestCaseDialog.TestCaseName;
                topologyTestCase.Description = saveTestCaseDialog.Description;
                topologyTestCase.ToXml(testCasesFilePath + "\\" + saveTestCaseDialog.TestCaseName);
                LoadTestCases();
            }
        }
        private void MainForm_Load(object sender, EventArgs e)
        {
            SetToolTip();
            winformsMap1.MapUnit           = GeographyUnit.Meter;
            winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.None;
            LoadTestCases();

            winformsMap1.CurrentScale             = new ZoomLevelSet().ZoomLevel10.Scale;
            currentTopologyTestCase               = new PolygonsMustNotOverlapTopologyTestCase();
            winformsMap1.TrackOverlay.TrackEnded += new EventHandler <TrackEndedTrackInteractiveOverlayEventArgs>(TrackOverlay_TrackEnded);
            if (listboxNames.Items.Count > 0)
            {
                listboxNames.SelectedIndex = 0;
                txtCaseDescription.Text    = loadedTopologyTestCases[listboxNames.SelectedIndex].Description;
            }
            cmbTopologyRules.SelectedIndex = 0;
            listboxNames.SelectedIndex     = 0;
        }
Ejemplo n.º 5
0
 public ShapesWktLoader(TopologyTestCase testCase)
 {
     InitializeComponent();
     if (testCase is OneInputLayerTopologyTestCase)
     {
         isTwoInput = false;
         wkt1       = GetWktFromFeatureLayer(((OneInputLayerTopologyTestCase)testCase).InputFeatureLayer);
     }
     else if (testCase is TwoInputLayersTopologyTestCase)
     {
         isTwoInput = true;
         wkt1       = GetWktFromFeatureLayer(((TwoInputLayersTopologyTestCase)testCase).FirstInputFeatureLayer);
         wkt2       = GetWktFromFeatureLayer(((TwoInputLayersTopologyTestCase)testCase).SecondInputFeatureLayer);
     }
     else
     {
         throw new Exception("TestCase not supported.");
     }
 }
        private void cmbTopologyRules_SelectedIndexChanged(object sender, EventArgs e)
        {
            winformsMap1.TrackOverlay.TrackShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(102, 0, 0, 255), GeoColor.FromArgb(255, 0, 0, 255), 2);
            currentTopologyTestCase = GetTestCaseInstance(cmbTopologyRules.SelectedItem.ToString());
            if (!fromEvent)
            {
                listboxNames.SelectedIndex = -1;
            }
            else
            {
                fromEvent = false;
            }
            UpdateEditButtons();

            if (currentTopologyTestCase == null)
            {
                MessageBox.Show("The test case is not implemented");
            }
            ClearAll();
        }