示例#1
0
        private void AnalyzePlaceButton_Click(object sender, EventArgs e)
        {
            if (!coordinatesAnalyze.IsEmpty)
            {
                var pointDictionary = AreaColors(PointSide);
                using (StreamWriter writer = new StreamWriter($@"{ProjectDir}\pointColors.txt"))
                {
                    foreach (KeyValuePair <string, ColorInfo> keyValue in pointDictionary.OrderByDescending(elem => elem.Value.ColorCount))
                    {
                        writer.WriteLine($"{keyValue.Key} : {keyValue.Value.ColorCount}");
                    }
                }
                var pointAnalyze       = ColorsAnalyze(pointDictionary);
                var fragmentDictionary = AreaColors(RectSide);
                var fragmentAnalyze    = ColorsAnalyze(fragmentDictionary);
                var analyze            = new StringBuilder();

                if (detectSizeRadio.Checked)
                {
                    ImageColors(fragmentAnalyze);
                    var imageObjectsParameters         = FragmentObjectsSizeAnalyze(fragmentAnalyze);
                    var imageObjectsParametersPresence = imageObjectsParameters.Where(param => param.Value.Count > 0);
                    if (imageObjectsParametersPresence.Any())
                    {
                        foreach (var elem in imageObjectsParametersPresence)
                        {
                            var objectName = elem.Key;
                            analyze.AppendLine(DetectObjectName(objectName));
                            foreach (var objectParameters in elem.Value)
                            {
                                if (objectParameters.Area > 1)
                                {
                                    analyze.AppendLine($"Длина = {objectParameters.ArcLength}, площадь: {objectParameters.Area}");
                                }
                            }
                        }
                    }
                }
                var criteriaFragmentAnalyze = CriteriaObject.GetInstance().CalculateAnalyze(fragmentAnalyze);
                var criteriaPointAnalyze    = CriteriaObject.GetInstance().CalculateAnalyze(pointAnalyze, true);
                analyze.AppendLine(criteriaFragmentAnalyze);
                analyze.AppendLine(criteriaPointAnalyze);
                AnalyzeForm analyzeForm = new AnalyzeForm();
                analyzeForm.SetPointGridView(pointAnalyze);
                analyzeForm.SetFragmentGridView(fragmentAnalyze);
                analyzeForm.AddAnalyze(analyze.ToString());
                analyzeForm.Show();
            }
            else
            {
                MessageBox.Show("Выберите участок карты!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void setDataGridView()
        {
            var criteries = CriteriaObject.GetInstance().CriteriaDict;
            //var currentRow = 0;
            //var currentRow = criteriaGridView.Rows.Add();
            var currentRow = 0;

            foreach (var criteria in criteries)
            {
                currentRow = criteriaGridView.Rows.Add();
                var buildingName = criteria.Key;
                var row          = criteriaGridView.Rows[currentRow];
                row.Cells["Building"].Value = buildingName;
                foreach (var mapObject in criteria.Value)
                {
                    var objectName = mapObject.Key;
                    var priority   = mapObject.Value;
                    var cell       = row.Cells[objectName];
                    cell.Value = priority;
                }
            }
            //criteriaGridView.Rows.RemoveAt(currentRow + 1);
        }