Esempio n. 1
0
        private void Pregunta33()
        {
            p1 = "INCORRECTO";

            Word.Shapes       shapes  = docAlumno.Shapes;       //4
            Word.InlineShapes iShapes = docAlumno.InlineShapes; //1

            if (shapes.Count == 4 && iShapes.Count == 1)
            {
                string tipo  = iShapes[1].Type.ToString(); //wdInlineShapePicture
                var    rango = iShapes[1].Range;
                int    start = rango.Start;                //2365
                int    end   = rango.End;                  //2366

                if (tipo.Equals("wdInlineShapePicture") &&
                    start == 2365 && end == 2366)
                {
                    p1 = "CORRECTO";
                }
            }

            GuardarPuntaje();
            CerrarWords();

            BorrarPreguntasTemporales();
        }
Esempio n. 2
0
        private void Pregunta29()
        {
            p1 = "INCORRECTO";

            Word.Shapes shapes = docAlumno.Sections[1].Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Shapes;//1

            if (shapes.Count == 1)
            {
                Word.Range rango = docAlumno.Sections[1].Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;

                string tipo       = rango.Case.ToString();                       //wdTitleWord
                string texto      = rango.Text;                                  //"Los Fractales\r\r"
                string tipoFuente = rango.Font.Name;                             //"Calibri"
                float  tamaño     = rango.Font.Size;                             //10
                int    color      = Math.Abs(Convert.ToInt32(rango.Font.Color)); //-738131969
                string indexColor = rango.Font.ColorIndex.ToString();            //wdYellow
                string alineacion = rango.Paragraphs.Alignment.ToString();       //wdAlignParagraphLeft

                if (tipo.Contains("wdTitleWord") && texto.Contains("Los Fractales\r\r") &&
                    tipoFuente.Contains("Calibri") && tamaño == 10 && color == 738131969 &&
                    indexColor.Contains("wdYellow") && alineacion.Contains("wdAlignParagraphLeft"))
                {
                    p1 = "CORRECTO";
                }
            }

            GuardarPuntaje();
            CerrarWords();

            BorrarPreguntasTemporales();
        }
Esempio n. 3
0
        public void StartSpellChecking()
        {
            Cursor.Current = Cursors.WaitCursor;

            Globals.ThisAddIn.SpellOn = true;
            ResetAllInitVariables();

            if (!tabControl.TabPages.Contains(tabPage1))
            {
                tabControl.TabPages.Add(tabPage1);
            }
            tabControl.SelectTab(tabPage1);

            m_Inspector = Globals.ThisAddIn.Application.ActiveInspector();
            m_Document  = m_Inspector.WordEditor;
            if (!m_Inspector.IsWordMail())
            {
                m_Document = m_Inspector.CurrentItem as Word.Document;
            }

            // get the cursor position in the document
            nCursorPos = m_Document.Application.Selection.Start;
            // get all shapes in the document
            oShapes = m_Document.Application.ActiveDocument.Shapes;

            Word.ShapeRange oShpRng = m_Document.Application.Selection.ShapeRange;
            if (oShpRng.Count > 0)
            {
                object     obj = 1;
                Word.Shape shp = oShpRng.get_Item(ref obj);
                bCheckNormalText = false;
                bCursorInShape   = true;

                for (int i = 1; i <= oShapes.Count; i++)
                {
                    obj         = i;
                    nShapeIndex = i;
                    Word.Shape oShp = oShapes.get_Item(ref obj);
                    if (oShp.Name == shp.Name)
                    {
                        break;
                    }
                }
            }
            RestartParagraph();
            SetSpellingState("Անտեսել");
        }
