Ejemplo n.º 1
0
        /// <summary>
        /// several types of question can be treat as compare font
        /// </summary>
        /// <param name="anwser"></param>
        /// <param name="submission"></param>
        /// <returns></returns>

        public IResult Compare(ABIW_Document answer, ABIW_Document submission)
        {
            ABIW_Font answerFont  = new ABIW_Font(answer.Document.Range().Font);
            ABIW_Font submissFont = new ABIW_Font(submission.Document.Range().Font);

            if (answerFont.Compare(submissFont).Result == ComparisonResultIndicate.equal)
            {
                return(new ComparisonResult(ComparisonResultIndicate.equal));
            }
            else
            {
                return(new ComparisonResult(ComparisonResultIndicate.not_equal));
            }
        }
Ejemplo n.º 2
0
        public bool checkTwoParagraphs(Paragraphs ps1, Paragraphs ps2)
        {
            bool a = true;

            if (ps1.Count == ps2.Count)
            {
                for (int j = 1; j <= ps1.Count; j++)
                {
                    ABIW_Paragraph paragraph1 = new ABIW_Paragraph(ps1[j]);
                    ABIW_Paragraph paragraph2 = new ABIW_Paragraph(ps2[j]);
                    if (paragraph1.Compare(paragraph2).Result == ComparisonResultIndicate.not_equal)
                    {
                        a = false;
                        break;
                    }
                    else
                    {
                        List <Range> customRangesCorrect = classifyRange2(paragraph1.Paragraph.Range);
                        List <Range> customRangesAnswer  = classifyRange2(paragraph2.Paragraph.Range);
                        if (customRangesCorrect.Count() == customRangesAnswer.Count())
                        {
                            for (int k = 0; k < customRangesCorrect.Count(); k++)
                            {
                                ABIW_Font font1 = new ABIW_Font(customRangesCorrect[k].Font);
                                ABIW_Font font2 = new ABIW_Font(customRangesAnswer[k].Font);
                                //ABIW_Borders borders1 = new ABIW_Borders(customRangesCorrect[k].Borders);
                                //ABIW_Borders borders2 = new ABIW_Borders(customRangesAnswer[k].Borders);
                                if (font1.Compare(font2).Result == ComparisonResultIndicate.not_equal
                                    //|| borders1.Compare(borders2).Result == ComparisonResultIndicate.not_equal
                                    )
                                {
                                    a = false;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            a = false;
                        }
                    }
                }
            }
            else
            {
                a = false;
            }
            return(a);
        }
Ejemplo n.º 3
0
        public static bool CompareTextRange(Range ran1, Range ran2)
        {
            List <StartEnd> startEnds1   = new List <StartEnd>();
            List <StartEnd> startEnds2   = new List <StartEnd>();
            StartEnd        oriStartEnd1 = new StartEnd(ran1.Start, ran1.End);
            StartEnd        oriStartEnd2 = new StartEnd(ran2.Start, ran2.End);

            classifyRange(ran1, ran1.Start, ran1.End, startEnds1);
            classifyRange(ran2, ran2.Start, ran2.End, startEnds2);

            if (startEnds1.Count == startEnds2.Count)
            {
                for (int i = 0; i < startEnds1.Count; i++)
                {
                    if (startEnds1[i].start == startEnds2[i].start && startEnds1[i].end == startEnds2[i].end)
                    {
                        ran1.Start = startEnds1[i].start;
                        ran1.End   = startEnds1[i].end;
                        ran2.Start = startEnds2[i].start;
                        ran2.End   = startEnds2[i].end;
                        ABIW_Font font1 = new ABIW_Font(ran1.Font);
                        ABIW_Font font2 = new ABIW_Font(ran2.Font);
                        if (font1.Compare(font2).Result == ComparisonResultIndicate.equal)
                        {
                            ran1.Start = oriStartEnd1.start;
                            ran1.End   = oriStartEnd1.end;
                            ran2.Start = oriStartEnd2.start;
                            ran2.End   = oriStartEnd2.end;
                            continue;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }