protected override void RemoveProcess(Message message) { if (message != null) { String data = message.Text; int processID; if (Int32.TryParse(data, out processID)) { ProcessPrototype process = ProcessCollection.FirstOrDefault(x => x.ID == processID); if (process != null) { Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { ProcessCollection.Remove(process); })); } if (SelectedPrototype != null && SelectedPrototype.ID == processID) { SelectedPrototype = null; RefreshProperties(); } } } }
protected override void AddProcess(Message message) { if (message != null) { String[] dataArray = message.Text.Split(';'); int processID; if (dataArray.Count() >= 2 && Int32.TryParse(dataArray[0], out processID)) { ProcessPrototype process = ProcessCollection.FirstOrDefault(x => x.ID == processID); if (process == null) { process = new ProcessPrototype(processID, dataArray[1]); Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { ProcessCollection.Add(process); })); Connection.Send(Connection.Socket, new Message(MessageTypes.REQUEST_NEXT_PROCESS, process.ID.ToString())); } } } }
private void SetCurrentTask(ProcessTask task) { var process = ProcessCollection.FirstOrDefault(d => d.Name == task.Name); if (process == null) { return; } var configDocument = (process as IDictionarySerializable).DictSerialize(); task.ProcessToDo = configDocument; XLogSys.Print.Info("已经成功覆盖任务"); }
protected override void AddProcessIcon(Message message) { if (message != null) { int processID; if (Int32.TryParse(Utils.GetTextBetween(message.Text, ConnectionService.PROCESS_START_DELIMITER, ConnectionService.PROCESS_END_DELIMITER), out processID)) { String imageText = message.Text.Substring(0, message.Text.IndexOf(ConnectionService.PROCESS_START_DELIMITER)); Bitmap bitmap = Utils.Base64StringToBitmap(imageText); if (bitmap != null) { ProcessPrototype prototype = null; prototype = ProcessCollection.FirstOrDefault(x => x.ID == processID); if (prototype == null) { prototype = ProcessToStartCollection.FirstOrDefault(x => x.ID == processID); } if (prototype != null) { ImageSource imageSource = Utils.BitmapToImageSource(bitmap); bitmap.Dispose(); prototype.AddIcon(imageSource); } Connection.Send(Connection.Socket, new Message(MessageTypes.REQUEST_NEXT_ICON, prototype.ID.ToString())); } } } }