Example #1
0
 public void SetPath(string gamepath)
 {
     this.gamepath = gamepath;
     picpath       = MyPath.Combine(gamepath, "pics");
     fieldpath     = MyPath.Combine(picpath, "field");
     picpath2      = MyPath.Combine(picpath, "thumbnail");
     luapath       = MyPath.Combine(gamepath, "script");
     ydkpath       = MyPath.Combine(gamepath, "deck");
     replaypath    = MyPath.Combine(gamepath, "replay");
 }
Example #2
0
        //字符串id
        public string GetImage(string id)
        {
            string img = MyPath.Combine(picpath, id + ".png");

            if (!File.Exists(img))
            {
                img = MyPath.Combine(picpath, id + ".jpg");
            }
            return(img);
        }
Example #3
0
        public void ExportData(string path, string zipname, string _cdbfile)
        {
            int i = 0;

            Card[] cards = cardlist;
            if (cards == null || cards.Length == 0)
            {
                return;
            }
            int     count   = cards.Length;
            YgoPath ygopath = new YgoPath(path);
            string  name    = Path.GetFileNameWithoutExtension(zipname);
            //数据库
            string cdbfile = zipname + ".cdb";
            //说明
            string readme = MyPath.Combine(path, name + ".txt");
            //新卡ydk
            string deckydk = ygopath.GetYdk(name);

            File.Delete(cdbfile);
            DataBase.Create(cdbfile);
            DataBase.CopyDB(cdbfile, false, cardlist);

            if (File.Exists(zipname))
            {
                File.Delete(zipname);
            }
            using (ZipStorer zips = ZipStorer.Create(zipname, ""))
            {
                zips.AddFile(cdbfile, Path.GetFileNameWithoutExtension(_cdbfile) + ".cdb", "");
                if (File.Exists(readme))
                {
                    zips.AddFile(readme, "readme_" + name + ".txt", "");
                }
                if (File.Exists(deckydk))
                {
                    zips.AddFile(deckydk, "deck/" + name + ".ydk", "");
                }
                foreach (Card c in cards)
                {
                    i++;
                    worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
                    string[] files = ygopath.GetCardfiles(c.id);
                    foreach (string file in files)
                    {
                        if (File.Exists(file))
                        {
                            zips.AddFile(file, file.Replace(path, ""), "");
                        }
                    }
                }
            }
            File.Delete(cdbfile);
        }
Example #4
0
        void Init()
        {
            //文件路径
            conflang = DEXConfig.GetLanguageFile(datapath);
            //游戏数据,MSE数据
            olddatacfg = datacfg = new DataConfig(DEXConfig.GetCardInfoFile(datapath));
            string confstring = MyPath.Combine(datapath, DEXConfig.FILE_STRINGS);

            if (File.Exists(confstring))
            {
                Dictionary <long, string> d = datacfg.dicSetnames;
                if (!d.ContainsKey(0))
                {
                    d.Add(0L, "Archetype");
                }
                foreach (string l in File.ReadAllLines(confstring))
                {
                    if (l.StartsWith("!setname"))
                    {
                        string[] sn = l.Split(new char[] { ' ' }, 3);
                        _ = long.TryParse(sn[1], System.Globalization.NumberStyles.HexNumber, null,
                                          out long sc);
                        if (!d.ContainsKey(sc))
                        {
                            d.Add(sc, sn[2]);
                        }
                    }
                }
            }
            //初始化YGOUtil的数据
            YGOUtil.SetConfig(datacfg);

            //代码提示
            string funtxt = MyPath.Combine(datapath, DEXConfig.FILE_FUNCTION);
            string conlua = MyPath.Combine(datapath, DEXConfig.FILE_CONSTANT);

            codecfg = new CodeConfig();
            //添加函数
            codecfg.AddFunction(funtxt);
            //添加指示物
            codecfg.AddStrings(confstring);
            //添加常量
            codecfg.AddConstant(conlua);
            codecfg.SetNames(datacfg.dicSetnames);
            //生成菜单
            codecfg.InitAutoMenus();
            history = new History(this);
            //读取历史记录
            history.ReadHistory(MyPath.Combine(datapath, DEXConfig.FILE_HISTORY));
            //加载多语言
            LanguageHelper.LoadFormLabels(conflang);
        }
