public void Execute(object parameter)
        {
            var v = parameter as ViewModel;

            Microsoft.Win32.OpenFileDialog file = new Microsoft.Win32.OpenFileDialog();
            if (file.ShowDialog() == true)
            {
                try
                {
                    var bmp = new Bitmap(file.FileName);

                    if (bmp.Width == 64 && (bmp.Height == 64 || bmp.Height == 32))
                    {
                        Rectangle section = new Rectangle(new Point(0, 0), new Size(64, 32));
                        bmp = BitmapConverter.CropImage(bmp, section);
                        v.UndoRedoBitmap.Reset();
                        v.Skin        = bmp;
                        v.ImageSource = BitmapConverter.BitmapToImageSource(bmp);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Failed to open file? Not a correct minecraft skin");
                }
            }
        }
Пример #2
0
        public void Execute(object parameter)
        {
            var b = parameter as ViewModel;

            if (b.ImageSource == null)
            {
                return;
            }
            var    myBitmapImage = b.ImageSource as BitmapImage;
            Bitmap bmp           = BitmapConverter.BitmapImage2Bitmap(myBitmapImage);


            var p = Mouse.GetPosition(Picture.PICTURE);


            p.X /= Picture.PICTURE.ActualWidth / b.ImageSource.Width;
            p.Y /= Picture.PICTURE.ActualHeight / b.ImageSource.Height;
            if (p.X < b.Skin.Width && p.X > 0 && p.Y < b.Skin.Height && p.Y > 0)
            {
                var col = new Color();
                col = Color.FromArgb(b.BrushColorPick.A, b.BrushColorPick.R, b.BrushColorPick.G, b.BrushColorPick.B);
                bmp.SetPixel((int)p.X, (int)p.Y, col);
                b.Skin        = bmp;
                b.ImageSource = BitmapConverter.BitmapToImageSource(bmp);
            }
        }
Пример #3
0
        public void Execute(object parameter)
        {
            int width = 64, height = 32;

            //bitmap
            Bitmap bmp = new Bitmap(width, height);

            //random number
            Random rand = new Random();

            //create random pixels
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    //generate random ARGB value
                    int a = rand.Next(256);
                    int r = rand.Next(256);
                    int g = rand.Next(256);
                    int b = rand.Next(256);

                    //set ARGB value
                    bmp.SetPixel(x, y, Color.FromArgb(a, r, g, b));
                }
            }
            var v = parameter as ViewModel;

            v.Skin        = bmp;
            v.ImageSource = BitmapConverter.BitmapToImageSource(bmp);
            v.UndoRedoBitmap.Reset();
            v.UndoRedoBitmap.Add(bmp);
        }
Пример #4
0
        public void Execute(object parameter)
        {
            var v   = parameter as ViewModel;
            var bmp = v.UndoRedoBitmap.Redo();

            if (bmp == null)
            {
                return;
            }
            v.Skin        = bmp;
            v.ImageSource = BitmapConverter.BitmapToImageSource(bmp);
        }
        public void Execute(object parameter)
        {
            var b        = parameter as ViewModel;
            var filepath = System.AppDomain.CurrentDomain.BaseDirectory;

            filepath += "\\Resources\\Tex\\SkinTemplate.png";
            Bitmap bm = new Bitmap(filepath);

            b.Skin        = bm;
            b.ImageSource = BitmapConverter.BitmapToImageSource(bm);
            b.UndoRedoBitmap.Reset();
            b.UndoRedoBitmap.Add(bm);
        }
Пример #6
0
        public void Execute(object parameter)
        {
            var         b              = parameter as ViewModel;
            string      webURL         = "https://mcskinsearch.com/api/download/" + b.SelecteListItem.Content;
            WebRequest  request        = WebRequest.Create(webURL);
            WebResponse response       = request.GetResponse();
            Stream      responseStream = response.GetResponseStream();
            Bitmap      bmp            = new Bitmap(responseStream);
            Rectangle   section        = new Rectangle(new Point(0, 0), new Size(64, 32));

            bmp           = BitmapConverter.CropImage(bmp, section);
            b.Skin        = bmp;
            b.ImageSource = BitmapConverter.BitmapToImageSource(bmp);
        }
Пример #7
0
        private void LoadFiles()
        {
            mappings = FileLoader.LoadMapings();
            nameToId = new Dictionary <string, string>();
            mappings.ForEach(mapping => nameToId[mapping[1]] = mapping[0]);

            var images = FileLoader.LoadImages(mappings);

            foreach (KeyValuePair <string, Bitmap> entry in images)
            {
                this.images[entry.Key] = BitmapConverter.BitmapToImageSource(entry.Value);
                grayImages[entry.Key]  = BitmapConverter.BitmapImageToGraycale(this.images[entry.Key]);
            }

            var avatarMappings = new List <List <string> >()
            {
                new List <string> {
                    "ally_avatar"
                },
                new List <string> {
                    "enemy_avatar"
                },
                new List <string> {
                    "player_avatar"
                }
            };
            var avatarImages = FileLoader.LoadImages(avatarMappings);

            foreach (KeyValuePair <string, Bitmap> entry in avatarImages)
            {
                this.avatarImages[entry.Key] = BitmapConverter.BitmapToImageSource(entry.Value);
            }


            Heroes = FileLoader.LoadHeroes(mappings);


            items = FileLoader.LoadItems();
        }