Esempio n. 1
0
        private void btn_bulkEdit_Click(object sender, RoutedEventArgs e)
        {
            Corel.Interop.VGCore.ShapeRange sel = corelApp.ActiveDocument.SelectionRange;
            LatexEquation eq = ShapeTags.getLatexEquation(sel.FirstShape);

            if (eq != null)
            {
                m_sdialog.init(eq, "Bulk-edit style");
                m_sdialog.ShowDialog();
                if (m_sdialog.Result == System.Windows.Forms.DialogResult.OK)
                {
                    foreach (Corel.Interop.VGCore.Shape s in sel)
                    {
                        eq = ShapeTags.getLatexEquation(s);
                        m_sdialog.LatexEquation = eq;
                        if (m_sdialog.generateEquation())
                        {
                            Corel.Interop.VGCore.Shape latexObj = m_sdialog.LatexEquation.m_shape;
                            if (latexObj != null)
                            {
                                latexObj.TransformationMatrix = s.TransformationMatrix;
                                s.Delete();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public bool generateEquation()
        {
            // Check paths
            SettingsManager mgr = SettingsManager.getCurrent();

            // Check font size
            string fontSize = comboBoxFontSize.Text;
            float  size     = 12;

            try
            {
                size = Convert.ToSingle(fontSize);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Font size exception: \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            // Check Dpi
            float[] systemDPI = AddinUtilities.getSystemDPI();
            float   dpiValue  = systemDPI[0];

            mgr.SettingsData.fontSize   = comboBoxFontSize.Text;
            mgr.SettingsData.font       = comboBoxFont.Text;
            mgr.SettingsData.fontSeries = comboBoxSeries.Text;
            mgr.SettingsData.fontShape  = comboBoxShape.Text;
            mgr.SettingsData.mathFont   = comboBoxMathFont.Text;
            mgr.SettingsData.textColor  = m_textColor;
            mgr.saveSettings();

            m_latexEquation = new LatexEquation(m_latexEquation.m_code, size, m_textColor, (LatexFont)comboBoxFont.SelectedItem,
                                                (LatexFontSeries)comboBoxSeries.SelectedItem,
                                                (LatexFontShape)comboBoxShape.SelectedItem,
                                                (LatexMathFont)comboBoxMathFont.SelectedItem);

            m_finishedSuccessfully = AddinUtilities.createLatexPdf(m_latexEquation);

            if (m_finishedSuccessfully)
            {
                string imageFile = Path.Combine(AddinUtilities.getAppDataLocation(), "teximport.pdf");
                Corel.Interop.VGCore.StructImportOptions impopt = new Corel.Interop.VGCore.StructImportOptions();
                impopt.MaintainLayers = true;
                Corel.Interop.VGCore.ImportFilter impflt = DockerUI.Current.CorelApp.ActiveLayer.ImportEx(imageFile, Corel.Interop.VGCore.cdrFilter.cdrPDF, impopt);
                impflt.Finish();
                m_latexEquation.m_shape = DockerUI.Current.CorelApp.ActiveShape;
                ShapeTags.setShapeTags(m_latexEquation);
            }

            return(m_finishedSuccessfully);
        }
Esempio n. 3
0
        public bool editLatexObject(Corel.Interop.VGCore.Shape s)
        {
            LatexEquation eq = ShapeTags.getLatexEquation(s);

            if (eq != null)
            {
                m_dialog.init(eq, "Edit latex object");

                m_dialog.ShowDialog();
                if (m_dialog.Result == System.Windows.Forms.DialogResult.OK)
                {
                    Corel.Interop.VGCore.Shape latexObj = m_dialog.LatexEquation.m_shape;
                    if (latexObj != null)
                    {
                        latexObj.TransformationMatrix = s.TransformationMatrix;
                        s.Delete();
                    }
                }
                return(true);
            }
            return(false);
        }