void client_getHostInfosCompleted(object sender, ProcessService.getHostInfosCompletedEventArgs e) { hostinfos = e.Result; foreach (SLProcessController.ProcessService.HostInfo hi in e.Result) { ProcessService.ServiceSoapClient client = new ProcessService.ServiceSoapClient(); AccordionHeader header=new AccordionHeader(){ DataContext=hi }; header.OnChangeHostAllState += new OnHostChangeAllStateHandler(header_OnChangeHostAllState); AccordionItem item = new AccordionItem() { Header = header, Content = new ListBox() { Width = this.ActualWidth } }; item.Tag = hi; accordion.Items.Add(item); client.GetProcessInfoCompleted += (o, a) => { loadHostCnt++; if (e.Error != null) { // MessageBox.Show(e.Error.Message); return; } if (a.Result != null) foreach (ProcessService.ProcessInfo info in a.Result) { ProcessInfoCtl ctl = new ProcessInfoCtl(); ctl.Tag=info; ctl.Name = info.ProcessName; dict.Add(info.ProcessName, ctl); if (info.ProcessName.ToUpper() == "HOST") { ctl.SetProgressMaxValue(10000); ctl.ProgressBar.SetBinding(ProgressBar.ValueProperty, new System.Windows.Data.Binding() { Path =new PropertyPath( "DataQueueCnt"), Converter = new HostQueueCntProgressConverter() }); // ctl.ProgressBar.GetBindingExpression(ProgressBar.ValueProperty).ParentBinding.Converter = new HostQueueCntProgressConverter(); } else ctl.ProgressBar.SetBinding(ProgressBar.ValueProperty, new System.Windows.Data.Binding() { Path = new PropertyPath("DataQueueCnt"), Converter = new MFCCQueueCntProcessConverter() }); // ctl.ProgressBar.GetBindingExpression(ProgressBar.ValueProperty).ParentBinding.Converter = new MFCCQueueCntProcessConverter(); } if (loadHostCnt == hostinfos.Count) { for (int i = 0; i < dict.Count; i++) { ProcessInfoCtl ctl; ctl= dict.Values.ToArray<ProcessInfoCtl>()[i]; ProcessInfo info = ctl.Tag as ProcessInfo; foreach (AccordionItem aitem in accordion.Items) { //if(aitem.Content==null) // aitem.Content = new ListBox() { Width = this.ActualWidth }; if ((aitem.Tag as HostInfo).IP == info.HostIP) { (aitem.Content as ListBox).Items.Add(ctl); ctl.OnChangeState += new OnChangeStateHandler(ctl_OnChangeState); ctl.setDataContext(info); break; } } } tmr30sec.Start(); } // item.IsEnabled = true; // lock(client) // System.Threading.Monitor.PulseAll(client); }; client.GetProcessInfoAsync(hi.IP); this.accordion.SelectedIndex = 1; } }
void ctl_OnChangeState(ProcessInfoCtl ctl,ProcessInfo info, bool bPlay) { //throw new NotImplementedException(); if (!bPlay) { ConfirmChild child = new ConfirmChild("TCS", "確定要停止" + info.ProcessName + "?"); child.Closed += (s, a) => { if (child.DialogResult == true) { ProcessService.ServiceSoapClient client = new ServiceSoapClient(); client.ChangeProcessStateAsync(info.HostIP, info.ProcessName, false); VisualStateManager.GoToState(ctl, "Stop", true); } }; child.Show(); } else { new ServiceSoapClient().ChangeProcessStateAsync(info.HostIP, info.ProcessName, true); VisualStateManager.GoToState(ctl, "Normal",true); } }