Beispiel #1
0
 public abstract void AddGraphic(Graphic g);
        public GraphicEditorVM()
        {
            PixelCommand = new RelayCommand<Pixel>((p) =>
            {
                if (SelectedColor.A != 0)
                {
                    var old = SelectedGraphicPixelData;
                    old[p.Y][p.X].PixelColor = SelectedColor;
                    SelectedGraphicPixelData = null;
                    SelectedGraphicPixelData = old;
                }
            });

            NewCommand = new RelayCommand(() =>
            {
                CurrentGraphic = new Graphic();
                isNewGraphic = true;
            });

            SaveCommand = new RelayCommand(() =>
            {
                var colors = currentGraphic.ValidColors;
                var backDict = new Dictionary<Color, char>();
                foreach (var kv in colors)
                {
                    backDict.Add(kv.Value, kv.Key);
                }

                var chars = new List<char>();
                foreach (var row in selectedGraphicPixelData)
                {
                    foreach (var pix in row)
                    {
                        chars.Add(backDict[pix.PixelColor]);
                    }
                }
                currentGraphic.Data = string.Concat(chars);
                currentGraphic.Save();
                if (isNewGraphic)
                {
                    currentSign.AddGraphic(currentGraphic);
                }
                isNewGraphic = false;
                RaisePropertyChanged("");
            });

            ResetCommand = new RelayCommand(() =>
            {
            });

            DeleteCommand = new RelayCommand(() =>
            {
            }); 
        }
Beispiel #3
0
 public override void AddGraphic(Graphic g)
 {
     Effects["Graphic"].Add(g);
 }