void LoadMinimap(string mapName, BattleIcon battleIcon)
 {
     Program.SpringScanner.MetaData.GetMapAsync(mapName,
                                                (map, minimap, heightmap, metalmap) =>
     {
         if (map != null && map.Name != battleIcon.Battle.MapName)
         {
             return;
         }
         Image image = null;
         if (minimap != null && minimap.Length != 0)
         {
             image = Image.FromStream(new MemoryStream(minimap));
         }
         Program.MainWindow.InvokeFunc(() =>
         {
             battleIcon.MinimapImage = image;
             BattleChanged(this, new EventArgs <BattleIcon>(battleIcon));
         });
     },
                                                a => Program.MainWindow.InvokeFunc(() =>
     {
         if (battleIcon != null)
         {
             battleIcon.MinimapImage = null;
             BattleChanged(this, new EventArgs <BattleIcon>(battleIcon));
         }
     }));
 }
Пример #2
0
 void PainBattle(BattleIcon t, Graphics g, ref int x, ref int y, int scaledIconWidth, int scaledIconHeight)
 {
     battleIconPositions[t] = new Point(x, y);
     if (g.VisibleClipBounds.IntersectsWith(new RectangleF(x, y, scaledIconWidth, scaledIconHeight)))
     {
         g.DrawImageUnscaled(t.Image, x, y);
     }
     x += scaledIconWidth;
 }
        BattleIcon AddBattle(Battle battle)
        {
            RemoveBattleIcon(battle);

            var battleIcon = new BattleIcon(battle) { IsInGame = battle.IsInGame};
            try
            {
                battleIcons.Add(battleIcon);
                LoadMinimap(battle.MapName, battleIcon);
                battleIcon.SetPlayers();
            } catch
            {
                battleIcon.Dispose();
                throw;
            }
            return battleIcon;
        }
 Battle GetBattle(int x, int y)
 {
     x -= AutoScrollPosition.X;
     y -= AutoScrollPosition.Y;
     foreach (var kvp in battleIconPositions)
     {
         BattleIcon battleIcon     = kvp.Key;
         Point      position       = kvp.Value;
         var        battleIconRect = new Rectangle(position.X,
                                                   position.Y,
                                                   (int)BattleIcon.Width,
                                                   (int)BattleIcon.Height);
         if (battleIconRect.Contains(x, y) && battleIcon.HitTest(x - position.X, y - position.Y))
         {
             return(battleIcon.Battle);
         }
     }
     return(null);
 }
Пример #5
0
 Battle GetBattle(int x, int y)
 {
     x -= AutoScrollPosition.X;
     y -= AutoScrollPosition.Y;
     foreach (var kvp in battleIconPositions)
     {
         BattleIcon battleIcon = kvp.Key;
         Point      position   = kvp.Value;
         DpiMeasurement.DpiXYMeasurement(this);
         var battleIconRect = new Rectangle(position.X,
                                            position.Y,
                                            DpiMeasurement.ScaleValueX(BattleIcon.Width),
                                            DpiMeasurement.ScaleValueY(BattleIcon.Height));
         if (battleIconRect.Contains(x, y) && battleIcon.HitTest(x - position.X, y - position.Y))
         {
             return(battleIcon.Battle);
         }
     }
     return(null);
 }
        BattleIcon AddBattle(Battle battle)
        {
            RemoveBattleIcon(battle);

            var battleIcon = new BattleIcon(battle)
            {
                IsInGame = battle.IsInGame
            };

            try
            {
                battleIcons.Add(battleIcon);
                LoadMinimap(battle.MapName, battleIcon);
                battleIcon.SetPlayers();
            } catch
            {
                battleIcon.Dispose();
                throw;
            }
            return(battleIcon);
        }
        void LoadMinimap(string mapName, BattleIcon battleIcon)
        {
            Program.SpringScanner.MetaData.GetMapAsync(mapName,
                                                       (map, minimap, heightmap, metalmap) =>
                                                       	{
																													if (map != null && map.Name != battleIcon.Battle.MapName) return;
                                                       		Image image = null;
																													if (minimap != null && minimap.Length != 0) image = Image.FromStream(new MemoryStream(minimap));
                                                       		Program.MainWindow.InvokeFunc(() =>
                                                       			{
                                                       				battleIcon.MinimapImage = image;
                                                       				BattleChanged(this, new EventArgs<BattleIcon>(battleIcon));
                                                       			});
                                                       	},
                                                       a => Program.MainWindow.InvokeFunc(() =>
                                                           {
                                                               if (battleIcon != null)
                                                               {
                                                                   battleIcon.MinimapImage = null;
                                                                   BattleChanged(this, new EventArgs<BattleIcon>(battleIcon));
                                                               }
                                                           }));
        }
Пример #8
0
        BattleIcon AddBattle(int battleID)
        {
            var battle = Program.TasClient.ExistingBattles[battleID];
            //string modName = null;
            //foreach (var game in KnownGames.List) if (game.Regex.IsMatch(battle.ModName)) modName = game.Shortcut;
            var founder    = battle.Founder;
            var battleIcon = new BattleIcon(battle)
            {
                IsInGame = founder.IsInGame
            };

            try
            {
                battleIcons.Add(battleIcon);
                LoadMinimap(battle.MapName, battleIcon);
                battleIcon.SetPlayers();
            } catch
            {
                battleIcon.Dispose();
                throw;
            }
            return(battleIcon);
        }
 void PainBattle(BattleIcon t, Graphics g, ref int x, ref int y, int scaledIconWidth, int scaledIconHeight)
 {
     battleIconPositions[t] = new Point(x, y);
     if (g.VisibleClipBounds.IntersectsWith(new RectangleF(x, y, scaledIconWidth, scaledIconHeight))) g.DrawImageUnscaled(t.Image, x, y);
     x += scaledIconWidth;
 }
Пример #10
0
 private void CreateBattleIcon(BattleIcon e)
 {
     gameBox.Image = e.GenerateImage(true);
 }