示例#1
0
        public override bool Clear()
        {
            CurrentPath.Reset();

            origin         = finalDestination = requestedDestination = Vector3.Zero;
            generatingPath = false;
            pathGeneratorStopwatch.Reset();

            return(Original.Clear());
        }
示例#2
0
 internal void ClearSections()
 {
     if (Sections != null)
     {
         Sections.Clear();
     }
     if (Original != null)
     {
         Original.Clear();
     }
     if (Empty != null)
     {
         Empty.Clear();
     }
 }
示例#3
0
        public static ObservableCollection <ImageModel> SplitImage(string img, int length)
        {
            Original.Clear();
            GameList.Clear();
            Bitmap original = new Bitmap(img);
            int    position = 0;
            int    index    = 0;


            int widthOrg = original.Width / length, heighOrg = original.Height / length;

            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < length; j++)
                {
                    Rectangle srcRect = new Rectangle(j * widthOrg, i * heighOrg, widthOrg, heighOrg);
                    Bitmap    objImg  = original.Clone(srcRect, original.PixelFormat);
                    using (var memory = new MemoryStream())
                    {
                        objImg.Save(memory, ImageFormat.Png);
                        memory.Position = position;

                        BitmapImage bitmapImage = new BitmapImage();
                        bitmapImage.BeginInit();
                        bitmapImage.StreamSource = memory;
                        bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                        bitmapImage.EndInit();
                        bitmapImage.Freeze();
                        Original.Add(new ImageModel {
                            Image = bitmapImage, Row = i, Col = j, Text = index.ToString()
                        });
                    }
                    index++;
                }
            }
            Original.Last().Image = null;

            do
            {
                Randomize(length);
            } while (CheckIt(length) == false);

            return(GameList);
        }