예제 #1
0
        /// <summary>
        /// Pack theme *.igtheme
        /// </summary>
        /// <param name="dir">Temporary folder path</param>
        /// <param name="des">Destination *.igtheme file</param>
        public static void PackTheme(string src, string des)
        {
            if (!Directory.Exists(src))
            {
                return;
            }

            src = (src + "\\").Replace("\\\\", "\\");
            Theme th = new Theme(src + "config.xml");

            //if file exist, rename & backup
            if (File.Exists(des))
            {
                File.Move(des, des + ".old");
            }

            try
            {
                using (ZipFile z = new ZipFile(des, Encoding.UTF8))
                {
                    z.AddDirectory(src, th.name);
                    z.Save();
                };

                frmMsg f = new frmMsg("ImageGlass theme", "ImageGlass theme has been successfully saved. \n\n" + des, FormMessageIcons.OK, "Close");
                f.ShowDialog();
            }
            catch (Exception ex)
            {
                frmMsg f = new frmMsg("ImageGlass theme", "Error: \n\n" + ex.Message, FormMessageIcons.Warning, "Close");
                f.ShowDialog();

                //if file exist, rename & backup
                if (File.Exists(des + ".old"))
                {
                    File.Move(des + ".old", des);
                }
            }

            if (File.Exists(des + ".old"))
            {
                File.Delete(des + ".old");
            }
        }
예제 #2
0
파일: Core.cs 프로젝트: d2phap/ImageGlass
        /// <summary>
        /// Pack theme *.igtheme
        /// </summary>
        /// <param name="dir">Temporary folder path</param>
        /// <param name="des">Destination *.igtheme file</param>
        public static void PackTheme(string src, string des)
        {
            if (!Directory.Exists(src))
            {
                return;
            }

            src = (src + "\\").Replace("\\\\", "\\");
            Theme th = new Theme(src + "config.xml");

            //if file exist, rename & backup
            if (File.Exists(des))
            {
                File.Move(des, des + ".old");
            }

            try
            {
                using (ZipFile z = new ZipFile(des, Encoding.UTF8))
                {
                    z.AddDirectory(src, th.name);
                    z.Save();
                };

                frmMsg f = new frmMsg("ImageGlass theme", "ImageGlass theme has been successfully saved. \n\n" + des, FormMessageIcons.OK, "Close");
                f.ShowDialog();
            }
            catch (Exception ex)
            {
                frmMsg f = new frmMsg("ImageGlass theme", "Error: \n\n" + ex.Message, FormMessageIcons.Warning, "Close");
                f.ShowDialog();

                //if file exist, rename & backup
                if (File.Exists(des + ".old"))
                {
                    File.Move(des + ".old", des);
                }
            }

            if (File.Exists(des + ".old"))
            {
                File.Delete(des + ".old");
            }
        }