private void RunColorRequest(ColorAtPoint cap) { requestColorQueue.Enqueue(cap); if (requestColorWorker == null) { requestColorWorker = new RequestColorWorker(requestColorQueue, masterImage, OnRequestColorCompleted); requestColorWorker.UpdateStatusText += new TextEventHandler(Form_UpdateStatusText); requestColorWorker.Run(); } else if (!requestColorWorker.IsBusy) { requestColorWorker.Run(masterImage); } }
//todo accept cancellation from wait form //todo update main form status bar with "Processing request 2 of 6..." //todo on cancellation, still update main form with the last successfully completed coloration #region Color Bitmap /// <summary> /// The main worker method: colors in a region of the image. /// </summary> private void ColorPixel(object sender, DoWorkEventArgs e) { if (queue.Count == 0) { return; } ColorAtPoint request = queue.Dequeue(); Color color = request.Color; Point point = request.Point; Color oldPureColor = masterImage.CleanGetCopy.GetPixel(point.X, point.Y); ConvertRegionToColor(color, point); //todo: refactor for new design - in master image keep partially updated image separate from last complete version //todo cont: basically, a buffered version to edit on, and a completed version that can always be displayed e.Result = new RequestColorWorkerResult(masterImage.CleanGetCopy, request, request.ChangeColor(oldPureColor)); }
private void Image_OnClick(object sender, EventArgs e) { if (!HasImage) { OpenFile(); return; } if (masterImage.IsBusy) { ShowWaitMessage("Please wait until the image is prepped."); return; } Point screenPoint = new Point(MousePosition.X, MousePosition.Y); Point masterImagePoint = ScreenPointToMasterImagePoint(screenPoint); if (!masterImage.InRange(masterImagePoint)) { return; } if (isDropperOperation) { Color pureColor = masterImage.PureColor(masterImagePoint); palettePanel.SelectedColor = pureColor; isDropperOperation = false; UpdateOperationMode(); } if (SelectedColor == null) { return; } ColorAtPoint newColor = new ColorAtPoint(SelectedColor.Value, masterImagePoint); RunColorRequest(newColor); }
public RequestColorAction(ColorAtPoint newCap, ColorAtPoint oldCap) { this.newCap = newCap; this.oldCap = oldCap; }
public RequestColorWorkerResult(Bitmap bitmap, ColorAtPoint newWhite, ColorAtPoint previousWhite) { Bitmap = bitmap; NewWhite = newWhite; PreviousWhite = previousWhite; }
public ColorEventArgs(ColorAtPoint colorAtPoint) : base() { ColorAtPoint = colorAtPoint; }