Ejemplo n.º 1
0
        private void configDlg_FormClosing(object sender, FormClosingEventArgs e)
        {
            foreach (Control control in this.tabPage2.Controls)
            {
                if (control.GetType() == this.txtPassword.GetType())
                {
                    if ((control == this.txtWidth) && (control.Text == string.Empty))
                    {
                        control.Text = "700";
                    }
                    if ((control == this.txtHeight) && (control.Text == string.Empty))
                    {
                        control.Text = "500";
                    }
                }
            }
            this.cfg.password   = this.txtPassword.Text;
            this.cfg.pic_width  = System.Convert.ToInt32(this.txtWidth.Text);
            this.cfg.pic_height = System.Convert.ToInt32(this.txtHeight.Text);
            this.cfg.isMerger   = this.cbIsMerger.Checked ? 1 : 0;
            this.edt(this.cfg);
            ini_config _config = new ini_config("config.ini");

            _config.write_ini("isMerger", this.cfg.isMerger.ToString(), "App");
            _config.write_ini("pwd", this.cfg.password, "App");
            if (this.old_type != this.new_type)
            {
                new ini_config("config.ini").write_ini("formtype", this.new_type.ToString(), "App");
                MessageBox.Show("界面修改将在下次软件重启后生效", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Ejemplo n.º 2
0
        private static void RunForm()
        {
            bool  flag;
            Mutex mutex = new Mutex(false, "XJ_PDF_CONVERT", out flag);

            if (!flag)
            {
                MessageBox.Show("本程序已经在运行了", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                string str = new ini_config("config.ini").read_ini("formtype", "App");
                if (((str == string.Empty) || (str == "0")) || (str != "1"))
                {
                    Application.Run(new mainDlg());
                }
                else
                {
                    Application.Run(new mainDlg_A());
                }
                try
                {
                    mutex.ReleaseMutex();
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 3
0
        public static int GetFilePage(string filePath)
        {
            int    count     = 0;
            string extension = Path.GetExtension(filePath);
            string fileName  = Path.GetFileName(filePath);
            string password  = new ini_config("config.ini").read_ini("pwd", "App");

            switch (extension.ToLower())
            {
            case ".pdf":
                try
                {
                    Aspose.Pdf.Document document = new Aspose.Pdf.Document(filePath, password);
                    count = document.Pages.Count;
                }
                catch (Aspose.Pdf.Exceptions.InvalidPasswordException exception)
                {
                    throw new Exception(exception.Message);
                }
                return(count);

            case ".doc":
            {
                Aspose.Words.Document document2 = new Aspose.Words.Document(filePath);
                return(document2.PageCount);
            }

            case ".docx":
            {
                Aspose.Words.Document document3 = new Aspose.Words.Document(filePath);
                return(document3.PageCount);
            }

            case ".xls":
            {
                Workbook workbook = new Workbook(filePath);
                return(workbook.Worksheets.Count);
            }

            case ".xlsx":
            {
                Workbook workbook2 = new Workbook(filePath);
                return(workbook2.Worksheets.Count);
            }

            case ".ppt":
            {
                Presentation presentation = new Presentation(filePath);
                return(presentation.Slides.Count);
            }

            case ".pptx":
            {
                Presentation presentation2 = new Presentation(filePath);
                return(presentation2.Slides.Count);
            }
            }
            return(1);
        }
Ejemplo n.º 4
0
        private void btnActive_MouseClick(object sender, MouseEventArgs e)
        {
            //写入注册码失败! 把config.ini改为只读,然后点击注册会产生这种错误。改进的方法是:再次注册,或者把注册码直接写入config.ini的“RegCode=”后面。先把config.ini用Word打开,再向config.ini写任何内容都不可以(这种情况是只读的)。
            //郑侃炜:你查下文档,微软有推荐配置文件的写出目录,往其目录写的话是没有权限问题的
            //测试用例:
            //   1、Administrator安装,普通用户User1使用
            //   2、普通用户User1安装,Administrator使用
            //   3、普通用户User1安装,普通用户User2使用
            //   4、找一个写入config.ini的地方(比如主界面的“设置输出目录”),设置一下,让config.ini会变化,再在此处点击"开始激活"
            //可能的Bug
            //Administrator安装,普通用户User1使用,正常
            //普通用户User1安装,Administrator使用,输入注册码后,其它所有用户都可使用
            //普通用户User1安装,普通用户User2使用,不输入注册码,为免费版
            //普通用户User2安装,普通用户User1使用,不输入注册码,为正式版,奇怪吧(这里要测试是为什么)
            //Win10 64位安装完成后,目录是只读的,所以config.ini也就不可以修改了(但其它系统就不成问题)。在Win10 64位的操作系统里面,如果文件夹是只读的,里面的文件也不可以修改。Win10的普通用户安装的软件,对于config.ini等任何文件没有写入权限(可以右击文件---属性---安全---编辑,增加当前用户后,再所"写入"打上勾)

            //想重新变回试用码,只要把Release目录下面的config.ini里面的RegCode后面的数字清空就行了,KongMengyuan,2015-11-06
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                //测试人员用,生成注册码,内部人员使用
                string regCode = new reg().get_reg_code("710519949"); //后面是测试用的本机序号
                Console.WriteLine(regCode);

                this.btnActive.BackgroundImage = Properties.Resources.RegDlg_btn_dialog_ac_03;
                if (new reg().get_reg_code() == this.txtRegCode.OutText)
                {
                    ini_config ini = new ini_config("config.ini"); //这句话一定要加,如果不加的话,所有操作系统都可以写入,但是Win10 64位普通用户就不可以,保存时说文件只读(从外部修改也是只读的),加上这句话Win10也可以读写了,2015-12-25,KongMengyuan增加
                    if (new reg().write_reg_code(this.txtRegCode.OutText))
                    {
                        //MessageBox.Show("写入注册码成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MessageBox.Show(rm.GetString("RegisteredSuccessfully"), rm.GetString("Tips"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //发送请求信息
                        Version.Post("http://all.jsocr.com/", Version.GetParamName("Data"), Program.appProgName, Version.GetParamName("Version"), new reg().get_reg_code(), "注册窗口", "激活成功" + this.txtRegCode.OutText);
                    }
                    else
                    {
                        //MessageBox.Show("写入注册码失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        MessageBox.Show(rm.GetString("RegistrationFailed"), rm.GetString("Tips"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //发送请求信息
                        Version.Post("http://all.jsocr.com/", Version.GetParamName("Data"), Program.appProgName, Version.GetParamName("Version"), new reg().get_reg_code(), "注册窗口", "激活失败" + this.txtRegCode.OutText);
                    }
                }
                else
                {
                    //MessageBox.Show("您输入的注册码不正确,如果您无注册码,请及时购买!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(rm.GetString("msg13"), rm.GetString("Tips"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Process.Start("iexplore.exe", "http://www.xjpdf.com/software/pdfConvert/buy/?version=" + Version.version + "&machine=" + new reg().get_machine_code()); //KongMengyuan增加,2015-11-04,常规作法是转到购买页面
                    //KongMengyuan修改,郑总提出来:在点击右上角的“购买”时打开页面会卡一下,而点击右下角的"在线教程"就不卡,改变写法(提取机器码浪费了多余的时间)
                    Process.Start("iexplore.exe", "http://www.xjpdf.com/software/pdfConvert/buy/?version=" + httpVersion + "&machine=" + httpMachineCode);
                    return;
                }

                this.DialogResult   = DialogResult.Abort;
                Program.dialogClose = true; //KongMengyuan增加,2015-11-11,判断注册页面窗体是直接关闭还是激活后关闭
                this.Close();
            }
        }
Ejemplo n.º 5
0
        static Encrypt()
        {
            string decryptString = new ini_config("config.ini").read_ini("Data", "App");

            if (decryptString == string.Empty)
            {
                APPTITLE = "迅捷PDF万能转换器";
            }
            else
            {
                APPTITLE = DecryptDES(decryptString);
            }
        }
Ejemplo n.º 6
0
        private void registerCodeEnter()
        {
            //测试人员用,生成注册码,内部人员使用
            string regCode = new reg().get_reg_code("200035742"); //后面是测试用的本机序号

            Console.WriteLine(regCode);

            this.pbActive.BackgroundImage = Image.FromFile(spath01 + "Active_03.png");
            if (new reg().get_reg_code() == this.txtRegCode.Text)
            {
                ini_config ini = new ini_config("config.ini"); //这句话一定要加,如果不加的话,所有操作系统都可以写入,但是Win10 64位普通用户就不可以,保存时说文件只读(从外部修改也是只读的),加上这句话Win10也可以读写了,2015-12-25,KongMengyuan增加
                if (new reg().write_reg_code(this.txtRegCode.Text))
                {
                    string msg01 = Program.Language_Load(Program.iniLanguage, this.Name, "MSG_01"); //提示
                    string msg02 = Program.Language_Load(Program.iniLanguage, this.Name, "MSG_02"); //写入注册码成功!
                    MessageBox.Show(msg02, msg01, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //发送请求信息
                    Version.Post("http://all.jsocr.com/", Version.GetParamName("Data"), Program.appProgName, Version.GetParamName("Version"), new reg().get_reg_code(), "注册窗口", "激活成功" + this.txtRegCode.Text);
                }
                else
                {
                    //MessageBox.Show("写入注册码失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    string msg01 = Program.Language_Load(Program.iniLanguage, this.Name, "MSG_01"); //提示
                    string msg02 = Program.Language_Load(Program.iniLanguage, this.Name, "MSG_03"); //写入注册码失败!
                    MessageBox.Show(msg02, msg01, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //发送请求信息
                    Version.Post("http://all.jsocr.com/", Version.GetParamName("Data"), Program.appProgName, Version.GetParamName("Version"), new reg().get_reg_code(), "注册窗口", "激活失败" + this.txtRegCode.Text);
                }
            }
            else
            {
                string msg01 = Program.Language_Load(Program.iniLanguage, this.Name, "MSG_01"); //提示
                string msg02 = Program.Language_Load(Program.iniLanguage, this.Name, "MSG_04"); //您输入的注册码不正确,如果您无注册码,请及时购买!
                MessageBox.Show(msg02, msg01, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                try
                {
                    Process.Start("http://www.xjpdf.com/software/pdfConvert/buy/?version=" + Program.httpVersion + "&machine=" + Program.httpMachineCode);
                }
                catch
                {
                    Process.Start("iexplore.exe", "http://www.xjpdf.com/software/pdfConvert/buy/?version=" + Program.httpVersion + "&machine=" + Program.httpMachineCode);
                }
                return;
            }

            this.DialogResult   = DialogResult.Abort;
            Program.dialogClose = true; //KongMengyuan增加,2015-11-11,判断注册页面窗体是直接关闭还是激活后关闭
            this.Close();
        }
Ejemplo n.º 7
0
        static void RunForm()
        {
            //同时运行一个实例,实现此功能,对于VB.NET是非常容易的,只要指定一个属性即可,但是C#实现起来,就稍微繁琐了。C#实现单实例运行的方法,也有多种,比如利用 Process 查找进程的方式,利用 API findwindow 查找窗体的方式,还有就是利用 Mutex 原子操作,上面几种方法中,综合考虑利用 Mutex 的方式是较好的选择。
            bool mutex_succ = false;
            // Mutex mutex = new Mutex(false, "XJ_PDF_CONVERT2", out mutex_succ);
            Mutex mutex = new Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out mutex_succ);

            if (!mutex_succ)
            {
                ////MessageBox.Show("本程序已经在运行了", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ////string iniLanguage = ini.read_ini("language");
                //string sTip = Language_Load(iniLanguage, "Program.cs", "MSG_01"); //提示
                //string sOld = Language_Load(iniLanguage, "Program.cs", "MSG_02"); //本程序已经在运行了
                //MessageBox.Show(sOld, sTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //// return;
                Environment.Exit(1);
            }

            string form_type = new ini_config("config.ini").read_ini("formtype");

            //Application.Run(new MainInfoOld()); //没有frmSplash窗体,直接运行MainInfo主窗体(这种情况如果在主窗体启动时有检查CPU序列号等硬件就会变得比较慢,所以把检测CPU序列号放在frmSplash窗体里面)

            //加载Splash窗体方法1,在frmSplash窗体里面运行MainInfo窗体.两种方法都不可以使用gif动画,只有在frmSplash里面使用线程加载MainInfo窗体才可以使用动画,但是那样如果MainInfo再使用线程就会引起线程冲突)
            Application.Run(new frmSplash());

            //不采用下面的方法原因:下面的常规加载方法在frmSplash和MainInfo主窗体之间会有一个空闲等待,而MainInfo放在frmSplash里面就不存在这个问题了(后者界面就比较流畅)
            ////加载Splash窗体方法2,在Program里面运行MainInfo窗体.两种方法都不可以使用gif动画,只有在frmSplash里面使用线程加载MainInfo窗体才可以使用动画,但是那样如果MainInfo再使用线程就会引起线程冲突)
            //frmSplash sp = new frmSplash(); //启动窗体
            //sp.Show(); //显示启动窗体
            //context = new ApplicationContext();
            //context.Tag = sp;
            //Application.Idle += new EventHandler(Application_Idle); //注册程序运行空闲去执行主程序窗体相应初始化代码
            //Application.Run(context);

            try
            {
                mutex.ReleaseMutex();
            }
            catch { }
        }
Ejemplo n.º 8
0
        public static string Refresh()
        {
            string tmp         = new ini_config("config.ini").read_ini("Data");
            string iniLanguage = new ini_config("config.ini").read_ini("language");

            switch (iniLanguage.ToLower())
            {
            case "zh-cn":
                tmp = new ini_config("config.ini").read_ini("Data");
                break;

            default:
                tmp = new ini_config("config.ini").read_ini("EData");
                break;
            }
            if (tmp == string.Empty)
            {
                APPTITLE = Program.appProgName;//"PDF Converter";
                return(APPTITLE);
            }

            return(APPTITLE = DecryptDES(tmp));
        }
Ejemplo n.º 9
0
        static Encrypt()
        {
            string tmp = new ini_config("config.ini").read_ini("Data");

            //string iniLanguage = new ini_config("config.ini").read_ini("language");
            //switch (iniLanguage.ToLower())
            switch (Program.iniLanguage.ToLower())
            {
            case "zh-cn":
                tmp = new ini_config("config.ini").read_ini("Data");
                break;

            default:
                tmp = new ini_config("config.ini").read_ini("EData");
                break;
            }
            if (tmp == string.Empty)
            {
                APPTITLE = Program.appProgName;
                return;
            }

            APPTITLE = DecryptDES(tmp);
        }
Ejemplo n.º 10
0
        private void dl_config()
        {
            AddText     method = new AddText(this.add_text);
            AddListItem item   = new AddListItem(this.add_list_item);

            base.Invoke(method, new object[] { "检测是否有新版本..." });
            base.Invoke(method, new object[] { "读取远程配置文件..." });
            ini_config _config = new ini_config("config.ini");

            try
            {
                bool   flag   = false;
                Thread thread = new Thread(new ThreadStart(this.GetAddress))
                {
                    IsBackground = true
                };
                thread.Start();
                thread.Join();
                if (!string.IsNullOrEmpty(this.text))
                {
                    if (this.text.IndexOf("#END#") == -1)
                    {
                        throw new Exception();
                    }
                    string[] strArray = this.text.Split(Environment.NewLine.ToCharArray());
                    string   str      = string.Empty;
                    string   str2     = _config.read_ini("VeryPdf", "App");
                    string   str3     = string.Empty;
                    string   str4     = "";
                    for (int i = 0; i < (strArray.Length - 1); i++)
                    {
                        if (strArray[i] != string.Empty)
                        {
                            if (strArray[i].Contains("#END#"))
                            {
                                break;
                            }
                            if (strArray[i].Contains("version"))
                            {
                                str = strArray[i].Split(new char[] { ',' })[1];
                            }
                            else if (strArray[i].Contains("veryPdf"))
                            {
                                str3 = strArray[i].Split(new char[] { ',' })[1];
                            }
                            else
                            {
                                string[] strArray2 = strArray[i].Split(new char[] { ',' });
                                if (!(PDF_Convert.Version.dic_ver.TryGetValue(strArray2[0], out str4) && (System.Convert.ToInt32(PDF_Convert.Version.dic_ver[strArray2[0]].Replace(".", "")) >= System.Convert.ToInt32(strArray2[1].Replace(".", "")))))
                                {
                                    this.dl_lst.Add(new detail_list(strArray2[2], System.Convert.ToInt32(strArray2[3])));
                                    base.Invoke(item);
                                    flag = true;
                                }
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(str3))
                    {
                        try
                        {
                            if (string.IsNullOrEmpty(str2) || (System.Convert.ToDouble(str2) < System.Convert.ToDouble(str3)))
                            {
                                this.dl_lst.Add(new detail_list("VeryPdf.rar", 0x4f832a));
                                base.Invoke(item);
                                flag = true;
                            }
                        }
                        catch
                        {
                        }
                    }
                    if (flag)
                    {
                        base.Invoke(new _Show(this.show_this_window));
                        base.Invoke(method, new object[] { "开始下载新文件..." });
                        Thread thread2 = new Thread(new ThreadStart(this.dl_file))
                        {
                            IsBackground = true
                        };
                        thread2.Start();
                        thread2.Join();
                        ProcessStartInfo startInfo = new ProcessStartInfo(Application.StartupPath + @"\PDF Update.exe")
                        {
                            Arguments = "Madoka " + Process.GetCurrentProcess().Id.ToString()
                        };
                        foreach (detail_list _list in this.dl_lst)
                        {
                            startInfo.Arguments = startInfo.Arguments + string.Format(" \"{0}\"", _list.file_name);
                        }
                        Process.Start(startInfo);
                        base.Invoke(method, new object[] { "下载新文件成功,程序即将退出以便进行更新" });
                        Thread.Sleep(0x3e8);
                        _config.write_ini("Version", str, "App");
                        _config.write_ini("VeryPdf", str3, "App");
                    }
                    base.Invoke(new _Exit(this.Close));
                }
            }
            catch
            {
                base.Invoke(new _Exit(this.Close));
            }
        }
Ejemplo n.º 11
0
        private void pdf_to_epub(save_progress progress, System.Windows.Forms.Form dlg, int c)
        {
            try
            {
                Pdf          pdf;
                ListViewItem item;
                string       text;
                Aspose.Pdf.Generator.Section section;
                Aspose.Pdf.Generator.Image   image;
                string str4;
                string extension;
                if (progress != null)
                {
                    dlg.Invoke(progress, new object[] { 0 });
                }
                string str = new ini_config("config.ini").read_ini("isMerger", "App");
                ListView.ListViewItemCollection items = null;
                int num = 0;
                if (dlg.Name == "mainDlg")
                {
                    items = ((mainDlg)dlg).lstFile.Items;
                    num   = 0;
                }
                else
                {
                    items = ((mainDlg_A)dlg).lstFile.Items;
                    num   = 1;
                }
                if (str == "1")
                {
                    if (c == (items.Count - 1))
                    {
                        pdf = new Pdf();
                        for (int i = 0; i < items.Count; i++)
                        {
                            item    = items[i];
                            text    = item.SubItems[num].Text;
                            section = pdf.Sections.Add();
                            image   = new Aspose.Pdf.Generator.Image(section);
                            section.Paragraphs.Add(image);
                            image.ImageInfo.File = text;
                            extension            = Path.GetExtension(text);
                            if (extension == null)
                            {
                                goto Label_01C8;
                            }
                            if (!(extension == ".jpg"))
                            {
                                if (extension == ".gif")
                                {
                                    goto Label_0188;
                                }
                                if (extension == ".bmp")
                                {
                                    goto Label_0198;
                                }
                                if (extension == ".png")
                                {
                                    goto Label_01A8;
                                }
                                if (extension == ".tiff")
                                {
                                    goto Label_01B8;
                                }
                                goto Label_01C8;
                            }
                            image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
                            continue;
Label_0188:
                            image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Gif;
                            continue;
Label_0198:
                            image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp;
                            continue;
Label_01A8:
                            image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;
                            continue;
Label_01B8:
                            image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;
                            continue;
Label_01C8:
                            image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
                        }
                        str4 = this.global_config.target_dic + Path.GetFileNameWithoutExtension(this.file_path) + this.get_suffix();
                        pdf.Save(str4);
                    }
                    goto Label_0366;
                }
                pdf     = new Pdf();
                item    = items[c];
                text    = item.SubItems[num].Text;
                section = pdf.Sections.Add();
                image   = new Aspose.Pdf.Generator.Image(section);
                section.Paragraphs.Add(image);
                image.ImageInfo.File = text;
                extension            = Path.GetExtension(text);
                if (extension == null)
                {
                    goto Label_0329;
                }
                if (!(extension == ".jpg"))
                {
                    if (extension == ".gif")
                    {
                        goto Label_02E9;
                    }
                    if (extension == ".bmp")
                    {
                        goto Label_02F9;
                    }
                    if (extension == ".png")
                    {
                        goto Label_0309;
                    }
                    if (extension == ".tiff")
                    {
                        goto Label_0319;
                    }
                    goto Label_0329;
                }
                image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
                goto Label_0339;
Label_02E9:
                image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Gif;
                goto Label_0339;
Label_02F9:
                image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp;
                goto Label_0339;
Label_0309:
                image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;
                goto Label_0339;
Label_0319:
                image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;
                goto Label_0339;
Label_0329:
                image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
Label_0339:
                str4 = this.global_config.target_dic + Path.GetFileNameWithoutExtension(this.file_path) + this.get_suffix();
                pdf.Save(str4);
Label_0366:
                if (progress != null)
                {
                    dlg.Invoke(progress, new object[] { 100 });
                }
            }
            catch (Exception)
            {
            }
        }