Esempio n. 1
0
 public void StartGame()
 {
     if (GameGlobal.PictrueSource == null && string.IsNullOrEmpty(IsGallery) && TempBorder != null || !IsPictureSelected && string.IsNullOrEmpty(IsGallery) && TempBorder != null)
     {
         GameGlobal.PictrueSource = (TempBorder.Child as Image).Source as BitmapImage;
     }
     GameGlobal.SetLevel(new Size(CountParts * K, CountParts));
     this.NavigationService.Navigate(new Uri("/GameInterface.xaml", UriKind.Relative));
 }
Esempio n. 2
0
 public void StartGame()
 {
     if (GameGlobal.PictrueSource == null && string.IsNullOrEmpty(IsGallery) && TempBorder != null || !IsPictureSelected && string.IsNullOrEmpty(IsGallery) && TempBorder != null)
     {
         GameGlobal.PictrueSource = (TempBorder.Child as Image).Source as BitmapImage;
     }
     GameGlobal.SetLevel(new Size(CountParts * K, CountParts));
     if (!AppSettings.Contains("countParts"))
     {
         AppSettings.Add("countParts", CountParts);
     }
     if (AppSettings.Contains("countParts") && (int)AppSettings["countParts"] != CountParts)
     {
         AppSettings["countParts"] = CountParts;
     }
     this.NavigationService.Navigate(new Uri("/GameInterface.xaml", UriKind.Relative));
 }
Esempio n. 3
0
        void GameInterface_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
#if FREE7
                if (microsoftAds == null)
                {
                    microsoftAds = new PhotoPuzzle.Advertising.MicrosoftAds();
                    microsoftAds.AddAds(adsGrid, "11569641");
                }
#endif
#if FREE8
                if (adsMob == null || adsMob != null && IsTryReminderCompleted)
                {
                    adsMob = new PhotoPuzzle.Advertising.AdsMob();
                    adsMob.AddInterstitialAd("ca-app-pub-4981977246797551/6369725024");
                    IsTryReminderCompleted = false;
#endif
                isGameRunning    = false;
                helpImage.Source = GameGlobal.PictrueSource;
                ///////////////////////////////////////
                var bmi          = GameGlobal.PictrueSource;
                int imgWidth     = bmi.PixelWidth;
                int imgHeight    = bmi.PixelHeight;
                double maxWidth  = (int)sizeGrid.ActualWidth;
                double maxHeight = (int)sizeGrid.ActualHeight;
                double kW        = (double)maxWidth / imgWidth;
                double kH        = (double)maxHeight / imgHeight;

                if (imgWidth > imgHeight)
                {
                    double k = (double)imgWidth / imgHeight;
                    if (kW < kH)
                    {
                        Tiles.Width  = maxWidth;
                        Tiles.Height = maxWidth / k;
                    }
                    else
                    {
                        Tiles.Height = maxHeight;
                        Tiles.Width  = maxHeight * k;
                    }
                }
                else
                {
                    double k = (double)imgHeight / imgWidth;
                    if (kW < kH)
                    {
                        Tiles.Width  = maxWidth;
                        Tiles.Height = maxWidth * k;
                    }
                    else
                    {
                        Tiles.Height = maxHeight;
                        Tiles.Width  = maxHeight / k;
                    }
                }
                MaxWidth            = pictrueshow.Width = pictrueshow.MinWidth = pictrueshow.MaxWidth = blackBorder.Width = blackBorder.MinWidth = blackBorder.MaxWidth = Tiles.MinWidth = Tiles.MaxWidth = Tiles.Width;
                MaxHeight           = pictrueshow.Height = pictrueshow.MinHeight = pictrueshow.MaxHeight = blackBorder.Height = blackBorder.MinHeight = blackBorder.MaxHeight = Tiles.MinHeight = Tiles.MaxHeight = Tiles.Height;
                previewImage.Width  = Tiles.Width * 0.9;
                previewImage.Height = Tiles.Height * 0.9;
                GameGlobal.TileW    = Tiles.Width / GameGlobal.MaxTilesW;
                GameGlobal.TileH    = Tiles.Height / GameGlobal.MaxTilesH;
                ///////////////////////////////////////
                if (GameGlobal.PictrueSource == null)
                {
                    var uri = PhoneApplicationService.Current.State["ImageData"] as Uri;
                    if (uri.OriginalString == "")
                    {
                        GameGlobal.PictrueSource = null;
                        this.NavigationService.GoBack();
                    }
                    GameGlobal.PictrueSource = new BitmapImage(uri);
                    if (PhoneApplicationService.Current.State.ContainsKey("GameLevel"))
                    {
                        var size = (Size)PhoneApplicationService.Current.State["GameLevel"];
                        GameGlobal.SetLevel((int)size.Width, (int)size.Height);
                    }
                }
                for (int i = 0; i < GameGlobal.MaxTilesH * GameGlobal.MaxTilesW; i++)
                {
                    Tiles.Children.Add(new Tile()
                    {
                        Width = GameGlobal.TileW, Height = GameGlobal.TileH
                    });
                }
                foreach (Tile tile in this.Tiles.Children)
                {
                    tile.MouseLeftButtonDown += new MouseButtonEventHandler(tile_MouseLeftButtonDown);
                    tile.OnMoveComplete       = OnMoveComplete;
                    tile.OnMoveStart          = OnMoveStart;
                }
                CreatePictrue(GameGlobal.PictrueSource);
#if FREE8
            }
