示例#1
0
        //start downloading
        private void button1_Click(object sender, EventArgs e)
        {
            total = 0;
            for (int i = 0; i < GlobalConstants.GENERATION.Count; i++)
            {
                foreach (TreeNode season in treeView1.Nodes[i].Nodes)
                {
                    if (season.Checked)
                    {
                        total++;
                    }
                }
            }
            total *= 6;

            if (total == 0)
            {
                SelfDesignedMsg sdm = new SelfDesignedMsg("要先点选需要下载赛季,小女子才能帮您下载哦~", false);
                sdm.ShowDialog();
                return;
            }
            errorExists = false;
            bkWorker.WorkerReportsProgress      = true;
            bkWorker.WorkerSupportsCancellation = true;
            bkWorker.DoWork             += new DoWorkEventHandler(startUpdate);
            bkWorker.ProgressChanged    += new ProgressChangedEventHandler(updateProgress);
            bkWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(completeWork);
            label2.Text = "已开始下载";
            bkWorker.RunWorkerAsync();
        }
示例#2
0
        public ArrayList getModelLists()
        {
            ArrayList res = new ArrayList();

            try
            {
                string strLine = sr.ReadLine();

                while (strLine != null)
                {
                    res.Add(double.Parse(strLine));
                    strLine = sr.ReadLine();
                }
            }
            catch
            {
                sr.Close();
                SelfDesignedMsg sdm = new SelfDesignedMsg("Sorry~ 您自定义模型中存在我无法解析的数据, 小女子只能识别int和double型数据...", false);
                sdm.ShowDialog();
                return(null);
            }
            sr.Close();
            aFile.Close();
            return(res);
        }
示例#3
0
        //进行分析统计
        private void updateAnalysis()
        {
            if (battleType == -1)
            {
                return;
            }

            double para = 1;

            if (textBox1.Text != "")
            {
                try
                {
                    para = -double.Parse(textBox1.Text);
                }
                catch
                {
                    SelfDesignedMsg sdm = new SelfDesignedMsg("Sorry~ 小女子无法解析您所输入的参数a的值,请重新输入或直接拖动滑动条~", false);
                    sdm.ShowDialog();
                    return;
                }
            }
            az = new Analyze(curSingleFile, battleType, para, selfDefined);

            if (az.initalFailed)
            {
                return;
            }
            presentResult(battleType);
            pictureBox1.Refresh();
        }
示例#4
0
        public Analyze(string dbFile, int battleType, double userPara, bool selfDefined)
        {
            para            = userPara;
            this.battleType = battleType;
            ah     = new AccessHandler(dbFile);
            curDir = Environment.CurrentDirectory;

            initalFailed = true;

            raceData       = ah.SelectToDataTable("select pokemon.hp,pokemon.attack,pokemon.defense,pokemon.specialAttack,pokemon.specialDefense,pokemon.speed,battleType" + battleType + ".ranking,battleType" + battleType + ".nature1,battleType" + battleType + ".nu1,battleType" + battleType + ".nature2,battleType" + battleType + ".nu2,battleType" + battleType + ".nature3,battleType" + battleType + ".nu3 from battleType" + battleType + " inner join [;database=" + curDir + "/Data/PokeData.mdb].pokemon on pokemon.poke_id = battleType" + battleType + ".poke_id");
            rankingDetails = ah.SelectToDataTable("select * from battleType" + battleType + "");
            total          = 0;

            if (selfDefined)
            {
                SelfDefinedModelParser sdmp;
                try
                {
                    sdmp = new SelfDefinedModelParser("Data/SelfDefinedModel.txt");
                }
                catch
                {
                    SelfDesignedMsg sdm = new SelfDesignedMsg("Sorry~ 小女子找不到您定义模型的文件...\r\n请确认文件Data/SelfDefinedModel.txt的存在~", false);
                    sdm.ShowDialog();
                    return;
                }
                ArrayList selfModel = sdmp.getModelLists();
                if (selfModel == null)
                {
                    return;
                }
                if (selfModel.Count < rankingDetails.Rows.Count)
                {
                    SelfDesignedMsg sdm = new SelfDesignedMsg("您定义的模型数据不足哦~ 请至少定义" + rankingDetails.Rows.Count + "条", false);
                    sdm.ShowDialog();
                    return;
                }
                model    = new double[rankingDetails.Rows.Count + 1];
                model[0] = 0;
                for (int i = 1; i <= rankingDetails.Rows.Count; i++)
                {
                    model[i] = (double)selfModel[i - 1];
                    total   += model[i];
                }
            }
            else
            {
                model    = new double[rankingDetails.Rows.Count + 1];
                model[0] = 0;
                for (int i = 1; i <= rankingDetails.Rows.Count; i++)
                {
                    model[i] = Math.Pow(i, para);
                    total   += model[i];
                }
            }
            initalFailed = false;
        }
