Example #1
0
        public AskDL(DLRequest r)
        {
            InitializeComponent();
            pictureBox1.BackgroundImage = Strings.Image1;
            textBox_Url.Text            = "    " + r.Url;
            textBox_Name.Text           = r.Filename;
            textBox_Type.Text           = r.ContentType;
            textBox_Size.Text           = ByteSize.Parse(r.ContentLength + "B").ToString();
            button_DM.Text = r.DefaultDM;
            switch (r.DefaultDM)
            {
            case "Thunder":
                button_DM.ButtonClick += button_Thunder_Click;
                break;

            case "EagleGet":
                button_DM.ButtonClick += button_EagleGet_Click;
                break;
            }
            foreach (var dm in DownloadManager.DMList)
            {
                if (((IDownloadManager)Activator.CreateInstance(Type.GetType("ThunderCross.DM" + dm), true)).Valid())
                {
                    button_DM.AddDropDownItemAndHandle(dm, (EventHandler)Delegate.CreateDelegate(typeof(EventHandler), this, "button_" + dm + "_Click"));
                }
            }
        }
Example #2
0
 public AskDL(DLRequest r)
 {
     InitializeComponent();
     //mod title
     this.Text += (": " + r.Filename);
     //save method for further warning(thunder X POST
     method = r.Method;
     //set font for chinese env. since 宋体 is too ugly.
     if (CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("zh-cn")))
     {
         this.Font = new System.Drawing.Font("微软雅黑", 10);
     }
     //whether show in the center of the screen
     if (r.ShowCenter)
     {
         this.StartPosition = FormStartPosition.CenterScreen;
     }
     //show host
     label_fileurl.Text = label_fileurl.Text + new Uri(r.Url).Host;
     //filename.
     textBox1_filename.Text = r.Filename;
     //show file size in most suitable unit.
     label_filetypesize.Text = label_filetypesize.Text + string.Format("{0} ({1})", r.ContentType, ByteSize.Parse(r.ContentLength + "B").ToString());
     //load icon from system according to extension
     picture_icon.Image = Etier.IconHelper.IconReader.GetFileIcon(Path.GetExtension(r.Filename), Etier.IconHelper.IconReader.IconSize.Large, false).ToBitmap();
     //load default dm
     if (r.DefaultDM == DLAgent.Customized.ToString())
     {
         comboBox_dm.Items.Add(string.Format("{0} ({1})", r.CustomizedDM[0].Name, DLAgent.Customized.ToString()));
     }
     else
     {
         comboBox_dm.Items.Add(Enum.Parse(typeof(DLAgent), r.DefaultDM));
     }
     comboBox_dm.SelectedIndex    = 0;
     radioButton_external.Checked = true;
     //load other available dm
     foreach (var dm in DownloadManager.DMList)
     {
         if (dm != r.DefaultDM && ((IDownloadManager)Activator.CreateInstance(Type.GetType("ThunderCross.DM" + dm), true)).Valid())
         {
             comboBox_dm.Items.Add(Enum.Parse(typeof(DLAgent), dm));
         }
     }
     //set hosts for "save option"
     string[] hostpart = new Uri(r.Url).Host.Split('.');
     for (int i = hostpart.Length - 1; i >= 0; i--)
     {
         comboBox_Host.Items.Add(string.Join(".", hostpart, i, hostpart.Length - i));
     }
     comboBox_Host.SelectedIndex = hostpart.Length - 1;
 }
Example #3
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                switch (args[0].ToLower())
                {
                case "breaked":
                {
                    NamedPipeClientStream aPipeClient = new NamedPipeClientStream(args[1]);
                    BinaryReader          br          = new BinaryReader(aPipeClient);
                    aPipeClient.Connect(5000);
                    string sTask = br.ReadString();
                    aPipeClient.Close();
                    DLTask dt = JsonConvert.DeserializeObject <DLTask>(sTask);
                    dt.Perform();
                    break;
                }

                default:
                {
                    Web_ext_Message msg   = GetMsg();
                    DLRequest       req   = msg.Dispatch();
                    DLReply         reply = req.Process();
                    SendMsg(reply);
                    break;
                }
                }
            }
            else
            {
                Application.EnableVisualStyles();
                DBG       dbg = new DBG();
                DLRequest r   = new DLRequest();
                r.RequestType   = "Download";
                r.ContentLength = "1G";
                dbg.ShowDialog();
                CheckInstallation();
            }
        }
Example #4
0
		static void Main(string[] args)
		{
			Application.EnableVisualStyles();
			if (args.Length > 0)
			{
				switch(args[0].ToLower())
				{
					case "breaked":
						{
							NamedPipeClientStream aPipeClient = new NamedPipeClientStream(args[1]);
							BinaryReader br = new BinaryReader(aPipeClient);
							aPipeClient.Connect(5000);
							string sTask = br.ReadString();
							aPipeClient.Close();
							DLTask dt = JsonConvert.DeserializeObject<DLTask>(sTask);
							dt.Perform();
							break;
						}
					case "fix":
						{
							string thunderexe = args[1];
							string thunderagentdll = args[2];
							string thunderagent64bit = thunderagentdll.ToLower().Replace("thunderagent.dll", "thunderagent64.dll");
							Stack<string> tpaths = new Stack<string>(thunderexe.Split('\\'));
							tpaths.Pop();
							if (tpaths.Peek().ToLower() == "program")
								tpaths.Pop();
							string thunderroot = string.Join("\\", tpaths.Reverse())+"\\";
							string version = FileVersionInfo.GetVersionInfo(thunderexe).FileVersion.Replace(',','.');
							if (Environment.Is64BitOperatingSystem && Environment.Is64BitProcess)
							{
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Thunder Network\ThunderOem\thunder_backwnd", "dir", thunderroot, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Thunder Network\ThunderOem\thunder_backwnd", "Path", thunderexe, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Thunder Network\ThunderOem\thunder_backwnd", "instdir", thunderroot, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Thunder Network\ThunderOem\thunder_backwnd", "Version", version, RegistryValueKind.String);
							}
							else
							{
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Thunder Network\ThunderOem\thunder_backwnd", "dir", thunderroot, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Thunder Network\ThunderOem\thunder_backwnd", "Path", thunderexe, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Thunder Network\ThunderOem\thunder_backwnd", "instdir", thunderroot, RegistryValueKind.String);
								Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Thunder Network\ThunderOem\thunder_backwnd", "Version", version, RegistryValueKind.String);
							}
							Process.Start("regsvr32", "/s \"" + thunderagentdll + "\"");
							if (Environment.Is64BitOperatingSystem && File.Exists(thunderagent64bit))
							{
								Process.Start("regsvr32", "/s \"" + thunderagent64bit + "\"");
							}
							else
							{
								MessageBox.Show((IWin32Window)null,Strings.This_copy_of_Thunder_supports_32_bit_only);
							}
							break;
						}
					default:
						{
							Web_ext_Message msg = GetMsg();
							DLRequest req = msg.Dispatch();
							DLReply reply = req.Process();
							SendMsg(reply);
							break;
						}
				}
			}
			else
			{
				DMThunder dM = new DMThunder
				{
					Url = "http://baidu.com/index.html",
					PostData = new PostInfo()
				};
				dM.Fire();
				WelcomeDialog dialog = new WelcomeDialog();
				dialog.ShowDialog();
			}
		}