/// <summary> /// Gestisce l'azione dell'add button permettendo l'inserimento di una /// nuova categoria /// </summary> private void AddHandler(Object sender, EventArgs eventArgs) { //MessageBox.Show(""+_categoryTree.SelectedNode); //Genero una finestra di dialogo per inserire il parametri della servizio string serviceName = ""; string serviceDescription = ""; string servicePrice = ""; DateRange range; using (ServiceDialog sd = new ServiceDialog("Inserire parametri servizio")) { if (sd.ShowDialog() == DialogResult.OK) { serviceName = sd.NameText; serviceDescription = sd.Description; servicePrice = sd.Price.ToString(); range = new DateRange(sd.Start, sd.End); } else { return; } } double price = Double.Parse(servicePrice); coordinator.AddService(new BasicService(new DatePriceDescriptor(serviceName, serviceDescription, range, price))); _services = coordinator.Services; ServiceChangedHandler(this, EventArgs.Empty); }
/// <summary> /// Launches the DIPS processor using the provided command-line arguments /// </summary> private static void _launch() { string[] args = Environment.GetCommandLineArgs(); if (args.Contains("/interactive")) { if (Environment.UserInteractive) { // Launch the processor with the GUI ServiceDialog dialog = new ServiceDialog(); ServiceViewModel vm = new ServiceViewModel(InternalService.Service); vm.IsInInteractiveMode = true; dialog.DataContext = vm; dialog.ShowDialog(); } } else { _launchWindowsService(); } }
// 添加服务 internal void menuAddService_Click(object sender, EventArgs e) { // 弹出对话框,构建服务 using (ServiceDialog dlg = new ServiceDialog(ServiceDialog.Operation.New)) { if (dlg.ShowDialog() == DialogResult.OK) { var service = new Service(); service.Name = dlg.ServiceName; dcmDocument.Services.Add(service); var node = new TreeNode(service.Name, ImageIndexService, ImageIndexService); node.Tag = service; treeView.Nodes.Add(node); treeView.SelectedNode = node; //选择刚添加的节点 mainForm.ContentChanged = true; } } }
internal void menuEditService_Click(object sender, EventArgs e) { var node = treeView.SelectedNode; if (node != null) { if (node.Tag is Service service) //模式匹配 { using (ServiceDialog dlg = new ServiceDialog(ServiceDialog.Operation.Update)) { dlg.ServiceName = service.Name; if (dlg.ShowDialog() == DialogResult.OK) { service.Name = dlg.ServiceName; node.Text = service.Name; mainForm.ContentChanged = true; } } } } }
public static void Main() { Application.Init(); ServiceDialog dialog = new ServiceDialog("Choose SSH Server", null, Stock.Cancel, ResponseType.Cancel, Stock.Connect, ResponseType.Accept); dialog.BrowseServiceTypes = new string[] { "_ssh._tcp" }; dialog.ResolveServiceEnabled = true; if (dialog.Run() == (int)ResponseType.Accept) { Console.WriteLine("Connecting to {0}:{1}", dialog.Address, dialog.Port); string user = Environment.UserName; foreach (byte[] txtBytes in dialog.TxtData) { string txt = System.Text.Encoding.UTF8.GetString(txtBytes); string[] splitTxt = txt.Split(new char[] { '=' }, 2); if (splitTxt.Length != 2) { continue; } if (splitTxt[0] == "u") { user = splitTxt[1]; } string args = String.Format("gnome-terminal -t {0} -x ssh -p {1} -l {2} {3}", dialog.HostName, dialog.Port, user, dialog.Address.ToString()); Console.WriteLine("Launching: " + args); Process.Start(args); } } }