Exemplo n.º 1
0
        public static void FreezeHubTile(HubTile tile)
        {
            WeakReference tile1 = new WeakReference((object)tile, false);

            HubTileService.AddReferenceToFrozenPool(tile1);
            HubTileService.RemoveReferenceFromEnabledPool(tile1);
            HubTileService.RemoveReferenceFromStalledPipeline(tile1);
        }
Exemplo n.º 2
0
        internal static void FinalizeReference(HubTile tile)
        {
            WeakReference tile1 = new WeakReference((object)tile, false);

            HubTileService.RemoveReferenceFromEnabledPool(tile1);
            HubTileService.RemoveReferenceFromFrozenPool(tile1);
            HubTileService.RemoveReferenceFromStalledPipeline(tile1);
        }
Exemplo n.º 3
0
        private static void OnTimerTick(object sender, object e)
        {
            HubTileService.Timer.Stop();
            for (int index = 0; index < HubTileService.StalledImagesPipeline.Count; ++index)
            {
                if ((HubTileService.StalledImagesPipeline[index].Target as HubTile)._stallingCounter-- == 0)
                {
                    HubTileService.AddReferenceToEnabledPool(HubTileService.StalledImagesPipeline[index]);
                    HubTileService.RemoveReferenceFromStalledPipeline(HubTileService.StalledImagesPipeline[index]);
                    --index;
                }
            }
            if (HubTileService.EnabledImagesPool.Count > 0)
            {
                for (int index1 = 0; index1 < 1; ++index1)
                {
                    int index2 = HubTileService.ProbabilisticBehaviorSelector.Next(HubTileService.EnabledImagesPool.Count);
                    switch ((HubTileService.EnabledImagesPool[index2].Target as HubTile).State)
                    {
                    case ImageState.Expanded:
                        if ((HubTileService.EnabledImagesPool[index2].Target as HubTile)._canDrop || (HubTileService.EnabledImagesPool[index2].Target as HubTile)._canFlip)
                        {
                            if (!(HubTileService.EnabledImagesPool[index2].Target as HubTile)._canDrop && (HubTileService.EnabledImagesPool[index2].Target as HubTile)._canFlip)
                            {
                                (HubTileService.EnabledImagesPool[index2].Target as HubTile).State = ImageState.Flipped;
                                break;
                            }
                            else if (!(HubTileService.EnabledImagesPool[index2].Target as HubTile)._canFlip && (HubTileService.EnabledImagesPool[index2].Target as HubTile)._canDrop)
                            {
                                (HubTileService.EnabledImagesPool[index2].Target as HubTile).State = ImageState.Semiexpanded;
                                break;
                            }
                            else if (HubTileService.ProbabilisticBehaviorSelector.Next(2) == 0)
                            {
                                (HubTileService.EnabledImagesPool[index2].Target as HubTile).State = ImageState.Semiexpanded;
                                break;
                            }
                            else
                            {
                                (HubTileService.EnabledImagesPool[index2].Target as HubTile).State = ImageState.Flipped;
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }

                    case ImageState.Semiexpanded:
                        (HubTileService.EnabledImagesPool[index2].Target as HubTile).State = ImageState.Collapsed;
                        break;

                    case ImageState.Collapsed:
                        (HubTileService.EnabledImagesPool[index2].Target as HubTile).State = ImageState.Expanded;
                        break;

                    case ImageState.Flipped:
                        (HubTileService.EnabledImagesPool[index2].Target as HubTile).State = ImageState.Expanded;
                        break;
                    }
                    (HubTileService.EnabledImagesPool[index2].Target as HubTile)._stallingCounter = 3;
                    HubTileService.AddReferenceToStalledPipeline(HubTileService.EnabledImagesPool[index2]);
                    HubTileService.RemoveReferenceFromEnabledPool(HubTileService.EnabledImagesPool[index2]);
                }
            }
            else if (HubTileService.StalledImagesPipeline.Count == 0)
            {
                return;
            }
            HubTileService.Timer.Interval = TimeSpan.FromMilliseconds((double)(HubTileService.ProbabilisticBehaviorSelector.Next(1, 31) * 100));
            HubTileService.Timer.Start();
        }