Esempio n. 4
0
        private void Pregunta34()
        {
            p1 = "INCORRECTO";
            BorrarTemporales();

            Word.Shapes       shapes  = docAlumno.Shapes;       //4
            Word.InlineShapes iShapes = docAlumno.InlineShapes; //1

            if (shapes.Count == 4 && iShapes.Count == 1)
            {
                string tipo  = iShapes[1].Type.ToString(); //wdInlineShapePicture
                var    rango = iShapes[1].Range;
                int    start = rango.Start;                //528
                int    end   = rango.End;                  //529

                //name=\"Eleven.jpg\"/><pic

                CerrarWords();
                string ruta_ResTem = Application.StartupPath + @"\Documentos\Temp\Ejercicio\";
                Task   task1       = Task.Factory.StartNew(() => DescomprimirZipWord());
                ComprobarDescompresion();

                string cadenaAchequear = "name=\"Eleven.jpg\"/><pic";

                String[] contenidoDeArchivo = File.ReadAllLines(Path.Combine(ruta_ResTem, @"word\document.xml"));

                if (contenidoDeArchivo[1].Contains(cadenaAchequear) &&
                    tipo.Equals("wdInlineShapePicture") &&
                    start == 528 && end == 529)
                {
                    p1 = "CORRECTO";
                }
                else
                {
                    p1 = "INCORRECTO";
                }
            }

            CerrarWords();
            GuardarPuntaje();

            BorrarPreguntasTemporales();
        }