Example #5
0
        /// <summary>
        /// 图片缓存
        /// </summary>
        /// <param name="img"></param>
        /// <param name="card"></param>
        /// <returns></returns>
        public string getImageCache(string img, Card card)
        {
            if (!cfg.reimage)
            {
                //不需要调整
                return(img);
            }
            bool isPendulum = card.IsType(CardType.TYPE_PENDULUM);

            if (isPendulum)
            {
                if (cfg.pwidth <= 0 && cfg.pheight <= 0)
                {
                    return(img);
                }
            }
            else
            {
                if (cfg.width <= 0 && cfg.height <= 0)
                {
                    return(img);
                }
            }
            string md5 = MyUtils.GetMD5HashFromFile(img);

            if (MyUtils.Md5isEmpty(md5) || cfg.imagecache == null)
            {
                //md5为空
                return(img);
            }
            string file = MyPath.Combine(cfg.imagecache, md5);

            if (!File.Exists(file))
            {
                //生成缓存
                Bitmap bmp = MyBitmap.readImage(img);
                //缩放
                if (isPendulum)
                {
                    bmp = MyBitmap.Zoom(bmp, cfg.pwidth, cfg.pheight);
                }
                else
                {
                    bmp = MyBitmap.Zoom(bmp, cfg.width, cfg.height);
                }
                //保存文件
                MyBitmap.SaveAsJPEG(bmp, file, 100);
            }
            return(file);
        }
Example #6
0
        public void init(string path)
        {
            Iscn2tw = false;

            //读取配置
            string tmp = MyPath.Combine(path, MyPath.getFileName(MSEConfig.TAG, MyConfig.readString(MyConfig.TAG_MSE)));

            if (!File.Exists(tmp))
            {
                tmp = MyPath.Combine(path, MyPath.getFileName(MSEConfig.TAG, FILE_CONFIG_NAME));
                if (!File.Exists(tmp))
                {
                    return;                    //如果默认的也不存在
                }
            }
            SetConfig(tmp, path);
        }
Example #7
0
        public static void CheckVersion(bool showNew)
        {
            string newver = CheckUpdate.GetNewVersion(MyConfig.ReadString(MyConfig.TAG_UPDATE_URL));

            if (newver == CheckUpdate.DEFAULT)
            {   //检查失败
                if (!showNew)
                {
                    return;
                }

                MyMsg.Error(LMSG.CheckUpdateFail);
                return;
            }

            if (CheckUpdate.CheckVersion(newver, Application.ProductVersion))
            {//有最新版本
                if (!MyMsg.Question(LMSG.HaveNewVersion))
                {
                    return;
                }
            }
            else
            {//现在就是最新版本
                if (!showNew)
                {
                    return;
                }

                if (!MyMsg.Question(LMSG.NowIsNewVersion))
                {
                    return;
                }
            }
            //下载文件
            if (CheckUpdate.DownLoad(
                    MyPath.Combine(Application.StartupPath, newver + ".zip")))
            {
                MyMsg.Show(LMSG.DownloadSucceed);
            }
            else
            {
                MyMsg.Show(LMSG.DownloadFail);
            }
        }
