Example #1
0
        private void confirm_Click(object sender, EventArgs e)
        {
            UofAddinLib.ConfigManager cfg = new UofAddinLib.ConfigManager(System.IO.Path.GetDirectoryName(typeof(MainDialog).Assembly.Location) + @"\conf\config.xml");

            cfg.LoadConfig();

            // transitional
            if (rBtn.Checked)
            {
                cfg.IsUofToTransitioanlOOX = true;
                cfg.IsUofToStrictOOX       = false;
                cfg.SaveConfig();
            }
            else // strict
            {
                cfg.IsUofToStrictOOX       = true;
                cfg.IsUofToTransitioanlOOX = false;
                cfg.SaveConfig();
            }
            this.Close();
        }
        private static void OpenFileByOffice(string OpenFileType, string FileNameToOpen)
        {
            string procStartInfoArguments = "\"" + FileNameToOpen + "\"";

            UofAddinLib.ConfigManager cfg = new UofAddinLib.ConfigManager(System.IO.Path.GetDirectoryName(typeof(MainDialog).Assembly.Location) + @"\conf\config.xml");
            cfg.LoadConfig();

            //try
            //{
            switch (OpenFileType.ToLower())
            {
            case "docx":
            // case "vnd.uof.text":
            case "uot":
            {
                //  System.Windows.Forms.MessageBox.Show("im here");

                string tmpFile   = Path.GetTempFileName();
                string tmpResult = tmpFile.Substring(0, tmpFile.LastIndexOf(".")) + ".docx";

                //System.Windows.Forms.MessageBox.Show("tmpFile=" + tmpResult);
                if (cfg.IsUofToTransitioanlOOX)
                {
                    Act.UofTranslator.UofTranslatorLib.IUOFTranslator trans = new Act.UofTranslator.UofTranslatorLib.WordTranslator();
                    trans.UofToOox(FileNameToOpen, tmpResult);
                }
                else
                {
                    Act.UofTranslator.UofTranslatorStrictLib.IUOFTranslator trans = new Act.UofTranslator.UofTranslatorStrictLib.WordTranslator();
                    trans.UofToOox(FileNameToOpen, tmpResult);
                }
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.EnableRaisingEvents = false;
                proc.StartInfo.FileName  = "WINWORD";
                // proc.StartInfo.FileName = procStartInfoArguments;
                proc.StartInfo.Arguments = "\"" + tmpResult + "\"";
                proc.Start();
                //  System.Diagnostics.Process.Start(typeof(UofTranslatorShell.UofTranslatorShellOperation).Assembly.Location, "\"" + FileNameToOpen + "\"");

                //OpenByWord(FileNameToOpen);

                break;
            }

            case "xlsx":
            // case "vnd.uof.spreadsheet":
            case "uos":
            {
                string tmpFile   = Path.GetTempFileName();
                string tmpResult = tmpFile.Substring(0, tmpFile.LastIndexOf(".")) + ".xlsx";

                // System.Windows.Forms.MessageBox.Show("tmpFile="+tmpResult);
                System.Diagnostics.Process proc2 = new System.Diagnostics.Process();
                proc2.EnableRaisingEvents = false;
                proc2.StartInfo.FileName  = "EXCEL";

                if (cfg.IsUofToTransitioanlOOX)
                {
                    Act.UofTranslator.UofTranslatorLib.IUOFTranslator trans = new Act.UofTranslator.UofTranslatorLib.SpreadsheetTranslator();
                    trans.UofToOox(FileNameToOpen, tmpResult);
                }
                else
                {
                    Act.UofTranslator.UofTranslatorStrictLib.IUOFTranslator trans = new Act.UofTranslator.UofTranslatorStrictLib.SpreadsheetTranslator();
                    trans.UofToOox(FileNameToOpen, tmpResult);
                }

                proc2.StartInfo.Arguments = "\"" + tmpResult + "\"";
                //proc2.StartInfo.Arguments = procStartInfoArguments;
                proc2.Start();
                break;
            }

            case "pptx":
            // case "vnd.uof.presentation":
            case "uop":
            {
                System.Diagnostics.Process proc3 = new System.Diagnostics.Process();
                proc3.EnableRaisingEvents = false;
                proc3.StartInfo.FileName  = "POWERPNT";
                string tmpFile   = Path.GetTempFileName();
                string tmpResult = tmpFile.Substring(0, tmpFile.LastIndexOf(".")) + ".pptx";

                if (cfg.IsUofToTransitioanlOOX)
                {
                    Act.UofTranslator.UofTranslatorLib.IUOFTranslator trans = new Act.UofTranslator.UofTranslatorLib.PresentationTranslator();
                    trans.UofToOox(FileNameToOpen, tmpResult);
                }
                else
                {
                    Act.UofTranslator.UofTranslatorStrictLib.IUOFTranslator trans = new Act.UofTranslator.UofTranslatorStrictLib.PresentationTranslator();
                    trans.UofToOox(FileNameToOpen, tmpResult);
                }
                //System.Windows.Forms.MessageBox.Show("tmpFile=" + tmpResult);

                proc3.StartInfo.Arguments = "\"" + tmpResult + "\"";
                proc3.Start();

                break;
            }

            default:
            {
                System.Windows.Forms.MessageBox.Show(OpenFileType);
                break;
            }
            }
        }