Пример #1
0
 void PixelColorChanged(object sender, PixelChangedEventArgs e)
 {
     if (!UndoRegistrationSuppressed)
     {
         AddUndoAction(new UndoRedoActionChangePixelColor(Image, e.X, e.Y, (CodedColor)e.OldColor, (CodedColor)e.NewColor));
     }
 }
Пример #2
0
        private void OnSelectedPixelChanged(object sender, PixelChangedEventArgs e)
        {
            FrameNumber   = _selectionService.SelectedFrame.Number;
            PixelLocation = e.SelectedPixel;

            HasSelectedPixel = true;
            _pixelEvents.Clear();

            var swapChainPresenter = new WpfSwapChainPresenter(Dispatcher.CurrentDispatcher);
            var replayer           = new Replayer(
                _selectionService.SelectedFrame.Model, _selectionService.SelectedEvent.Model,
                swapChainPresenter,
                _selectionService.SelectedFrame.ActiveRenderTargetViewIdentifier,
                _selectionService.SelectedFrame.ActiveRenderTargetArraySlice,
                e.SelectedPixel.X, e.SelectedPixel.Y);

            Task.Factory.StartNew(() =>
            {
                replayer.Replay();

                var events = replayer.Logger.GetPixelHistoryEvents(_selectionService.SelectedFrame.Number);
                _pixelEvents.AddRange(events.Select(x => new PixelHistoryEventViewModel(x)));

                FinalFrameBufferColor = ((ColorResultViewModel)_pixelEvents.Last(x => x.Result is ColorResultViewModel).Result).Result;
            });
        }
Пример #3
0
        private async void Matrix_PixelChanged(object sender, PixelChangedEventArgs e)
        {
            Color color;
            Color borderColor;

            // ***
            // *** Check the type of pixel to be drawn.
            // ***
            if (e.NewItem.ItemType == ColorItem.ColorItemType.Background || e.NewItem.A == 0)
            {
                // ***
                // *** Any color with a alpha of 0 is considered a "clear" pixel. Having
                // *** an alpha channel of 0 with cause the mouse events not to fire.
                // ***
                color       = e.Background;
                borderColor = this.LedMatrix.DefaultBorderColor;
            }
            else if (e.NewItem.ItemType == ColorItem.ColorItemType.Sand)
            {
                color       = e.NewItem;
                borderColor = Colors.LightPink;
            }
            else if (e.NewItem.ItemType == ColorItem.ColorItemType.Pixel)
            {
                // ***
                // *** Blend the pixel on the background
                // ***
                color       = ((Color)e.NewItem).NormalBlendColor(e.Background);
                borderColor = this.LedMatrix.DefaultBorderColor;
            }

            await this.LedMatrix.SetPixelAsync(e.Row, e.Column, color, borderColor);
        }
Пример #4
0
        public Task PublishPixelChangedEvent(PixelChangedEventArgs e)
        {
            if (this.PixelChanged != null)
            {
                this.PixelChanged.Invoke(this, e);
            }

            return(Task.FromResult(0));
        }
Пример #5
0
        private static void Wrapper_OnPixelChanged(object sender, PixelChangedEventArgs e)
        {
            short x = PixelMap.ConvertToAbsolute(e.Chunk.Item1, e.Pixel.Item1);
            short y = PixelMap.ConvertToAbsolute(e.Chunk.Item2, e.Pixel.Item2);

            if (x <= options.RightX && x >= options.LeftX && y <= options.BottomY && y >= options.TopY)
            {
                logger.LogPixel("Received pixel update:", e.DateTime, MessageGroup.PixelInfo, x, y, e.Color);
                lock (listLockObj)
                {
                    updates.Add((x, y, e.Color));
                }
            }
        }
Пример #6
0
        private static void LogPixelChanged(object sender, PixelChangedEventArgs e)
        {
            MessageGroup msgGroup;
            short        x = PixelMap.ConvertToAbsolute(e.Chunk.Item1, e.Pixel.Item1);
            short        y = PixelMap.ConvertToAbsolute(e.Chunk.Item2, e.Pixel.Item2);

            if (!placed.Remove((x, y, e.Color)))
            {
                try
                {
                    EarthPixelColor desiredColor = imagePixels[x - options.LeftX, y - options.TopY];
                    if (desiredColor == EarthPixelColor.None)
                    {
                        msgGroup = MessageGroup.PixelInfo;
                    }
                    else
                    {
                        if (desiredColor == e.Color)
                        {
                            msgGroup = MessageGroup.Assist;
                            builtInLastMinute++;
                        }
                        else
                        {
                            msgGroup = MessageGroup.Attack;
                            griefedInLastMinute++;
                            gotGriefed?.Set();
                        }
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    logger.LogDebug("LogPixelChanged(): pixel update beyond rectangle");
                    msgGroup = MessageGroup.PixelInfo;
                }
                catch (Exception ex)
                {
                    logger.LogDebug($"LogPixelChanged(): unhandled exception - {ex.Message}");
                    msgGroup = MessageGroup.PixelInfo;
                }
                logger.LogPixel($"Received pixel update:", e.DateTime, msgGroup, x, y, e.Color);
            }
Пример #7
0
        private static void LogPixelChanged(object sender, PixelChangedEventArgs e)
        {
            MessageGroup msgGroup;
            short        x = PixelMap.ConvertToAbsolute(e.Chunk.Item1, e.Pixel.Item1);
            short        y = PixelMap.ConvertToAbsolute(e.Chunk.Item2, e.Pixel.Item2);

            if (!placed.Remove((x, y, e.Color)))
            {
                try
                {
                    PixelColor desiredColor = imagePixels[x - leftX, y - topY];
                    if (desiredColor == PixelColor.None)
                    {
                        msgGroup = MessageGroup.PixelInfo;
                    }
                    else
                    {
                        if (desiredColor == e.Color)
                        {
                            msgGroup = MessageGroup.Assist;
                            builtInLastMinute++;
                        }
                        else
                        {
                            msgGroup = MessageGroup.Attack;
                            griefedInLastMinute++;
                            gotGriefed?.Set();
                        }
                    }
                }
                catch
                {
                    msgGroup = MessageGroup.PixelInfo;
                }
                logger.LogPixel($"Received pixel update:", msgGroup, x, y, e.Color);
            }
Пример #8
0
 private async void ColorMatrix_PixelChanged(object sender, PixelChangedEventArgs e)
 {
     await this.PixelEventService.PublishPixelChangedEvent(e);
 }
 void Image_PixelChanged(object sender, PixelChangedEventArgs e)
 {
     UpdateVisualImage();
 }