コード例 #1
0
        public bool LoadImage()
        {
            if (opfDialog.ShowDialog() == true)
            {
                spriteCollection.Children.Clear();
                scale      = 1;
                scaleLevel = 1;
                _keyColor  = Color.FromRgb(255, 255, 255);
                ToolBarViewModel.GetInstance().ChangeColorPickerColor();

                currentTexture      = new BitmapImage(new Uri(opfDialog.FileName));
                ImageDisplay.Source = CurrentTexture;
                ImageDisplay.Width  = (int)(CurrentTexture.PixelWidth);
                ImageDisplay.Height = (int)(CurrentTexture.PixelHeight);
                originalWidth       = (int)ImageDisplay.Width;
                originalHeight      = (int)ImageDisplay.Height;

                imageBitmap = new Bitmap(new Uri(opfDialog.FileName));

                imageName = Path.GetFileName(opfDialog.FileName);
                return(true);
            }

            return(false);
        }
コード例 #2
0
 public EditTool()
 {
     toolBar     = ToolBarViewModel.GetInstance();
     oldPoint    = new Point();
     point       = new Point();
     newPosition = new Point();
 }
コード例 #3
0
        public bool Import()
        {
            if (CurrentTexture == null)
            {
                return(false);
            }

            if (opfJsonDialog.ShowDialog() == true)
            {
                JObject data = JObject.Parse(File.ReadAllText(opfJsonDialog.FileName));
                _keyColor.A = 255;
                _keyColor.R = data["KeyColor"]["Red"].ToObject <byte>();
                _keyColor.G = data["KeyColor"]["Green"].ToObject <byte>();
                _keyColor.B = data["KeyColor"]["Blue"].ToObject <byte>();

                List <int[]> sprites = data["Sprites"].ToObject <List <int[]> >();
                int          index   = SpriteCollection.Children.Count;
                foreach (int[] sprite in sprites)
                {
                    SpriteCut cut = new SpriteCut();
                    cut.X      = sprite[0];
                    cut.Y      = sprite[1];
                    cut.Width  = sprite[2];
                    cut.Height = sprite[3];
                    cut.Index  = index;
                    index++;
                    spriteCollection.Children.Add(cut);
                }

                ToolBarViewModel.GetInstance().ChangeColorPickerColor();
            }

            return(false);
        }
コード例 #4
0
 public ColorPickerTool()
 {
     toolBar = ToolBarViewModel.GetInstance();
 }