示例#5
0
        public ShowAnalysis(AccessHandler ah, string curSingleFile, string[]  rankTables)
        {
            InitializeComponent();

            if (GlobalConstants.dpiX == 120)
            {
                foreach (Control ct in this.Controls)
                {
                    ct.Font = new System.Drawing.Font(ct.Font.FontFamily, (float)(ct.Font.Size / 1.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                }
            }
            label15.Text = "Top" + GlobalConstants.POPULARTHRESHOLD + label15.Text;

            battleType         = -1;
            this.curSingleFile = curSingleFile;
            this.ah            = ah;
            this.rankTables    = rankTables;
            defaultpara        = new double[6];
            defaultpara[0]     = 0;
            for (int i = 1; i < 6; i++)
            {
                defaultpara[i] = double.Parse(GlobalConstants.ANALYSISPARA[i - 1]);
            }

            radioButton1.Checked = true;

            string fileName = curSingleFile.Split('/')[2].Replace(".mdb", "");

            string[] nameParts = fileName.Split('-');
            label6.Text = nameParts[0] + "-" + nameParts[1] + "赛季-" + nameParts[2];

            comboBox1.Items.Clear();
            string generationSelected = curSingleFile.Split('/')[1];
            int    defaultTable       = -1;

            for (int i = 0; i < rankTables.Length; i++)
            {
                comboBox1.Items.Add(generationSelected + "-" + GlobalConstants.TABLENAMES[rankTables[i][10] - '0']);
                if (GlobalConstants.DEFAULTBATTLETYPE[0] - '0' == rankTables[i][10] - '0')
                {
                    defaultTable = i;
                }
            }
            if (defaultTable >= 0)
            {
                comboBox1.SelectedIndex = -1;
                comboBox1.SelectedIndex = defaultTable;
            }
            else
            {
                SelfDesignedMsg sdm = new SelfDesignedMsg("Sorry~~【对战类型】下拉菜单中没有找到您所设的默认榜单, 请手动选择其它榜单~", false);
                sdm.ShowDialog();
            }
        }
示例#6
0
        //start updating
        private void button1_Click(object sender, EventArgs e)
        {
            pkIdList = new ArrayList();
            try
            {
                FileStream   file = new FileStream("Data/pokeIdList.dat", FileMode.Open);
                StreamReader sr   = new StreamReader(file);
                string       line = sr.ReadLine();
                while (line != null)
                {
                    pkIdList.Add(line);
                    line = sr.ReadLine();
                }
                sr.Close();
            }
            catch
            {
                textBox1.Text += "读取文件pokeIdList.dat失败\r\n";
                errorExists    = true;
                return;
            }

            progressBar1.Value = 0;

            total           = 0;
            generationTotal = new int[treeView1.Nodes.Count];
            for (int i = 0; i < treeView1.Nodes.Count; i++)
            {
                generationTotal[i] = 0;
                for (int j = 0; j < treeView1.Nodes[i].Nodes.Count; j++)
                {
                    if (treeView1.Nodes[i].Nodes[j].Checked)
                    {
                        total++;
                        generationTotal[i]++;
                    }
                }
                generationTotal[i] *= pkIdList.Count;
            }
            total *= pkIdList.Count;

            if (total == 0)
            {
                SelfDesignedMsg sdm = new SelfDesignedMsg("要先点选需更新的榜单,小女子才能帮您下载哦~", false);
                sdm.ShowDialog();
                return;
            }


            textBox1.Text += "下载开始\r\n";
            stopwatch      = new System.Diagnostics.Stopwatch();
            bkWorker.RunWorkerAsync();
        }
示例#7
0
        //start app updating
        private void button1_Click(object sender, EventArgs e)
        {
            SelfDesignedMsg sdm = new SelfDesignedMsg("更新就交给我啦~ 我会暂时关闭当前程序,在下载和替换完成后会启动新版本程序,那么,现在开始吗?", true);
            DialogResult    dr  = sdm.ShowDialog();

            if (dr == DialogResult.Yes)
            {
                //call the PGLToolUpdate app
                Process proc = Process.Start(Environment.CurrentDirectory + "/Update/PGLToolUpdateV1.0.exe", newVersion);
                Environment.Exit(0);
            }
        }
示例#8
0
 //选择对战类型
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex < 0)
     {
         battleType = -1;
         return;
     }
     battleType = rankTables[comboBox1.SelectedIndex][10] - '0';
     if (battleType == 0)
     {
         SelfDesignedMsg sdm = new SelfDesignedMsg("该对战类型无法进行分析哦~", false);
         sdm.ShowDialog();
         return;
     }
     textBox1.Text   = defaultpara[battleType].ToString();
     trackBar1.Value = (int)(defaultpara[battleType] / 0.05);
     updateAnalysis();
 }