Example #8
0
        //removed thumbnail
        #region 转换图片
        public void ConvertImages(string imgpath, string gamepath, bool isreplace)
        {
            string picspath = MyPath.Combine(gamepath, "pics");

            //string thubpath = MyPath.Combine(picspath, "thumbnail");
            string[] files = Directory.GetFiles(imgpath);
            int      i     = 0;
            int      count = files.Length;

            foreach (string f in files)
            {
                if (this.isCancel)
                {
                    break;
                }

                i++;
                this.worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
                string ex    = Path.GetExtension(f).ToLower();
                string name  = Path.GetFileNameWithoutExtension(f);
                string jpg_b = MyPath.Combine(picspath, name + ".jpg");
                //string jpg_s = MyPath.Combine(thubpath, name + ".jpg");
                if (ex == ".jpg" || ex == ".png" || ex == ".bmp")
                {
                    if (File.Exists(f))
                    {
                        Bitmap bmp = new Bitmap(f);
                        //大图,如果替换,或者不存在
                        if (isreplace || !File.Exists(jpg_b))
                        {
                            MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, this.imgSet.W, this.imgSet.H),
                                                jpg_b, this.imgSet.quilty);
                        }
                        //小图,如果替换,或者不存在
                        //if (isreplace || !File.Exists(jpg_s))
                        //{
                        //	MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
                        //						jpg_s, imgSet.quilty);

                        //}
                    }
                }
            }
        }
Example #9
0
        //获取图片路径
        public static string GetCardImagePath(string picpath, Card c)
        {
            //密码,带0密码,卡名
            string jpg  = MyPath.Combine(picpath, c.id + ".jpg");
            string jpg2 = MyPath.Combine(picpath, c.idString + ".jpg");
            string jpg3 = MyPath.Combine(picpath, c.name + ".jpg");
            string png  = MyPath.Combine(picpath, c.id + ".png");
            string png2 = MyPath.Combine(picpath, c.idString + ".png");
            string png3 = MyPath.Combine(picpath, c.name + ".png");

            if (File.Exists(jpg))
            {
                return(jpg);
            }
            else if (File.Exists(jpg2))
            {
                return(jpg2);
            }
            else if (File.Exists(jpg3))
            {
                File.Copy(jpg3, jpg, true);
                if (File.Exists(jpg))
                {                //复制失败
                    return(jpg);
                }
            }
            else if (File.Exists(png))
            {
                return(png);
            }
            else if (File.Exists(png2))
            {
                return(png2);
            }
            else if (File.Exists(png3))
            {
                File.Copy(png3, png, true);
                if (File.Exists(png))
                {                //复制失败
                    return(png);
                }
            }
            return("");
        }
Example #10
0
        public Card[] ReadMSE(string mseset, bool repalceOld)
        {
            //解压所有文件
            using (ZipStorer zips = ZipStorer.Open(mseset, FileAccess.Read))
            {
                zips.EncodeUTF8 = true;
                List <ZipStorer.ZipFileEntry> files = zips.ReadCentralDir();
                int count = files.Count;
                int i     = 0;
                foreach (ZipStorer.ZipFileEntry file in files)
                {
                    this.worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
                    string savefilename = MyPath.Combine(this.mseHelper.ImagePath, file.FilenameInZip);
                    zips.ExtractFile(file, savefilename);
                }
            }
            string setfile = MyPath.Combine(this.mseHelper.ImagePath, "set");

            return(this.mseHelper.ReadCards(setfile, repalceOld));
        }
Example #11
0
 public bool Open(string file)
 {
     if (!string.IsNullOrEmpty(file))
     {
         if (!File.Exists(file))
         {
             FileStream fs = new FileStream(file, FileMode.Create);
             fs.Close();
         }
         nowFile = file;
         string cdb = MyPath.Combine(
             Path.GetDirectoryName(file), "../cards.cdb");
         SetCardDB(cdb);//后台加载卡片数据
         fctb.OpenFile(nowFile, new UTF8Encoding(false));
         oldtext = fctb.Text;
         SetTitle();
         return(true);
     }
     return(false);
 }
Example #12
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case MyConfig.WM_OPEN:    //处理消息
                string file = MyPath.Combine(Application.StartupPath, MyConfig.FILE_TEMP);
                if (File.Exists(file))
                {
                    this.Activate();
                    string openfile = File.ReadAllText(file);
                    //获取需要打开的文件路径
                    this.Open(openfile);
                    //File.Delete(file);
                }
                break;

            default:
                base.DefWndProc(ref m);
                break;
            }
        }
