void saveRingtoneTask_Completed(object sender, TaskEventArgs e) { //string chooserResult = ""; if (e.Error != null) chooserResult.Text = e.Error.Message; else if (e.TaskResult == TaskResult.Cancel) chooserResult.Text = "user canceled"; else if (e.TaskResult == TaskResult.None) chooserResult.Text = "no result"; else if (e.TaskResult == TaskResult.OK) chooserResult.Text = "ok"; System.Diagnostics.Debug.WriteLine(chooserResult.Text); }
void taskTree_OpenTaskConfigFileEvent(object sender, TaskEventArgs e) { try { //get the top form MainForm mainform = this.TopLevelControl as MainForm; if (mainform != null) mainform.OpenTaskConfigFile(e.Task); } catch (Exception ex) { Program.ShowMessageBox("FrmTaskManager", ex); } }
private void TaskStoppedHandler(object sender, TaskEventArgs<HttpFileDownloadTask> e) { lock (SyncRoot) { if (e.Task.IsCompleted) { tasks.Remove (e.Task); } } }
private void OnTaskEdited(object sender, TaskEventArgs e) { lock (tasksLock) for (int i = 0; i != scheduledTasks.Count; ++i) for (int j = 0; j < scheduledTasks.Values[i].Count; ) { Task currentTask = scheduledTasks.Values[i][j]; if (currentTask == e.Task) scheduledTasks.Values[i].RemoveAt(j); else j++; } if (e.Task.Schedule is RecurringSchedule) ScheduleTask(e.Task); }
// However, if you pick a task in the colonist manager screen, this // shuts down the whole building UI. You can't place two tasks in a building // anyway so this is probably what the player would want. void OnTaskStarted(object sender, TaskEventArgs args) { CloseBuildingUI(); }
public static void FireTaskToggleEvent (object sender, TaskEventArgs e) { var handler = TaskToggled; if (handler != null) handler (sender, e); }
void TaskAdded (object sender, TaskEventArgs e) { AddTasks (e.Tasks); }
protected virtual void OnTaskToggled (TaskEventArgs e) { EventHandler<TaskEventArgs> handler = this.TaskToggled; if (handler != null) handler (this, e); }
protected virtual void OnTaskCompleted(TaskEventArgs args) { //TODO: (jmd 2015-09-30) Consider wrapping in try catch. They can force the thread to close the app. TaskCompleted?.Invoke(this, args); }
public void cancelPrintInfo(TaskEventArgs e) { print("取消任务" + e.taskID); }
public void Handler(TaskEventArgs arg) { Console.WriteLine("Task \"" + arg.desc + "\" is due (" + arg.toDueTime + ")"); }
public void GetPrintInfo(TaskEventArgs e) { print("接受任务" + e.taskID); }
public void rewardPrintInfo(TaskEventArgs e) { print("奖励物品" + e.id + "数量" + e.amount); }
public void AddWarnListener(TaskEventArgs listener) { warnEventListeners += listener; }
private void TaskAssociatedHandler(object sender, TaskEventArgs <HttpFileDownloadTask> e) { dg.Execute(); }
/// <summary> /// Start the task routine and observe the result of the previous task routine /// </summary> /// <param name="routine"></param> /// <param name="token"></param> /// <param name="cancelPrevious"></param> /// <param name="throwImmediately"></param> public Task <T> StartAsync( Func <CancellationToken, Task <T> > routine, CancellationToken token, bool cancelPrevious = true, bool throwImmediately = true) { Task <T> previousTask = null; // pending instance CancellationTokenSource previousCts = null; // pending instance CTS CancellationTokenSource thisCts = CancellationTokenSource.CreateLinkedTokenSource(token); TaskCompletionSource <T> thisTcs = new TaskCompletionSource <T>(); // this task CancellationToken thisToken; // this task's cancellation Token Task <T> routineTask = null; // as returned by routine lock (_lock) { // remember the _currentTask as previousTask previousTask = _currentTask; previousCts = _currentCts; thisToken = thisCts.Token; // set the new _currentTask _currentTask = thisTcs.Task; _currentCts = thisCts; } Action startAsync = async() => { // because startAsync is "async void" method, // any exception not handled inside it // will be immediately thrown on the current synchronization context, // more details: http://stackoverflow.com/a/22395161/1768303 // run and await this task try { // await the previous task instance if (previousTask != null) { if (cancelPrevious) { previousCts.Cancel(); } try { await previousTask; } catch (OperationCanceledException) { // ignore previous cancellations } } thisToken.ThrowIfCancellationRequested(); routineTask = routine(thisToken); await routineTask; } catch (Exception ex) { // ignore cancellation if (ex is OperationCanceledException) { System.Diagnostics.Debug.Print("Task cancelled, id={0}", thisTcs.Task.Id); thisTcs.SetCanceled(); return; } // fire TaskFailing System.Diagnostics.Debug.Print("Task failing, id={0}", thisTcs.Task.Id); if (this.TaskFailing != null) { var args = new TaskEventArgs(thisTcs.Task, ex); this.TaskFailing(this, args); if (args.Handled) { // exception handled // make thisTcs cancelled rather than faulted thisTcs.SetCanceled(); return; } } // exception unhandled thisTcs.SetException(ex); if (throwImmediately) { throw; // rethrow on the current synchronization context } // exception should be observed via CurrentTask.Exception return; } // success, fire TaskSucceeded System.Diagnostics.Debug.Print("Task succeded, id={0}", thisTcs.Task.Id); thisTcs.SetResult(routineTask.Result); if (this.TaskSucceeded != null) { this.TaskSucceeded(this, new TaskEventArgs(thisTcs.Task)); } }; startAsync(); return(thisTcs.Task); }
private void TaskAdded(object sender, TaskEventArgs e) { if (InvokeRequired) { Invoke((EventHandler<TaskEventArgs>)TaskAdded, sender, e); return; } MainForm parent = (MainForm)FindForm(); if (parent != null && (parent.WindowState == FormWindowState.Minimized || !parent.Visible)) { parent.ShowNotificationBalloon(S._("New task added"), S._("{0} " + "has just been added to the list of tasks.", e.Task.UIText), ToolTipIcon.Info); } DisplayTask(e.Task); }
private void ValidateScriptAdded(object sender, TaskEventArgs <TaskScript> e) { Assert.Equal(SqlTaskStatus.Succeeded, e.TaskData.Status); Assert.Equal(SampleScript, e.TaskData.Script); }
private void saveEmailTask_Completed(object sender, TaskEventArgs e) { if (e.TaskResult == TaskResult.OK) { saveEmailButton.Visibility = Visibility.Collapsed; } }
/// <summary> /// Method used to handle the event. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The task information.</param> private void OnDownloadCompleted(object sender, TaskEventArgs e) { if (e.Task == null) { return; } string fileLocation = Path.Combine(e.Task.DownloadFilesBase, e.Task.DownloadItem.File.LocalName); string finalLocation = Path.Combine(e.Task.DownloadItem.TargetFolder, e.Task.DownloadItem.File.LocalName); _log.InfoFormat("Finished downloading enclosure '{0}' from item '{1}' in feed '{2}' to {3}", e.Task.DownloadItem.Enclosure.Url, e.Task.DownloadItem.OwnerItemId, e.Task.DownloadItem.OwnerFeedId, finalLocation); // We have a UI for managing enclosures we'll need to keep the task around ! //DownloadRegistryManager.Current.UnRegisterTask(e.Task); try { /* * Add Zone.Identifier to File to indicate that the file was downloaded from the Web * See http://geekswithblogs.net/ssimakov/archive/2004/08/17/9805.aspx for more details */ try { var FS = new FileStreams(fileLocation); //Remove Zone.Identifier if it already exists since we can't trust it //Not sure if this can happen. int i = FS.IndexOf("Zone.Identifier"); if (i != -1) { FS.Remove("Zone.Identifier"); } FS.Add("Zone.Identifier"); using (FileStream fs = FS["Zone.Identifier"].Open(FileMode.OpenOrCreate, FileAccess.Write)) { var writer = new StreamWriter(fs); writer.WriteLine("[ZoneTransfer]"); writer.WriteLine("ZoneId=3"); writer.Flush(); } } catch (Exception ex) { _log.ErrorFormat("Failed to assign Internet (Download) Zone to {0}: {1}", fileLocation, ex.Message); } if (!Directory.Exists(e.Task.DownloadItem.TargetFolder)) { Directory.CreateDirectory(e.Task.DownloadItem.TargetFolder); } /* Move file to TargetFolder from temporary download location*/ FileHelper.MoveFile(fileLocation, finalLocation, MoveFileFlag.CopyAllowed | MoveFileFlag.ReplaceExisting); e.Task.FileName = finalLocation; /* Initiate callback to waiting callers */ if (DownloadCompleted != null) { DownloadCompleted(this, new DownloadItemEventArgs(e.Task.DownloadItem)); } var downloader = sender as IDownloader; if (downloader != null) { Release(downloader); } } catch (Exception error) { OnDownloadError(this, new DownloadTaskErrorEventArgs(e.Task, error)); return; } e.Task.State = DownloadTaskState.Downloaded; DownloadRegistryManager.Current.UpdateTask(e.Task); }
void TaskServiceAdded(object sender, TaskEventArgs e) { if (e.Task.TaskType == TaskType.Comment) { AddItem(e.Task); } }
public void scriptHandler_taskEventHandler(object sender, TaskEventArgs e) { onScriptUpdate(e); }
private void saveRingtoneChooser_Completed(object sender, TaskEventArgs e) { switch (e.TaskResult) { //Logic for when the ringtone was saved successfully case TaskResult.OK: // MessageBox.Show("Ringtone saved."); break; //Logic for when the task was cancelled by the user case TaskResult.Cancel: // MessageBox.Show("Save cancelled."); break; //Logic for when the ringtone could not be saved case TaskResult.None: MessageBox.Show("Ringtone could not be saved."); break; } }
public void FinishTask(TaskEventArgs e) { finishEvent(this, e); }
void GeneratedTaskRemoved (object sender, TaskEventArgs e) { foreach (Task t in e.Tasks) RemoveGeneratedTask (t); }
private SimpleMarkerSymbol GetPointSymbol(XmlNode data) { XmlDocument xd = new XmlDocument(); xd.LoadXml(data.OuterXml); SimpleMarkerSymbol sms = new SimpleMarkerSymbol(); try { Color c = ColorTranslator.FromHtml(TaskEventArgs.GetString(xd, "//LColor")); sms.Color = System.Windows.Media.Color.FromArgb(255, 255, 255, 255); sms.Size = 5; sms.Outline = new SimpleLineSymbol { Color = System.Windows.Media.Color.FromArgb((byte)(double.Parse(TaskEventArgs.GetString(xd, "//Transpatecy")) * 255), c.R, c.G, c.B) , Style = SimpleLineStyle.Solid, Width = sms.Size }; } catch (Exception ee) { LogUtil.Error(GetType(), ee); } return(sms); }
private void OnTaskAdded(object sender, TaskEventArgs e) { e.Task.TaskEdited += OnTaskEdited; }
private Graphic GetGraphic(XmlNode data) { var xd = new XmlDocument(); var g = new Graphic(); try { xd.LoadXml(data.OuterXml); g.Geometry = new MapPoint(TaskEventArgs.GetDouble(xd, "//LON"), TaskEventArgs.GetDouble(xd, "//LAT")); g.Attributes["ID"] = TaskEventArgs.GetGuid(xd, "//Guid"); g.Attributes["Lon"] = TaskEventArgs.GetDouble(xd, "//LON"); g.Attributes["Lat"] = TaskEventArgs.GetDouble(xd, "//LAT"); g.Attributes["Label"] = TaskEventArgs.GetString(xd, "//Label"); g.Attributes["Time"] = TaskEventArgs.GetTime(xd, "//Time").ToString(); g.Attributes["Speed"] = TaskEventArgs.GetDouble(xd, "//Speed"); g.Attributes["Status"] = TaskEventArgs.GetString(xd, "//Status"); g.Attributes["Icon"] = TaskEventArgs.GetString(xd, "//Icon"); g.Attributes["Remark"] = TaskEventArgs.GetString(xd, "//Remark"); g.Attributes["Angle"] = TaskEventArgs.GetString(xd, "//Angle"); } catch (Exception ee) { LogUtil.Error(GetType(), ee); g = null; } return(g); }
void HandleErrorListPadTaskToggled (object sender, TaskEventArgs e) { this.TextEditor.QueueDraw (); }
private void GetIcon(XmlNode data) { XmlDocument xd = new XmlDocument(); xd.LoadXml(data.OuterXml); _startIcon = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Asset\\Icon\\" + TaskEventArgs.GetString(xd, "//StartIcon") + ".png"); _icon = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Asset\\Icon\\" + TaskEventArgs.GetString(xd, "//Icon") + ".png"); }
public void finishPrintInfo(System.Object sender, TaskEventArgs e) { Debug.Log("完成任务" + e.teskID); }
private SimpleLineSymbol GetTrackSymbol(XmlNode data) { XmlDocument xd = new XmlDocument(); xd.LoadXml(data.OuterXml); var sls = new SimpleLineSymbol(); try { Color c; switch (TaskEventArgs.GetString(xd, "//LStyle")) { case "solid": sls = new SimpleLineSymbol(); c = ColorTranslator.FromHtml(TaskEventArgs.GetString(xd, "//LColor")); sls.Color = System.Windows.Media.Color.FromArgb((byte)(double.Parse(TaskEventArgs.GetString(xd, "//Transpatecy")) * 255), c.R, c.G, c.B); sls.Width = double.Parse(TaskEventArgs.GetString(xd, "//LWight")); break; case "dash": sls = new SimpleLineSymbol { Style = SimpleLineStyle.Dash }; c = ColorTranslator.FromHtml(TaskEventArgs.GetString(xd, "//LColor")); sls.Color = System.Windows.Media.Color.FromArgb((byte)(double.Parse(TaskEventArgs.GetString(xd, "//Transpatecy")) * 255), c.R, c.G, c.B); sls.Width = double.Parse(TaskEventArgs.GetString(xd, "//LWight")); break; default: sls = new SimpleLineSymbol(); c = ColorTranslator.FromHtml(TaskEventArgs.GetString(xd, "//LColor")); sls.Color = System.Windows.Media.Color.FromArgb((byte)(double.Parse(TaskEventArgs.GetString(xd, "//Transpatecy")) * 255), c.R, c.G, c.B); sls.Width = double.Parse(TaskEventArgs.GetString(xd, "//LWight")); break; } } catch (Exception ee) { LogUtil.Error(GetType(), ee); } return(sls); }
void UserTasksChanged (object sender, TaskEventArgs e) { if (updating) return; if (view.IsRealized) view.ScrollToPoint (0, 0); store.Clear (); foreach (TaskListEntry task in TaskService.UserTasks) { store.AppendValues (GettextCatalog.GetString (Enum.GetName (typeof (TaskPriority), task.Priority)), task.Completed, task.Description, task, GetColorByPriority (task.Priority), task.Completed ? (int)Pango.Weight.Light : (int)Pango.Weight.Bold); } ValidateButtons (); }
void OnGUI() { if (GUILayout.Button("接受任务Task1")) { TaskManager.Instance.GetTask("Task1"); } if (GUILayout.Button("接受任务Task2")) { TaskManager.Instance.GetTask("Task2"); } if (GUILayout.Button("接受任务Task3")) { TaskManager.Instance.GetTask("Task3"); } if (GUILayout.Button("打怪Enemy1")) { TaskEventArgs e = new TaskEventArgs(); e.id = "Enemy1"; e.amount = 1; MesManager.Instance.Check(e); } if (GUILayout.Button("打怪Enemy2")) { TaskEventArgs e = new TaskEventArgs(); e.id = "Enemy2"; e.amount = 1; MesManager.Instance.Check(e); } if (GUILayout.Button("获取物体Item1")) { TaskEventArgs e = new TaskEventArgs(); e.id = "Item1"; e.amount = 1; MesManager.Instance.Check(e); } if (GUILayout.Button("获取物体Item2")) { TaskEventArgs e = new TaskEventArgs(); e.id = "Item2"; e.amount = 1; MesManager.Instance.Check(e); } if (GUILayout.Button("丢弃物体Item1")) { TaskEventArgs e = new TaskEventArgs(); e.id = "Item1"; e.amount = -1; MesManager.Instance.Check(e); } if (GUILayout.Button("丢弃物体Item2")) { TaskEventArgs e = new TaskEventArgs(); e.id = "Item2"; e.amount = -1; MesManager.Instance.Check(e); } if (GUILayout.Button("打开任务面板")) { taskPanel.SetActive(true); } if (GUILayout.Button("关闭任务面板")) { taskPanel.SetActive(false); } }
private void TaskDeleted(object sender, TaskEventArgs e) { if (InvokeRequired) { Invoke((EventHandler<TaskEventArgs>)TaskDeleted, sender, e); return; } foreach (ListViewItem item in scheduler.Items) if (((Task)item.Tag) == e.Task) { scheduler.Items.Remove(item); break; } PositionProgressBar(); }
//检查事件 public void Check(TaskEventArgs e) { checkEvent(this, e); }
void value_OnStatusChange(object sender, TaskEventArgs e) { UpdatedTask.Raise(sender, e); }
private void MakeRingtone(object sender, TaskEventArgs e) { MP3File Test = new MP3File(); Test.Initialize("RINGIFY_RINGTONE.mp3"); if (e.TaskResult == TaskResult.OK) { MessageBox.Show("Your Ringtone was created!\n\nThe Ringtone is now listed in\n[Settings] -> [Ringtones + Sounds]\n under the Rintones selector."); Debugger.Trace("Save Completed"); } else if (e.TaskResult == TaskResult.Cancel) { Debugger.Trace("Save Cancelled"); if (e.Error != null) { MessageBox.Show(e.Error.Message); //TextBlock_Error.Text = e.Error.Message; Debugger.Trace(e.Error); Debugger.Trace("FILE_SIZE [" + Test.Size + "]"); } } else if (e.TaskResult == TaskResult.None) { TextBlock_Error.Text = "None!"; Debugger.Trace("None"); if (e.Error != null) { TextBlock_Error.Text = e.Error.Message; Debugger.Trace(e.Error); } } TextBlock_Error.Text += "FILE_SIZE [" + Test.Size + "]"; }
void UpdateTasks (object sender, TaskEventArgs e) { Task[] tasks = TaskService.Errors.GetFileTasks (ContentName); if (tasks == null) return; DisposeErrorMarkers (); if (IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.Never) return; widget.Document.BeginAtomicUndo (); foreach (Task task in tasks) { if (task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning) { if (IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.ForErrors && task.Severity == TaskSeverity.Warning) continue; LineSegment lineSegment = widget.Document.GetLine (task.Line - 1); if (lineSegment == null) continue; var marker = currentErrorMarkers.FirstOrDefault (m => m.LineSegment == lineSegment); if (marker != null) { marker.AddError (task.Severity == TaskSeverity.Error, task.Description); continue; } MessageBubbleTextMarker errorTextMarker = new MessageBubbleTextMarker (widget.TextEditor, task, lineSegment, task.Severity == TaskSeverity.Error, task.Description); currentErrorMarkers.Add (errorTextMarker); errorTextMarker.IsExpanded = !IdeApp.Preferences.DefaultHideMessageBubbles; widget.Document.AddMarker (lineSegment, errorTextMarker, false); } } widget.Document.EndAtomicUndo (); widget.TextEditor.QueueDraw (); }
void TaskServiceAdded(object sender, TaskEventArgs e) { if (TaskService.InUpdate) return; AddTask(e.Task); MenuService.UpdateText(toolBar.Items); }
void TaskServiceRemoved(object sender, TaskEventArgs e) { if (e.Task.TaskType == TaskType.Comment) { tasks.Remove(e.Task); } }
/// <summary> /// 初始化任务池事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void TaskPoolBuilder_OnInitTaskPoolEvent(object sender, TaskEventArgs e) { OnInit(e.msg, e.ex); }
void OnTaskDeleted(object sender, TaskEventArgs e) { e.Task.TaskStarted -= OnTaskProcessing; e.Task.TaskFinished -= OnTaskProcessed; }
void mt_TaskCompleted(object sender, TaskEventArgs e) { StringBuilder sb = new StringBuilder(); if (e is MensurationPointEventArgs) { MensurationPointResult result = (e as MensurationPointEventArgs).Result; if (result != null && result.Point != null) { sb.Append(result.Point); sb.Append("\n"); } } else if (e is MensurationHeightEventArgs) { MensurationHeightResult result = (e as MensurationHeightEventArgs).Result; if (result != null) { if (result.Height != null) { sb.Append("Height\n"); sb.AppendFormat("Value:\t\t{0}\n", result.Height.Value); sb.AppendFormat("Display Value:\t{0}\n", result.Height.DisplayValue); sb.AppendFormat("Uncertainty:\t{0}\n", result.Height.Uncertainty); sb.AppendFormat("Unit:\t\t{0}\n", result.Height.LinearUnit); sb.Append("\n"); } } } else if (e is MensurationLengthEventArgs) { MensurationLengthResult result = (e as MensurationLengthEventArgs).Result; if (result != null) { if (result.Distance != null) { sb.Append("Distance\n"); sb.AppendFormat("Value:\t\t{0}\n", result.Distance.Value); sb.AppendFormat("Display Value:\t{0}\n", result.Distance.DisplayValue); sb.AppendFormat("Uncertainty:\t{0}\n", result.Distance.Uncertainty); sb.AppendFormat("Unit:\t\t{0}\n", result.Distance.LinearUnit); sb.Append("\n"); } if (result.AzimuthAngle != null) { sb.Append("Azimuth Angle\n"); sb.AppendFormat("Value:\t\t{0}\n", result.AzimuthAngle.Value); sb.AppendFormat("Display Value:\t{0}\n", result.AzimuthAngle.DisplayValue); sb.AppendFormat("Uncertainty:\t{0}\n", result.AzimuthAngle.Uncertainty); sb.AppendFormat("Unit:\t\t{0}\n", result.AzimuthAngle.AngularUnit); sb.Append("\n"); } if (result.ElevationAngle != null) { sb.Append("Elevation Angle\n"); sb.AppendFormat("Value:\t\t{0}\n", result.ElevationAngle.Value); sb.AppendFormat("Display Value:\t{0}\n", result.ElevationAngle.DisplayValue); sb.AppendFormat("Uncertainty:\t{0}\n", result.ElevationAngle.Uncertainty); sb.AppendFormat("Unit:\t\t{0}\n", result.ElevationAngle.AngularUnit); sb.Append("\n"); } } } else if (e is MensurationAreaEventArgs) { MensurationAreaResult result = (e as MensurationAreaEventArgs).Result; if (result != null) { if (result.Area != null) { sb.Append("Area\n"); sb.AppendFormat("Value:\t\t{0}\n", result.Area.Value); sb.AppendFormat("Display Value:\t{0}\n", result.Area.DisplayValue); sb.AppendFormat("Uncertainty:\t{0}\n", result.Area.Uncertainty); sb.AppendFormat("Unit:\t\t{0}\n", result.Area.AreaUnit); sb.Append("\n"); } if (result.Perimeter != null) { sb.Append("Perimeter\n"); sb.AppendFormat("Value:\t\t{0}\n", result.Perimeter.Value); sb.AppendFormat("Display Value:\t{0}\n", result.Perimeter.DisplayValue); sb.AppendFormat("Uncertainty:\t{0}\n", result.Perimeter.Uncertainty); sb.AppendFormat("Unit:\t\t{0}\n", result.Perimeter.LinearUnit); sb.Append("\n"); } } } MessageBox.Show(sb.ToString()); }
void TaskServiceRemoved(object sender, TaskEventArgs e) { if (TaskService.InUpdate) return; errors.Remove(e.Task); MenuService.UpdateText(toolBar.Items); }
private void Task_Completed(BackgroundTaskRunner <IBackgroundTask> sender, TaskEventArgs <IBackgroundTask> e) { _logger.Info <ScheduledLoggerComponent>("Scheduled Logger run finished"); }
void UpdateTasks (object sender, TaskEventArgs e) { TaskListEntry [] tasks = TaskService.Errors.GetFileTasks (ContentName); if (tasks == null) return; DisposeErrorMarkers (); // disposes messageBubbleCache as well. if (IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.Never) return; messageBubbleCache = new MessageBubbleCache (widget.TextEditor); CancelMessageBubbleUpdate (); var token = messageBubbleUpdateSource; Task.Run (delegate { var errorMarkers = new List<MessageBubbleTextMarker> (); foreach (TaskListEntry task in tasks) { if (token.IsCancellationRequested) return null; if (task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning) { if (IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.ForErrors && task.Severity == TaskSeverity.Warning) continue; var errorTextMarker = new MessageBubbleTextMarker (messageBubbleCache, task, task.Severity == TaskSeverity.Error, task.Description); errorMarkers.Add (errorTextMarker); errorTextMarker.IsVisible = !IdeApp.Preferences.DefaultHideMessageBubbles; } } return errorMarkers; }).ContinueWith (t => { if (token.IsCancellationRequested) return; Application.Invoke (delegate { if (token.IsCancellationRequested) return; var newErrorMarkers = new List<MessageBubbleTextMarker> (); foreach (var marker in t.Result) { if (token.IsCancellationRequested) return; var lineSegment = widget.Document.GetLine (marker.Task.Line); if (lineSegment == null) continue; var oldMarker = lineSegment.Markers.OfType<MessageBubbleTextMarker> ().FirstOrDefault (); if (oldMarker != null) { oldMarker.AddError (marker.Task, marker.Task.Severity == TaskSeverity.Error, marker.Task.Description); } else { marker.LineSegment = lineSegment; widget.Document.AddMarker (lineSegment, marker, false); newErrorMarkers.Add (marker); } } this.currentErrorMarkers = newErrorMarkers; }); }); }
private void OnReceiveEvent(object sender, TaskEventArgs args) { _eventArgs = args; }
void GeneratedTaskAdded (object sender, TaskEventArgs e) { foreach (Task t in e.Tasks) AddGeneratedTask (t); }
void OnAdded(object sender, TaskEventArgs e) { AddTask(e.Task, true); }
void TaskChanged (object sender, TaskEventArgs e) { this.view.QueueDraw (); }
/// <summary> /// 接受消息后的回调函数 /// </summary> void OnTaskStep(int eventTypeId, TaskEventArgs e) { }
private void EraseFilesystemObject(Task task, FileSystemObjectTarget target) { long dataTotal = 0; List<string> paths = target.GetPaths(out dataTotal); ErasureMethod method = target.Method; TaskEventArgs eventArgs = new TaskEventArgs(task); SteppedProgressManager progress = new SteppedProgressManager(); target.Progress = progress; task.Progress.Steps.Add(new SteppedProgressManager.Step(progress, 1.0f / task.Targets.Count)); for (int i = 0; i < paths.Count; ++i) { ProgressManager step = new ProgressManager(); progress.Steps.Add(new SteppedProgressManager.Step(step, 1.0f / paths.Count, S._("Erasing files..."))); task.OnProgressChanged(target, new ProgressChangedEventArgs(step, new TaskProgressChangedEventArgs(paths[i], 0, method.Passes))); StreamInfo info = new StreamInfo(paths[i]); FileSystem fsManager = FileSystemManager.Get( VolumeInfo.FromMountpoint(info.DirectoryName)); if (!info.Exists) { task.Log.LastSessionEntries.Add(new LogEntry(S._("The file {0} was not erased " + "as the file does not exist.", paths[i]), LogLevel.Notice)); continue; } bool isReadOnly = false; try { if (isReadOnly = info.IsReadOnly) info.IsReadOnly = false; if ((info.Attributes & FileAttributes.Compressed) != 0 || (info.Attributes & FileAttributes.Encrypted) != 0 || (info.Attributes & FileAttributes.SparseFile) != 0) { task.Log.LastSessionEntries.Add(new LogEntry(S._("The file {0} could " + "not be erased because the file was either compressed, encrypted or " + "a sparse file.", info.FullName), LogLevel.Error)); } fsManager.EraseFileSystemObject(info, method, delegate(long lastWritten, long totalData, int currentPass) { if (currentTask.Canceled) throw new OperationCanceledException(S._("The task was cancelled.")); step.Completed += lastWritten; step.Total = totalData; task.OnProgressChanged(target, new ProgressChangedEventArgs(step, new TaskProgressChangedEventArgs(info.FullName, currentPass, method.Passes))); }); FileInfo fileInfo = info.File; if (fileInfo != null) fsManager.DeleteFile(fileInfo); step.Completed = step.Total = 1; } catch (UnauthorizedAccessException) { task.Log.LastSessionEntries.Add(new LogEntry(S._("The file {0} could not " + "be erased because the file's permissions prevent access to the file.", info.FullName), LogLevel.Error)); } catch (FileLoadException) { if (!ManagerLibrary.Settings.ForceUnlockLockedFiles) throw; List<System.Diagnostics.Process> processes = new List<System.Diagnostics.Process>(); foreach (OpenHandle handle in OpenHandle.Items) if (handle.Path == paths[i]) processes.Add(System.Diagnostics.Process.GetProcessById(handle.ProcessId)); StringBuilder processStr = new StringBuilder(); foreach (System.Diagnostics.Process process in processes) processStr.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "{0}, ", process.MainModule.FileName); task.Log.LastSessionEntries.Add(new LogEntry(S._( "Could not force closure of file \"{0}\" (locked by {1})", paths[i], processStr.ToString().Remove(processStr.Length - 2)), LogLevel.Error)); } finally { if (isReadOnly && info.Exists && !info.IsReadOnly) info.IsReadOnly = isReadOnly; } } if (target is FolderTarget) { ProgressManager step = new ProgressManager(); progress.Steps.Add(new SteppedProgressManager.Step(step, 0.0f, S._("Removing folders..."))); FolderTarget fldr = (FolderTarget)target; FileSystem fsManager = FileSystemManager.Get(VolumeInfo.FromMountpoint(fldr.Path)); Action<DirectoryInfo> eraseEmptySubFolders = null; eraseEmptySubFolders = delegate(DirectoryInfo info) { foreach (DirectoryInfo subDir in info.GetDirectories()) eraseEmptySubFolders(subDir); task.OnProgressChanged(target, new ProgressChangedEventArgs(step, new TaskProgressChangedEventArgs(info.FullName, 0, 0))); FileSystemInfo[] files = info.GetFileSystemInfos(); if (files.Length == 0) fsManager.DeleteFolder(info); }; eraseEmptySubFolders(new DirectoryInfo(fldr.Path)); if (fldr.DeleteIfEmpty) { DirectoryInfo info = new DirectoryInfo(fldr.Path); task.OnProgressChanged(target, new ProgressChangedEventArgs(step, new TaskProgressChangedEventArgs(info.FullName, 0, 0))); bool isVolumeRoot = info.Parent == null; foreach (VolumeInfo volume in VolumeInfo.Volumes) foreach (string mountPoint in volume.MountPoints) if (info.FullName == mountPoint) isVolumeRoot = true; if (!isVolumeRoot && info.Exists && info.GetFiles("*", SearchOption.AllDirectories).Length == 0) fsManager.DeleteFolder(info); } } if (target is RecycleBinTarget) { ProgressManager step = new ProgressManager(); progress.Steps.Add(new SteppedProgressManager.Step(step, 0.0f, S._("Emptying recycle bin..."))); task.OnProgressChanged(target, new ProgressChangedEventArgs(step, new TaskProgressChangedEventArgs(string.Empty, 0, 0))); ShellApi.EmptyRecycleBin(EmptyRecycleBinOptions.NoConfirmation | EmptyRecycleBinOptions.NoProgressUI | EmptyRecycleBinOptions.NoSound); } target.Progress = null; }
void TaskChanged(object sender, TaskEventArgs e) { this.view.QueueDraw(); }
private void OnTaskDeleted(object sender, TaskEventArgs e) { e.Task.TaskEdited -= OnTaskEdited; }
void TaskAdded(object sender, TaskEventArgs e) { AddTasks(e.Tasks); }
void HandleTaskServiceJumpedToTask (object sender, TaskEventArgs e) { var task = e.Tasks != null ? e.Tasks.FirstOrDefault () : null; var doc = Document; if (task == null || doc == null || task.FileName != doc.FileName || this.TextEditor == null) return; var lineSegment = doc.GetLine (task.Line); if (lineSegment == null) return; var marker = (MessageBubbleTextMarker)lineSegment.Markers.FirstOrDefault (m => m is MessageBubbleTextMarker); if (marker == null) return; marker.SetPrimaryError (task.Description); if (TextEditor != null && TextEditor.IsComposited) { if (messageBubbleHighlightPopupWindow != null) messageBubbleHighlightPopupWindow.Destroy (); messageBubbleHighlightPopupWindow = new MessageBubbleHighlightPopupWindow (this, marker); messageBubbleHighlightPopupWindow.Destroyed += delegate { messageBubbleHighlightPopupWindow = null; }; messageBubbleHighlightPopupWindow.Popup (); } }
public void getPrintInfo(System.Object sender, TaskEventArgs e) { Debug.Log("接受任务" + e.teskID); }
void UpdateTasks (object sender, TaskEventArgs e) { Task[] tasks = TaskService.Errors.GetFileTasks (ContentName); if (tasks == null) return; DisposeErrorMarkers (); // disposes messageBubbleCache as well. if (IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.Never) return; using (var undo = Document.OpenUndoGroup ()) { if (messageBubbleCache != null) messageBubbleCache.Dispose (); messageBubbleCache = new MessageBubbleCache (widget.TextEditor); foreach (Task task in tasks) { if (task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning) { if (IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.ForErrors && task.Severity == TaskSeverity.Warning) continue; DocumentLine lineSegment = widget.Document.GetLine (task.Line); if (lineSegment == null) continue; var marker = currentErrorMarkers.FirstOrDefault (m => m.LineSegment == lineSegment); if (marker != null) { marker.AddError (task.Severity == TaskSeverity.Error, task.Description); continue; } MessageBubbleTextMarker errorTextMarker = new MessageBubbleTextMarker (messageBubbleCache, task, lineSegment, task.Severity == TaskSeverity.Error, task.Description); currentErrorMarkers.Add (errorTextMarker); errorTextMarker.IsVisible = !IdeApp.Preferences.DefaultHideMessageBubbles; widget.Document.AddMarker (lineSegment, errorTextMarker, false); } } } widget.TextEditor.QueueDraw (); }
//<snippet208> protected override void OnInvoked(EventArgs e) { EventArgs = e as TaskEventArgs; }