示例#9
0
 //thread finishes
 private void completeWork(object sender, RunWorkerCompletedEventArgs e)
 {
     label2.Text = "0分0秒";
     label1.Text = "100%";
     if (WindowState == FormWindowState.Minimized)
     {
         Text = "100%";
     }
     progressBar1.Value = 100;
     if (errorExists)
     {
         textBox1.Text += "下载因异常而中断\r\n";
     }
     else
     {
         textBox1.Text += "下载全部完成\r\n";
         SelfDesignedMsg sdm = new SelfDesignedMsg("小女子已经为您下载完全部数据啦~~~\r\n要阅览最新数据请重启软件哦~", false);
         sdm.ShowDialog();
     }
 }
示例#10
0
 //thread finishes
 private void completeWork(object sender, RunWorkerCompletedEventArgs e)
 {
     label1.Text = "100%";
     if (WindowState == FormWindowState.Minimized)
     {
         Text = "100%";
     }
     progressBar1.Value = 100;
     if (errorExists)
     {
         label2.Text = "下载中断";
         SelfDesignedMsg sdm = new SelfDesignedMsg("Sorry~ 下载因为异常而中断了... \r\n可能github服务器暂时无法连接", false);
         sdm.ShowDialog();
     }
     else
     {
         label2.Text = "下载完成";
         SelfDesignedMsg sdm = new SelfDesignedMsg("您需要的旧赛季数据已经都下载好啦~~~\r\n要阅览最新数据请重启软件哦~", false);
         sdm.ShowDialog();
     }
 }