Example #13
0
        public void CutImages(string imgpath, bool isreplace)
        {
            int count = this.cardlist.Length;
            int i     = 0;

            foreach (Card c in this.cardlist)
            {
                if (this.isCancel)
                {
                    break;
                }

                i++;
                this.worker.ReportProgress((i / count), string.Format("{0}/{1}", i, count));
                string jpg     = MyPath.Combine(imgpath, c.id + ".jpg");
                string savejpg = MyPath.Combine(this.mseHelper.ImagePath, c.id + ".jpg");
                if (File.Exists(jpg) && (isreplace || !File.Exists(savejpg)))
                {
                    Bitmap bp = new Bitmap(jpg);
                    Bitmap bmp;
                    if (c.IsType(CardType.TYPE_XYZ))//超量
                    {
                        bmp = MyBitmap.Cut(bp, this.imgSet.xyzArea);
                    }
                    else if (c.IsType(CardType.TYPE_PENDULUM))//P怪兽
                    {
                        bmp = MyBitmap.Cut(bp, this.imgSet.pendulumArea);
                    }
                    else//一般
                    {
                        bmp = MyBitmap.Cut(bp, this.imgSet.normalArea);
                    }
                    bp.Dispose();
                    MyBitmap.SaveAsJPEG(bmp, savejpg, this.imgSet.quilty);
                    //bmp.Save(savejpg, ImageFormat.Png);
                }
            }
        }
Example #14
0
        static void SaveLanguage()
        {
            string datapath = MyPath.Combine(Application.StartupPath, MyConfig.TAG_DATA);
            string conflang = MyConfig.GetLanguageFile(datapath);

            LanguageHelper.LoadFormLabels(conflang);
            LanguageHelper langhelper = new LanguageHelper();
            MainForm       form1      = new MainForm();

            LanguageHelper.SetFormLabel(form1);
            langhelper.GetFormLabel(form1);
            DataEditForm form2 = new DataEditForm();

            LanguageHelper.SetFormLabel(form2);
            langhelper.GetFormLabel(form2);
            CodeEditForm form3 = new CodeEditForm();

            LanguageHelper.SetFormLabel(form3);
            langhelper.GetFormLabel(form3);
            // LANG.GetFormLabel(this);
            //获取窗体文字
            langhelper.SaveLanguage(conflang + ".bak");
        }
 /// <summary>
 /// 语言配置文件名
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public static string GetLanguageFile(string path)
 {
     if (readBoolean(TAG_CHECK_SYSLANG) && Directory.Exists(path))
     {
         Save(TAG_CHECK_SYSLANG, "false");
         string[] words   = CultureInfo.InstalledUICulture.EnglishName.Split(' ');
         string   syslang = words[0];
         string[] files   = Directory.GetFiles(path);
         foreach (string file in files)
         {
             string name = MyPath.getFullFileName(MyConfig.TAG_LANGUAGE, file);
             if (string.IsNullOrEmpty(name))
             {
                 continue;
             }
             if (syslang.Equals(name, StringComparison.OrdinalIgnoreCase))
             {
                 Save(MyConfig.TAG_LANGUAGE, syslang);
                 break;
             }
         }
     }
     return(MyPath.Combine(path, MyPath.getFileName(MyConfig.TAG_LANGUAGE, GetAppConfig(TAG_LANGUAGE))));
 }
Example #16
0
 public string GetYdk(string name)
 {
     return(MyPath.Combine(ydkpath, name + ".ydk"));
 }
