Exemplo n.º 1
0
 private static void AddReferenceToFrozenPool(WeakReference tile)
 {
     if (HubTileService.ContainsTarget(HubTileService.FrozenImagesPool, tile.Target))
     {
         return;
     }
     HubTileService.FrozenImagesPool.Add(tile);
 }
Exemplo n.º 2
0
 private static void AddReferenceToStalledPipeline(WeakReference tile)
 {
     if (HubTileService.ContainsTarget(HubTileService.StalledImagesPipeline, tile.Target))
     {
         return;
     }
     HubTileService.StalledImagesPipeline.Add(tile);
 }
Exemplo n.º 3
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.º 4
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.º 5
0
 public static void UnfreezeGroup(string group)
 {
     for (int index = 0; index < HubTileService.FrozenImagesPool.Count; ++index)
     {
         if ((HubTileService.FrozenImagesPool[index].Target as HubTile).GroupTag == group)
         {
             (HubTileService.FrozenImagesPool[index].Target as HubTile).IsFrozen = false;
             --index;
         }
     }
     HubTileService.RestartTimer();
 }
Exemplo n.º 6
0
        private static void OnIsFrozenChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            HubTile tile = (HubTile)obj;

            if ((bool)e.NewValue)
            {
                HubTileService.FreezeHubTile(tile);
            }
            else
            {
                HubTileService.UnfreezeHubTile(tile);
            }
        }
Exemplo n.º 7
0
        internal static void InitializeReference(HubTile tile)
        {
            WeakReference tile1 = new WeakReference((object)tile, false);

            if (tile.IsFrozen)
            {
                HubTileService.AddReferenceToFrozenPool(tile1);
            }
            else
            {
                HubTileService.AddReferenceToEnabledPool(tile1);
            }
            HubTileService.RestartTimer();
        }
Exemplo n.º 8
0
 private void HubTile_Unloaded(object sender, RoutedEventArgs e)
 {
     HubTileService.FinalizeReference(this);
 }
Exemplo n.º 9
0
 private static void RemoveReferenceFromStalledPipeline(WeakReference tile)
 {
     HubTileService.RemoveTarget(HubTileService.StalledImagesPipeline, tile.Target);
 }
Exemplo n.º 10
0
 private static void RemoveReferenceFromFrozenPool(WeakReference tile)
 {
     HubTileService.RemoveTarget(HubTileService.FrozenImagesPool, tile.Target);
 }
Exemplo n.º 11
0
 private static void RemoveReferenceFromEnabledPool(WeakReference tile)
 {
     HubTileService.RemoveTarget(HubTileService.EnabledImagesPool, tile.Target);
 }
Exemplo n.º 12
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();
        }