예제 #1
0
        private async void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
#if DEBUG
                currentVersionLabel.Content = "当前版本号:1.0.0.0";
#else
                currentVersionLabel.Content = "当前版本号:" + ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
#endif

                codeforcesApi = new CodeforcesAPI();
                await LoadContestList();

                ///
                //for (int i = 444; i < 470; i++)
                //{
                //    contestListComboBox.Items.Add(" " + i.ToString() + " hahahahah");
                //}
                ///

                titleLabel.Content        = "请选择一个 Edu Round or Div. 3";
                hackCountButton.IsEnabled = true;
                hackItButton.IsEnabled    = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " error: MainWindow.Grid_Loaded",
                                "Error",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
        public HackExcuteWindow(IDictionary <string, object> settings)
        {
            InitializeComponent();

            try
            {
                // 创建 api
                codeforcesApi = new CodeforcesAPI();

                this.settings         = settings;
                contestId             = int.Parse(settings["contestId"].ToString());
                problems              = settings["problems"] as Dictionary <string, KeyValuePair <string[], string[]> >;
                lang                  = settings["lang"] as ArrayList;
                contestStatusFilePath = settings["contestStatusFilePath"] as string;

                // 设置查询区间
                var submissionIdRange = (KeyValuePair <int, int>)settings["submissionIdRange"];
                submissionIdRangeLeft  = submissionIdRange.Key;
                submissionIdRangeRight = submissionIdRange.Value;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " error: HackExcuteWindow.HackExcuteWindow",
                                "Error",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
예제 #3
0
        public SelectedWindow(string contestId = "1")
        {
            InitializeComponent();

            try
            {
                codeforcesApi = new CodeforcesAPI();
                // 初始化竞赛 id
                this.contestId = contestId;
                // 初始化 contest Status Url
                this.contestStatusUrl.NavigateUri = new Uri(codeforcesApi.GetContestStatusUrl(int.Parse(contestId)));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " SelectedWindow.SelectedWindow",
                                "Error",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
        private async void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                // 检查当前应用程序是否是通过 ClickOnce 部署,若是,获取部署版本,若不是,获取程序内定版本
                currentVersionLabel.Content = "当前版本号:" + (ApplicationDeployment.IsNetworkDeployed ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString() : Application.ResourceAssembly.GetName().Version.ToString());

                codeforcesApi = new CodeforcesAPI();
                await LoadContestList();

                titleLabel.Content        = "请选择一个 Edu Round or Div. 3";
                hackCountButton.IsEnabled = true;
                hackItButton.IsEnabled    = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " error: MainWindow.Grid_Loaded",
                                "Error",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            //try
            //{
            //    //CodeforcesAPI a = new CodeforcesAPI();
            //    ////var b = a.GetContestStandings(962, true, 1, 2, "im0qianqian", -1);
            //    //var b = a.GetContestList();
            //    //foreach (var item in b["result"])
            //    //{
            //    //    Console.WriteLine(item["id"] + " " + item["name"]);
            //    //}
            //    //Console.WriteLine(b);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.Message);
            //}


            try
            {
                CodeforcesAPI a    = new CodeforcesAPI();
                var           code = a.GetCodeBySubmissionIdAsync(958, 37366158).Result;
                Console.WriteLine(code["code"]);
                Console.WriteLine(code["language"]);
                Console.WriteLine(code["handle"]);
                //var b = new CompilingEnvironment.GNUCompiler();
                //string end = b.Execute(code, "4\n-5 R\n0 P\n3 P\n7 B");
                //Console.WriteLine(end);
                //Console.WriteLine(b.ExcuteTotalTime.TotalSeconds);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            //try
            //{
            //    var a = new Dictionary<string, string>();
            //    a.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");
            //    HttpClientSingleton.SetRequestHeaders(a);
            //    string url = "http://christmas.dreamwings.cn/";
            //    string data = HttpClientSingleton.DoGet(url);
            //    Console.WriteLine(data);

            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.Message);
            //}


            //try
            //{
            //    StreamReader sr = new StreamReader("main.cpp");
            //    string code = sr.ReadToEnd();

            //    var a = new CompilingEnvironment.GNUCompiler();
            //    string end = a.Execute(code, "44");
            //    Console.WriteLine(end);
            //    Console.WriteLine(a.ExcuteTotalTime.TotalSeconds);

            //    end = a.Execute(code, "55");
            //    Console.WriteLine(end);
            //    Console.WriteLine(a.ExcuteTotalTime.TotalSeconds);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex.Message);
            //}
        }