Example #17
0
        public void SetConfig(string config, string path)
        {
            if (!File.Exists(config))
            {
                return;
            }
            regx_monster  = "(\\s\\S*?)";
            regx_pendulum = "(\\s\\S*?)";
            //设置文件名
            configName = MyPath.getFullFileName(MSEConfig.TAG, config);

            replaces = new SortedList <string, string>();

            typeDic = new SortedList <long, string>();
            raceDic = new SortedList <long, string>();
            string[] lines = File.ReadAllLines(config, Encoding.UTF8);
            foreach (string line in lines)
            {
                if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
                {
                    continue;
                }
                if (line.StartsWith(TAG_CN2TW))
                {
                    Iscn2tw = ConfHelper.getBooleanValue(line);
                }
                else if (line.StartsWith(TAG_SPELL))
                {
                    str_spell = ConfHelper.getValue(line);
                }
                else if (line.StartsWith(TAG_HEAD))
                {
                    head = ConfHelper.getMultLineValue(line);
                }
                else if (line.StartsWith(TAG_END))
                {
                    end = ConfHelper.getMultLineValue(line);
                }
                else if (line.StartsWith(TAG_TEXT))
                {
                    temp_text = ConfHelper.getMultLineValue(line);
                }
                else if (line.StartsWith(TAG_TRAP))
                {
                    str_trap = ConfHelper.getValue(line);
                }
                else if (line.StartsWith(TAG_REG_PENDULUM))
                {
                    regx_pendulum = ConfHelper.getValue(line);
                }
                else if (line.StartsWith(TAG_REG_MONSTER))
                {
                    regx_monster = ConfHelper.getValue(line);
                }
                else if (line.StartsWith(TAG_MAXCOUNT))
                {
                    maxcount = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_WIDTH))
                {
                    width = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_HEIGHT))
                {
                    height = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_PEND_WIDTH))
                {
                    pwidth = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_PEND_HEIGHT))
                {
                    pheight = ConfHelper.getIntegerValue(line, 0);
                }
                else if (line.StartsWith(TAG_NO_TEN))
                {
                    no10 = ConfHelper.getBooleanValue(line);
                }
                else if (line.StartsWith(TAG_NO_START_CARDS))
                {
                    string   val = ConfHelper.getValue(line);
                    string[] cs  = val.Split(',');
                    noStartCards = new long[cs.Length];
                    int i = 0;
                    foreach (string str in cs)
                    {
                        long l = 0;
                        long.TryParse(str, out l);
                        noStartCards[i++] = l;
                    }
                }
                else if (line.StartsWith(TAG_IMAGE))
                {
                    //如果路径不合法,则为后面的路径
                    imagepath = MyPath.CheckDir(ConfHelper.getValue(line), MyPath.Combine(path, PATH_IMAGE));
                    //图片缓存目录
                    imagecache = MyPath.Combine(imagepath, "cache");
                    MyPath.CreateDir(imagecache);
                }
                else if (line.StartsWith(TAG_REPALCE))
                {                //特数字替换
                    string word = ConfHelper.getValue(line);
                    string p    = ConfHelper.getRegex(ConfHelper.getValue1(word));
                    string r    = ConfHelper.getRegex(ConfHelper.getValue2(word));
                    if (!string.IsNullOrEmpty(p))
                    {
                        replaces.Add(p, r);
                    }
                }
                else if (line.StartsWith(TAG_RACE))
                {                //种族
                    ConfHelper.DicAdd(raceDic, line);
                }
                else if (line.StartsWith(TAG_TYPE))
                {                //类型
                    ConfHelper.DicAdd(typeDic, line);
                }
                else if (line.StartsWith(TAG_REIMAGE))
                {
                    reimage = ConfHelper.getBooleanValue(line);
                }
            }
        }
Example #18
0
 //save local file
 void saveFileDictionary(Dictionary <string, string> myDictionary)
 {
     ES2.Save(myDictionary, MyPath.Combine(appPath, "filesClient.txt"));
 }
 /// <summary>
 /// 卡片信息配置文件名
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public static string GetCardInfoFile(string path)
 {
     return(MyPath.Combine(path, MyPath.getFileName(MyConfig.TAG_CARDINFO, GetAppConfig(TAG_LANGUAGE))));
 }
