Ejemplo n.º 1
0
        private void CheckChanged(ItemCheckedState state)
        {
            var scroll = panelImage.AutoScrollPosition;

            switch (state)
            {
            case (ItemCheckedState.Checked):
                correctionMenu.MenuItems[2].Checked = true;
                break;

            case (ItemCheckedState.Doubt):
                correctionMenu.MenuItems[1].Checked = true;
                break;

            case (ItemCheckedState.Unchecked):
                correctionMenu.MenuItems[0].Checked = true;
                break;
            }

            int indexOfChangingPage = CorrectingPageIndex();

            CorrectedPages[indexOfChangingPage].CheckImage.ItemAltsCheckedState[selectedPosition.X, selectedPosition.Y] = state;
            CorrectedPages[indexOfChangingPage].AnalyzeTooManyAndDoubts();

            PutOnGrid(CorrectedPages[indexOfChangingPage], IndexToRow(indexOfChangingPage));
            panelImage.AutoScrollPosition = new Point(-scroll.X, -scroll.Y);

            Draw();
        }
Ejemplo n.º 2
0
        public void AddAlternative(string alternative = "", int number = -1)
        {
            if (number == -1)
            {
                number = NumberOfAlternatives;
            }
            _alternatives.Insert(number, alternative);

            foreach (Item it in _items)
            {
                Fraction[] tmpWeights = new Fraction[it.Weights.Count()];
                it.Weights.CopyTo(tmpWeights, 0);
                ItemCheckedState[] tmpChecked = new ItemCheckedState[it.Checked.Count()];
                it.Checked.CopyTo(tmpChecked, 0);

                it.Weights = new Fraction[NumberOfAlternatives];
                it.Checked = new ItemCheckedState[NumberOfAlternatives];
                for (int i = 0; i < number; i++)
                {
                    it.Weights[i] = tmpWeights[i];
                    it.Checked[i] = tmpChecked[i];
                }
                it.Weights[number] = new Fraction(0);
                it.Checked[number] = ItemCheckedState.Unknown;
                for (int i = number + 1; i < NumberOfAlternatives; i++)
                {
                    it.Weights[i] = tmpWeights[i - 1];
                    it.Checked[i] = tmpChecked[i - 1];
                }
            }
            SetAlternativesNames();
        }
Ejemplo n.º 3
0
        public void RemoveAlternative(int number = -1)
        {
            if (number == -1)
            {
                number = NumberOfAlternatives - 1;
            }
            _alternatives.RemoveAt(number);

            foreach (Item it in _items)
            {
                Fraction[] tmpWeights = new Fraction[it.Weights.Count()];
                it.Weights.CopyTo(tmpWeights, 0);
                ItemCheckedState[] tmpChecked = new ItemCheckedState[it.Weights.Count()];
                if (it.Checked != null)
                {
                    it.Checked.CopyTo(tmpChecked, 0);
                }

                it.Weights = new Fraction[NumberOfAlternatives];
                it.Checked = new ItemCheckedState[NumberOfAlternatives];
                for (int i = 0; i < number; i++)
                {
                    it.Weights[i] = tmpWeights[i];
                    it.Checked[i] = tmpChecked[i];
                }
                for (int i = number; i < NumberOfAlternatives; i++)
                {
                    it.Weights[i] = tmpWeights[i + 1];
                    it.Checked[i] = tmpChecked[i + 1];
                }
            }
        }
Ejemplo n.º 4
0
        private ItemCheckedState[] GetCheckedStateFromCorrectedPage(CorrectedPage page, int item)
        {
            var check = new ItemCheckedState[NumberOfAlternatives];

            for (int i = 0; i < NumberOfAlternatives; i++)
            {
                var grid = ItemAltPointGrid(item, i);
                check[i] = page.CheckImage.ItemAltsCheckedState[grid.X, grid.Y];
            }
            return(check);
        }
Ejemplo n.º 5
0
        public void CalculateInitialItemAltsCheckedState(int pageNumber, float sure, float doubt)
        {
            if (ItemAltsCheckedState == null)
            {
                ItemAltsCheckedState = new ItemCheckedState[Program.Test.Paper.Blocks.X, Program.Test.Paper.Blocks.Y];
            }
            var itemAlternativeOnLocation = Program.Test.Pages[pageNumber].ItemAlternativeOnLocation();

            for (int i = 0; i < Program.Test.Paper.Blocks.X; i++)
            {
                for (int j = 0; j < Program.Test.Paper.Blocks.Y; j++)
                {
                    if (itemAlternativeOnLocation[i, j])
                    {
                        var crop = Processing.Crop(ScannedImage, ItemAltRectangle(i, j));
                        int w    = crop.GetLength(0);
                        int h    = crop.GetLength(1);

                        double val = 0;
                        Single w2  = (Single)(w - 1) / 2;
                        Single h2  = (Single)(h - 1) / 2;
                        Single max = w2 * w2 * h2 * h2;
                        double old = 0;
                        double nw  = 0;
                        for (int x = 0; x < w; x++)
                        {
                            for (int y = 0; y < h; y++)
                            {
                                val += crop[x, y] * (max - ((x - w2) * (x - w2) * (y - h2) * (y - h2)));;
                                old += crop[x, y];
                                nw  += crop[x, y] * (max - ((x - w2) * (x - w2) * (y - h2) * (y - h2)));
                            }
                        }
                        val /= 2.55f * ((w * h * max) - (
                                            (w * (w - 1) * (w + 1) / 12) *
                                            (h * (h - 1) * (h + 1) / 12)
                                            ));
                        ColorDistribution.Add(val);
                        ItemCheckedState state = ItemCheckedState.Unknown;

                        if (val < sure)
                        {
                            state = ItemCheckedState.Checked;
                        }
                        else if (val < doubt)
                        {
                            state = ItemCheckedState.Doubt;
                        }
                        else
                        {
                            state = ItemCheckedState.Unchecked;
                        }
                        ItemAltsCheckedState[i, j] = state;
                    }
                    else
                    {
                        ItemAltsCheckedState[i, j] = ItemCheckedState.Unavailable;
                    }
                }
            }
        }