private void button_OK_Click(object sender, EventArgs e) { if (radioButton_external.Checked) { if (comboBox_dm.SelectedItem.ToString().EndsWith("(" + DLAgent.Customized.ToString() + ")")) { RetAgent = DLAgent.Customized; } else { if (method == HttpMethod.POST && comboBox_dm.SelectedItem.ToString() == "Thunder" && MessageBox.Show(this, Strings.Thunder_is_not_capable_with_POST_method, Strings.Warning, MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } else { RetAgent = (DLAgent)comboBox_dm.SelectedItem; } } } else if (radioButton_default.Checked) { RetAgent = DLAgent.Default; } this.DialogResult = DialogResult.OK; this.Close(); }
private void ChainStart(DLAgent agent) { string pipeName = Guid.NewGuid().ToString().Replace("-", string.Empty); PipeSecurity ps = new PipeSecurity(); ps.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.FullControl, System.Security.AccessControl.AccessControlType.Allow)); aPipeServer = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 10, PipeTransmissionMode.Message, PipeOptions.WriteThrough, 1024, 1024, ps); string command = "\"" + Application.ExecutablePath + "\"" + ' ' + "breaked" + ' ' + pipeName; ProcessUtility.CreateProcessBreakFromJob(command); DLTask task = new DLTask { Request = this, Agent = agent }; string sTask = JsonConvert.SerializeObject(task); aPipeServer.WaitForConnection(); BinaryWriter bw = new BinaryWriter(aPipeServer); bw.Write(sTask); if (aPipeServer != null) { aPipeServer.WaitForPipeDrain(); } }
public DLReply(DLAgent a) { switch (a) { case DLAgent.CheckDM: Choice = "CkeckDM"; AddtionInfo = ""; foreach (var dm in DownloadManager.DMList) { if (((IDownloadManager)Activator.CreateInstance(Type.GetType("ThunderCross.DM" + dm), true)).Valid()) { AddtionInfo += (dm + ": " + "Ready\n"); } else { AddtionInfo += (dm + ": " + "Failed\n"); } } break; case DLAgent.Version: Choice = @"Version"; AddtionInfo = typeof(Program).Assembly.GetName().Version.ToString(); break; case DLAgent.Cancel: Choice = @"Canceled"; break; case DLAgent.Default: Choice = @"Default"; break; case DLAgent.EagleGet: case DLAgent.Thunder: Choice = @"External"; break; default: Choice = @"error!!"; break; } }
public DLReply(DLAgent a, bool save = false, string host = null) { switch (a) { case DLAgent.CheckDM: Choice = a.ToString(); AddtionInfo = ""; foreach (var dm in DownloadManager.DMList) { if (((IDownloadManager)Activator.CreateInstance(Type.GetType("ThunderCross.DM" + dm), true)).Valid()) { AddtionInfo += (dm + ": " + Strings.Ready + "\n"); } else { AddtionInfo += (dm + ": " + Strings.Failed + "\n"); } } break; case DLAgent.SelectDM: Choice = a.ToString(); { OpenFileDialog openFile = new OpenFileDialog(); openFile.CheckFileExists = true; openFile.CheckPathExists = true; openFile.DefaultExt = "exe"; openFile.Filter = "Executable files(*.exe) | *.exe"; if (openFile.ShowDialog() == DialogResult.OK) { AddtionInfo = openFile.FileName; } } break; case DLAgent.Version: Choice = a.ToString(); AddtionInfo = typeof(Program).Assembly.GetName().Version.ToString(); break; case DLAgent.Cancel: case DLAgent.Default: Choice = a.ToString(); break; case DLAgent.EagleGet: case DLAgent.Thunder: case DLAgent.Idm: case DLAgent.Customized: Choice = @"External"; break; default: Choice = @"error!!"; break; } if (save && (a == DLAgent.Default || (int)a >= 5)) //if a is an external dm { Save = save; Host = host; } }
private void button_Cancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.RetAgent = DLAgent.Cancel; this.Close(); }
private void button_EagleGet_Click(object sender, EventArgs e) { RetAgent = DLAgent.EagleGet; this.DialogResult = DialogResult.OK; this.Close(); }
private void button_Thunder_Click(object sender, EventArgs e) { RetAgent = DLAgent.Thunder; this.DialogResult = DialogResult.OK; this.Close(); }