Example #20
0
    IEnumerator Start()
    {
        Application.RegisterLogCallback(HandleLog);
        print("开始检查软件更新");

        WWW www = new WWW(serverurl + "filesClient.txt" + "?time=" + UnityEngine.Random.Range(0.1f, 1000f));

        print(www.url);
        yield return(www);

        if (www.error != null)
        {
            //0.net off ,Open the App
            //StartCoroutine(StartApp());
            print(www.error);

            print("更新完成,正在启动中");
            StartCoroutine(StartApp());
        }
        if (www.isDone)
        {
            //0.net on , Check Update

            appPath = MyPath.Combine(Application.dataPath, "Application");

            ES2.SaveRaw(www.bytes, MyPath.Combine(appPath, "filesServer.txt"));

            GetDirs(appPath);

            //1.get Local file
            saveFileDictionary(filesClient);
            print("======fileClient======");
            string temp = "";
            foreach (var i in filesClient)
            {
                temp += i;
                temp += "\n\r\n\r";
            }
            print(temp);


            //2.get server file
            print("======fileServer======");
            filesServer = ES2.LoadDictionary <string, string>(MyPath.Combine(appPath, "filesServer.txt"));
            temp        = "";
            foreach (var i in filesServer)
            {
                temp += i;
                temp += "\n\r\n\r";
            }
            print(temp);


            //3.compare with file
            print("======Server don't have Client have,Should Delete======");
            IEnumerable <string> filesDelete = filesClient.Keys.Except(filesServer.Keys);
            temp = "";
            foreach (var i in filesDelete)
            {
                temp += i;
                temp += "\n\r\n\r";
                File.Delete(MyPath.Combine(appPath, filesClient[i]));
            }
            print(temp);


            //4.compare with file
            print("======Server have Client don't have,Should Download======");
            IEnumerable <string> filesDownload = filesServer.Keys.Except(filesClient.Keys);
            temp = "";

            mTotalBundleCount = filesDownload.Count();


            foreach (var i in filesDownload)
            {
                temp += i;
                temp += "\n\r\n\r";

                StartCoroutine(CoDownloadAndWriteFile(MyPath.Combine(serverurl, filesServer[i]), MyPath.Combine(appPath, filesServer[i])));
            }
            print(temp);

            //5.检查是否下载完毕
            StartCoroutine(CheckLoadFinish());
        }
    }
Example #21
0
 public void testZipfile()
 {
     ZipFile.CreateFromDirectory(MyPath.Combine(Env.WebRootPath, "Upload", "testZipFile"), MyPath.Combine(Env.WebRootPath, "Download", "2.zip"));
 }
Example #22
0
        async public Task <object> ExportWhenBudgetProjectOfArgument(BudgetProjectFilter filter, IEnumerable <int> listOfId)
        {
            //后台指定归口部门的过滤条件;
            var filterExtend = Tool.ModelToModel <BudgetProjectExtendFilter, BudgetProjectFilter>(filter);

            filterExtend.RelevantDepartmentId = CurrentUser.DepartmentId;
            filterExtend.WhereInId            = listOfId.Count() == 0 ? null : listOfId.ToStringIdWithSpacer();

            var list = (await Db.GetListSpAsync <VBudgetProjectNotInFlow, BudgetProjectExtendFilter>(filterExtend)).ToList();

            var listOfPackage = (await Db.GetListSpAsync <VPackageOfDeclareProject, PackageOfBudgetProjectFilter>(
                                     new PackageOfBudgetProjectFilter()
            {
                WhereInBudgetProjectId = list.Select(i => i.Id).ToStringIdWithSpacer()
            })).ToList();

            var zipFileName = $"导出待论证项目_{DateTime.Now.ToString("yyyyMMddHHmmss")}";
            var zipPathName = MyPath.Combine(Env.WebRootPath, "Download", zipFileName);

            Directory.CreateDirectory(zipPathName);

            zipFileName = $"{zipFileName}.zip";
            var zipPathFileName     = MyPath.Combine(Env.WebRootPath, "Download", zipFileName);
            var relativeZipPathName = MyPath.Combine("Download", zipFileName);

            for (int i = 0, countOfList = list.Count(); i < countOfList; i++)
            {
                var item             = list[i];
                var itemName         = $"{item.Name}-{item.MergeTypeWhenBudget}";
                var zipChildPathName = MyPath.Combine(zipPathName, itemName);
                Directory.CreateDirectory(zipChildPathName);
                //如果是集采-货物,则生成一个容纳了各个包为ExportWhenBudgetProjectOfArgumentCaseGoods的excel
                if (item.IsCenterPurchase && item.ProjectType == "货物")
                {
                    var packages = from itemOfPackage in listOfPackage
                                   where itemOfPackage.BudgetProjectId.Equals(item.Id)
                                   select Tool.ModelToModel <ExportWhenBudgetProjectOfArgumentCaseGoods, VPackageOfDeclareProject>(itemOfPackage);

                    MyXls.Export(zipChildPathName, packages, itemName);
                }
                else
                {
                    var packages = (from itemOfPackage in listOfPackage
                                    where itemOfPackage.BudgetProjectId.Equals(item.Id)
                                    select Tool.ModelToModel <ExportWhenBudgetProjectOfArgumentCaseOther, VPackageOfDeclareProject>(itemOfPackage)).ToList();

                    for (int j = 0, countOfPackages = packages.Count(); j < countOfPackages; j++)
                    {
                        var itemOfPackage = packages[j];
                        itemOfPackage.Id = j + 1;
                        //itemOfPackage.Attachment = Path.GetFileName(itemOfPackage.Attachment);

                        System.IO.File.Copy(
                            MyPath.Combine(Env.WebRootPath, itemOfPackage.Attachment),
                            MyPath.Combine(zipChildPathName, $"第{itemOfPackage.Id }包-{Path.GetFileName(itemOfPackage.Attachment)}"));
                    }

                    MyXls.Export(zipChildPathName, packages, itemName);
                }
            }
            ZipFile.CreateFromDirectory(zipPathName, zipPathFileName);
            return(relativeZipPathName);
        }