示例#11
0
        public UpdateApp(bool autoCheck)
        {
            InitializeComponent();

            if (GlobalConstants.dpiX == 120)
            {
                foreach (Control ct in this.Controls)
                {
                    ct.Font = new System.Drawing.Font(ct.Font.FontFamily, (float)(ct.Font.Size / 1.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                }
            }


            Register();

            hasNew = false;
            if (!checkUpdate())
            {
                if (!autoCheck)
                {
                    SelfDesignedMsg sdm = new SelfDesignedMsg("您的软件已经是最新版本啦~", false);
                    sdm.ShowDialog();
                }
                return;
            }
            hasNew = true;
            string    url         = "https://raw.githubusercontent.com/DearUnknown/PGLToolUpdate/master/PGLToolUpdate/VersionV1.0/info.txt";
            WebClient myWebClient = new WebClient();

            myWebClient.DownloadFile(url, "Update/info.txt");
            FileStream   aFile = new FileStream("Update/info.txt", FileMode.Open);
            StreamReader sr    = new StreamReader(aFile, Encoding.GetEncoding("UTF-8"));
            string       info  = sr.ReadToEnd();

            textBox1.Text = info.Replace("\n", "\r\n");
            sr.Close();
            aFile.Close();
        }
示例#12
0
        public UpdateData(bool autoCheck)
        {
            InitializeComponent();

            if (GlobalConstants.dpiX == 120)
            {
                foreach (Control ct in this.Controls)
                {
                    ct.Font = new System.Drawing.Font(ct.Font.FontFamily, (float)(ct.Font.Size / 1.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                }
            }


            valid                = false;
            defaultHasNew        = false;
            radioButton2.Enabled = false;
            radioButton2.Visible = false;

            int  checkRes = checkUpdate();
            bool gitValid = checkGit();

            //fail to connect to PGL
            if (checkRes == -2)
            {
                radioButton1.Enabled = false;
                radioButton1.Visible = false;
                radioButton1.Checked = false;
                if (!gitValid)
                {
                    if (!autoCheck)
                    {
                        SelfDesignedMsg sdm = new SelfDesignedMsg("Sorry~ 无法连接PGL服务器, 可能这货在维护...", false);
                        sdm.ShowDialog();
                    }
                    return;
                }
            }

            //no return for PGL http post
            else if (checkRes == -1)
            {
                radioButton1.Enabled = false;
                radioButton1.Visible = false;
                radioButton1.Checked = false;
                if (!gitValid)
                {
                    if (!autoCheck)
                    {
                        SelfDesignedMsg sdm = new SelfDesignedMsg("刚刚进入新赛季,PGL服务器上暂时还找不到新的数据~", false);
                        sdm.ShowDialog();
                    }
                    return;
                }
            }

            //no new data
            else if (checkRes == 0)
            {
                if (!autoCheck)
                {
                    SelfDesignedMsg sdm = new SelfDesignedMsg("您已拥有最新各项榜单啦~", false);
                    sdm.ShowDialog();
                }
                return;
            }

            //initialize a new thread
            valid       = true;
            errorExists = false;
            bkWorker.WorkerReportsProgress      = true;
            bkWorker.WorkerSupportsCancellation = true;
            bkWorker.DoWork             += new DoWorkEventHandler(startUpdate);
            bkWorker.ProgressChanged    += new ProgressChangedEventHandler(updateProgress);
            bkWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(completeWork);

            //get user's selection for new data
            treeView1.CheckBoxes = true;
            if (checkRes > 0 && (!gitValid))
            {
                for (int i = 0; i < fetchTasks.Count; i++)
                {
                    TreeNode tn = new TreeNode();
                    tn.Text = ((Fetch)fetchTasks[i]).generation + "-" + ((Fetch)fetchTasks[i]).curSeasonName + "-" + ((Fetch)fetchTasks[i]).updateTime.Split('-')[0];
                    if (((int[])newTables[i])[0] == 1)
                    {
                        tn.Nodes.Add("All Matches");
                    }
                    if (((int[])newTables[i])[1] == 1)
                    {
                        tn.Nodes.Add("Single");
                    }
                    if (((int[])newTables[i])[2] == 1)
                    {
                        tn.Nodes.Add("Double");
                    }
                    if (((int[])newTables[i])[3] == 1)
                    {
                        tn.Nodes.Add("Triple");
                    }
                    if (((int[])newTables[i])[4] == 1)
                    {
                        tn.Nodes.Add("Rotation");
                    }
                    if (((int[])newTables[i])[5] == 1)
                    {
                        tn.Nodes.Add("Special");
                    }
                    treeView1.Nodes.Add(tn);
                }
            }
            else
            {
                gitTasks = new ArrayList();
                newTables.Clear();
                for (int i = 0; i < GlobalConstants.GENERATION.Count; i++)
                {
                    int[] blankTable = { 1, 1, 1, 1, 1, 1 };

                    if (gitVersions[i].ToString().Equals(""))
                    {
                        int           tableCount = 0;
                        AccessHandler ah         = new AccessHandler(GlobalConstants.MOSTRECENTFILES[i].ToString());
                        string[]      rankTables = ah.showAllTables();
                        foreach (string rankTable in rankTables)
                        {
                            blankTable[rankTable[10] - '0'] = 0;
                            tableCount++;
                        }
                        if (tableCount < 6)
                        {
                            newTables.Add(blankTable);
                            gitTasks.Add(GlobalConstants.MOSTRECENTFILES[i].ToString());
                            if (GlobalConstants.DEFAULTGENERATION.Equals(i.ToString()))
                            {
                                defaultHasNew = true;
                            }
                        }
                    }
                    else
                    {
                        newTables.Add(blankTable);
                        gitTasks.Add(gitVersions[i].ToString());
                        if (GlobalConstants.DEFAULTGENERATION.Equals(i.ToString()))
                        {
                            defaultHasNew = true;
                        }
                    }
                }

                if (gitTasks.Count == 0)
                {
                    valid = false;
                    if (!autoCheck)
                    {
                        SelfDesignedMsg sdm = new SelfDesignedMsg("您已拥有最新各项榜单啦~", false);
                        sdm.ShowDialog();
                    }
                    return;
                }


                for (int i = 0; i < gitTasks.Count; i++)
                {
                    TreeNode tn        = new TreeNode();
                    string[] nameParts = gitTasks[i].ToString().Split('/');
                    tn.Text = nameParts[1] + "-" + nameParts[2].Split('-')[1] + "-" + nameParts[2].Split('-')[2];
                    if (((int[])newTables[i])[0] == 1)
                    {
                        tn.Nodes.Add("All Matches");
                    }
                    if (((int[])newTables[i])[1] == 1)
                    {
                        tn.Nodes.Add("Single");
                    }
                    if (((int[])newTables[i])[2] == 1)
                    {
                        tn.Nodes.Add("Double");
                    }
                    if (((int[])newTables[i])[3] == 1)
                    {
                        tn.Nodes.Add("Triple");
                    }
                    if (((int[])newTables[i])[4] == 1)
                    {
                        tn.Nodes.Add("Rotation");
                    }
                    if (((int[])newTables[i])[5] == 1)
                    {
                        tn.Nodes.Add("Special");
                    }
                    treeView1.Nodes.Add(tn);
                }
            }
        }