Пример #1
0
 public SettingForm(Aria2Config config)
 {
     this.config = config;
     explains    = JsonConvert.DeserializeObject <Dictionary <string, string> >(Resource.explains);
     InitializeComponent();
     //this.panel1.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(this.panel1, true, null);
     //this.panel1.CellPaint += (s, e) =>
     //{
     //    Pen pen = new Pen(Color.Black);
     //    e.Graphics.DrawLine(pen, e.CellBounds.X, e.CellBounds.Y, e.CellBounds.X + this.panel1.Width - 1, e.CellBounds.Y);
     //    //e.Graphics.DrawRectangle(pen, e.CellBounds.X, e.CellBounds.Y, e.CellBounds.X + this.panel1.Width - 1, e.CellBounds.Y + this.panel1.Height - 1);
     //};
 }
Пример #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();
            };
        }
Пример #3
0
        private void ReadConfig()
        {
            var cfgfile = Path.Combine(path, "aria2c.json");

            if (File.Exists(cfgfile))
            {
                using (var reader = new StreamReader(cfgfile, Encoding.UTF8))
                {
                    this.Config = JsonConvert.DeserializeObject <Aria2Config>(reader.ReadToEnd());
                    reader.Close();
                }
            }
            else
            {
                this.Config = new Aria2Config();
            }
        }
Пример #4
0
 public Aria2c(Aria2Config config)
 {
     this.Config = config;
 }