Esempio n. 5
0
        private void Pregunta20()
        {
            p1 = "INCORRECTO";

            string cadenaAchequear = "anticonceptivas. \n  \nDepósitos";//anticonceptivas. \n  \nDepósitos

            string textPdf = obtenerTextoDePdf();

            Word.Shapes temp = docAlumno.Shapes;
            if (temp.Count == 5 && textPdf.Contains(cadenaAchequear))
            {
                Word.Shape shape            = temp[5];
                string     cadenaAchequear1 = "5-Point Star";
                string     cadenaAchequear2 = "Depósitos Biliares";

                string texto = shape.TextFrame.TextRange.Text;                                 //Depósitos Biliares

                if (shape.Name.Contains(cadenaAchequear1) && texto.Contains(cadenaAchequear2)) //5-Point Star 7 //5-Point Star 8
                {
                    float size = shape.TextFrame.TextRange.Font.Size;                          //9
                    float top  = shape.Top;                                                    //-999997 --abajo
                    float left = shape.Left;                                                   //-999998 --izquierda

                    if (size == 9 && top == -999997 && left == -999998)
                    {
                        p1 = "CORRECTO";
                    }
                }
                ;
            }

            CerrarWords();
            GuardarPuntaje();

            BorrarPreguntasTemporales();
        }
 /// <summary>
 /// Найти таблицы в фигуре
 /// </summary>
 public static IEnumerable <Table> GetTablesFromShapes(Shapes shapes) =>
 shapes.ToEnumerable().
 Where(shape => shape.AutoShapeType != MsoAutoShapeType.msoShapeMixed).
 SelectMany(shape => shape.TextFrame.ContainingRange.Tables.ToEnumerable());
        public void findMathTypeEquations()
        {
            Word.Shapes objects = docOpen.Shapes;
            foreach (Word.Shape shape in objects)
            {
                Console.WriteLine(shape.TextFrame);
            }

            int OMathsCount = myRange.OMaths.Count;

            Console.WriteLine(OMathsCount);
            Console.WriteLine("Bar max:");

            form.progressBar1.Maximum = OMathsCount;


            try
            {
                String     clipboard_memory = Clipboard.GetText();
                Word.Range endRange         = docOpen.Range(myRange.End - 1, myRange.End - 1);



                if (OMathsCount > 0)
                {
                    string final_eq_file_path_clear = this.inputFileDir + @"\EquationsFile.txt";
                    File.WriteAllText(final_eq_file_path_clear, String.Empty);

                    string temp_file_path = this.inputFileDir + @"\EquationTemporaryFile.txt";
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(temp_file_path))

                    {
                        int  offset = 1;
                        bool empty_eq_fl;
                        bool break_for_fl = false;
                        for (int i = 0; i < OMathsCount && offset <= myRange.OMaths.Count; i++)
                        {
                            empty_eq_fl = true;
                            Thread staThread = new Thread(
                                delegate()
                            {
                                Word.OMath currentEquation = myRange.OMaths[offset];
                                while (empty_eq_fl)
                                {
                                    try
                                    {
                                        currentEquation.Range.Select();

                                        currentEquation.Range.TextRetrievalMode.IncludeHiddenText = true;
                                        currentEquation.Range.TextRetrievalMode.IncludeFieldCodes = true;

                                        currentEquation.Range.Application.Selection.Copy();
                                        empty_eq_fl = false;
                                    }
                                    catch (System.Runtime.InteropServices.COMException ex)
                                    {
                                        if (offset <= myRange.OMaths.Count - 1)
                                        {
                                            offset++;
                                            currentEquation = myRange.OMaths[offset];
                                        }
                                        else
                                        {
                                            break_for_fl = true;
                                            break;
                                        }
                                    }
                                }
                                if (!break_for_fl)
                                {
                                    //currentEquation.Range.Application.Selection.Range.HighlightColorIndex = Word.WdColorIndex.wdYellow;
                                    String tekst     = Clipboard.GetText();
                                    String new_tekst = "$";
                                    /////////////////////////////////////////////////////////////////////////////////////

                                    char[] tokens   = tekst.ToCharArray();
                                    string[] parsed = TranslateTokensToTex(tokens);
                                    for (int p = 0; p < parsed.Length; p++)
                                    {
                                        Console.Write(parsed[p] + "^.^");
                                    }
                                    Console.WriteLine("---------------------------------------------------");
                                    for (int p = 0; p < parsed.Length; p++)
                                    {
                                        parsed[p] = ParseToken(ref parsed, p);
                                    }
                                    for (int p = 0; p < parsed.Length; p++)
                                    {
                                        if (parsed[p] != @"")
                                        {
                                            new_tekst += parsed[p];
                                        }
                                    }
                                    new_tekst += "$";
                                    /////////////////////////////////////////////////////////////////////////////////////
                                    file.WriteLine(tekst);

                                    string final_eq_file_path = this.inputFileDir + @"\EquationsFile.txt";
                                    using (System.IO.StreamWriter file2 = File.AppendText(final_eq_file_path))
                                    {
                                        file2.WriteLine(new_tekst);
                                    }

                                    if (clipboard_memory.CompareTo("") != 0)
                                    {
                                        Clipboard.SetText(clipboard_memory);
                                    }
                                    else
                                    {
                                        Clipboard.Clear();
                                    }

                                    //removing text from start to end

                                    int start = currentEquation.Range.Start;
                                    int end   = currentEquation.Range.End;
                                    currentEquation.Range.Application.Selection.Delete();

                                    if (new_tekst != "$$")
                                    {
                                        currentEquation.Range.InsertBefore(new_tekst);
                                    }
                                }
                            });

                            staThread.SetApartmentState(ApartmentState.STA);
                            staThread.Start();
                            staThread.Join();
                            form.progressBar1.PerformStep();
                            if (break_for_fl)
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No equations found.");
                }

                if (form.checkBox2.Checked == false)
                {
                    docOpen.SaveAs(second_file_path);
                }
                else
                {
                    docOpen.SaveAs();
                }
                docOpen.Close();
                app.Quit();

                string final_message = "Process Completed\n\nFile \"EquationsFile.txt\" containing all converted equations and needed packages.\n";
                if (packages.Count != 0)
                {
                    final_message += "Additional packages required for further use:\n";
                    string final_eq_file_path = this.inputFileDir + @"\EquationsFile.txt";
                    using (System.IO.StreamWriter file2 = File.AppendText(final_eq_file_path))
                    {
                        file2.WriteLine("\n" + @"\usepackage{amsmath}");
                        foreach (string pack in packages)
                        {
                            final_message += pack;
                            final_message += "\n";
                            file2.WriteLine(pack);
                        }
                    }
                }
                MessageBox.Show(final_message);
            }
            catch (Exception)
            {
                throw;
            }
        }