Beispiel #1
0
        private void dldir_ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            dialog.ShowDialog();
            this.aria2c.Config.__dir = dialog.SelectedPath;
            aria2c.Stop();
            aria2c = new Aria2c(this.aria2c.Config);
            aria2c.Start();
        }
Beispiel #2
0
        private void setting_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var setting = new SettingForm(aria2c.Config);

            setting.Show();
            setting.FormClosing += (s, ea) =>
            {
                Aria2Config config = new Aria2Config();
                foreach (var p in config.GetType().GetProperties())
                {
                    p.SetValue(config, setting.TextBoxes.FirstOrDefault(en => en.Name == p.Name).Text);
                }
                aria2c.Stop();
                aria2c = new Aria2c(config);
                aria2c.Start();
            };
        }
Beispiel #3
0
 public MainForm(Aria2c aria2c, InternalWebServer server)
 {
     InitializeComponent();
     this.aria2c = aria2c;
     this.server = server;
 }
Beispiel #4
0
        public void Start()
        {
            //For Windows 7 and above, best to include relevant app.manifest entries as well
            Cef.EnableHighDPISupport();

            var cefsettings = new CefSettings()
            {
                Locale = "zh-CN",
                //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
                CachePath = Path.Combine(Environment.CurrentDirectory, "cache"),
                IgnoreCertificateErrors = true,
                LogSeverity             = LogSeverity.Disable,
            };

            cefsettings.CefCommandLineArgs.Add("disable-gpu", "1");
            cefsettings.CefCommandLineArgs.Add("disable-gpu-compositing", "1");

            //Perform dependency check to make sure all relevant resources are in our output directory.
            Cef.Initialize(cefsettings, performDependencyCheck: true, browserProcessHandler: null);


            var path     = new FileInfo(Process.GetCurrentProcess().MainModule.FileName).DirectoryName;
            var resource = Path.Combine(path, "resource");
            var webuis   = Directory.GetDirectories(resource);

            if (webuis.Length == 0)
            {
                MessageBox.Show("缺少WebUI资源");
                Application.Exit();
            }

            var portHelper = new PortHelper();
            var aria2c     = new Aria2c();

            if (portHelper.GetUsedPorts().Contains(6800))
            {
                var choice = MessageBox.Show(
                    "检测到6800端口已被占用,请检查是否为aria2c程序。\r\n\r\n"
                    + "若为aria2c,是否关闭已开启的aria2c,并开启新的例程?\r\n\r\n"
                    + "选择“是”开启新的例程,选择“否”继续使用已开启的例程,选择“取消”退出程序"
                    , "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                if (choice == DialogResult.Yes)
                {
                    aria2c.Stop();
                    aria2c.Start();
                }
                else if (choice == DialogResult.No)
                {
                }
                else
                {
                    Environment.Exit(0);
                    return;
                }
            }
            else
            {
                aria2c.Start();
            }
            var port   = portHelper.GetRandPort();
            var server = new InternalWebServer(resource, port);

            server.Start();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(aria2c, server));
        }