Example #23
0
 public string GetScript(string id)
 {
     return(MyPath.Combine(luapath, "c" + id + ".lua"));
 }
Example #24
0
        //打开脚本
        public bool OpenScript(bool openinthis, string addrequire)
        {
            if (!dataform.CheckOpen())
            {
                return(false);
            }

            Card   c  = dataform.GetCard();
            long   id = c.id;
            string lua;

            if (c.id > 0)
            {
                lua = dataform.GetPath().GetScript(id);
                if (c.omega[0] > 0 && !File.Exists(lua))
                {
                    string tmp = MyPath.Combine(dataform.GetPath().gamepath, "../Scripts", "c" + id + ".lua");
                    if (File.Exists(tmp))
                    {
                        lua = tmp;
                    }
                    if (c.omega[0] > 0 && !string.IsNullOrEmpty(c.script) &&
                        !byte.TryParse(c.script, out _) && !File.Exists(lua) && openinthis)
                    {
                        DEXConfig.OpenFileInThis(c.script);
                        return(true);
                    }
                }
            }
            else if (addrequire.Length > 0)
            {
                lua = dataform.GetPath().GetModuleScript(addrequire);
            }
            else
            {
                return(false);
            }
            if (!File.Exists(lua))
            {
                if (c.omega[0] > 0 && !string.IsNullOrEmpty(c.script) && !byte.TryParse(c.script, out _) &&
                    !openinthis)
                {
                    MyPath.CreateDirByFile(lua);
                    using FileStream fs = new(lua,
                                              FileMode.OpenOrCreate, FileAccess.Write);
                    StreamWriter sw = new(fs, new UTF8Encoding(false));
                    sw.Write(c.script);
                    sw.Close();
                    fs.Close();
                }
                if (MyMsg.Question(LMSG.IfCreateScript))//是否创建脚本
                {
                    MyPath.CreateDirByFile(lua);
                    using FileStream fs = new(lua,
                                              FileMode.OpenOrCreate, FileAccess.Write);
                    StreamWriter sw = new(fs, new UTF8Encoding(false));
                    sw.WriteLine("--" + c.name);
                    sw.WriteLine("local s,id=GetID()");
                    if (!string.IsNullOrEmpty(addrequire))
                    {
                        sw.WriteLine("Duel.LoadScript(\"" + addrequire + ".lua\")"); // DIY script
                    }
                    sw.WriteLine("function s.initial_effect(c)");
                    sw.WriteLine("\t");
                    sw.WriteLine("end");
                    sw.Close();
                    fs.Close();
                }
            }
            if (File.Exists(lua)) //如果存在,则打开文件
            {
                if (openinthis)   //是否用本程序打开
                {
                    DEXConfig.OpenFileInThis(lua);
                }
                else
                {
                    _ = System.Diagnostics.Process.Start(lua);
                }

                return(true);
            }
            return(false);
        }