#endif
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 4
0
        void GameInterface_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                isGameRunning    = false;
                helpImage.Source = GameGlobal.PictrueSource;
                ///////////////////////////////////////
                var    bmi       = GameGlobal.PictrueSource;
                int    imgWidth  = bmi.PixelWidth;
                int    imgHeight = bmi.PixelHeight;
                double maxWidth  = (int)sizeGrid.ActualWidth;
                double maxHeight = (int)sizeGrid.ActualHeight;
                double kW        = (double)maxWidth / imgWidth;
                double kH        = (double)maxHeight / imgHeight;

                if (imgWidth > imgHeight)
                {
                    double k = (double)imgWidth / imgHeight;
                    if (kW < kH)
                    {
                        Tiles.Width  = maxWidth;
                        Tiles.Height = maxWidth / k;
                    }
                    else
                    {
                        Tiles.Height = maxHeight;
                        Tiles.Width  = maxHeight * k;
                    }
                }
                else
                {
                    double k = (double)imgHeight / imgWidth;
                    if (kW < kH)
                    {
                        Tiles.Width  = maxWidth;
                        Tiles.Height = maxWidth * k;
                    }
                    else
                    {
                        Tiles.Height = maxHeight;
                        Tiles.Width  = maxHeight / k;
                    }
                }
                MaxWidth            = pictrueshow.Width = pictrueshow.MinWidth = pictrueshow.MaxWidth = blackBorder.Width = blackBorder.MinWidth = blackBorder.MaxWidth = Tiles.MinWidth = Tiles.MaxWidth = Tiles.Width;
                MaxHeight           = pictrueshow.Height = pictrueshow.MinHeight = pictrueshow.MaxHeight = blackBorder.Height = blackBorder.MinHeight = blackBorder.MaxHeight = Tiles.MinHeight = Tiles.MaxHeight = Tiles.Height;
                previewImage.Width  = Tiles.Width * 0.9;
                previewImage.Height = Tiles.Height * 0.9;
                GameGlobal.TileW    = Tiles.Width / GameGlobal.MaxTilesW;
                GameGlobal.TileH    = Tiles.Height / GameGlobal.MaxTilesH;
                ///////////////////////////////////////
                if (GameGlobal.PictrueSource == null)
                {
                    var uri = PhoneApplicationService.Current.State["ImageData"] as Uri;
                    if (uri.OriginalString == "")
                    {
                        GameGlobal.PictrueSource = null;
                        this.NavigationService.GoBack();
                    }
                    GameGlobal.PictrueSource = new BitmapImage(uri);
                    if (PhoneApplicationService.Current.State.ContainsKey("GameLevel"))
                    {
                        var size = (Size)PhoneApplicationService.Current.State["GameLevel"];
                        GameGlobal.SetLevel((int)size.Width, (int)size.Height);
                    }
                }
                for (int i = 0; i < GameGlobal.MaxTilesH * GameGlobal.MaxTilesW; i++)
                {
                    Tiles.Children.Add(new Tile()
                    {
                        Width = GameGlobal.TileW, Height = GameGlobal.TileH
                    });
                }
                foreach (Tile tile in this.Tiles.Children)
                {
                    tile.MouseLeftButtonDown += new MouseButtonEventHandler(tile_MouseLeftButtonDown);
                    tile.OnMoveComplete       = OnMoveComplete;
                    tile.OnMoveStart          = OnMoveStart;
                }
                CreatePictrue(GameGlobal.PictrueSource);
            }
            catch (Exception ex)
            {
            }
        }