Example #25
0
 //字符串id
 public string GetImage(string id)
 {
     return(MyPath.Combine(picpath, id + ".jpg"));
 }
Example #26
0
 //save server file
 void saveServerData(Byte[] bytes)
 {
     ES2.SaveRaw(bytes, MyPath.Combine(appPath, "filesServer.txt"));
 }
Example #27
0
 //public string GetImageThum(string id)
 //{
 //	return MyPath.Combine(picpath2, id + ".jpg");
 //}
 public string GetImageField(string id)
 {
     return(MyPath.Combine(fieldpath, id + ".png"));//场地图
 }
Example #28
0
        private static void Main(string[] args)
        {
            string arg = (args.Length > 0) ? args[0] : "";

            if (arg == DEXConfig.TAG_SAVE_LAGN || arg == DEXConfig.TAG_SAVE_LAGN2)
            {
                //保存语言
                SaveLanguage();
                _ = MessageBox.Show("Save Language OK.");
                Environment.Exit(1);
            }
            if (DEXConfig.OpenOnExistForm(arg))//在已经存在的窗口打开文件
            {
                Environment.Exit(1);
            }
            else//新建窗口
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                MainForm mainForm = new();
                //设置将要打开的文件
                mainForm.SetOpenFile(arg);
                //数据目录
                mainForm.SetDataPath(MyPath.Combine(Application.StartupPath, DEXConfig.TAG_DATA));

                Application.Run(mainForm);

                Dictionary <long, string> dic = mainForm.GetDataConfig().dicSetnames;
                Dictionary <long, string> old = mainForm.GetDataConfig(true).dicSetnames;
                foreach (long setcode in dic.Keys)
                {
                    if (old.ContainsKey(setcode))
                    {
                        continue;
                    }
                    string cardinfo = DEXConfig.GetCardInfoFile(MyPath.Combine(Application.StartupPath,
                                                                               DEXConfig.TAG_DATA));
                    if (File.Exists(cardinfo))
                    {
                        using (FileStream cStream = new(cardinfo, FileMode.Open, FileAccess.ReadWrite))
                        {
                            try
                            {
                                byte[] content = Encoding.UTF8.GetBytes($"\n0x{setcode:x}\t{dic[setcode]}\n#end");
                                _ = cStream.Seek(-5, SeekOrigin.End);
                                cStream.Write(content, 0, content.Length);
                            }
                            catch { }
                            finally
                            {
                                cStream.Close();
                            }
                        }
                    }
                    string file = MyPath.Combine(Application.StartupPath, DEXConfig.TAG_DATA, DEXConfig.FILE_STRINGS);
                    if (!string.IsNullOrEmpty(file) && File.Exists(file))
                    {
                        using FileStream sStream = new(file, FileMode.Open, FileAccess.Write);
                        try
                        {
                            byte[] content = Encoding.UTF8.GetBytes($"!setname 0x{setcode:x} {dic[setcode]}\n");
                            _ = sStream.Seek(0, SeekOrigin.End);
                            sStream.Write(content, 0, content.Length);
                        }
                        catch { }
                        finally
                        {
                            sStream.Close();
                        }
                    }
                }
            }
        }
Example #29
0
 public string GetModuleScript(string modulescript)
 {
     return(MyPath.Combine(luapath, modulescript + ".lua"));
 }
Example #30
0
 public DataConfig()
 {
     InitMember(MyPath.Combine(Application.StartupPath, DEXConfig.TAG_CARDINFO + ".txt"));
 }